/* The site's shared base: palette, type, ambient light, the light/dark switch and motion.
   A page links it before its own <style> and keeps its own layout on top. The look is the
   Familiars page's: graphite carries the page, violet marks what is live or a label, the warm
   ember appears once or twice per view. Light is a full second theme, not an inversion.
   scripts/site-style.mjs holds this file to that palette, to readable contrast in both themes
   and to motion that only runs when the visitor allows it. */

/* ---------- fonts: served from this site, no third-party request ----------
   Familjen Grotesk is its released variable font, re-encoded as WOFF2 with outlines and names
   unchanged. IBM Plex Mono is IBM's own WOFF2, split by script as IBM publishes it in
   @ibm/plex-mono 2.5.0, so the Reserved Font Name "Plex" stays on files its copyright holder
   made; a browser fetches a script's file only when the page uses a character from it. */
@font-face {
  font-family: "Familjen Grotesk";
  src: url("fonts/FamiljenGrotesk-VF.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/IBMPlexMono-Regular-Latin1.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0020-007E, U+00A0-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2013-2014, U+2018-201A, U+201C-201E, U+2020-2022, U+2026, U+2030, U+2039-203A, U+2044, U+20AC, U+2122, U+2212, U+FB01-FB02;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/IBMPlexMono-Regular-Latin2.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-0101, U+0104-0130, U+0132-0151, U+0154-017F, U+018F, U+0192, U+01A0-01A1, U+01AF-01B0, U+01FA-01FF, U+0218-021B, U+0237, U+0259, U+1E80-1E85, U+1E9E, U+20A1, U+20A4, U+20A6, U+20A8-20AA, U+20AD-20AE, U+20B1-20B2, U+20B4-20B5, U+20B8-20BA, U+20BD, U+20BF;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/IBMPlexMono-Regular-Latin3.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0102-0103, U+01CD-01DC, U+1E0C-1E0D, U+1E12-1E13, U+1E24-1E25, U+1E36-1E37, U+1E3C-1E3D, U+1E40-1E47, U+1E4A-1E4B, U+1E62-1E63, U+1E6C-1E6D, U+1E70-1E71, U+1E92-1E93, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/IBMPlexMono-Regular-Pi.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+03C0, U+0E3F, U+2000-200D, U+2010-2012, U+2015, U+2028-2029, U+202F, U+2032-2033, U+203E, U+205F, U+2070, U+2074-2079, U+2080-2089, U+2113, U+2116, U+2126, U+212E, U+2150-2151, U+2153-215E, U+2190-2199, U+21A9-21AA, U+21B0-21B3, U+21B6-21B7, U+21BA-21BB, U+21C4, U+21C6, U+2202, U+2206, U+220F, U+2211, U+2215, U+2219-221A, U+221E, U+222B, U+2236, U+2248, U+2260, U+2264-2265, U+2400-2421, U+2500-259F, U+25CA, U+2713, U+274C, U+2B0E-2B11, U+3000, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/IBMPlexMono-Medium-Latin1.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0020-007E, U+00A0-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2013-2014, U+2018-201A, U+201C-201E, U+2020-2022, U+2026, U+2030, U+2039-203A, U+2044, U+20AC, U+2122, U+2212, U+FB01-FB02;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/IBMPlexMono-Medium-Latin2.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-0101, U+0104-0130, U+0132-0151, U+0154-017F, U+018F, U+0192, U+01A0-01A1, U+01AF-01B0, U+01FA-01FF, U+0218-021B, U+0237, U+0259, U+1E80-1E85, U+1E9E, U+20A1, U+20A4, U+20A6, U+20A8-20AA, U+20AD-20AE, U+20B1-20B2, U+20B4-20B5, U+20B8-20BA, U+20BD, U+20BF;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/IBMPlexMono-Medium-Latin3.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0102-0103, U+01CD-01DC, U+1E0C-1E0D, U+1E12-1E13, U+1E24-1E25, U+1E36-1E37, U+1E3C-1E3D, U+1E40-1E47, U+1E4A-1E4B, U+1E62-1E63, U+1E6C-1E6D, U+1E70-1E71, U+1E92-1E93, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/IBMPlexMono-Medium-Pi.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+03C0, U+0E3F, U+2000-200D, U+2010-2012, U+2015, U+2028-2029, U+202F, U+2032-2033, U+203E, U+205F, U+2070, U+2074-2079, U+2080-2089, U+2113, U+2116, U+2126, U+212E, U+2150-2151, U+2153-215E, U+2190-2199, U+21A9-21AA, U+21B0-21B3, U+21B6-21B7, U+21BA-21BB, U+21C4, U+21C6, U+2202, U+2206, U+220F, U+2211, U+2215, U+2219-221A, U+221E, U+222B, U+2236, U+2248, U+2260, U+2264-2265, U+2400-2421, U+2500-259F, U+25CA, U+2713, U+274C, U+2B0E-2B11, U+3000, U+FEFF, U+FFFD;
}

/* ---------- tokens ---------- */
:root {
  --ground: #0F0F13;      /* page */
  --ground-2: #16161C;    /* cards, buttons */
  --raise: #1C1C24;       /* raised panels */
  --ink: #EDEBF3;         /* text */
  --mute: #9C99AA;        /* secondary text */
  --faint: #9C99AA;       /* small print: as readable as secondary text */
  --hair: #2A2933;        /* 1px borders, dividers */
  --accent: #A898FF;      /* violet: labels, focus, live states, links */
  --accent-soft: rgba(168, 152, 255, 0.16);
  --accent-dim: color-mix(in srgb, var(--accent) 42%, var(--hair));
  --ember: #FFB46B;       /* the one warm point */
  --ember-soft: rgba(255, 180, 107, 0.28);
  --halo: 0.55;
  --radius-card: 14px;
  --radius-panel: 18px;
  --display: "Familjen Grotesk", "Helvetica Neue", Arial, sans-serif;
  --body: "Familjen Grotesk", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --ground: #F2F1F6;
    --ground-2: #FFFFFF;
    --raise: #F8F7FB;
    --ink: #16151C;
    --mute: #5C5A6A;
    --faint: #5C5A6A;
    --hair: #DAD8E2;
    --accent: #5A45D6;
    --accent-soft: rgba(90, 69, 214, 0.12);
    --ember: #B8601A;
    --ember-soft: rgba(184, 96, 26, 0.22);
    --halo: 0.32;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --ground: #F2F1F6;
  --ground-2: #FFFFFF;
  --raise: #F8F7FB;
  --ink: #16151C;
  --mute: #5C5A6A;
  --faint: #5C5A6A;
  --hair: #DAD8E2;
  --accent: #5A45D6;
  --accent-soft: rgba(90, 69, 214, 0.12);
  --ember: #B8601A;
  --ember-soft: rgba(184, 96, 26, 0.22);
  --halo: 0.32;
  color-scheme: light;
}

/* A terminal shown on a page (.cmd, or anything marked .specimen) is a dark specimen in either
   theme: inside one, every colour token keeps its dark value, so its text stays light on its
   surface. --accent-dim is re-declared too: a token built from others is resolved where it is
   declared, so the :root one would keep the light mix. */
.specimen,
.cmd {
  --ground: #0F0F13;
  --ground-2: #16161C;
  --raise: #1C1C24;
  --ink: #EDEBF3;
  --mute: #9C99AA;
  --faint: #9C99AA;
  --hair: #2A2933;
  --accent: #A898FF;
  --accent-soft: rgba(168, 152, 255, 0.16);
  --accent-dim: color-mix(in srgb, var(--accent) 42%, var(--hair));
  --ember: #FFB46B;
  --ember-soft: rgba(255, 180, 107, 0.28);
  color-scheme: dark;
}

/* ---------- base ---------- */
/* Keyboard focus scrolled into view stops above the floating switch, never under it. */
html { scroll-padding-bottom: 96px; }
body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--body);
  /* A turning stage's square corners would otherwise widen the page while they turn. */
  overflow-x: clip;
}
/* Colours cross-fade when the visitor flips the switch (the script sets data-theme-fade first),
   not when a remembered choice is applied as the page loads. */
