/* Förrädarna — design system.
   Ink, bone, ash and blood. No cards, no rounded rectangles, no boxes in boxes.
   Typography is the interface; the light follows the game (html[data-light]). */

:root {
  --ink: #0c0b0d;
  --ink-soft: #19171b;
  --bone: #ebe7e0;
  --bone-dim: #cdc7bd;
  --ash: #8b8682;
  --ash-deep: #55514d;
  --blood: #b5002d;
  --blood-hot: #ff2453;
  --blood-black: #19000a;
  --frost: #9cc2e4;
  --steel: #a8b1bb;

  --f-ritual: "Grenze Gotisch", "UnifrakturMaguntia", "Old English Text MT", Georgia, serif;
  --f-text: "Familjen Grotesk", "Helvetica Neue", Arial, system-ui, sans-serif;

  /* semantic, re-pointed per light */
  --ground: var(--ink);
  --fg: var(--bone);
  --accent: var(--blood-hot);
  --dim: color-mix(in srgb, var(--fg) 56%, var(--ground));
  --faint: color-mix(in srgb, var(--fg) 17%, var(--ground));
  --whisper: color-mix(in srgb, var(--fg) 7%, var(--ground));

  --spine-w: 46px;
  --pad: 20px;
  --band-h: 76px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-drama: cubic-bezier(.7, 0, .2, 1);
  --light-t: 1.4s;

  color-scheme: dark;
}

html[data-light="day"]   { --ground: var(--bone); --fg: var(--ink); --accent: var(--blood); color-scheme: light; }
html[data-light="night"] { --ground: var(--ink); --fg: var(--bone); --accent: var(--blood-hot); }
html[data-light="blood"] { --ground: var(--blood-black); --fg: #f2dde2; --accent: var(--blood-hot); }
html[data-light="ash"]   { --ground: #1b1a19; --fg: #b9b4ae; --accent: #d2ccc5; }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ground);
  color: var(--fg);
  font-family: var(--f-text);
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  transition: background-color var(--light-t) var(--ease-drama), color var(--light-t) var(--ease-drama);
}

/* film grain over everything, never intercepts input */
body::before {
  content: "";
  position: fixed;
  inset: -50%;
  z-index: 90;
  pointer-events: none;
  opacity: .07;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .5  0 0 0 0 .5  0 0 0 0 .5  0 0 0 1.2 -.1'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
html[data-light="day"] body::before { opacity: .11; }

::selection { background: var(--accent); color: var(--ground); }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-underline-offset: .18em; }

/* ---------- frame ---------- */

.spine {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  width: var(--spine-w);
  z-index: 20;
  border-right: 1px solid var(--faint);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: calc(18px + var(--safe-t)) 0 calc(18px + var(--safe-b));
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--f-ritual);
  font-weight: 700;
  font-size: 34px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
}
.spine small {
  font-family: var(--f-text);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--dim);
  margin-top: 14px;
}

.stage {
  padding: calc(22px + var(--safe-t)) var(--pad) calc(var(--band-h) + var(--safe-b) + 40px) calc(var(--spine-w) + var(--pad));
  min-height: 100dvh;
  overflow-x: clip;
}
.stage.no-band { padding-bottom: calc(40px + var(--safe-b)); }

/* ---------- type ---------- */

.ritual {
  font-family: var(--f-ritual);
  font-weight: 800;
  font-size: clamp(60px, 23vw, 150px);
  line-height: .8;
  letter-spacing: -.012em;
  margin: 0;
  overflow-wrap: normal;
}
.ritual.crop { margin-left: -.06em; white-space: nowrap; }
.ritual-m {
  font-family: var(--f-ritual);
  font-weight: 700;
  font-size: clamp(36px, 11vw, 64px);
  line-height: .9;
  margin: 0;
}

.kicker {
  font-family: var(--f-text);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0;
}

.lede {
  font-size: 21px;
  line-height: 1.3;
  max-width: 26ch;
  margin: 0;
  letter-spacing: -.01em;
}

.dim { color: var(--dim); }
.accent { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }

hr, .rule {
  border: 0;
  height: 1px;
  background: var(--faint);
  margin: 0;
}

.stack > * + * { margin-top: var(--gap, 18px); }
.gap-s { --gap: 8px; }
.gap-l { --gap: 34px; }
.gap-xl { --gap: 64px; }

/* ---------- the cast list: names as typography ---------- */

.cast { list-style: none; margin: 0; padding: 0; }
.cast > li {
  display: grid;
  grid-template-columns: 2.7em 1fr auto;
  align-items: baseline;
  column-gap: 8px;
  padding: 13px 0 11px;
  border-top: 1px solid var(--faint);
}
.cast > li:last-child { border-bottom: 1px solid var(--faint); }
.cast .seat {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.cast .name {
  font-size: 30px;
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
  transition: color .3s, font-size .3s;
}
.cast .tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--dim);
  text-align: right;
  white-space: nowrap;
}

.cast > li.is-me .seat::after { content: " · du"; letter-spacing: .06em; }

