/* Into the Edge — styles. Dark, minimal, the picture comes first. */

@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/ibm-plex-sans-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/ibm-plex-sans-cyrillic-400-normal.woff2) format('woff2'); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url(../fonts/ibm-plex-sans-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url(../fonts/ibm-plex-sans-cyrillic-500-normal.woff2) format('woff2'); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url(../fonts/ibm-plex-sans-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url(../fonts/ibm-plex-sans-cyrillic-600-normal.woff2) format('woff2'); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/ibm-plex-mono-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/ibm-plex-mono-cyrillic-400-normal.woff2) format('woff2'); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url(../fonts/ibm-plex-mono-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url(../fonts/ibm-plex-mono-cyrillic-500-normal.woff2) format('woff2'); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }

:root {
  --bg: #0b0c0e;
  --fg: #ece8e0;
  --fg-2: #b8b2a7;
  --fg-3: #85807a;
  --line: rgba(236, 232, 224, 0.16);
  --line-2: rgba(236, 232, 224, 0.34);
  --gold: #d6aa52;
  --gold-2: #a8853e;
  --panel: #121417;
  --panel-line: #262a30;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --gutter: 24px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--fg);
  overflow: hidden; overscroll-behavior: none;
}
body {
  font-family: var(--sans);
  font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
#app {
  position: fixed; inset: 0; overflow: hidden;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
  background: var(--bg);
}
#gl, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#overlay { pointer-events: none; }
#ui { position: absolute; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
button { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Boot screen */
.boot {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  pointer-events: none; transition: opacity .6s ease;
}
.boot-title { font-weight: 500; letter-spacing: .02em; font-size: 18px; }
.boot-sub { font-family: var(--mono); font-size: 12px; color: var(--fg-3); }
#app:not(.is-loading) .boot { opacity: 0; }
.nojs, .fatal {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(520px, calc(100% - 32px)); text-align: center; color: var(--fg-2);
}

/* Soft darkening behind the text so it stays legible over bright pictures */
#ui > .scrim { position: absolute; left: 0; right: 0; pointer-events: none; }
.scrim-top { top: 0; height: 150px; background: linear-gradient(to bottom, rgba(11, 12, 14, 0.55), rgba(11, 12, 14, 0)); }
.scrim-bottom { bottom: 0; height: 42vh; background: linear-gradient(to top, rgba(11, 12, 14, 0.86) 0%, rgba(11, 12, 14, 0.62) 38%, rgba(11, 12, 14, 0) 100%); }

/* Top bar */
.top {
  position: absolute; left: calc(var(--gutter) + var(--safe-left)); right: calc(var(--gutter) + var(--safe-right));
  top: calc(var(--gutter) + var(--safe-top) - 6px);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.brand { display: flex; flex-direction: column; gap: 2px; text-decoration: none; }
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: .01em; }
.brand-tag { font-size: 12.5px; color: var(--fg-3); }
.controls { display: flex; gap: 8px; flex-wrap: nowrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 13px 0 11px;
  background: transparent; border: 1px solid var(--line); border-radius: 17px;
  color: var(--fg); font-size: 13px; letter-spacing: .01em; cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background-color .15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--line-2); }
.btn:active { background: rgba(236, 232, 224, 0.06); }
.btn svg { width: 14px; height: 14px; flex: none; }
.btn .lbl { display: inline; }
.btn-lang { font-family: var(--mono); font-size: 12px; padding: 0 12px; gap: 5px; }
.btn-lang .lang-opt { color: var(--fg-3); }
.btn-lang .lang-opt.is-on { color: var(--gold); }
.btn-lang .lang-sep { color: var(--fg-3); opacity: .6; }
.btn[aria-pressed="true"] { border-color: var(--gold-2); color: var(--gold); }

/* Ruler (right) */
.ruler {
  position: absolute; right: calc(var(--gutter) + var(--safe-right)); top: 50%;
  height: min(58vh, 540px); width: 96px; transform: translateY(-50%);
  touch-action: none; cursor: pointer;
}
.ruler-track { position: absolute; right: 0; top: 0; bottom: 0; width: 1px; background: var(--line); }
.ruler-fill { position: absolute; right: 0; top: 0; width: 1px; background: var(--gold-2); height: 0; }
.ruler-minor { position: absolute; right: 0; width: 5px; height: 1px; background: var(--line); }
.ruler-stop {
  position: absolute; right: -6px; height: 22px; transform: translateY(-50%);
  display: flex; align-items: center; gap: 8px; padding: 0 6px 0 4px;
  background: none; border: 0; cursor: pointer; color: var(--fg-3);
  font-family: var(--mono); font-size: 11px; line-height: 1; white-space: nowrap;
}
.ruler-stop::after { content: ''; width: 11px; height: 1px; background: var(--line-2); flex: none; }
.ruler-stop.is-minor::after { width: 7px; }
.ruler-stop:hover, .ruler-stop:focus-visible { color: var(--fg); }
.ruler-stop.is-active { color: var(--gold); }
.ruler-stop.is-active::after { background: var(--gold); }
.ruler-marker {
  position: absolute; right: -4px; top: 0; width: 9px; height: 9px; margin-top: -4.5px;
  border: 1.5px solid var(--gold); border-radius: 50%; background: var(--bg);
  pointer-events: none; will-change: transform;
}

/* Scale bar (bottom left, microscope style) */
.scalebar {
  position: absolute; left: calc(var(--gutter) + var(--safe-left)); bottom: calc(var(--gutter) + var(--safe-bottom) + 18px);
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  pointer-events: none;
}
.scalebar-label { font-family: var(--mono); font-size: 12px; color: var(--fg); letter-spacing: .02em; }
.scalebar-bar { position: relative; height: 7px; border-left: 1.5px solid var(--fg); border-right: 1.5px solid var(--fg); min-width: 4px; will-change: width; }
.scalebar-bar::before { content: ''; position: absolute; left: 0; right: 0; top: 3px; height: 1.5px; background: var(--fg); }
.scalebar-fov { font-family: var(--mono); font-size: 11px; color: var(--fg-3); }

/* Caption (bottom) */
.caption {
  position: absolute; left: 50%; bottom: calc(var(--gutter) + var(--safe-bottom) + 14px);
  width: min(600px, calc(100% - 2 * var(--gutter) - 2 * 130px));
  transform: translateX(-50%);
  pointer-events: none;
}
.caption > * { pointer-events: auto; }
.caption-inner { transition: opacity .28s ease; }
.caption.is-swapping .caption-inner { opacity: 0; }
.caption-meta {
  display: flex; gap: 12px; align-items: baseline;
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-3);
  margin-bottom: 8px;
}
.caption-meta .fov { color: var(--gold); text-transform: none; letter-spacing: .02em; }
.caption-text { margin: 0; font-size: 19px; line-height: 1.45; font-weight: 400; color: var(--fg); text-wrap: pretty; }
.caption-actions { margin-top: 12px; display: flex; gap: 10px; align-items: center; min-height: 30px; }
.link-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px 0 10px;
  border: 1px solid var(--line); border-radius: 15px; background: transparent;
  color: var(--fg-2); font-size: 13px; cursor: pointer;
}
.link-btn:hover { color: var(--fg); border-color: var(--line-2); }
.link-btn svg { width: 12px; height: 12px; transition: transform .2s ease; }
.link-btn[aria-expanded="true"] { color: var(--gold); border-color: var(--gold-2); }
.link-btn[aria-expanded="true"] svg { transform: rotate(45deg); }

