/* santi quiroz. Stone, ink, one pine accent. Familjen Grotesk for voice, Newsreader for reading. */
:root {
  --bg: #eef0eb;
  --bg-sunk: #e4e7e0;
  --ink: #161a18;
  --muted: #586059;
  --rule: #c9cec5;
  --accent: #0d5a46;
  --accent-ink: #f4f7f3;
  --danger: #9b2c1f;
  --sans: "Familjen Grotesk", ui-sans-serif, system-ui, sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --gutter: clamp(1.25rem, 5vw, 3rem);
  --max: 72rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111513;
    --bg-sunk: #181d1a;
    --ink: #e9ede7;
    --muted: #9aa39c;
    --rule: #2c332f;
    --accent: #8fcdb3;
    --accent-ink: #0d1411;
    --danger: #ef8d7e;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.65;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent); color: var(--accent-ink); }
a { color: inherit; text-decoration-color: var(--accent); text-decoration-thickness: 0.09em; text-underline-offset: 0.2em; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--bg); padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 0; }

/* Header and footer */
.top, main > section, main > .feed, main > .pager, main > article, main > .crumb, .foot {
  width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter);
}
.top { display: flex; justify-content: space-between; align-items: baseline; padding-block: 1.25rem; }
.wordmark { font-family: var(--sans); font-weight: 600; font-size: 1.125rem; letter-spacing: -0.02em; text-decoration: none; }
.top nav { display: flex; gap: 1.25rem; align-items: baseline; font-family: var(--sans); font-size: .95rem; }
.top nav a { text-decoration: none; }
.top nav a:hover { text-decoration: underline; }
form.inline { display: inline; margin: 0; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: .2em; }
.linkish:hover { color: var(--accent); }
.foot { padding-block: 4rem 3rem; font-family: var(--sans); font-size: .9rem; color: var(--muted); }
.foot p { margin: 0; }

/* Home: a dark stage with the ridge scene behind real text.
   html.fx = scene allowed (set in <head> by /assets/boot.js); html.still = static version. */
body.home {
  --bg: #0a0c0b;
  --bg-sunk: #141715;
  --ink: #e7e2d7;
  --muted: #a29d92;
  --rule: #2b2f2c;
  --accent: #8fcdb3;
  --accent-ink: #08110d;
  --danger: #ef8d7e;
  --col: 34rem;
  background: var(--bg);
  color: var(--ink);
  overflow-x: clip;
}
.home .top { position: relative; z-index: 3; }
.home main { position: relative; z-index: 1; }
.home .foot { position: relative; z-index: 2; }
.home main > .ch, .home main > .signin-line { position: relative; z-index: 1; }
.home main > div.ch { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }

.stage { position: fixed; inset: 0 0 auto 0; height: 100vh; height: 100lvh; z-index: 0; pointer-events: none; overflow: hidden; background: var(--bg); }
.stage-gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity 1.4s cubic-bezier(.3,.6,.2,1); }
.scene-ready .stage-gl { opacity: 1; }
.scene-failed .stage-gl, .still .stage-gl { display: none; }
.stage-poster {
  position: absolute; display: none; opacity: 0; max-width: none; height: auto;
  width: 150vw; left: -12vw; top: 5vh;
  transition: opacity 1.2s ease;
}
.still .stage-poster, .scene-failed .stage-poster, .scene-slow:not(.scene-ready) .stage-poster { display: block; opacity: .5; }
.stage-veil {
  position: absolute; inset: 0; opacity: 0;
  background: linear-gradient(to top, rgba(10,12,11,.95) 0%, rgba(10,12,11,.82) 34%, rgba(10,12,11,.36) 66%, rgba(10,12,11,.16) 100%);
}
@media (max-width: 51.99rem) {
  .fx .ch-lede, .fx .ch-get { text-shadow: 0 1px 14px rgba(10,12,11,.95), 0 0 2px rgba(10,12,11,.8); }
}
.still .stage-veil, .scene-failed .stage-veil { opacity: 1 !important; }
@media (min-width: 52rem) {
  .stage-poster { width: 68vw; left: auto; right: -4vw; top: 50%; transform: translateY(-50%); }
  .stage-veil { background: linear-gradient(90deg, rgba(10,12,11,.93) 0%, rgba(10,12,11,.8) 30%, rgba(10,12,11,0) 56%); }
}

