:root {
  --bg: #0b0b0b;
  --fg: #f4f2ec;
  --text: #e6e3db;
  --soft: #c9c6be;
  --muted: #9a978f;
  --line: #2a2a2a;
  --line-strong: #3a3a3a;
  --surface: #1a1a1a;
  --accent: #e4ff3a;
  --gutter: clamp(16px, 2.8vw, 40px);
  --gap: 20px;
  --display: "Oswald", "Arial Narrow", sans-serif;
  --sans: "Golos Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --logo: "Unbounded", var(--sans);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 var(--sans);
}
main { flex: 1; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.pill {
  display: inline-block;
  white-space: nowrap;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--fg);
  border-radius: 999px;
  padding: 5px 12px;
  font: 600 10px/1.2 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.pill-link { text-decoration: none; padding: 9px 16px; font-size: 11px; }
.pill-link:hover { background: var(--fg); color: var(--bg); }

/* ---------- Header ---------- */
.top {
  display: flex;
  align-items: center;
  gap: 32px;
  min-height: 64px;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
}
.logo {
  font: italic 800 20px/1 var(--logo);
  letter-spacing: -0.02em;
  text-transform: uppercase;
  text-decoration: none;
  flex-shrink: 0;
}
.cats {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font: 600 11px/1 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cats a {
  text-decoration: none;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  white-space: nowrap;
}
.cats a:hover { border-color: var(--line-strong); }
/* Many sections and the header icons share one row: the sections scroll instead of pushing the icons off screen. */
@media (min-width: 901px) {
  .cats { min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .cats::-webkit-scrollbar { display: none; }
}
.cats a.is-active { border-color: var(--fg); }
.top-link {
  font: 600 11px/1 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}
.top-link:hover { color: var(--accent); }

/* ---------- Feed ---------- */
.intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 48px var(--gutter) 32px;
}
.intro h1 {
  margin: 0;
  font: 700 clamp(56px, 8vw, 112px)/0.9 var(--display);
  text-transform: uppercase;
  letter-spacing: -0.01em;
}
.intro-count { margin: 0 0 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.intro-count a { color: var(--accent); }
.empty { padding: 0 var(--gutter) 64px; color: var(--muted); }

.feed {
  display: grid;
  column-gap: var(--gap);
  row-gap: 44px;
  padding: 0 var(--gutter) 72px;
  /* The max() term caps the grid at 10 columns on very wide screens. */
  grid-template-columns: repeat(auto-fill, minmax(max(220px, (100% - 9 * var(--gap)) / 10), 1fr));
}

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-decoration: none;
  color: var(--fg);
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.card-media {
  position: relative;
  display: block;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--surface);
}
.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(.2, .7, .2, 1);
}
.card-media .pill {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 16px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-blank {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: 16px;
  font: 700 28px/1 var(--display);
  text-transform: uppercase;
  color: var(--muted);
}
.card-title {
  font: 600 22px/1.05 var(--display);
  text-transform: uppercase;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { font-size: 12px; color: var(--muted); }
@media (hover: hover) {
  .card:hover .card-media img { transform: scale(1.035); }
  .card:hover .card-title { color: var(--accent); }
}

/* ---------- Post ---------- */
.draft-banner {
  margin: 16px var(--gutter) 0;
  padding: 12px 16px;
  border: 1px dashed var(--accent);
  color: var(--accent);
  font-size: 14px;
}
.post-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 28px;
  padding: 40px var(--gutter) 0;
}
.post-head h1 {
  margin: 0;
  max-width: 1240px;
  font: 700 clamp(44px, 8.4vw, 128px)/0.92 var(--display);
  text-transform: uppercase;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.lead { margin: 0; max-width: 760px; font-size: clamp(17px, 1.6vw, 22px); line-height: 1.45; color: var(--soft); }
.facts {
  align-self: stretch;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.facts div { padding: 18px 24px; border-left: 1px solid var(--line); min-width: 0; }
.facts div:first-child { padding-left: 0; border-left: 0; }
.facts dt {
  font: 600 10px/1 var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.facts dd {
  margin: 0;
  font: 500 22px/1.15 var(--display);
  text-transform: uppercase;
  overflow-wrap: anywhere;
}
.facts a { text-decoration: none; }
.facts a:hover { color: var(--accent); }

.posters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  padding: 48px var(--gutter) 0;
}
.posters.is-single { grid-template-columns: minmax(0, 720px); justify-content: center; }
.poster { margin: 0; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.poster-media { position: relative; display: block; background: var(--surface); }
.poster-media img { width: 100%; }
.poster-media .pill { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); font-size: 11px; padding: 6px 14px; }
.poster figcaption {
  display: flex;
  justify-content: space-between;
  font: 600 11px/1 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.poster figcaption a { color: var(--accent); text-decoration: none; }

/* Two posters in one frame: the English one lies on top and is cut off at the line (--pos). */
.curtain-stage { position: relative; overflow: hidden; background: var(--surface); cursor: ew-resize; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.curtain-stage img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; -webkit-user-drag: none; }
.curtain-top { position: absolute; inset: 0; clip-path: inset(0 calc(100% - var(--pos)) 0 0); }
.curtain-line { position: absolute; top: 0; bottom: 0; left: var(--pos); width: 2px; margin-left: -1px; background: var(--fg); outline: none; }
.curtain-knob {
  position: absolute; top: 50%; left: 50%; width: 44px; height: 44px; transform: translate(-50%, -50%);
  display: grid; place-items: center; border-radius: 50%; background: var(--fg); color: var(--bg);
  box-shadow: 0 4px 18px rgb(0 0 0 / 0.5);
}
.curtain-line:focus-visible .curtain-knob { background: var(--accent); outline: 2px solid var(--bg); outline-offset: 2px; }
.curtain-tag { position: absolute; top: 16px; font-size: 11px; padding: 6px 14px; pointer-events: none; transition: opacity 0.15s; }
.curtain-tag-left { left: 16px; }
.curtain-tag-right { right: 16px; }
/* A label disappears once its poster is almost covered. */
.curtain[data-side="right"] .curtain-tag-left, .curtain[data-side="left"] .curtain-tag-right { opacity: 0; }
.curtain figcaption { gap: 12px; flex-wrap: wrap; line-height: 1.4; }
.curtain-links { display: flex; gap: 16px; }

.prose {
  max-width: 680px;
  margin: 0 auto;
  padding: 80px var(--gutter) 0;
  box-sizing: content-box;
  font-size: 19px;
  line-height: 1.65;
  color: var(--text);
}
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose figure, .prose table, .prose pre { margin: 0 0 1.2em; }
.prose h2, .prose h3 {
  font-family: var(--display);
  font-weight: 600;
  text-transform: uppercase;
  line-height: 1;
  color: var(--fg);
  margin: 1.8em 0 0.6em;
}
.prose h2 { font-size: 40px; }
.prose h3 { font-size: 28px; }
.prose strong { color: var(--fg); }
.prose a { color: var(--accent); }
.prose img { width: 100%; margin: 1.6em 0; }
.prose blockquote {
  margin: 0 0 1.2em;
  padding-left: 20px;
  border-left: 2px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.4em 0; }
.prose code { font-family: var(--mono); font-size: 0.86em; background: var(--surface); padding: 0.1em 0.35em; border-radius: 4px; }
/* Code and schemes drawn in pseudographics (box lines and arrows line up only in a monospace font with tight lines). */
.prose pre {
  background: var(--surface);
  padding: 18px 20px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: 14px/1.4 var(--mono);
  color: var(--soft);
  tab-size: 2;
}
.prose pre code { background: none; padding: 0; font-size: inherit; border-radius: 0; }
/* Formulas (KaTeX, drawn on the server, see math.mjs): a wide one scrolls sideways instead of widening the page. */
.prose .math { margin: 0 0 1.2em; padding: 4px 0; overflow-x: auto; overflow-y: hidden; }
.prose .math .katex-display { margin: 0; font-size: 1.12em; }
.prose .katex { font-size: 1.1em; color: var(--fg); }
.prose table { width: 100%; border-collapse: collapse; font-size: 15px; display: block; overflow-x: auto; border-top: 1px solid var(--fg); }
.prose th {
  text-align: left;
  font: 600 11px/1.2 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.prose th, .prose td { padding: 12px 16px 12px 0; border-bottom: 1px solid var(--line); }
/* A table in its frame (render.mjs): as wide as the text, scrolls sideways when wider; numbers line up on the right. */
.prose .table-wrap { margin: 0 0 1.4em; overflow-x: auto; border-top: 1px solid var(--fg); }
.prose .table-wrap table { display: table; margin: 0; border-top: 0; line-height: 1.45; font-variant-numeric: tabular-nums; }
.prose .table-wrap th { vertical-align: bottom; }
.prose .table-wrap td { vertical-align: top; }
.prose .table-wrap td:first-child { color: var(--fg); }
.prose .table-wrap .num { text-align: right; padding-left: 16px; }
.prose .table-wrap td.num { white-space: nowrap; }
.prose .table-wrap th:last-child, .prose .table-wrap td:last-child { padding-right: 0; }
.prose .table-wrap tbody tr:hover td { background: rgb(255 255 255 / 0.03); }

/* ---------- Related rail ---------- */
.related { margin-top: 96px; padding: 32px 0 64px; border-top: 1px solid var(--line); }
.related-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 0 var(--gutter) 24px;
}
.related h2 { margin: 0; font: 700 clamp(36px, 4vw, 56px)/1 var(--display); text-transform: uppercase; }
.rail-nav { display: flex; gap: 8px; }
.round {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--fg);
  background: transparent;
  color: var(--fg);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.round:hover { background: var(--fg); color: var(--bg); }
.round:disabled { opacity: 0.3; cursor: default; background: transparent; color: var(--fg); }
.rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 256px;
  gap: var(--gap);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--gutter);
  padding: 0 var(--gutter) 8px;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail .card { scroll-snap-align: start; border-bottom: 0; }

/* ---------- 404 ---------- */
.nf-hero {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  padding: clamp(56px, 12vh, 128px) var(--gutter) 24px;
}
.nf-hero h1 {
  margin: 0;
  font: 700 clamp(96px, 18vw, 220px)/0.82 var(--display);
  letter-spacing: -0.02em;
  color: var(--accent);
}
.nf-hero p { margin: 0; max-width: 34em; color: var(--muted); font-size: clamp(16px, 1.6vw, 19px); }
.nf-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.nf .related { margin-top: clamp(40px, 8vh, 80px); }

/* ---------- Footer ---------- */
.foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 28px var(--gutter) calc(28px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  font: 600 11px/1 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.foot a { text-decoration: none; }
.foot-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px 20px; }
.foot a:hover { color: var(--fg); }

/* ---------- Tablets ---------- */
@media (max-width: 900px) {
  .top { flex-wrap: wrap; gap: 0 16px; padding-top: 12px; }
  .top-link { margin-left: auto; }
  .cats {
    order: 3;
    flex: 1 0 100%;
    margin: 0 calc(-1 * var(--gutter));
    padding: 12px var(--gutter);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .cats::-webkit-scrollbar { display: none; }
  .cats a { border-color: var(--line-strong); }
  .cats a.is-active { background: var(--accent); border-color: var(--accent); color: var(--bg); }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts div { padding: 14px 0 14px 16px; border-bottom: 1px solid var(--line); }
  .facts div:nth-child(odd) { padding-left: 0; border-left: 0; }
  .facts div:nth-last-child(-n+2):nth-child(odd), .facts div:last-child { border-bottom: 0; }
  /* Sticky header (site.js): hides on scroll down, slides back on scroll up. */
  .top.is-pinned {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(11, 11, 11, 0.94);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: transform 0.22s ease;
  }
  .top.is-pinned.is-away { transform: translateY(-100%); }
  /* Reading progress of the page: hangs under the header, so it alone stays on screen while the header is away. */
  .top.is-pinned::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(var(--accent), var(--accent)) 0 0 / calc(var(--progress, 0) * 100%) 100% no-repeat, var(--line);
    opacity: 0;
    transition: opacity 0.22s ease;
    pointer-events: none;
  }
  .top.is-pinned.is-away::after { opacity: 1; }
}

/* ---------- Phones ---------- */
@media (max-width: 640px) {
  :root { --gap: 12px; }
  .logo { font-size: 17px; }
  .intro { flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px var(--gutter) 20px; }
  .intro-count { margin: 0; }
  .intro h1 { font-size: clamp(40px, 13vw, 56px); max-width: 100%; overflow-wrap: anywhere; }
  .feed { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 28px; padding-bottom: 48px; }
  .card { gap: 10px; padding-bottom: 0; border-bottom: 0; }
  .card-media .pill { top: 8px; padding: 4px 9px; font-size: 9px; letter-spacing: 0.06em; }
  .card-title { font-size: 17px; }
  .card-meta { font-size: 11px; }

  .post-head { gap: 18px; padding-top: 20px; }
  /* Long Russian words must fit whole on a phone; when one still does not, it is hyphenated, not chopped. */
  .post-head h1 { font-size: clamp(30px, 10.5vw, 44px); hyphens: auto; }
  .facts dd { font-size: 17px; }
  .facts dt { font-size: 9px; }

  /* RU/EN posters: swipe between them, the next one peeks from the edge. */
  .posters {
    display: flex;
    gap: 12px;
    padding: 28px var(--gutter) 0;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gutter);
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  .posters::-webkit-scrollbar { display: none; }
  .poster { flex: 0 0 84%; scroll-snap-align: start; }
  .posters.is-single .poster { flex-basis: 100%; }
  .poster-media .pill { top: 10px; font-size: 9px; padding: 5px 11px; }
  .curtain-tag { top: 10px; font-size: 9px; padding: 5px 11px; }
  .curtain-tag-left { left: 10px; }
  .curtain-tag-right { right: 10px; }

  .prose { padding-top: 40px; font-size: 17px; line-height: 1.6; }
  .prose h2 { font-size: 30px; }
  .prose h3 { font-size: 23px; }

  .related { margin-top: 56px; padding: 24px 0 40px; }
  .rail-nav { display: none; }
  .rail { grid-auto-columns: 44vw; }
  .card-title { -webkit-line-clamp: 4; }
}

@media (prefers-reduced-motion: reduce) {
  .card-media img, .top.is-pinned, .top.is-pinned::after { transition: none; }
}

/* ---------- Tags ---------- */
.prose .tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2.4em; }
.prose .tags a { color: var(--fg); text-decoration: none; }
.prose .tags a:hover { color: var(--bg); }

/* ---------- Language switch ---------- */
.top-links { display: flex; align-items: center; gap: 20px; flex-shrink: 0; }
.lang-switch { border: 1px solid var(--line-strong); border-radius: 999px; padding: 8px 12px; }
.lang-switch:hover { border-color: var(--accent); }
@media (max-width: 900px) { .top-links { margin-left: auto; } .top-link { margin-left: 0; } }

/* ---------- Search ---------- */
.icon-link { display: inline-flex; padding: 6px; margin: -6px; }
.intro h1.is-search { font-size: clamp(36px, 6vw, 72px); overflow-wrap: anywhere; }
.search-form { display: flex; gap: 10px; max-width: 720px; padding: 0 var(--gutter) 40px; }
.search-form input {
  flex: 1;
  min-width: 0;
  padding: 11px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg);
  font: 16px/1.2 var(--sans);
}
.search-form input:focus { outline: none; border-color: var(--accent); }
.search-form button { cursor: pointer; }

/* ---------- Ta-da burst (site.js window.tada) ---------- */
.tada { position: fixed; z-index: 70; width: 0; height: 0; pointer-events: none; }
.tada i {
  position: absolute;
  left: 0;
  top: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.tada i.is-white { background: var(--fg); }
.tada i.is-bar { width: 3px; height: 10px; border-radius: 2px; }
