/*
 * hirehay.com's content pages (#944): the privacy policy, the terms of use, the not-found page and
 * the feature status page (#1576, with roadmap.css for its chips).
 * They load home.css first, for the fonts, the tokens, the buttons and the site's header and
 * footer, and this sheet after it for their reading layout, modelled on tido.studio's content
 * pages in Hire Hay's brand: one reading column at a 640px measure (about 75 characters a line
 * at 17px, #3280), a table of contents built from the h2s (sticky beside the text from 1024px,
 * folded above it on a phone, with a line held at the window's bottom that leads back to it),
 * numbered sections, anchors on the headings, tables that stack each row into a card on a phone,
 * a back-to-top link and print styles. No script.
 *
 * Colours: home.css is light only, as the design draws the home page; these pages follow the
 * reader's theme, so the dark block below redefines home.css's tokens they use. Each value names
 * its hh token's path, in the hh theme (src/theme/hh in @hirehay/ui; light-dark() values, the second for the dark ones); build.test.mjs fails
 * when a copy drifts and when a colour appears anywhere else in this sheet.
 */
:root {
  color-scheme: light dark;

  --on-action: #1e1d18; /* --color-on-action */

  --measure: 640px;
  --toc-width: 232px;
}

@media screen and (prefers-color-scheme: dark) {
  :root {
    --bg-page: #12100b; /* --color-background-body */
    --bg-surface: #1c1b15; /* --color-background-card */
    --bg-subtle: #2a2923; /* --color-background-muted */
    --bg-sunken: #0d0b07; /* --color-background-sunken */
    --bg-lavender: #15112b; /* --color-background-navigation */
    --accent: #a79bff; /* --color-accent */
    --accent-soft: #282540; /* --color-info-muted */
    --nav-active: #282540; /* --color-accent-muted */
    --on-accent-soft: #e9e8e4; /* --color-on-info-muted */
    --text-primary: #e9e8e4; /* --color-text-primary */
    --text-muted: #d1d0c9; /* --color-text-secondary */
    --border: #37352f; /* --color-border */
    --border-strong: #8e8c84; /* --color-border-emphasized */
    --border-row: #37352f; /* --color-border-row */
    --action: #bacf7c; /* --color-action */
    --action-hover: #cde38f; /* --color-action-hover */
    --action-border: #788946; /* --color-action-edge */
    --on-action: #1e1d18; /* --color-on-action */
    --success: #96cda9; /* --color-success */
    --success-soft: #162f20; /* --color-success-muted */
    --warning: #dfb680; /* --color-warning */
    --warning-soft: #37250b; /* --color-warning-muted */
  }
}

/* The lime button keeps its dark ink in both themes. */
.btn-primary {
  color: var(--on-action);
}

/* Page -------------------------------------------------------------------------------------- */

.doc {
  padding: 24px var(--pad) 72px;
}

.doc-intro {
  padding-bottom: 32px;
}

.doc-intro h1 {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -1px;
  text-wrap: balance;
}

.version {
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 14px;
}

/* What the text says above its first section, such as the note that it is a first version:
   tido.studio's summary box, with Hire Hay's lime as its offset edge. */
.doc-note {
  display: grid;
  gap: 10px;
  margin: 28px 6px 0 0;
  padding: 18px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--text-primary);
  border-radius: 3px;
  /* Drawn like the lime button: its fill and, round it, its olive edge. */
  box-shadow:
    6px 6px 0 var(--action),
    6px 6px 0 1px var(--action-border);
  font-size: 15px;
  line-height: 1.65;
  text-wrap: pretty;
}

.doc-note > *,
.doc-note .notice > * {
  margin: 0;
}

/* A summary box's points: one short line each, linking the section that says it in full. */
.doc-note ul {
  display: grid;
  gap: 6px;
  padding-left: 1.2em;
  list-style: disc;
}

.doc-note li::marker {
  color: var(--accent);
}

.doc-note strong {
  font-weight: 600;
}

.doc-note .notice {
  display: grid;
  justify-items: start;
  gap: 10px;
}