/* HUD: chapter, build progress. Decorative; hidden from assistive tech. */
.hud {
  position: fixed; z-index: 2; right: var(--gutter); top: 1.1rem;
  display: flex; align-items: center; gap: .85rem;
  font-family: var(--sans); font-weight: 500; font-size: .6875rem; line-height: 1; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); font-variant-numeric: tabular-nums;
  opacity: 0; transition: opacity .6s ease; pointer-events: none;
}
.fx.scrolled .hud { opacity: 1; }
/* Phones: just a hairline of build progress along the top edge. */
@media (max-width: 51.99rem) {
  .hud { inset: 0 0 auto 0; top: 0; }
  .hud .hud-ch, .hud .hud-pct { display: none; }
  .hud .hud-bar { width: 100%; background: rgba(231,226,215,.1); }
}
.fx.at-join .hud, .scene-failed .hud { opacity: 0 !important; }
.hud-ch { display: inline-flex; gap: .6em; min-width: 8.5em; }
.hud-n { color: var(--ink); }
.hud-bar { position: relative; width: 4.5rem; height: 1px; background: rgba(231,226,215,.2); overflow: hidden; }
.hud-bar i { position: absolute; inset: 0; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }
.hud-pct b { font-weight: 500; color: var(--ink); }
.fx:not(.scene-ready) .hud-pct { visibility: hidden; }
.fx:not(.scene-ready) .hud-bar i { animation: hud-load 1.2s cubic-bezier(.6,0,.3,1) infinite; transform: scaleX(.3); }
@keyframes hud-load { from { transform: translateX(-100%) scaleX(.3); } to { transform: translateX(340%) scaleX(.3); } }
@media (min-width: 52rem) {
  .hud { top: auto; bottom: 1.6rem; }
  .fx .hud { opacity: 1; }
  .hud-bar { width: 7rem; }
}

