/* Frightober — Alpen Archive type system, dark by default, blood red in place of terracotta. */

:root {
  --bg: #f6f4f1;
  --surface: #ebe7e2;
  --surface-2: #dfdad4;
  --ink: #1b1b1b;
  --muted: #6b6762;
  --faint: #a19b95;
  --blood: #9e1b1b;
  --veil: #f6f4f1;
  --sans: 'Inter', system-ui, sans-serif;
  --serif: 'Newsreader', Georgia, serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --gutter: clamp(16px, 4vw, 64px);
}
.dark {
  --bg: #141212;
  --surface: #1f1c1c;
  --surface-2: #2a2626;
  --ink: #f2efe9;
  --muted: #a39d97;
  --faint: #5f5955;
  --blood: #c62a22;
  --veil: #141212;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); color-scheme: light dark; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
body.locked { overflow: hidden; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.material-symbols-outlined { font-size: 20px; line-height: 1; }

.label {
  display: block;
  font: 700 10px/1.4 var(--sans);
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--blood);
}

/* Nav */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px var(--gutter);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  font: 700 10px var(--sans); letter-spacing: 0.3em; text-transform: uppercase;
}
.nav__back { display: flex; gap: 10px; align-items: center; text-decoration: none; }
.nav__back:hover, .nav__theme:hover { color: var(--blood); }
.nav__center { color: var(--muted); }
@media (max-width: 640px) { .nav__center { display: none; } }