.doc-note a,
.doc-body a {
  color: var(--accent);
  font-weight: 500;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.doc-note a:hover,
.doc-body a:hover {
  text-decoration-thickness: 2px;
}

/* A placeholder text (site/legal/<page>.placeholder.html): its tag and its dashed slots. */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px;
  background: var(--nav-active);
  border-radius: 999px;
  color: var(--on-accent-soft);
  font-size: 13px;
  font-weight: 600;
}

.tag-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--action-border);
}

.pending {
  padding: 10px 14px;
  color: var(--text-muted);
  outline: 1.5px dashed var(--border-strong);
  outline-offset: -1.5px;
  border-radius: 3px;
}

/* Table of contents ------------------------------------------------------------------------- */

.toc-list {
  display: grid;
  gap: 2px;
  counter-reset: toc;
  font-size: 14px;
  line-height: 1.45;
}

.toc-list a {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  color: var(--text-muted);
  /* An entry wider than the column never leaves its last word alone on a line (#2263); balance
     would split more compounds, such as "xử / lý", and content.mjs keeps some on one line. */
  text-wrap: pretty;
  transition: color var(--quick) var(--ease);
}

.toc-list a:hover {
  color: var(--text-primary);
}

.doc[data-numbered] .toc-list li {
  counter-increment: toc;
}

.toc-list .toc-n,
.doc[data-numbered] .toc-list a::before {
  flex: none;
  min-width: 1.6em;
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  content: counter(toc, decimal-leading-zero);
}

/* On a phone the contents fold into one box above the text; the line at the window's bottom
   (.doc-end) leads back to it, and it stays open once opened. */
.toc-fold {
  margin-bottom: 40px;
  scroll-margin-top: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 3px;
}

.toc-fold summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.toc-fold summary::-webkit-details-marker {
  display: none;
}

.toc-fold summary svg.i {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transition: transform var(--base) var(--ease);
}

.toc-fold[open] summary svg.i {
  transform: rotate(180deg);
}

.toc-fold nav {
  padding: 0 16px 10px;
  border-top: 1px solid var(--border-row);
}

.toc-fold .toc-list {
  padding-top: 6px;
}

.toc-fold .toc-list li + li {
  border-top: 1px solid var(--border-row);
}

.toc-fold .toc-list a {
  padding: 10px 0;
}

.toc-side {
  display: none;
}

.doc .to-top,
.doc .to-contents {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: color var(--quick) var(--ease);
}

.doc .to-top:hover,
.doc .to-contents:hover {
  color: var(--text-primary);
}

.doc .to-top svg.i,
.doc .to-contents svg.i {
  width: 14px;
  height: 14px;
}

/* Text -------------------------------------------------------------------------------------- */

.doc-body {
  font-size: 16px;
  line-height: 1.7;
  text-wrap: pretty;
}

.doc-body section {
  scroll-margin-top: 24px;
}

.doc-body h2 {
  position: relative;
  margin: 56px 0 14px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.4px;
  text-wrap: balance;
  scroll-margin-top: 24px;
}

.doc-body > h2:first-child,
.doc-body > section:first-child > h2:first-child {
  margin-top: 0;
}

/* The page numbers its sections when the text does not: 01, 02 … above each heading, as the home
   page numbers its steps. */
.doc[data-numbered] .doc-body {
  counter-reset: section;
}

.doc[data-numbered] .doc-body h2 {
  counter-increment: section;
}

.doc[data-numbered] .doc-body h2::before {
  display: block;
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.4px;
  font-variant-numeric: tabular-nums;
  content: counter(section, decimal-leading-zero);
}

/* A heading's own number ("1 Bên cung cấp…"), set above its words as the page numbers its own. */
.doc-body h2 .doc-n {
  display: block;
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.4px;
  font-variant-numeric: tabular-nums;
}

.doc-body h3 {
  margin: 28px 0 8px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.45;
}

.doc-body p,
.doc-body ul,
.doc-body ol,
.doc-body dl,
.doc-body blockquote,
.doc-body table {
  margin: 0 0 16px;
}

.doc-body ul,
.doc-body ol {
  padding-left: 1.4em;
}