/* Chapters */
.hero-title {
  font-family: var(--sans); font-weight: 600; margin: 0;
  font-size: clamp(3.1rem, 13.4vw, 9.25rem); line-height: .9; letter-spacing: -0.048em;
  text-wrap: balance;
}
.hero-title .ln { display: block; overflow: hidden; padding-bottom: .08em; }
@keyframes rise { from { opacity: 0; transform: translateY(.22em); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: no-preference) {
  .hero-title .ln { animation: rise .75s cubic-bezier(.2,.7,.1,1) both; }
  .hero-title .ln:nth-child(2) { animation-delay: .1s; }
  .cue { animation: fade 1s ease 1.1s both; }
}
.ch-intro { padding-block: clamp(2.5rem, 12vh, 7rem) clamp(3rem, 8vw, 5rem); }
.cue {
  display: none; margin: 2.25rem 0 0; font-family: var(--sans); font-size: .6875rem; font-weight: 500;
  letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
  align-items: center; gap: .8rem;
}
.cue::after { content: ""; width: 3.5rem; height: 1px; background: linear-gradient(90deg, var(--accent), transparent); }
.fx .cue { display: flex; transition: opacity .5s ease; }
.fx.scrolled .cue { opacity: 0; }

.hero-copy { max-width: var(--col); }
.hero-copy p { margin: 0 0 1.1em; }
.lede { font-size: clamp(1.25rem, 1.1rem + .6vw, 1.5rem); line-height: 1.45; letter-spacing: -0.005em; }
.sign { font-family: var(--sans); color: var(--muted); font-size: 1rem; }
.sign::before { content: ""; display: inline-block; width: 1.5rem; height: 1px; background: var(--muted); vertical-align: middle; margin-right: .7rem; }

.ledger { border-top: 1px solid var(--rule); padding-block: 2rem 3.5rem; display: grid; gap: 1.5rem; }
.ledger > * { max-width: var(--col); }
.ledger-title { font-family: var(--sans); font-weight: 600; font-size: clamp(1.75rem, 1.3rem + 1.8vw, 2.75rem); letter-spacing: -0.035em; margin: 0; line-height: 1.05; }
.ledger-list { margin: 0; display: grid; }
.ledger-list > div { padding-block: 1.1rem; border-top: 1px solid var(--rule); }
.ledger-list > div:first-child { border-top: 0; padding-top: 0; }
.ledger-list dt { font-family: var(--sans); font-weight: 600; font-size: 1.1875rem; letter-spacing: -0.015em; }
.ledger-list dd { margin: .3rem 0 0; color: var(--muted); max-width: 32rem; }
.ch-join { scroll-margin-top: 1rem; }

/* With the scene: give the camera room to travel between chapters. */
.fx .ch-intro { min-height: calc(100svh - 4.25rem); display: flex; flex-direction: column; justify-content: flex-end; padding-top: 0; padding-bottom: clamp(2.5rem, 9vh, 5.5rem); }
.fx .ch-lede { padding-block: 62vh 38vh; }
.fx .ch-get { border-top: 0; padding-top: 30vh; gap: 0; }
.fx .ch-get .ledger-title { margin-bottom: 26vh; }
.fx .ch-get .ledger-list > div { border-top: 0; padding: 0 0 0 1.1rem; margin-bottom: 30vh; position: relative; }
.fx .ch-get .ledger-list > div::before { content: ""; position: absolute; left: 0; top: .45em; bottom: .3em; width: 1px; background: var(--accent); opacity: .7; }
.fx .ch-get .ledger-list > div:last-child { margin-bottom: 8vh; }
.fx .ch-get .ledger-list dt { font-size: clamp(1.375rem, 1.1rem + 1.1vw, 1.875rem); letter-spacing: -0.03em; line-height: 1.15; }
.fx .ch-get .ledger-list dd { font-size: 1.1875rem; margin-top: .5rem; }
.fx .ch-join { margin-top: 62vh; border-top: 0; padding-top: 0; }
.fx .ch-join .ledger-title { padding-top: 1.5rem; border-top: 1px solid var(--rule); }
.fx .signin-line { border-top: 0; }

/* Phones: the form rises over the scene on its own dark ground. */
@media (max-width: 51.99rem) {
  .fx .ch-join { margin-top: 48vh; padding-top: 30vh; background: linear-gradient(to bottom, rgba(10,12,11,0), rgba(10,12,11,.9) 26vh); }
}

/* Reveal on arrival (scene mode only, added by script so nothing hides without it). */
.rv [data-reveal] { opacity: 0; transform: translateY(16px); transition: opacity 1s cubic-bezier(.2,.7,.1,1), transform 1s cubic-bezier(.2,.7,.1,1); }
.rv [data-reveal].in { opacity: 1; transform: none; }
.rv [data-reveal].now { transition: none; }

/* Forms and buttons */
.form { display: grid; gap: 1.25rem; max-width: 30rem; margin-top: 1.25rem; font-family: var(--sans); }
.form.wide { max-width: 44rem; }
.form label { display: grid; gap: .4rem; font-size: .95rem; font-weight: 500; }
.opt { font-weight: 400; color: var(--muted); }
input, textarea, select {
  font: inherit; font-family: var(--serif); font-size: 1.0625rem; color: var(--ink);
  background: transparent; border: 0; border-bottom: 1.5px solid var(--ink); border-radius: 0; padding: .55rem 0; width: 100%;
}
textarea { border: 1.5px solid var(--rule); padding: .7rem; resize: vertical; }
textarea.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .95rem; line-height: 1.55; }
input:focus-visible, textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 1.5px 0 var(--accent); }
textarea:focus-visible { box-shadow: 0 0 0 1.5px var(--accent); }
input[type="file"] { border: 1.5px dashed var(--rule); padding: .7rem; font-family: var(--sans); font-size: .9rem; }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
.check { display: flex !important; grid-template-columns: none; align-items: center; gap: .5rem !important; font-weight: 400 !important; word-break: break-all; }
fieldset { border: 1.5px solid var(--rule); padding: .8rem 1rem; display: grid; gap: .5rem; }
legend { font-weight: 600; font-size: .9rem; padding-inline: .3rem; }
.hp { position: absolute; left: -9999px; height: 0; overflow: hidden; }
.btn {
  display: inline-block; font-family: var(--sans); font-weight: 600; font-size: 1rem; line-height: 1;
  background: var(--accent); color: var(--accent-ink); border: 1.5px solid var(--accent);
  padding: .95rem 1.4rem; border-radius: 999px; cursor: pointer; text-decoration: none; justify-self: start;
}
.btn:hover { color: var(--accent-ink); filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); filter: none; }
.btn:disabled { cursor: not-allowed; color: var(--muted); border-color: var(--rule); border-style: dashed; background: transparent; filter: none; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { color: var(--danger); }
.btn.sm { padding: .55rem .95rem; font-size: .875rem; }
.alt { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); display: grid; gap: .75rem; justify-items: start; }
.alt p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.notice { border-left: 3px solid var(--accent); padding: .25rem 0 .25rem 1rem; margin: 1rem 0; font-family: var(--sans); }
.notice p { margin: .3rem 0; }
.notice.dev a { word-break: break-all; }
.notice.slim { max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); border: 0; }
.error { border-left: 3px solid var(--danger); padding-left: 1rem; color: var(--danger); font-family: var(--sans); margin: 0; }
.error p { margin: .2rem 0; }
.signin-line { border-top: 1px solid var(--rule); padding-block: 1.5rem 0; font-family: var(--sans); }

