/*
 * LAINVOID — the whole site in one stylesheet.
 * Order: fonts, tokens, base, frame (bars, status line), index, entries,
 * dialogue, fragments, found, overexposed pages, 404, prompt, effects, small screens.
 *
 * Two voices: the system voice (mono, uppercase labels, // marks) lives in the
 * margins; the human voice (serif) is the text. The only colour on the site is
 * the visitor: the presence dot, text selection and the prompt caret.
 */

/* ── Fonts (self-hosted, SIL OFL 1.1, licences in /fonts/) ─────────────── */

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/jetbrains-mono-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 800;
  font-display: swap;
}

@font-face {
  font-family: 'Newsreader';
  src: url('/fonts/newsreader-latin-wght-normal.woff2') format('woff2');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Newsreader';
  src: url('/fonts/newsreader-latin-wght-italic.woff2') format('woff2');
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'Silkscreen';
  src: url('/fonts/silkscreen-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

/* ── Tokens ───────────────────────────────────────────────────────────── */

:root {
  --bg: #050505;
  --hover: #111111;
  --line: #262626;
  --line-soft: #161616;
  --text: #e8e8e8;
  --text-2: #9a9a9a;
  --label: #6a6a6a;
  --read: #d8d6d0;            /* body text: a little warmer and softer than white */
  --presence: #b9addb;        /* the visitor, and nothing else */

  --mono: 'JetBrains Mono', 'Cascadia Mono', Consolas, monospace;
  --serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --pixel: 'Silkscreen', 'JetBrains Mono', monospace;

  --fs-2xs: 10.5px;
  --fs-xs: 11.5px;
  --fs-sm: 13px;
  --fs-read: clamp(17px, 16px + 0.3vw, 19.5px);
  --spacing: 0.28em;          /* uppercase labels */

  --pad: clamp(18px, 4vw, 44px);
  --measure: 36rem;
  --status-h: 30px;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur: 140ms;

  --scan: 0.09;
  --grain: 0.035;
  --vignette: 0.55;

  color-scheme: dark;
}

/* ── Base ─────────────────────────────────────────────────────────────── */

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

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: calc(var(--status-h) + 8px);
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-sm) / 1.6 var(--mono);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
p,
ol,
ul,
figure,
blockquote {
  margin: 0;
}

ol,
ul {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

::selection {
  background: var(--presence);
  color: #050505;
}

:focus-visible {
  outline: 1px solid var(--text);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--text);
  color: var(--bg);
}

.skip-link:focus {
  top: 12px;
}

/* Uppercase label with wide spacing: the system voice */
.label {
  font-family: var(--mono);
  font-size: var(--fs-2xs);
  font-weight: 500;
  letter-spacing: var(--spacing);
  text-transform: uppercase;
  color: var(--label);
}

/* A lowercase system note, prefixed with // */
.note {
  font-family: var(--mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.1em;
  text-transform: lowercase;
  color: var(--label);
}

.note::before {
  content: '// ';
}

/* Links inside text: thin underline that wakes up on hover */
.prose a,
.link {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--label);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--dur) var(--ease);
}

.prose a:hover,
.link:hover {
  text-decoration-color: currentColor;
}

kbd {
  font-family: var(--mono);
  font-size: 0.95em;
  padding: 0 4px;
  border: 1px solid var(--line);
  color: var(--text-2);
}

.col {
  width: min(var(--measure), 100% - 2 * var(--pad));
  margin-inline: auto;
}

/* ── Frame: top bar ───────────────────────────────────────────────────── */

.sysbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 14px var(--pad);
}

.sysbar .label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sysbar a {
  color: var(--text-2);
  transition: color var(--dur) var(--ease);
}

.sysbar a:hover {
  color: var(--text);
}

.sysbar .dim {
  color: var(--label);
}

.sysbar .note {
  flex: none;
}

/* ── Frame: status line (filled in by the script; hidden without it) ──── */

.status {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  height: var(--status-h);
  padding: 0 var(--pad);
  border-top: 1px solid var(--line-soft);
  background: var(--bg);
  font-size: var(--fs-2xs);
  white-space: nowrap;
  overflow: hidden;
}

.status[hidden] {
  display: none;
}

.sl-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-left: 1px solid var(--line);
  line-height: 1.4;
}

.sl-item:first-child {
  padding-left: 0;
  border-left: 0;
}

.sl-key {
  letter-spacing: var(--spacing);
  text-transform: uppercase;
  color: var(--label);
}

