/* ============================================================================
   Design tokens. Single source of truth for the Meticulous brand system:
   cream paper, black ink, one yellow accent. Do not widen the palette.
   ========================================================================== */

:root {
  /* Color */
  --paper: #F6F1E6;
  --ink: #0D0D0D;
  --ink-muted: #5C574C;            /* 6.3:1 on paper, ok for small text */
  --accent: #EDB662;               /* wheat yellow, decorative + large accents only */
  --on-accent: #0D0D0D;            /* text on the yellow, in either theme */

  --hairline: rgba(13, 13, 13, 0.35);
  --trace: rgba(13, 13, 13, 0.28); /* underdrawing ink */
  --trace-faint: rgba(13, 13, 13, 0.10);

  --surface-dark: #16130D;         /* testimonial and footer ground */
  --paper-on-dark: #F6F1E6;
  --muted-on-dark: rgba(246, 241, 230, 0.78);
  --hairline-on-dark: rgba(246, 241, 230, 0.28);

  /* Type */
  --font-display: "Faraon", "Faraon Fallback", "Iowan Old Style", Georgia, serif;
  --font-body: "Gotham SSm A", "Gotham SSm B", "Avenir Next", "Segoe UI", Helvetica, Arial, sans-serif;

  --text-sm: 0.8125rem;
  --text-base: 1.125rem;
  --text-description: 1.0625rem;
  --text-lede: 1.1875rem;
  --text-h3: clamp(1.375rem, 1.2rem + 0.8vw, 1.75rem);
  --text-h2: clamp(1.875rem, 1.4rem + 2vw, 2.75rem);
  --text-h1: clamp(2.5rem, 1.5rem + 3.9vw, 4rem);

  /* Layout */
  --content-max: 72rem;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --margin-zone: clamp(0rem, 8vw - 4rem, 5rem); /* room for marginalia at wide sizes */
  --section-pad: clamp(4rem, 9vw, 7.5rem);

  /* Focus */
  --focus-ring-width: 2px;
  --focus-ring-offset: 3px;
}

/* ----------------------------------------------------------------------------
   Dark theme. The public layout puts `theme-dark` on <body>, so the whole
   site uses it; the admin layout does not, and stays on paper. The tokens are
   set on the root so the page ground behind the body follows. It swaps the
   paper and ink tokens, so anything built on the tokens follows. The same
   palette, reversed: dark ground, paper ink, the one yellow.
   -------------------------------------------------------------------------- */

:root:has(body.theme-dark) {
  --paper: #16130D;
  --ink: #F6F1E6;
  --ink-muted: #B4AE9F;            /* 8.4:1 on the dark ground */
  --hairline: rgba(246, 241, 230, 0.3);
  --trace: rgba(246, 241, 230, 0.24);
  --trace-faint: rgba(246, 241, 230, 0.12);
  color-scheme: dark;
}

body.theme-dark {
  background-image: none;
}

/* Yellow surfaces keep dark text whichever theme is on. Bands re-scope the
   ink tokens so everything inside them follows; single controls just set
   their text. */
.theme-dark :is(.entry-line, .cta-band, .flash, .copy-todo, .story-result) {
  --ink: #0D0D0D;
  --paper: #F6F1E6;
  --ink-muted: #5C574C;
  --hairline: rgba(13, 13, 13, 0.35);
  color: var(--ink);
}

.theme-dark :is(.button--primary, .button--ghost:hover, .site-nav__submenu a:hover,
                .post-filter a:hover, .newsletter-form .button,
                .newsletter-form input[type="submit"],
                .contact-sheet__form input[type="submit"], .video-facade__play) {
  color: var(--on-accent);
}

.theme-dark .post-filter a[aria-current="page"] {
  color: var(--paper);
}

/* Panels that were a veil of white over paper become a faint lift off the
   dark ground. */
.theme-dark :is(.form-sheet input[type="text"], .form-sheet input[type="email"],
                .form-sheet input[type="password"], .form-sheet input[type="date"],
                .form-sheet input[type="url"], .form-sheet input[type="file"],
                .form-sheet textarea, .form-sheet select, .offer-terms,
                .image-slot__frame, .contact-confirm, .devux-launch,
                .series-volume a, .case-study__wip) {
  background-color: rgba(246, 241, 230, 0.06);
}

.theme-dark .form-sheet select option {
  background: #16130D;
  color: #F6F1E6;
}

/* Sheets of white paper stay paper, with dark ink, lying on the dark ground:
   the article cards on /writings and the article sheet itself. */
.theme-dark :is(.post-card, .post-paper, .post-hero:not(.post-hero--illustrated),
                .hero__sheet) {
  --paper: #F6F1E6;
  --ink: #0D0D0D;
  --ink-muted: #5C574C;
  --hairline: rgba(13, 13, 13, 0.35);
  --trace: rgba(13, 13, 13, 0.28);
  --trace-faint: rgba(13, 13, 13, 0.10);
  color: var(--ink);
}

/* On small screens an illustrated headline drops below its picture onto a
   white strip (see writings.css), so it takes dark ink there too. */
@media (max-width: 767px) {
  .theme-dark .post-hero__headline {
    --ink: #0D0D0D;
    --ink-muted: #5C574C;
    color: var(--ink);
  }
}

/* Error red, lifted so it reads on the dark ground. */
.theme-dark :is(.form-sheet .error, .form-sheet__errors, .flash--alert) {
  color: #F2A98C;
  border-color: #F2A98C;
}

.theme-dark :is(.form-sheet input, .form-sheet textarea, .form-sheet select)[aria-invalid="true"] {
  border-color: #F2A98C;
}

/* Client logos are dark single-colour marks; reverse them. */
.theme-dark .clients__logo {
  filter: invert(1) grayscale(1);
}

/* The footer shares the page ground in this theme, so rule it off. */
.theme-dark .site-footer {
  border-top: 1px solid var(--hairline);
}