/* Narrow pages */
.narrow { max-width: 38rem !important; margin-inline: auto; padding-block: clamp(2rem, 7vw, 4.5rem); }
.h-page { font-family: var(--sans); font-weight: 600; font-size: clamp(2rem, 6vw, 3.25rem); letter-spacing: -0.035em; line-height: 1.05; margin: 0 0 1rem; }

/* Log */
.log-head { padding-block: clamp(2rem, 7vw, 4.5rem) 1rem; }
.log-head .lede { color: var(--muted); margin: 0; }
.crumb { font-family: var(--sans); font-size: .95rem; padding-top: 1.5rem; margin: 0 auto; }
.feed { padding-bottom: 1rem; }
.entry { padding-block: 2.25rem 2.75rem; border-top: 1px solid var(--rule); display: grid; gap: 1.1rem; }
.entry-head time { font-family: var(--sans); font-size: .9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.entry-title { font-family: var(--sans); font-weight: 600; font-size: clamp(1.75rem, 4.4vw, 2.6rem); letter-spacing: -0.03em; line-height: 1.08; margin: .35rem 0 0; text-wrap: balance; }
.entry-title a { text-decoration: none; }
.entry-title a:hover { color: var(--accent); }
.prose { max-width: 38rem; font-size: 1.1875rem; line-height: 1.72; hyphens: auto; }
.prose > *:first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.15em; }
.prose h2, .prose h3 { font-family: var(--sans); letter-spacing: -0.02em; line-height: 1.2; margin: 1.8em 0 .5em; }
.prose h2 { font-size: 1.5rem; } .prose h3 { font-size: 1.2rem; }
.prose blockquote { margin: 1.4em 0; padding-left: 1.1rem; border-left: 3px solid var(--accent); font-style: italic; color: var(--muted); }
.prose code { font-size: .9em; background: var(--bg-sunk); padding: .1em .3em; border-radius: 3px; }
.prose pre { background: var(--bg-sunk); padding: 1rem; overflow-x: auto; border-radius: 4px; font-size: .9rem; line-height: 1.5; }
.prose pre code { background: none; padding: 0; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2em 0; }
.entry-media { display: grid; gap: 1rem; max-width: 46rem; }
.entry-media figure { margin: 0; }
.entry-media img, .entry-media video { display: block; width: 100%; height: auto; border-radius: 3px; background: var(--bg-sunk); }
.empty { padding-block: 3rem; color: var(--muted); font-family: var(--sans); }
.pager { display: flex; gap: 1.5rem; font-family: var(--sans); padding-block: 1rem 2rem; }
@media (min-width: 60rem) {
  .entry { grid-template-columns: 11rem 1fr; column-gap: 2rem; }
  .entry-head { grid-column: 1 / -1; display: grid; grid-template-columns: 11rem 1fr; column-gap: 2rem; align-items: baseline; }
  .entry-head time { grid-column: 1; grid-row: 1; padding-top: .6rem; }
  .entry-title { grid-column: 2; grid-row: 1; margin: 0; }
  .prose, .entry-media { grid-column: 2; }
}

/* Admin: plainer, tidy on a phone */
.adm { padding-block: 1.5rem 2rem; font-family: var(--sans); }
.adm h2 { font-size: 1.15rem; font-weight: 600; margin: 2.25rem 0 .5rem; display: flex; align-items: center; gap: .75rem; }
.adm .h-page { font-size: clamp(1.75rem, 5vw, 2.5rem); }
.count { font-weight: 500; font-size: .85rem; color: var(--muted); }
.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.rows li { display: flex; flex-wrap: wrap; gap: .75rem 1rem; justify-content: space-between; align-items: center; padding: .85rem 0; border-bottom: 1px solid var(--rule); }
.rows .who { min-width: 0; overflow-wrap: anywhere; flex: 1 1 14rem; line-height: 1.45; }
.row-actions { display: flex; gap: .5rem; margin: 0; }
.note { margin: .4rem 0 0; font-family: var(--serif); color: var(--muted); max-width: 40rem; white-space: pre-wrap; }
.chip { font-size: .75rem; border: 1px solid var(--rule); border-radius: 999px; padding: .1rem .55rem; color: var(--muted); }
.chip.live { border-color: var(--accent); color: var(--accent); }
.actions { display: flex; gap: .75rem; flex-wrap: wrap; }
.danger-zone { margin-top: 3rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); }
body.admin .btn { font-size: .95rem; }