/* Researcher card */
.card {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 12px);
  max-height: min(52vh, 460px); overflow: auto; overscroll-behavior: contain;
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: 10px;
  padding: 18px 20px 16px; touch-action: pan-y;
  user-select: text; -webkit-user-select: text;
}
.card[hidden] { display: none; }
.card h3 {
  margin: 0 0 6px; font-family: var(--mono); font-weight: 400; font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--fg-3);
}
.card p { margin: 0 0 14px; font-size: 15px; line-height: 1.5; color: var(--fg); }
.card .q { color: var(--fg); }
.card .refs { list-style: none; margin: 0 0 14px; padding: 0; }
.card .refs li { font-size: 12.5px; line-height: 1.45; color: var(--fg-2); margin-bottom: 6px; }
.card .refs a { color: var(--fg-2); text-decoration-color: var(--line-2); text-underline-offset: 2px; }
.card .refs a:hover { color: var(--gold); }
.card .card-foot { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--panel-line); padding-top: 12px; margin-top: 4px; }
.card .discuss { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--gold); text-decoration: none; }
.card .discuss:hover { text-decoration: underline; text-underline-offset: 3px; }
.card .discuss svg { width: 14px; height: 14px; }

/* Hint */
.hint {
  position: absolute; left: 50%; top: calc(50% + min(26vh, 220px)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; pointer-events: none;
  font-family: var(--mono); font-size: 12px; color: var(--fg-2); letter-spacing: .03em;
  transition: opacity .6s ease;
}
.hint.is-hidden { opacity: 0; }
.hint svg { width: 16px; height: 16px; animation: hint-bob 1.8s ease-in-out infinite; }
@keyframes hint-bob { 0%, 100% { transform: translateY(-2px); } 50% { transform: translateY(3px); } }

/* Finale */
#ui > .finale-veil {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at 50% 50%, rgba(11, 12, 14, 0.9) 0%, rgba(11, 12, 14, 0.78) 45%, rgba(11, 12, 14, 0.55) 100%);
}
.finale {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(620px, calc(100% - 2 * var(--gutter)));
  text-align: center; pointer-events: none; opacity: 0;
}
.finale.is-on { pointer-events: auto; }
.finale-text { margin: 0 0 28px; font-size: clamp(21px, 2.6vw, 28px); line-height: 1.35; font-weight: 400; text-wrap: balance; }
.finale-author { font-size: 15px; font-weight: 500; margin-bottom: 10px; }
.finale-links { display: flex; justify-content: center; gap: 18px; margin-bottom: 26px; font-size: 14px; }
.finale-links a { color: var(--fg-2); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.finale-links a:hover { color: var(--gold); }
.finale-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.btn-primary { border-color: var(--gold-2); color: var(--gold); }

/* Footnote + toast */
.footnote {
  position: absolute; right: calc(var(--gutter) + var(--safe-right)); bottom: calc(10px + var(--safe-bottom));
  font-size: 11px; color: var(--fg-3); pointer-events: none; max-width: 46vw; text-align: right;
}
.toast {
  position: absolute; left: 50%; top: calc(var(--gutter) + var(--safe-top) + 44px); transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: 16px;
  padding: 6px 14px; font-size: 13px; color: var(--fg); opacity: 0; transition: opacity .25s ease; pointer-events: none;
}
.toast.is-on { opacity: 1; }

/* Debug readout */
.debug {
  position: absolute; left: calc(var(--gutter) + var(--safe-left)); top: calc(var(--gutter) + var(--safe-top) + 48px);
  font-family: var(--mono); font-size: 11px; color: var(--fg-2); white-space: pre; pointer-events: none;
  background: rgba(11, 12, 14, .7); padding: 6px 8px; border-radius: 6px;
}

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Record mode: the frame is drawn into the canvas, the UI is hidden */
.is-record #ui, .is-record .boot { display: none; }
.is-record #gl, .is-record #overlay { inset: auto; }
.is-record { touch-action: auto; user-select: auto; -webkit-user-select: auto; }
.rec-frame { box-shadow: 0 0 0 1px var(--panel-line); background: var(--bg); }
.rec-panel {
  position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 5;
  display: flex; gap: 10px; align-items: center; white-space: nowrap;
  font-family: var(--mono); font-size: 12px; color: var(--fg-2);
}
.rec-panel .btn { width: auto; padding: 0 14px; }
.rec-panel .btn .lbl { position: static; width: auto; height: auto; clip: auto; overflow: visible; }
.rec-panel a.btn { text-decoration: none; }

/* Narrow screens */
@media (max-width: 760px) {
  :root { --gutter: 16px; }
  .brand-tag { display: none; }
  .btn { width: 36px; height: 36px; padding: 0; justify-content: center; border-radius: 18px; }
  .btn .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .btn-lang { width: auto; padding: 0 10px; gap: 3px; font-size: 11.5px; }
  .btn svg { width: 15px; height: 15px; }
  .controls { gap: 6px; }
  .ruler { width: 34px; height: min(44vh, 360px); top: 44%; }
  .ruler-stop { font-size: 0; gap: 0; padding: 0; right: -8px; width: 30px; justify-content: flex-end; }
  .ruler-stop::after { margin-right: 8px; }
  .caption { width: calc(100% - 2 * var(--gutter)); bottom: calc(var(--gutter) + var(--safe-bottom) + 12px); }
  .caption-text { font-size: 16px; line-height: 1.42; }
  .caption-meta { margin-bottom: 6px; font-size: 10.5px; }
  .caption-actions { margin-top: 10px; }
  .scalebar { bottom: auto; top: calc(var(--gutter) + var(--safe-top) + 46px); }
  .card { max-height: 56vh; padding: 16px; }
  .card p { font-size: 14.5px; }
  .footnote { left: 0; right: 0; bottom: calc(4px + var(--safe-bottom)); max-width: none; text-align: center; font-size: 10px; }
  .hint { top: auto; bottom: calc(var(--gutter) + var(--safe-bottom) + 190px); }
  .finale .btn { width: auto; padding: 0 16px 0 14px; height: 38px; }
  .finale .btn .lbl { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
}
@media (max-width: 380px) {
  .controls { gap: 4px; }
  .btn { width: 34px; height: 34px; }
  .btn-lang { width: auto; padding: 0 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .hint svg { animation: none; }
  .caption-inner, .boot, .toast { transition: none; }
}