:root[data-theme-fade] body { transition: background-color 0.5s ease, color 0.5s ease; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- ambient light: <div class="lights" aria-hidden="true"> with three spans, early in
   <body>; the page lifts its content above it (position: relative; z-index: 1) ---------- */
.lights { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.lights span { position: absolute; border-radius: 50%; filter: blur(70px); opacity: var(--halo); }
.lights .l1 { width: 46vmax; height: 46vmax; left: -12vmax; top: -16vmax; background: radial-gradient(circle, var(--accent-soft), transparent 70%); }
.lights .l2 { width: 34vmax; height: 34vmax; right: -10vmax; top: 30vh; background: radial-gradient(circle, var(--ember-soft), transparent 70%); }
.lights .l3 { width: 40vmax; height: 40vmax; left: 20vw; bottom: -22vmax; background: radial-gradient(circle, var(--accent-soft), transparent 70%); }

/* ---------- the light/dark switch: a floating pill, bottom right, drawn as on the Familiars
   page; its knob holds the sun and moon as inline SVG (class sun and moon), and shows the sun
   while the page is dark and the moon while it is light, each naming the theme it turns on ---------- */
.theme-switch {
  position: fixed;
  right: calc(20px + env(safe-area-inset-right, 0px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 20px 0 8px;
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  background: var(--ground-2);
  color: var(--ink);
  font: 600 15px var(--body);
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(15, 15, 19, 0.25), 0 0 0 6px var(--accent-soft);
  transition: background-color 0.5s, color 0.5s;
}
/* The page's script unhides the switch; without the script it stays hidden, since it would do nothing. */
.theme-switch[hidden] { display: none; }
.theme-switch-knob {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--ground);
  flex: none;
}
.theme-switch svg { width: 20px; height: 20px; }
.theme-switch .moon,
:root[data-eff="light"] .theme-switch .sun { display: none; }
:root[data-eff="light"] .theme-switch .moon { display: block; }

/* Paused from the page (data-motion="paused" on the root): every looping animation holds its
   frame, the root's own included. What would hold a half-finished frame or still answer the
   pointer (a one-off animation, a lift on hover, the pointer light) is written under
   :root:not([data-motion="paused"]) below and on the page, so the pause removes it. */
:root[data-motion="paused"],
:root[data-motion="paused"] *,
:root[data-motion="paused"] *::before,
:root[data-motion="paused"] *::after { animation-play-state: paused !important; }

/* ---------- surfaces with a pointer light: the page's script marks them .lit and sets --mx and
   --my as the pointer moves; the page gives them their own border and background. The light
   itself shows only while motion is allowed and not paused; the border answers the pointer either way. */
.lit { --mx: 50%; --my: 50%; position: relative; overflow: hidden; }
.lit::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(260px circle at var(--mx) var(--my), var(--accent-soft), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.lit:hover { border-color: var(--accent); }
.lit > * { position: relative; }

/* ---------- motion, only when the visitor allows it ---------- */
@media (prefers-reduced-motion: no-preference) {
  .lights .l1 { animation: drift-a 26s ease-in-out infinite alternate; }
  .lights .l2 { animation: drift-b 32s ease-in-out infinite alternate; }
  .lights .l3 { animation: drift-a 38s ease-in-out infinite alternate-reverse; }
  @keyframes drift-a { to { transform: translate(8vw, 6vh) scale(1.1); } }
  @keyframes drift-b { to { transform: translate(-10vw, -8vh) scale(0.92); } }
  :root:not([data-motion="paused"]) .lit { transition: border-color 0.25s, transform 0.25s; }
  :root:not([data-motion="paused"]) .lit:hover { transform: translateY(-2px); }
  :root:not([data-motion="paused"]) .lit:hover::before { opacity: 1; }
  :root:not([data-motion="paused"]) .theme-switch { transition: background-color 0.5s, color 0.5s, transform 0.2s; }
  :root:not([data-motion="paused"]) .theme-switch:hover { transform: translateY(-2px); }
}
