/* ============================================================================
   DraftADay — documentation site.

   Layout only. Every colour here is a token declared in /styles.css, which is
   loaded first: --paper/--dawn/--card surfaces, --ink/--ink-2/--mist/--blue/
   --amber-2 text (each measured >= 4.5:1 on every surface it sits on, in both
   schemes), and --band/--band-fg-2 for code. Dark mode therefore arrives with
   the tokens, through prefers-color-scheme, with nothing to keep in sync here.

   Verified at 1280, 768 and 360 CSS pixels. Below 820 the left nav becomes a
   drawer behind a Menu button and the in-page contents collapse.
   ========================================================================== */

.wrap--docs { max-width: 1340px; }
.topbar--docs .wrap { gap: 16px; }
.topbar--docs .topnav { margin-left: auto; }

.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus {
  left: 12px; top: 10px; z-index: 100; padding: 10px 16px;
  background: var(--card); color: var(--ink); border: 1px solid var(--line-2);
  border-radius: 999px; font-weight: 600;
}

.docs-tag {
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--amber-2);
  border: 1px solid var(--amber-2); background: var(--amber-w);
  border-radius: 999px; padding: 4px 10px; line-height: 1.2;
}
.docs-tag:hover { text-decoration: none; background: var(--card); }

.dmenu {
  display: none; align-items: center; gap: 8px;
  font-family: var(--font-body); font-size: .88rem; font-weight: 600;
  color: var(--ink); background: transparent;
  border: 1.5px solid var(--line-2); border-radius: 999px;
  padding: 8px 14px; cursor: pointer;
}
.dmenu:hover { border-color: var(--ink-2); background: var(--card); }
.dmenu-i { font-size: 1.05rem; line-height: 1; }
.dmenu-t { line-height: 1; }

/* ---- shell ---------------------------------------------------------------- */
.dshell {
  max-width: 1340px; margin: 0 auto;
  display: grid; grid-template-columns: 264px minmax(0, 1fr);
  align-items: start;
}
.dmain { grid-column: 2; grid-row: 2; padding: 30px 40px 88px; min-width: 0; }
.dtoc  { grid-column: 2; grid-row: 1; }

@media (min-width: 1180px) {
  .dshell { grid-template-columns: 264px minmax(0, 1fr) 236px; }
  .dmain { grid-column: 2; grid-row: 1; padding-top: 38px; }
  .dtoc  { grid-column: 3; grid-row: 1; }
}

/* ---- left nav -------------------------------------------------------------- */
.dnav {
  grid-column: 1; grid-row: 1 / span 2;
  position: sticky; top: 64px; align-self: start;
  max-height: calc(100vh - 64px); overflow-y: auto;
  padding: 26px 20px 60px;
  border-right: 1px solid var(--line); background: var(--paper);
}
.dnav-h {
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--mist); margin: 22px 0 8px;
}
.dnav-l { list-style: none; margin: 0; padding: 0; }
.dnav-l a {
  display: flex; gap: 10px; align-items: baseline;
  padding: 9px 12px; border-radius: 9px;
  color: var(--ink-2); font-size: .93rem; line-height: 1.35;
}
.dnav-l a:hover { background: var(--mist-w); color: var(--ink); text-decoration: none; }
.dnav-l a[aria-current="page"] {
  background: var(--amber-w); color: var(--ink); font-weight: 600;
  box-shadow: inset 2px 0 0 var(--amber);
}
.dnum { font-family: var(--font-mono); font-size: .7rem; color: var(--mist); flex: 0 0 auto; }
.dnav-l a[aria-current="page"] .dnum { color: var(--amber-2); }
.dnt { min-width: 0; }

/* ---- search ----------------------------------------------------------------- */
.dsearch { position: relative; }
.dsr-label { position: absolute; left: -9999px; }
.dsearch input {
  width: 100%; font-family: var(--font-body); font-size: .93rem;
  padding: 10px 12px 10px 32px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--card); color: var(--ink);
}
.dsearch input::placeholder { color: var(--mist); }
.dsearch input:focus-visible { outline: 3px solid var(--amber); outline-offset: 1px; }
.dsearch-ic {
  position: absolute; left: 11px; top: 9px; font-size: 1rem;
  color: var(--mist); pointer-events: none; line-height: 1.4;
}
.dsearch-hint {
  font-family: var(--font-mono); font-size: .68rem; color: var(--mist);
  margin: 8px 0 0; letter-spacing: .04em;
}
.dsearch-res {
  position: absolute; z-index: 70; top: calc(100% + 6px); left: 0; right: 0;
  max-height: 62vh; overflow-y: auto; padding: 6px;
  background: var(--card); border: 1px solid var(--line-2);
  border-radius: 12px; box-shadow: var(--shadow-lg);
}
.dsearch-res a {
  display: block; padding: 9px 11px; border-radius: 8px;
  color: var(--ink); font-size: .9rem; line-height: 1.35;
}
.dsearch-res a:hover, .dsearch-res a.sel { background: var(--amber-w); text-decoration: none; }
.dsearch-res .p {
  display: block; font-family: var(--font-mono); font-size: .66rem;
  letter-spacing: .06em; text-transform: uppercase; color: var(--mist); margin-top: 3px;
}
.dsearch-none { padding: 11px; color: var(--mist); font-size: .88rem; }

