/* ──────────────────────────────────────────────────────────────
   tokens.css — semantic aliases + the dark palette
   Loads AFTER tailwind.css, so re-declaring --color-* here flips
   Tailwind utilities (bg-ground, text-ink-2 …) as well as the
   material classes. Light values live in the Tailwind @theme.
   ────────────────────────────────────────────────────────────── */

:root {
  color-scheme: light;

  /* Ink that sits ON the accent fill. */
  --on-accent: #ffffff;

  /* One material, expressed as alphas over the ground. */
  --material: rgb(255 255 255 / 0.62);
  --material-strong: rgb(255 255 255 / 0.78);
  --material-field: rgb(255 255 255 / 0.72);

  /* Hairlines and recesses derive from ink, never from a new hue. */
  --hairline: rgb(28 27 25 / 0.1);
  --hairline-strong: rgb(28 27 25 / 0.16);
  --recess: rgb(28 27 25 / 0.04);
  --gold-hairline: rgb(184 154 94 / 0.45);

  --blur: 24px;
  --saturate: 130%;

  /* The page photograph. Swap the filename to change it; set `none` to go
     back to the flat token colour. Three are shipped, all public domain —
     see app/assets/images/backgrounds/README.md.
       sacred_sunrise.webp   Kensett, quietest, horizontal bands  (default)
       morning_sky.webp      Sargent, soft blue watercolour
       heavenly_clouds.webp  Cole, a towering cumulus — most dramatic */
  --ground-image: url("/assets/backgrounds/sacred_sunrise-30765337.webp");
  --ground-image-opacity: 0.2;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --color-ground: #15161a;
    --color-ground-edge: #0d0e11;

    --color-ink: #f1eee8;
    --color-ink-2: #b4afa6;
    --color-ink-3: #837e76;

    --color-accent: #93b2e2;
    --color-accent-hover: #adc6ee;
    --color-accent-soft: #1e2635;
    --on-accent: #10161f;

    --color-gold: #c9ab6c;
    --color-rubric: #d98b85;
    --color-affirm: #78b394;
    --color-caution: #cfa65a;

    --material: rgb(255 255 255 / 0.07);
    --material-strong: rgb(255 255 255 / 0.11);
    --material-field: rgb(255 255 255 / 0.06);

    --hairline: rgb(255 255 255 / 0.12);
    --hairline-strong: rgb(255 255 255 / 0.2);
    --recess: rgb(0 0 0 / 0.22);
    --gold-hairline: rgb(201 171 108 / 0.4);

    --shadow-hair: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow-raise: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px -10px rgb(0 0 0 / 0.6);
    --shadow-float: 0 2px 4px rgb(0 0 0 / 0.35), 0 20px 48px -16px rgb(0 0 0 / 0.7);

    /* The photograph is lit for a light ground. On the dark palette it has to
       sit much further back or it washes the ink out. */
    --ground-image-opacity: 0.08;
  }
}

/* The ground. Solid token colour plus one optional tonal vignette
   made from a single colour at two alphas — one hue only. */
html {
  background-color: var(--color-ground);
}

body {
  /* Deliberately no background-color. `html` above paints the ground, while
     body::before (vignette) and body::after (photograph) sit at negative
     z-index. Because html carries a background, body's own background is not
     propagated to the canvas — it would paint as an ordinary block background,
     which comes after negative-z descendants and hides both of them. */
  color: var(--color-ink);
  min-height: 100dvh;
  position: relative;
  /* Column layout so the footer sits at the bottom of short pages. */
  display: flex;
  flex-direction: column;
}

main {
  flex: 1 0 auto;
}

/* Vignette: ground-edge at two alphas, fixed, behind everything. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-color: var(--color-ground);
  box-shadow: inset 0 0 180px 0 color-mix(in oklab, var(--color-ground-edge) 70%, transparent),
    inset 0 0 420px 0 color-mix(in oklab, var(--color-ground-edge) 30%, transparent);
}

/* Optional photograph slot. Stays invisible until --ground-image is set. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: var(--ground-image);
  background-size: cover;
  background-position: center;
  opacity: var(--ground-image-opacity);
}