/* Hero */
.hero { padding: 96px var(--gutter) 64px; max-width: 1920px; margin: 0 auto; }
.hero__title {
  font: 900 clamp(44px, 14vw, 260px)/0.82 var(--sans);
  letter-spacing: -0.05em;
  text-transform: uppercase;
}
/* The TV: a dark screen regardless of theme. tv.js swaps the fallback for a WebGL CRT. */
.tv {
  position: relative;
  aspect-ratio: 16 / 8;
  background: #0b0a0a;
  margin: 0 0 56px;
  overflow: hidden;
}
@media (max-width: 640px) { .tv { aspect-ratio: 4 / 3; } }
.tv__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity .6s; }
.tv__fallback {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: center;
  padding: 0 4%;
  color: #f2efe9;
}
.tv__fallback::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,.35) 0 1px, transparent 1px 3px),
              radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.65));
}
.tv__fallback .hero__lede { color: #a39d97; margin-top: 24px; font-size: clamp(15px, 1.8vw, 26px); }
.tv__fallback .hero__title { margin: 16px 0 0 -0.04em; font-size: clamp(40px, 12vw, 230px); }
.tv--live .tv__canvas { opacity: 1; }
.tv--live .tv__fallback { opacity: 0; }

.hero__lede {
  font: italic 400 clamp(22px, 2.4vw, 34px)/1.35 var(--serif);
  max-width: 34ch;
  color: var(--muted);
}
.hero__stats { display: flex; flex-wrap: wrap; gap: 32px 64px; margin-top: 64px; }
.hero__stats dt { font: 700 10px var(--sans); letter-spacing: 0.3em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.hero__stats dd { font: 800 clamp(32px, 4vw, 56px)/1 var(--sans); letter-spacing: -0.03em; }

/* Year tabs */
.archive { max-width: 1920px; margin: 0 auto; padding: 0 var(--gutter) 128px; }
.years {
  display: flex; gap: 8px; overflow-x: auto;
  position: sticky; top: 58px; z-index: 10;
  background: var(--bg); padding: 16px 0;
  scrollbar-width: none;
}
.years::-webkit-scrollbar { display: none; }
.years button {
  font: 800 clamp(20px, 2.4vw, 32px)/1 var(--sans);
  letter-spacing: -0.03em;
  padding: 12px 20px;
  color: var(--faint);
  background: var(--surface);
  white-space: nowrap;
  transition: color .2s, background .2s;
}
.years button:hover { color: var(--ink); }
.years button[aria-selected="true"] { color: var(--bg); background: var(--ink); }
.years sup { font: 700 9px var(--sans); letter-spacing: 0.2em; margin-left: 6px; vertical-align: top; color: var(--blood); }

.year__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 16px 48px; padding: 48px 0 32px; }
.year__title { font: italic 400 clamp(40px, 6vw, 96px)/1 var(--serif); }
.year__title .label { display: inline; margin-left: 16px; vertical-align: middle; }
.year__meta { font: 500 16px/1.7 var(--mono); color: var(--muted); max-width: 60ch; margin-top: -0.25em; }
.year__meta b { color: var(--ink); font-weight: 500; }
.year__meta button { font: inherit; color: var(--blood); text-decoration: underline; text-underline-offset: 3px; }

/* Grid of nights */
.grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: clamp(6px, 0.8vw, 14px);
}
@media (max-width: 1024px) { .grid { grid-template-columns: repeat(5, 1fr); } }
@media (max-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.night { position: relative; aspect-ratio: 2 / 3; background: var(--surface); }
.night__btn { position: absolute; inset: 0; display: block; width: 100%; overflow: hidden; text-align: left; }
.night img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  filter: grayscale(0.55) contrast(1.05);
  transition: filter .5s, transform .6s cubic-bezier(.16, 1, .3, 1);
}
.night__btn:hover img, .night__btn:focus-visible img { filter: none; transform: scale(1.04); }
.night__btn:focus-visible { outline: 2px solid var(--blood); outline-offset: 2px; }
.night__num {
  position: absolute; top: 8px; left: 8px;
  font: 500 11px var(--mono); color: #fff;
  background: rgba(0, 0, 0, .55); padding: 3px 6px;
}
.night__cap {
  position: absolute; inset: auto 0 0 0;
  padding: 40px 10px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .85));
  color: #fff;
  opacity: 0; transform: translateY(6px);
  transition: opacity .3s, transform .3s;
}
.night__btn:hover .night__cap, .night__btn:focus-visible .night__cap { opacity: 1; transform: none; }
@media (hover: none) { .night__cap { opacity: 1; transform: none; } }
.night__cap strong { display: block; font: 700 clamp(11px, 1vw, 14px)/1.2 var(--sans); }
.night__cap > span:not(.stars) { font: 500 10px var(--mono); color: #ddd; }
.night__play { position: absolute; top: 6px; right: 6px; color: #fff; background: var(--blood); padding: 3px; }

.night--empty { display: flex; flex-direction: column; justify-content: space-between; padding: 10px; }
.night--empty .night__day { font: 800 clamp(28px, 3.4vw, 56px)/1 var(--sans); letter-spacing: -0.04em; color: var(--surface-2); }
.night--empty .night__oct { font: 500 10px var(--mono); color: var(--faint); letter-spacing: 0.1em; }
.night--tonight { background: var(--surface-2); }
.night--tonight .night__day { color: var(--blood); }
.night--tonight .night__oct { color: var(--blood); }

/* Viewer */
.viewer {
  position: fixed; inset: 0; z-index: 50;
  background: var(--veil);
  display: flex; align-items: center; justify-content: center;
  padding: 72px var(--gutter) 32px;
}
.viewer[hidden] { display: none; }
.viewer__close { position: absolute; top: 20px; right: var(--gutter); }
.viewer__close .material-symbols-outlined { font-size: 28px; }
.viewer__step {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; display: grid; place-items: center;
  background: var(--surface);
}
.viewer__step:hover, .viewer__close:hover { color: var(--blood); }
.viewer__step[disabled] { opacity: .25; cursor: default; }
.viewer__step--prev { left: var(--gutter); }
.viewer__step--next { right: var(--gutter); }

.viewer__body {
  display: grid; grid-template-columns: auto minmax(0, 560px); gap: 56px;
  align-items: start; max-height: 100%; max-width: 1100px; width: 100%;
  padding: 0 72px;
}
.viewer__media { height: min(78vh, 760px); aspect-ratio: 2 / 3; background: var(--surface); }
.viewer__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewer__media--video { aspect-ratio: 9 / 16; }
.viewer__media iframe { width: 100%; height: 100%; border: 0; display: block; }
.viewer__text { max-height: min(78vh, 760px); overflow-y: auto; padding-right: 8px; }
.viewer__title { font: 900 clamp(32px, 4vw, 60px)/0.95 var(--sans); letter-spacing: -0.04em; text-transform: uppercase; margin: 16px 0 16px; }
.viewer__meta { font: 500 12px/1.8 var(--mono); color: var(--muted); }
.viewer__review { font: 400 19px/1.6 var(--serif); margin-top: 32px; }
.viewer__review p + p { margin-top: 1em; }
.viewer__review:empty { display: none; }
.viewer__links { display: flex; flex-wrap: wrap; gap: 24px; margin-top: 32px; }
.viewer__links a { font: 700 10px var(--sans); letter-spacing: 0.3em; text-transform: uppercase; text-decoration: none; border-bottom: 1px solid var(--blood); padding-bottom: 4px; }
.viewer__links a:hover { color: var(--blood); }

@media (max-width: 860px) {
  .viewer { align-items: stretch; overflow-y: auto; padding-bottom: 96px; }
  .viewer__body { grid-template-columns: 1fr; gap: 24px; padding: 0; max-height: none; }
  .viewer__media { height: auto; width: min(100%, 300px); margin: 0 auto; }
  .viewer__media--video { width: min(100%, 340px); }
  .viewer__text { max-height: none; overflow: visible; }
  .viewer__step { top: auto; bottom: 24px; transform: none; position: fixed; }
}

.footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px;
  padding: 48px var(--gutter);
  background: var(--surface);
  font: 700 10px var(--sans); letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted);
}
.footer a { text-decoration: none; }
.footer a:hover { color: var(--blood); }