.sl-val {
  font-weight: 600;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.sl-square {
  width: 6px;
  height: 6px;
  background: var(--label);
}

.sl-item.is-lost .sl-square {
  background: var(--text);
}

.sl-you {
  margin-left: auto;
  padding-right: 0;
  border-left: 0;
  color: var(--text-2);
}

.sl-dot {
  width: 6px;
  height: 6px;
  background: var(--presence);
}

:root[data-motion='full'] .sl-dot {
  animation: breathe 3.2s steps(1) infinite;
}

@keyframes breathe {
  80% {
    opacity: 1;
  }
  90% {
    opacity: 0.25;
  }
}

/* ── Logo: LAIN has a face, VOID is only the shadow of letters ───────── */

.logo {
  display: inline-flex;
  margin: 0;
  font-family: var(--pixel);
  font-size: clamp(38px, 8.6vw, 92px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
  user-select: none;
}

.logo-lain {
  display: inline-grid;
}

.logo-shadow,
.logo-face {
  grid-area: 1 / 1;
}

/* Outline drawn with 8 shadows, not text-stroke: the pixel font has overlapping
   squares inside its letters, and a stroke would draw every seam. */
.logo-shadow,
.logo-void {
  --edge: var(--text-2);
  color: var(--bg);
  text-shadow:
    1px 0 var(--edge), -1px 0 var(--edge), 0 1px var(--edge), 0 -1px var(--edge),
    1px 1px var(--edge), -1px -1px var(--edge), 1px -1px var(--edge), -1px 1px var(--edge);
  transform: translate(0.07em, 0.07em);
}

.logo-void {
  --edge: var(--label);
}

/* Face: horizontal raster lines, like the NAVI and CARRIER icons */
.logo-face {
  color: transparent;
  background: repeating-linear-gradient(
    0deg,
    var(--text) 0 0.055em,
    color-mix(in srgb, var(--text) 62%, var(--bg)) 0.055em 0.08em
  );
  -webkit-background-clip: text;
  background-clip: text;
}

/* Hover: the face goes away for a moment and the whole word is void */
:root[data-motion='full'] .logo:hover .logo-face {
  animation: go-void 900ms steps(1) 1;
}

@keyframes go-void {
  0%,
  12%,
  30% {
    opacity: 0;
  }
  8%,
  22% {
    opacity: 1;
  }
  100% {
    opacity: 1;
  }
}

/* ── Index page ───────────────────────────────────────────────────────── */

.home-head {
  padding-top: clamp(64px, 20vh, 220px);
}

.tagline {
  margin-top: 26px;
  font-family: var(--serif);
  font-size: clamp(18px, 1.6vw, 21px);
  font-style: italic;
  font-weight: 300;
  color: var(--text-2);
}

.home-head .note {
  margin-top: 14px;
}

.index-wrap {
  margin-top: clamp(56px, 14vh, 150px);
}

.index-head {
  display: flex;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.index a {
  display: grid;
  grid-template-columns: 3ch 9ch minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 18px;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line-soft);
  transition:
    background-color var(--dur) var(--ease),
    color var(--dur) var(--ease);
}

.index .n,
.index .type,
.index .date {
  font-size: var(--fs-2xs);
  color: var(--label);
  font-variant-numeric: tabular-nums;
}

.index .type {
  letter-spacing: 0.1em;
}

.index .title {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.35;
  color: var(--read);
}

.index a:hover {
  background: var(--hover);
}

.index a:hover .title {
  color: var(--text);
}

/* Keyboard selection: inversion, like a selected line in a terminal */
.index a:focus-visible {
  outline: 0;
  background: var(--text);
}

.index a:focus-visible * {
  color: var(--bg);
}

.index-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 20px;
  margin-top: 18px;
  font-size: var(--fs-2xs);
  color: var(--label);
}

.index-foot .keys {
  letter-spacing: 0.06em;
}

.home-end {
  height: clamp(60px, 16vh, 160px);
}

/* ── Entry pages ──────────────────────────────────────────────────────── */

.entry-head {
  padding-top: clamp(48px, 13vh, 140px);
  padding-bottom: clamp(28px, 6vh, 56px);
}

.kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 0 12px;
}

.kicker span + span::before {
  content: '·';
  margin-right: 12px;
}

/* Hints that only make sense when the script runs (it sets data-motion) */
:root:not([data-motion]) .js-only {
  display: none;
}

.entry-title {
  margin-top: 18px;
  font-family: var(--serif);
  font-size: clamp(30px, 3.4vw, 42px);
  font-weight: 300;
  font-style: italic;
  line-height: 1.12;
  letter-spacing: -0.005em;
  color: var(--text);
}

.entry-head .note {
  margin-top: 16px;
}