.doc-body ul {
  list-style: disc;
}

.doc-body ol {
  list-style: decimal;
}

.doc-body li::marker {
  color: var(--accent);
}

.doc-body ol > li::marker {
  font-weight: 600;
}

.doc-body li + li,
.doc-body li > ul,
.doc-body li > ol {
  margin-top: 8px;
}

.doc-body li > ul,
.doc-body li > ol {
  margin-bottom: 0;
}

.doc-body strong {
  font-weight: 600;
}

.doc-body code {
  padding: 1px 5px;
  background: var(--bg-sunken);
  border-radius: 3px;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 0.86em;
  overflow-wrap: anywhere;
}

.doc-body blockquote {
  padding: 12px 16px;
  background: var(--bg-subtle);
  border-left: 3px solid var(--action-border);
  border-radius: 0 3px 3px 0;
}

.doc-body blockquote > :last-child {
  margin-bottom: 0;
}

/* A list of kinds, each a bold term and what it covers. */
.doc-body dt {
  font-weight: 600;
}

.doc-body dd {
  margin: 2px 0 0;
}

.doc-body dd + dt {
  margin-top: 14px;
}

.doc-body dd > p {
  margin-bottom: 8px;
}

.doc-body dd > :last-child {
  margin-bottom: 0;
}

/* A table: hairline rows, a bold first column. On a phone each row stacks into a card, each cell
   under its column's name, which content.mjs copies from the header row (data-label). */
.doc-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  line-height: 1.55;
}

.doc-body caption {
  padding-bottom: 8px;
  color: var(--text-muted);
  font-size: 14px;
  text-align: left;
}

.doc-body th,
.doc-body td {
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid var(--border-row);
  text-align: left;
  vertical-align: top;
}

.doc-body th:last-child,
.doc-body td:last-child {
  padding-right: 0;
}

.doc-body thead th {
  padding-top: 0;
  border-bottom-color: var(--border);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}

.doc-body tbody td:first-child {
  font-weight: 600;
}

.doc-body td code {
  overflow-wrap: normal;
}

.doc-body td p {
  margin: 0;
}

.doc-body td p + p {
  margin-top: 6px;
}

@media (max-width: 639px) {
  /* The caption too, or as a table caption it shrinks to one word a line (#3376). */
  .doc-body table,
  .doc-body caption,
  .doc-body tbody,
  .doc-body tr,
  .doc-body td {
    display: block;
  }

  .doc-body thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .doc-body tr {
    padding: 12px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 3px;
  }

  .doc-body tr + tr {
    margin-top: 10px;
  }

  .doc-body td {
    padding: 0;
    border: 0;
  }

  .doc-body td + td {
    margin-top: 8px;
  }

  .doc-body td[data-label]:not(:first-child)::before {
    display: block;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    content: attr(data-label);
  }

  .doc-body td code {
    overflow-wrap: anywhere;
  }
}

/* Each heading's link to itself, shown on hover and when it is the target; the table of
   contents carries the same links for keyboards and screen readers. */
.anchor {
  margin-left: 0.3em;
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
  opacity: 0;
  transition: opacity var(--quick) var(--ease);
}

.anchor::before {
  content: '#';
}

.doc-body h2:hover .anchor,
.doc-body h2:target .anchor,
.doc-body section:target > h2 .anchor {
  opacity: 1;
}

@media (hover: none) {
  .anchor {
    display: none;
  }
}

/* The text's last line: back to the top, and on a phone back to the contents too, held at the
   window's bottom while the text scrolls past (GOV.UK's contents link, with no script). */
.doc-body .doc-end {
  position: sticky;
  bottom: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 48px calc(-1 * var(--pad)) 0;
  padding: 12px var(--pad);
  background: var(--bg-page);
  border-top: 1px solid var(--border);
}

/* The footer marks the page it closes. */
.footer-column a[aria-current='page'] {
  color: var(--text-primary);
  font-weight: 600;
}

/* Not found --------------------------------------------------------------------------------- */