/* ---- in-page contents -------------------------------------------------------- */
.dtoc {
  position: sticky; top: 80px; align-self: start;
  max-height: calc(100vh - 110px); overflow-y: auto;
  margin: 22px 24px 0 0; padding: 0 0 20px;
}
.dtoc > summary {
  cursor: pointer; list-style: none;
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--mist);
  padding: 8px 0; border-bottom: 1px solid var(--line); margin-bottom: 8px;
}
.dtoc > summary::-webkit-details-marker { display: none; }
.dtoc > summary::after { content: " +"; color: var(--amber-2); }
.dtoc[open] > summary::after { content: " \2013"; }
.dtoc ul { list-style: none; margin: 0; padding: 0; }
.dtoc a {
  display: block; padding: 5px 10px; border-left: 2px solid var(--line);
  color: var(--ink-2); font-size: .85rem; line-height: 1.35;
}
.dtoc a:hover { color: var(--ink); border-left-color: var(--line-2); text-decoration: none; }
.dtoc a.cur { color: var(--ink); border-left-color: var(--amber); font-weight: 600; }
.dtoc .lv3 a { padding-left: 22px; font-size: .82rem; }

@media (min-width: 1180px) {
  .dtoc { margin: 38px 24px 0 8px; }
  .dtoc > summary::after, .dtoc[open] > summary::after { content: ""; }
}

/* ---- article ------------------------------------------------------------------ */
.dart { max-width: 78ch; }
.dart h1 { font-size: clamp(1.85rem, 3.4vw, 2.6rem); max-width: 24ch; margin-bottom: 18px; }
.dart h2 {
  font-size: clamp(1.28rem, 2.2vw, 1.66rem); margin: 54px 0 14px;
  padding-top: 24px; border-top: 1px solid var(--line); scroll-margin-top: 88px;
}
.dart h3 { font-size: 1.14rem; margin: 36px 0 10px; scroll-margin-top: 88px; }
.dart h2 + h3 { margin-top: 22px; }
.dart h1 + p, .dart .lede { margin-top: 0; }
.dart p, .dart li { color: var(--ink-2); }
.dart p { max-width: 74ch; }
.dart > p:first-of-type { font-size: 1.05rem; }
.dart a { color: var(--blue); }
.dart ul, .dart ol { padding-left: 22px; margin: 0 0 1.1em; }
.dart li { margin-bottom: .5em; max-width: 72ch; }
.dart li::marker { color: var(--mist); }
.dart ol li::marker { font-family: var(--font-mono); font-size: .85em; }
.dart hr { border: none; border-top: 1px solid var(--line); margin: 44px 0; }
.dart hr + h2 { border-top: none; padding-top: 0; margin-top: 0; }
.dart .subhead { max-width: none; }
.dart strong { color: var(--ink); font-weight: 650; }

.dart a.anch {
  /* --line-2 is a hairline token: 1.55:1 light / 2.09:1 dark as text. --mist is
     the quietest token measured >= 4.5:1 on every surface, in both schemes. */
  margin-left: 10px; color: var(--mist); font-family: var(--font-mono);
  font-size: .7em; text-decoration: none;
}
.dart a.anch:hover { color: var(--amber-2); text-decoration: none; }

.dart :not(pre) > code {
  font-family: var(--font-mono); font-size: .84em; color: var(--ink);
  background: var(--mist-w); border: 1px solid var(--line);
  border-radius: 6px; padding: 1px 5px;
}
.dart pre {
  background: var(--band); color: var(--band-fg-2);
  border: 1px solid var(--band-line); border-radius: var(--r);
  padding: 15px 18px; margin: 18px 0; overflow-x: auto;
  font-size: .85rem; line-height: 1.6;
}
.dart pre code { font-family: var(--font-mono); white-space: pre; }

.tablewrap {
  margin: 20px 0; overflow-x: auto;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--card);
}
.dart table { border-collapse: collapse; width: 100%; font-size: .91rem; }
.dart th {
  text-align: left; font-family: var(--font-mono); font-weight: 500;
  font-size: .68rem; letter-spacing: .07em; text-transform: uppercase;
  color: var(--mist); padding: 12px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.dart td {
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  color: var(--ink-2); vertical-align: top;
}
.dart tbody tr:last-child td { border-bottom: none; }

.callout {
  margin: 22px 0; padding: 16px 18px;
  border: 1px solid var(--line); border-left: 3px solid var(--amber);
  border-radius: 0 var(--r) var(--r) 0; background: var(--card);
}
.callout p { margin: 0 0 .7em; font-size: .93rem; max-width: 70ch; }
.callout p:last-child { margin-bottom: 0; }
.callout .callout-l {
  font-family: var(--font-display); font-weight: 650; font-size: .96rem;
  color: var(--amber-2); margin-bottom: .45em;
}

/* ---- prev / next ---------------------------------------------------------------- */
.dpn { display: grid; gap: 14px; margin-top: 60px; padding-top: 26px; border-top: 1px solid var(--line); }
@media (min-width: 700px) { .dpn { grid-template-columns: 1fr 1fr; } }
.dpn a {
  display: block; padding: 16px 18px; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r); background: var(--card);
}
.dpn a:hover { border-color: var(--line-2); text-decoration: none; }
.dpn .k {
  display: block; font-family: var(--font-mono); font-size: .68rem;
  letter-spacing: .1em; text-transform: uppercase; color: var(--mist); margin-bottom: 6px;
}
.dpn .n { font-weight: 650; }
.dpn .next { text-align: right; grid-column: 2; }
@media (max-width: 699px) { .dpn .next { text-align: left; grid-column: 1; } }