.prose {
  position: relative;
  font-family: var(--serif);
  font-size: var(--fs-read);
  line-height: 1.72;
  color: var(--read);
  hyphens: auto;
}

.prose p:not(:first-child) {
  margin-top: 1.05em;
}

.prose code {
  font-family: var(--mono);
  font-size: 0.82em;
  color: var(--text-2);
}

.prose em {
  font-style: italic;
}

/* Margin notes from the system voice */
.mark {
  display: block;
  margin: 2em 0 0;
}

@media (min-width: 1180px) {
  .mark {
    position: absolute;
    left: -15rem;
    width: 13rem;
    margin: 2.05em 0 0;
    text-align: right;
  }
}

.eof {
  margin-top: 3.2em;
  display: flex;
  align-items: center;
  gap: 14px;
}

.eof::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.entry-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  margin-top: 36px;
  margin-bottom: clamp(60px, 14vh, 140px);
  font-size: var(--fs-xs);
}

.entry-nav a {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid transparent;
  color: var(--text-2);
  transition:
    border-color var(--dur) var(--ease),
    color var(--dur) var(--ease);
}

.entry-nav a:hover {
  border-color: var(--line);
  color: var(--text);
}

.entry-nav .next {
  justify-self: end;
  text-align: right;
}

.entry-nav .up {
  justify-self: center;
}

.entry-nav small {
  font-size: var(--fs-2xs);
  letter-spacing: var(--spacing);
  text-transform: uppercase;
  color: var(--label);
}

/* Erasure: letters disappear for a moment (script adds the spans) */
.erase-char {
  transition: none;
}

.erase-char.is-gone {
  visibility: hidden;
}

/* ── Dialogue ─────────────────────────────────────────────────────────── */

.dialogue {
  display: grid;
  gap: 1.15em;
}

.say {
  display: grid;
  grid-template-columns: 6ch minmax(0, 1fr);
  gap: 2ch;
  align-items: baseline;
}

.say .who {
  font-family: var(--mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.08em;
  color: var(--label);
}

/* The one at the desk: the human voice */
.say--desk .line {
  font-family: var(--serif);
  font-size: var(--fs-read);
  line-height: 1.6;
  color: var(--read);
}

/* The one on the line: the system voice, pushed a little right */
.say--wire {
  padding-left: 3ch;
}

.say--wire .line {
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-2);
}

.say--wire .who {
  color: var(--text-2);
}

.cursor {
  display: inline-block;
}

:root[data-motion='full'] .cursor {
  animation: blink 1.1s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.say--pause .line {
  color: var(--label);
  letter-spacing: 0.3em;
}

/* ── Fragments ────────────────────────────────────────────────────────── */

.fragments {
  display: grid;
  gap: 1.5em;
}

.fragments li {
  display: grid;
  grid-template-columns: 9ch minmax(0, 1fr);
  gap: 2ch;
  align-items: baseline;
}

.fragments time,
.fragments .t {
  font-size: var(--fs-2xs);
  color: var(--label);
  font-variant-numeric: tabular-nums;
}

.fragments p {
  font-family: var(--serif);
  font-size: var(--fs-read);
  font-style: italic;
  font-weight: 300;
  line-height: 1.55;
  color: var(--read);
}

/* ── Found files ──────────────────────────────────────────────────────── */

.found {
  width: min(720px, 100% - 2 * var(--pad));
  margin: clamp(40px, 8vh, 72px) auto 0;
}

.found img {
  width: 720px;
  border: 1px solid var(--line);
  image-rendering: pixelated;
}

.found figcaption {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  padding-left: 2px;
}

.found .says {
  font-family: var(--serif);
  font-size: 17px;
  font-style: italic;
  font-weight: 300;
  color: var(--text-2);
}

.found + .col {
  margin-top: clamp(40px, 8vh, 72px);
}

/* ── Overexposed pages: white light instead of colour ────────────────── */

.overexposed {
  --bg: #f1efe9;
  --hover: #e6e3db;
  --line: #d2cec4;
  --line-soft: #e2dfd6;
  --text: #161616;
  --text-2: #4e4b45;
  --label: #8c887e;
  --read: #24221f;
  --scan: 0.05;
  --vignette: 0.35;
  color-scheme: light;
}

/* Light pouring in from above */
.overexposed::before {
  content: '';
  position: fixed;
  inset: 0 0 auto;
  height: 70vh;
  z-index: 25;
  pointer-events: none;
  background: radial-gradient(80vw 60vh at 60% -10%, rgba(255, 255, 255, 0.85), transparent 70%);
}

/* On arrival the page is blown out, then the eyes adjust */
:root[data-motion='full'] .overexposed main {
  animation: develop 2.2s var(--ease) both;
}

@keyframes develop {
  from {
    filter: brightness(2.6) contrast(0.55) blur(1.2px);
    opacity: 0.35;
  }
  to {
    filter: none;
    opacity: 1;
  }
}

.overexposed .found img,
.photo img {
  border-color: var(--line-soft);
}

.photo {
  width: min(720px, 100% - 2 * var(--pad));
  margin: 0 auto clamp(36px, 7vh, 64px);
}

.photo img {
  width: 720px;
  border: 1px solid var(--line-soft);
  image-rendering: pixelated;
}

.photo figcaption {
  margin-top: 10px;
}

/* ── 404 ──────────────────────────────────────────────────────────────── */

.lost {
  display: grid;
  align-content: center;
  min-height: calc(100vh - 140px);
  padding-block: 40px;
}

.lost-path {
  margin: 22px 0 28px;
  min-height: 1.3em;
  font-family: var(--mono);
  font-size: clamp(20px, 3.4vw, 34px);
  font-weight: 300;
  line-height: 1.3;
  color: var(--text);
  overflow-wrap: anywhere;
}

.lost-path .scheme {
  color: var(--label);
}

.lost p.says {
  font-family: var(--serif);
  font-size: var(--fs-read);
  font-style: italic;
  font-weight: 300;
  color: var(--read);
}

.lost .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 34px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: lowercase;
  transition:
    border-color var(--dur) var(--ease),
    color var(--dur) var(--ease),
    background-color var(--dur) var(--ease);
}