/* out of the game: a blood stroke through the name — through every line of it, when it wraps */
.cast > li.is-out .name {
  color: var(--dim);
  text-decoration-line: line-through;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 3px;
  width: fit-content;
}
.cast > li.is-banished .name { text-decoration-thickness: 1px; }

/* pickable lists: selecting a name turns it to gothic blood */
.cast.pick > li { cursor: pointer; user-select: none; -webkit-user-select: none; }
.cast.pick > li:active .name { transform: translateX(3px); }
.cast > li.is-selected .name {
  font-family: var(--f-ritual);
  font-weight: 800;
  font-size: 40px;
  line-height: .9;
  letter-spacing: 0;
  color: var(--accent);
}
.cast > li.is-disabled { opacity: .35; pointer-events: none; }

/* ---------- actions ---------- */

/* the band: one full-bleed action anchored to the thumb */
.band {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  height: calc(var(--band-h) + var(--safe-b));
  padding: 0 var(--pad) var(--safe-b);
  border: 0;
  border-radius: 0;
  background: var(--fg);
  color: var(--ground);
  font-family: var(--f-text);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .24em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  /* its own state (armed, disabled) changes at once; only a change of light is slow (below) */
  transition: background-color .12s ease-out, color .12s ease-out, box-shadow .12s ease-out, opacity .12s ease-out;
}
/* F.setLight marks the html while the light turns, so the band turns with the ground */
html.is-relit .band { transition-duration: var(--light-t); transition-timing-function: var(--ease-drama); }
.band.hold {
  --p: 0;
  background:
    linear-gradient(90deg, var(--accent) calc(var(--p) * 100%), transparent 0),
    var(--fg);
}
.band.hold.is-holding { color: var(--ground); }
/* a band with nothing to do yet is uninked: just its words between hairlines, not a grey slab */
.band[disabled] {
  cursor: default;
  background: var(--ground);
  color: var(--dim);
  box-shadow: inset 0 1px var(--faint), inset 0 -1px var(--faint);
}
.band.inline { position: static; width: 100%; height: var(--band-h); padding-bottom: 0; }

.text-btn {
  background: none;
  border: 0;
  padding: 10px 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--fg);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .5em;
  user-select: none;
  -webkit-user-select: none;
}
.text-btn[disabled] { opacity: .3; cursor: default; }
.text-btn.is-on { color: var(--accent); }

/* the seal: a circle you hold; it fills like a clock hand sweeping */
.seal {
  --p: 0;
  --size: 136px;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  border: 1.5px solid var(--fg);
  background: conic-gradient(var(--accent) calc(var(--p) * 1turn), transparent 0);
  display: grid;
  place-items: center;
  color: var(--fg);
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  transition: transform .4s var(--ease-out);
}
.seal svg { width: 46%; height: 46%; }
.seal.is-holding { transform: scale(.94); }

/* ---------- fields ---------- */

.field {
  display: block;
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--fg);
  border-radius: 0;
  padding: 6px 0 8px;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--fg);
  caret-color: var(--accent);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.field::placeholder { color: var(--faint); }
.field:focus { border-bottom-color: var(--accent); }
textarea.field { font-size: 20px; line-height: 1.35; resize: vertical; min-height: 4.2em; }

/* one line of feedback above the band — never a floating toast. The page scrolls under it,
   so the words stand on ground of their own. */
#say {
  position: fixed;
  left: calc(var(--spine-w) + var(--pad));
  right: var(--pad);
  bottom: calc(var(--band-h) + var(--safe-b) + 4px);
  z-index: 31;
  margin: 0;
  padding: 8px 0;
  background: var(--ground);
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .25s, transform .25s var(--ease-out), background-color var(--light-t) var(--ease-drama);
  pointer-events: none;
}
#say.is-on { opacity: 1; transform: none; }

/* connection pip */
.pip {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--faint);
  vertical-align: middle;
}
.pip.is-on { background: var(--accent); }

.sigil { display: inline-block; width: 1em; height: 1em; vertical-align: -.12em; }

/* the link-status hairline at the very top */
.wire {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  z-index: 95;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform .6s var(--ease-out);
}
.wire.is-lost { transform: scaleX(1); animation: wire-pulse 1.2s ease-in-out infinite; }
@keyframes wire-pulse { 50% { opacity: .25; } }

.hidden { display: none !important; }

@media (min-width: 720px) {
  :root { --spine-w: 64px; --pad: 40px; }
  .spine { font-size: 46px; }
  .stage { max-width: 860px; }
  .band { max-width: 860px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Safari before 16.2 has no color-mix(): a custom property holding one turns invalid where it is
   used, so dim text shows at full strength and the hairlines vanish. The same mixes, worked out
   per light (fg · p + ground · (1 − p), p = 56 / 17 / 7 %), stand in. */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
  :root, html[data-light="night"] { --dim: #898683; --faint: #323031; --whisper: #1c1a1c; }
  html[data-light="day"]   { --dim: #6e6c6a; --faint: #c5c2bc; --whisper: #dbd8d1; }
  html[data-light="blood"] { --dim: #937c83; --faint: #3e262f; --whisper: #280f19; }
  html[data-light="ash"]   { --dim: #73706c; --faint: #363432; --whisper: #262523; }
}