/* ---- overview ------------------------------------------------------------------- */
.dart--index { max-width: 92ch; }
.dart--index .subhead { margin-top: 48px; }
.dcards { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
@media (min-width: 820px) { .dcards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.dcard {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--card); padding: 22px 20px;
}
.dcard-n { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .1em; color: var(--amber-2); }
.dcard h2 {
  font-size: 1.1rem; margin: 8px 0 8px; padding: 0; border: none;
}
.dcard h2 a { color: var(--ink); }
.dcard h2 a:hover { color: var(--blue); text-decoration: none; }
.dcard p { font-size: .92rem; margin: 0; max-width: none; }
.dcard-s { list-style: none; margin: 14px 0 0; padding: 12px 0 0; border-top: 1px solid var(--line); }
.dcard-s li { margin: 0 0 2px; }
.dcard-s li { line-height: 1.45; margin-bottom: 5px; }
.dcard-s a { font-family: var(--font-mono); font-size: .74rem; color: var(--mist); }
.dcard-s a:hover { color: var(--blue); }

/* ---- the drawer, below 820 --------------------------------------------------------- */
.dscrim { display: none; }

@media (max-width: 820px) {
  .dmenu { display: inline-flex; }
  .topbar--docs .topnav { display: none; }
  .dshell { grid-template-columns: minmax(0, 1fr); }
  .dmain { grid-column: 1; grid-row: 2; padding: 22px 24px 76px; }
  .dtoc { grid-column: 1; grid-row: 1; position: static; max-height: none; margin: 20px 24px 0; }
  .dnav {
    /* align-self on a fixed grid item shifts it off its own `top` in Chromium */
    align-self: auto;
    position: fixed; top: 64px; left: 0; bottom: 0;
    /* leave >= 64px of scrim exposed at every phone width: at 360 CSS px, 86vw
       left a 50px strip, which is under the 44px target plus any margin. */
    width: min(320px, calc(100vw - 64px));
    z-index: 60; transform: translateX(-102%); transition: transform .2s ease;
    background: var(--card); border-right: 1px solid var(--line-2);
    max-height: none; padding-bottom: 80px;
  }
  .nav-open .dnav { transform: none; }
  .dscrim {
    display: block; position: fixed; top: 64px; left: 0; right: 0; bottom: 0;
    z-index: 55; background: rgba(14, 27, 44, .5);
  }
  .dscrim[hidden] { display: none; }
  .nav-open { overflow: hidden; }

  /* The drawer is modal, so the page behind it is HIDDEN, not dimmed. A 50%
     scrim over live text lands body copy at 4.2:1 and every quiet token near
     3:1; hiding the backdrop keeps the scrim as a flat wash and takes the
     content out of the tab order and the accessibility tree as well. The JS
     adds `inert` to the same region; this rule is what holds with JS off --
     with JS off the drawer never opens, so nothing is hidden either way. */
  .nav-open .dmain,
  .nav-open .dtoc,
  .nav-open .footer { visibility: hidden; }
}
@media (prefers-reduced-motion: reduce) { .dnav { transition: none; } }

@media (max-width: 620px) {
  .dart h2 { margin-top: 42px; }
  /* The header is one row and never wraps, so below 620 it sheds parts until
     what is left -- menu, wordmark, one call to action -- fits a 320px phone
     with room to spare. Measured at 320/360/414: no page-level h-scroll. */
  .topbar--docs .btn--ghost { display: none; }
  .docs-tag { display: none; }
  .topbar--docs .wrap { gap: 10px; }
  .topbar--docs .btn { padding: 8px 13px; font-size: .85rem; }
}

@media (max-width: 400px) {
  .dmain { padding: 18px 16px 64px; }
  .dtoc { margin: 16px 16px 0; }
  .dart h1 { font-size: 1.72rem; }
  .dart > p:first-of-type { font-size: 1rem; }
  .dart pre { padding: 13px 14px; font-size: .8rem; }
  .dart th, .dart td { padding: 10px 12px; }
  .callout { padding: 14px 15px; }
  .dmenu-t { display: none; }
  .dmenu { padding: 8px 11px; gap: 0; }
  .topbar--docs .brand { font-size: 1.1rem; }
  .topbar--docs .btn { padding: 8px 12px; font-size: .84rem; }
}