.btn:hover {
  border-color: var(--label);
  color: var(--text);
}

.btn--primary {
  border-color: var(--text);
  color: var(--text);
}

.btn--primary:hover {
  background: var(--text);
  color: var(--bg);
}

/* ── Prompt (press : ) ────────────────────────────────────────────────── */

.prompt {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--status-h);
  z-index: 21;
  padding: 10px var(--pad) 12px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  font-size: var(--fs-xs);
}

.prompt[hidden] {
  display: none;
}

.prompt-out {
  max-height: 40vh;
  overflow-y: auto;
  white-space: pre-wrap;
  color: var(--text-2);
}

.prompt-out:empty {
  display: none;
}

.prompt-out .echo {
  color: var(--label);
}

.prompt-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.prompt-row label {
  flex: none;
  color: var(--label);
}

.prompt-row input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  caret-color: var(--presence);
}

/* ── Effects: scan lines, grain, dark edges (as in CARRIER and NAVI, quieter) */

.fx {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  overflow: hidden;
}

.fx-scanlines {
  position: absolute;
  inset: 0;
  opacity: var(--scan);
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.85) 0 1px, transparent 1px 3px);
}

.overexposed .fx-scanlines {
  background: repeating-linear-gradient(0deg, rgba(60, 50, 40, 0.5) 0 1px, transparent 1px 3px);
}

.fx-noise {
  position: absolute;
  inset: -100%;
  opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.4 -0.2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

:root[data-motion='full'] .fx-noise {
  animation: grain 0.9s steps(6) infinite;
}

@keyframes grain {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-3%, 2%); }
  40% { transform: translate(2%, -4%); }
  60% { transform: translate(-4%, -1%); }
  80% { transform: translate(3%, 3%); }
  100% { transform: translate(0, 0); }
}

.fx-vignette {
  position: absolute;
  inset: 0;
  opacity: var(--vignette);
  background: radial-gradient(ellipse at center, transparent 58%, rgba(0, 0, 0, 0.5) 100%);
}

.overexposed .fx-vignette {
  background: radial-gradient(ellipse at center, transparent 62%, rgba(60, 50, 40, 0.16) 100%);
}

/* ── Small screens ────────────────────────────────────────────────────── */

@media (max-width: 760px) {
  .found img,
  .photo img {
    image-rendering: auto;
  }
}

@media (max-width: 640px) {
  .index a {
    grid-template-columns: 3ch minmax(0, 1fr) auto;
    grid-template-areas:
      'n type date'
      'n title title';
    gap: 4px 14px;
  }

  .index .n { grid-area: n; }
  .index .type { grid-area: type; }
  .index .date { grid-area: date; }
  .index .title { grid-area: title; }

  .say,
  .fragments li {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .say--wire {
    padding-left: 2ch;
  }

  .entry-nav {
    grid-template-columns: 1fr 1fr;
  }

  .entry-nav .up {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .sl-local {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fx-noise,
  .sl-dot,
  .cursor,
  .logo-face,
  .overexposed main {
    animation: none !important;
  }
}
