/* ============================================================
   base.css — resets, background, shared chrome (header / nav /
   footer / switcher), grade + grain. Page templates layer on top.
   Values from docs/reference/index-v5.dc.html (canvas px × --u).
   ============================================================ */

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

::selection {
  background: var(--paper);
  color: var(--ink);
}

body {
  min-height: 100vh;
  background-color: var(--ink);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--paper);
  font-family: var(--font-grotesque);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

/* ---- film grain overlay (desaturated fractal noise, 240px tile) ---- */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='gn'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23gn)'/%3E%3C/svg%3E");
  background-size: 240px 240px;
}

main {
  flex: 1;
  position: relative;
  z-index: 2;
  padding: 0 var(--page-pad);
}

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

img,
video {
  display: block;
  max-width: 100%;
}

/* ---- graded imagery: filter at rest, original + scale on hover ---- */
.graded {
  overflow: hidden;
}

.graded img,
.graded video {
  filter: var(--grade-filter);
  transition: var(--grade-transition);
}

.graded:hover img,
.graded:hover video,
.graded:focus-visible img,
.graded:focus-visible video {
  filter: none;
  transform: scale(var(--hover-scale));
}

/* ============================================================
   Header: name / tagline / nav / language switcher
   ============================================================ */

.site-header {
  position: relative;
  z-index: 2;
  padding-top: var(--header-top);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--header-gap);
  text-align: center;
}

/* SLAVA … GRYSHANIN spread across a fixed comp width;
   the tagline row shares that width so it can end under the N */
.site-header__name {
  display: flex;
  justify-content: space-between;
  width: var(--name-comp-width);
  font-family: var(--font-grotesque);
  font-weight: 500;
  font-size: var(--name-size);
  letter-spacing: var(--name-tracking);
  text-transform: uppercase;
  line-height: 1;
  color: var(--paper);
}

.site-header__tagline-row {
  width: var(--name-comp-width);
  display: flex;
  justify-content: flex-end; /* right-edge: ends under the final N (BRIEF §4) */
}

.site-header__tagline {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: var(--tagline-size);
  letter-spacing: var(--tagline-tracking);
  line-height: 1;
  white-space: nowrap;
  color: var(--tagline-color);
  /* letter-spacing leaves a trailing gap after the final N inside the
     name row; pull the tagline back so it ends under the N itself */
  padding-right: calc(var(--name-size) * 0.24);
}

/* ---- nav row ---- */
.site-nav {
  margin-top: calc(3 * var(--u));
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4em var(--nav-gap);
  font-family: var(--font-grotesque);
  font-size: var(--nav-size);
  letter-spacing: var(--nav-tracking);
  text-transform: uppercase;
}

/* hover: underline grows from center */
.site-nav a {
  position: relative;
  color: var(--secondary);
  padding-bottom: 3px;
  transition: color 0.35s ease;
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: var(--paper);
  transform: translateX(-50%) scaleX(0);
  transform-origin: center;
  transition: transform 0.45s var(--ease-slide);
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--paper);
}

.site-nav a:hover::after,
.site-nav a:focus-visible::after {
  transform: translateX(-50%) scaleX(1);
}

/* current page: paper text over a static gray rule */
.site-nav a[aria-current="page"] {
  color: var(--paper);
}

.site-nav a[aria-current="page"]::after {
  background: var(--rule);
  transform: translateX(-50%) scaleX(1);
}

/* ---- language switcher, top right ---- */
.lang-switcher {
  position: absolute;
  top: var(--edge-x);
  right: var(--edge-x);
  z-index: 6;
  display: flex;
  gap: calc(14 * var(--u));
  font-family: var(--font-mono);
  font-size: max(calc(8.5 * var(--u)), 8px);
  letter-spacing: var(--meta-tracking);
}

.lang-switcher a {
  color: var(--secondary);
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
}

.lang-switcher a[aria-current="true"] {
  color: var(--paper);
  border-bottom-color: var(--rule-lang);
}

.lang-switcher a:hover {
  color: var(--paper);
}

/* ---- section header: oversized numeral + title + bracket ----
   shared by category grids, filmography, case pages */
.section-head {
  position: relative;
  z-index: 2;
  max-width: calc(1280 * var(--u));
  margin: calc(74 * var(--u)) auto 0;
  padding: 0 calc(64 * var(--u));
  display: flex;
  align-items: flex-end;
  gap: calc(36 * var(--u));
}

.section-head .numeral {
  font-size: calc(150 * var(--u));
  line-height: 0.78;
}

.section-head__text {
  display: flex;
  flex-direction: column;
  gap: calc(14 * var(--u));
  padding-bottom: calc(5 * var(--u));
}

.section-head__title {
  font-family: var(--font-grotesque);
  font-size: calc(30 * var(--u));
  font-weight: 400;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--paper);
}

.section-head__genre {
  font-family: var(--font-mono);
  font-size: max(calc(10.5 * var(--u)), 9px);
  letter-spacing: var(--meta-tracking);
  color: var(--secondary);
}

/* ---- roman numeral section anchors ---- */
.numeral {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: var(--numeral-size);
  line-height: 1;
  color: var(--numerals);
  opacity: var(--numeral-opacity);
  user-select: none;
}

/* ---- hero-header pages: chrome rides over a full-bleed hero ---- */
.has-hero-header {
  position: relative;
}

.has-hero-header main {
  padding: 0;
}

.has-hero-header .site-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
}