/* Bleeding stars */
:root { --blood-deep: #6e0d0d; --blood-hi: #d8322a; --blood-drip: #a8150f; }
.dark { --blood-deep: #5e0a0a; --blood-hi: #f04236; --blood-drip: #b9180f; }
.stars { display: inline-flex; gap: 0.12em; vertical-align: middle; color: var(--blood); line-height: 1; }
.star { width: 1em; height: 1em; overflow: visible; flex: none; }
.star__body { fill: url(#blood-grad); stroke: var(--blood-deep); stroke-width: .7; stroke-linejoin: round; }
.star__ghost { fill: none; stroke: var(--faint); stroke-width: 1; stroke-linejoin: round; }
.star__drip, .star__drop, .star__pool { fill: var(--blood-drip); }
.star__drip { transform-box: fill-box; transform-origin: 50% 0; animation: ooze var(--t) cubic-bezier(.5, 0, .7, 1) var(--d) infinite both; }
.star__drop { transform-box: fill-box; animation: fall var(--t) cubic-bezier(.55, 0, 1, .45) var(--d) infinite both; }
@keyframes ooze {
  0% { transform: scaleY(.6); }
  55% { transform: scaleY(1); }
  62% { transform: scaleY(.8); }
  100% { transform: scaleY(.6); }
}
@keyframes fall {
  0%, 55% { opacity: 0; transform: translateY(-1px) scale(.6); }
  58% { opacity: 1; transform: translateY(0) scale(1); }
  82% { opacity: 0; transform: translateY(22px) scale(.8, 1.35); }
  100% { opacity: 0; transform: translateY(22px); }
}
/* Grid tiles only bleed while you look at them. */
@media (hover: hover) {
  .night__btn:not(:hover):not(:focus-visible) .star * { animation-play-state: paused; }
}

.stars--tile { font-size: 24px; margin-top: 6px; display: flex; }
.stars--big { font-size: 48px; margin: 16px 0 28px; gap: .18em; }
.stars--inline { font-size: 24px; margin: -6px 6px 0; }
.stars--stat { font-size: .9em; margin-left: .08em; vertical-align: baseline; }
.night__cap { padding-bottom: 30px; }
.viewer__meta { margin-bottom: 8px; }

@media (prefers-reduced-motion: reduce) {
  .star__drip { animation: none; transform: none; }
  .star__drop { display: none; }
  *, *::before, *::after { transition: none !important; }
}