.missing {
  display: grid;
  justify-items: start;
  align-content: center;
  gap: 16px;
  min-height: 56vh;
  padding: 48px var(--pad) 80px;
}

.missing-code {
  color: var(--accent);
  font-size: 88px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -3px;
  font-variant-numeric: tabular-nums;
}

.missing h1 {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.8px;
  text-wrap: balance;
}

.missing-lead {
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1.6;
}

/* Desktop ----------------------------------------------------------------------------------- */

@media (min-width: 1024px) {
  .doc {
    display: grid;
    grid-template-columns: var(--toc-width) minmax(0, var(--measure));
    column-gap: clamp(56px, 7vw, 112px);
    justify-content: center;
    align-items: start;
    padding: 64px 40px 112px;
  }

  .doc-intro {
    grid-column: 2;
    padding-bottom: 56px;
  }

  .doc-intro h1 {
    font-size: 56px;
    letter-spacing: -1.8px;
  }

  .toc-fold {
    display: none;
  }

  .toc-side {
    position: sticky;
    top: 24px;
    display: block;
    grid-column: 1;
    /* From the top of the content, beside the title and the summary, not below them (#3280). */
    grid-row: 1 / span 2;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    padding: 2px 0 2px 18px;
    border-left: 2px solid var(--nav-active);
  }

  .toc-title {
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
  }

  .toc-side .toc-list a {
    margin-left: -20px;
    padding: 4px 0 4px 18px;
    border-left: 2px solid transparent;
  }

  .toc-side .toc-list a:hover {
    border-left-color: var(--accent);
  }

  .toc-side .to-top {
    margin-top: 20px;
    font-size: 13px;
  }

  .doc-body {
    grid-column: 2;
    grid-row: 2;
    font-size: 17px;
    line-height: 1.75;
  }

  .doc-body h2 {
    margin-top: 64px;
    font-size: 26px;
    letter-spacing: -0.6px;
  }

  .doc-body h3 {
    font-size: 18px;
  }

  .doc-body p,
  .doc-body ul,
  .doc-body ol,
  .doc-body dl,
  .doc-body blockquote,
  .doc-body table {
    margin-bottom: 20px;
  }

  /* Beside the side contents the last line is the text's end again, back to the top only. */
  .doc-body .doc-end {
    position: static;
    margin: 48px 0 0;
    padding: 20px 0 0;
    background: none;
  }

  .doc .to-contents {
    display: none;
  }

  .missing {
    padding: 96px max(40px, calc((100% - 1280px) / 2)) 128px;
  }

  .missing-code {
    font-size: 144px;
    letter-spacing: -5px;
  }

  .missing h1 {
    font-size: 48px;
    letter-spacing: -1.4px;
  }

  .missing-lead {
    font-size: 18px;
  }
}

/* Print ------------------------------------------------------------------------------------- */

@media print {
  @page {
    margin: 18mm 16mm;
  }

  body {
    background: none;
    font-size: 11pt;
  }

  .skip,
  .nav-links,
  .nav-actions,
  .menu,
  .toc,
  .doc-end,
  .anchor,
  .footer-top {
    display: none !important;
  }

  .site-header {
    padding: 0 0 12mm;
  }

  .doc {
    display: block;
    padding: 0;
  }

  .doc-intro {
    padding-bottom: 10mm;
  }

  .doc-intro h1 {
    font-size: 26pt;
  }

  .doc-note {
    margin-right: 0;
    box-shadow: none;
  }

  .doc-body {
    font-size: 11pt;
    line-height: 1.6;
  }

  .doc-body h2 {
    margin-top: 10mm;
    font-size: 15pt;
  }

  .doc-body h2,
  .doc-body h3 {
    break-inside: avoid;
    break-after: avoid;
  }

  .doc-body p,
  .doc-body li {
    orphans: 3;
    widows: 3;
  }

  .doc-body blockquote {
    break-inside: avoid;
  }

  /* On paper a link shows where it goes. */
  .doc-body a[href^='http']::after {
    color: var(--text-muted);
    font-weight: 400;
    content: ' (' attr(href) ')';
  }

  .site-footer {
    padding: 8mm 0 0;
  }
}