/* ---- prev / next rail: film details and case pages ---- */
.film-nav {
  position: relative;
  z-index: 2;
  max-width: calc(1280 * var(--u));
  margin: calc(110 * var(--u)) auto 0;
  padding: 0 calc(64 * var(--u));
}

.film-nav__inner {
  border-top: 1px solid rgba(94, 98, 104, 0.25);
  padding-top: calc(26 * var(--u));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.film-nav__col {
  display: flex;
  flex-direction: column;
  gap: calc(9 * var(--u));
  align-items: flex-start;
}

.film-nav__col--next {
  align-items: flex-end;
  text-align: right;
}

.film-nav__label {
  font-family: var(--font-mono);
  font-size: max(calc(9 * var(--u)), 8px);
  letter-spacing: 0.26em;
  color: var(--numerals);
}

.film-nav__link {
  font-family: var(--font-mono);
  font-size: max(calc(10.5 * var(--u)), 9px);
  letter-spacing: var(--meta-tracking);
  text-transform: uppercase;
  color: var(--secondary);
  transition: color 0.35s ease;
}

.film-nav__link:hover,
.film-nav__link:focus-visible {
  color: var(--paper);
}

/* ============================================================
   Footer
   ============================================================ */

.site-footer {
  position: relative;
  z-index: 2;
  padding: calc(var(--page-pad) * 0.75) var(--edge-x) var(--footer-bottom);
  text-align: right;
  font-family: var(--font-mono);
  font-size: var(--meta-size);
  letter-spacing: var(--meta-tracking);
  color: var(--numerals);
}

/* ============================================================
   Mobile menu (shared, every page) — base state. The MENU
   trigger and the overlay are desktop-hidden here; the mobile
   media block below turns them on. Keep these rules BEFORE the
   media block so the display:block override wins by source order.
   ============================================================ */
.menu-trigger {
  display: none; /* desktop shows the full nav row instead */
  font-family: var(--font-mono);
  font-size: max(calc(9.5 * var(--u)), 9px);
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--secondary);
  background: none;
  border: 0;
  padding: 2px 0;
  cursor: pointer;
  transition: color 0.3s ease;
}

.menu-trigger:hover,
.menu-trigger:focus-visible {
  color: var(--paper);
}

.menu-overlay {
  display: none; /* desktop: never shown, never tabbable */
}

/* body scroll lock while the overlay is open */
.menu-open {
  overflow: hidden;
}

/* ============================================================
   Mobile chrome (≤768px) — reference index-mobile.html frame A.
   The nav row is replaced by a MENU trigger top-left (mirroring
   the switcher top-right); the name collapses to one centered
   line with the tagline right-aligned beneath it.
   ============================================================ */
@media (max-width: 768px) {
  .lang-switcher {
    top: 18px;
    gap: 13px;
  }

  .menu-trigger {
    display: block;
    position: absolute;
    top: 18px;
    left: var(--edge-x);
    z-index: 6;
  }

  .site-nav {
    display: none; /* navigation lives in the overlay */
  }

  .site-header {
    align-items: stretch;
    padding: var(--header-top) var(--edge-x) 0;
    gap: var(--header-gap);
  }

  /* single centered name line; letter-spacing tightened to 0.185em
     to fit 390px, negative margin offsets the trailing gap */
  .site-header__name {
    width: 100%;
    justify-content: center;
    gap: 0.34em;
    letter-spacing: 0.185em;
    margin-right: -0.185em;
  }

  .site-header__tagline-row {
    width: 100%;
    justify-content: flex-end;
  }

  .site-header__tagline {
    padding-right: 0;
  }

  .section-head {
    margin-top: 44px;
    padding: 0 var(--edge-x);
    gap: 20px;
  }

  .section-head .numeral {
    font-size: 92px;
  }

  .section-head__title {
    font-size: 20px;
    letter-spacing: 0.26em;
  }

  .film-nav {
    margin-top: 72px;
    padding: 0 var(--edge-x);
  }

  /* ---- full-screen INK menu overlay ---- */
  .menu-overlay {
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(14, 17, 22, 0.96);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
  }

  .menu-overlay.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.3s ease;
  }

  /* film grain over the ink, matching the page material */
  .menu-overlay::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: var(--grain-opacity);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='gn'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23gn)'/%3E%3C/svg%3E");
    background-size: 240px 240px;
  }

  .menu-overlay__close {
    align-self: flex-end;
    margin: 18px var(--edge-x) 0;
    z-index: 2;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.22em;
    color: var(--paper);
    background: none;
    border: 0;
    padding: 4px;
    cursor: pointer;
  }

  .menu-nav {
    position: relative;
    z-index: 2;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 26px;
    padding: 0 var(--edge-x) 40px;
  }

  .menu-nav__group {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .menu-nav a {
    font-family: var(--font-grotesque);
    font-size: 20px;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    line-height: 1;
    color: var(--paper);
  }

  .menu-nav a[aria-current="page"] {
    border-bottom: 1px solid var(--rule);
    padding-bottom: 3px;
  }

  .menu-nav__bracket {
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.14em;
    color: var(--secondary);
  }
}

/* touch devices: the graded rest state is the identity — no
   sticky hover, tap goes straight to navigation (§5 of the task;
   hover choreography is pointer-only) */
@media (hover: none) {
  .graded:hover img,
  .graded:hover video {
    filter: var(--grade-filter);
    transform: none;
  }
}
