/* ==========================================================================
   JTrail Productions — shared styles (every page)
   System: square edges, 1px rules, mono "slate" metadata, brackets for
   actions. Section looks (color, display type, texture) live in themes.css.
   ========================================================================== */

@view-transition { navigation: auto; }

:root {
  --font-base: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font-display: var(--font-base);

  --bg: #0c0c0b;
  --fg: #f2efe9;
  --muted: #9a968f;          /* 6.9:1 on --bg */
  --line: rgba(242, 239, 233, 0.16);
  --surface: #161615;
  --accent: #f2efe9;
  --accent-fg: #0c0c0b;
  --rec: #ff4a1c;
  --header-bg: rgba(12, 12, 11, 0.86);
  --vimeo-color: #f2efe9;

  --gutter: clamp(16px, 4vw, 56px);
  --max: 1520px;
  --header-h: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-base);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, iframe, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; border-radius: 0; }
h1, h2, h3, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
:focus-visible { outline: 1px solid currentColor; outline-offset: 4px; }
.modal-open, .menu-open { overflow: hidden; }
.container { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100; padding: 10px 14px;
  background: var(--fg); color: var(--bg); font-family: var(--font-mono); font-size: 12px;
}
.skip-link:focus { top: 12px; }

/* ---------------------------------------------------------------- slate (mono metadata) */
.slate, .eyebrow {
  font-family: var(--font-mono); font-size: 12px; font-weight: 400; line-height: 1.6;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.slate b, .eyebrow b { font-weight: 500; color: var(--fg); }

/* ---------------------------------------------------------------- actions */
.btn {
  display: inline-flex; align-items: center; gap: 0.6em; height: 44px; padding: 0 18px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap;
  color: var(--fg); box-shadow: inset 0 0 0 1px currentColor;
  transition: background 0.25s, color 0.25s;
}
.btn::before { content: "["; } .btn::after { content: "]"; }
.btn:hover, .btn:focus-visible { background: var(--fg); color: var(--bg); box-shadow: inset 0 0 0 1px var(--fg); }
.btn-solid { background: var(--accent); color: var(--accent-fg); box-shadow: none; }
.btn-solid:hover { background: var(--fg); color: var(--bg); }

.hdr-btn {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  opacity: 0.85; transition: opacity 0.2s; white-space: nowrap;
}
.hdr-btn:hover { opacity: 1; }
.sound-toggle .sound-state { display: inline-block; min-width: 3ch; }
.sound-toggle.is-muted { opacity: 0.55; }

/* ---------------------------------------------------------------- header */
.site-header {
  position: fixed; inset: 0 0 auto; z-index: 50; view-transition-name: site-header;
  transition: background 0.35s, box-shadow 0.35s;
}
.site-header.is-scrolled {
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 var(--line);
}
.header-inner {
  height: var(--header-h); max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter);
  display: flex; align-items: center; gap: 40px;
}
.logo { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.logo-mark { width: 30px; height: 30px; font-family: var(--font-base); }
.logo-rec { fill: var(--rec); }
.logo-word { display: flex; flex-direction: column; line-height: 1; }
.logo-word b { font-size: 15px; font-weight: 700; letter-spacing: 0.08em; }
.logo-word small { font-family: var(--font-mono); font-size: 8px; letter-spacing: 0.36em; margin-top: 5px; opacity: 0.75; }

.main-nav { display: flex; gap: 28px; }
.main-nav a {
  position: relative; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  opacity: 0.7; transition: opacity 0.2s;
}
.main-nav a:hover, .main-nav a[aria-current] { opacity: 1; }
.main-nav a[aria-current]::before {
  content: ""; position: absolute; left: -11px; top: 50%; width: 5px; height: 5px; margin-top: -2.5px;
  background: var(--rec); border-radius: 50%;
}
.header-actions { display: flex; align-items: center; gap: 24px; }
.menu-toggle { display: none; }

.mobile-menu {
  position: fixed; inset: var(--header-h) 0 0; background: var(--bg); padding: 16px var(--gutter) 40px;
  overflow-y: auto; animation: fade-in 0.25s var(--ease);
}
.mobile-menu nav { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.mobile-menu a {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: clamp(34px, 10vw, 52px); font-weight: 500; letter-spacing: -0.03em; line-height: 1.1;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.mobile-menu a[aria-current] { color: var(--muted); }

@media (max-width: 980px) {
  .main-nav { display: none; }
  .menu-toggle { display: inline-block; }
  .menu-open .site-header { background: var(--bg); }
}
@media (max-width: 480px) {
  .header-cta { display: none; }
  .header-actions { gap: 18px; }
}

/* ---------------------------------------------------------------- entrance reveals */
.js [data-reveal] { opacity: 0; transform: translateY(14px); transition: opacity 0.7s var(--ease), transform 0.9s var(--ease); }
.js [data-reveal].is-in { opacity: 1; transform: none; }

/* ---------------------------------------------------------------- media + hover previews */
.tile-media { position: relative; overflow: hidden; background: var(--surface); container-type: size; }
.tile-media > img { width: 100%; height: 100%; object-fit: cover; transition: transform 1s var(--ease); }
.preview-layer { position: absolute; inset: 0; opacity: 0; transition: opacity 0.45s var(--ease); pointer-events: none; }
.is-playing > .preview-layer { opacity: 1; }
.preview-layer img, .preview-layer video { width: 100%; height: 100%; object-fit: cover; }
.preview-layer iframe, .hero-media iframe {
  position: absolute; top: 50%; left: 50%; border: 0;
  width: max(100cqw, 177.78cqh); height: max(100cqh, 56.25cqw); transform: translate(-50%, -50%);
}

/* ---------------------------------------------------------------- project tiles (section grids) */
.tile { min-width: 0; }
.tile-link { display: block; }
.tile-media { aspect-ratio: 16 / 9; }
.tile-link:hover .tile-media > img { transform: scale(1.025); }
.tile-body { padding-top: 14px; border-top: 1px solid transparent; }
.tile-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.tile-title { font-family: var(--font-display); font-size: 20px; font-weight: 500; letter-spacing: -0.015em; line-height: 1.25; }
.tile-meta { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.tile-summary { margin-top: 6px; font-size: 14px; color: var(--muted); max-width: 52ch; }
.empty { color: var(--muted); padding: 48px 0; font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }

/* ---------------------------------------------------------------- project page */
.project { padding-top: calc(var(--header-h) + 24px); }
.back-link {
  display: inline-block; margin-bottom: 20px; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); transition: color 0.2s;
}
.back-link:hover { color: var(--fg); }
.video-frame { position: relative; aspect-ratio: 16 / 9; background: #000; overflow: hidden; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.project-intro {
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 48px 80px;
  padding: clamp(40px, 6vw, 88px) 0 clamp(40px, 5vw, 72px);
}
.project-title {
  font-family: var(--font-display); font-size: clamp(40px, 6vw, 88px); font-weight: 500;
  letter-spacing: -0.035em; line-height: 0.98; margin: 12px 0 24px;
}
.project-desc { font-size: clamp(17px, 1.4vw, 19px); max-width: 58ch; }
.project-meta { margin: 0; align-self: end; border-top: 1px solid var(--line); }
.project-meta div { display: flex; justify-content: space-between; gap: 24px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.project-meta dt { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.project-meta dd { margin: 0; font-size: 15px; text-align: right; }

.stills { columns: 2; column-gap: 8px; }
.still { display: block; width: 100%; margin-bottom: 8px; break-inside: avoid; overflow: hidden; }
.still img { width: 100%; height: auto; transition: transform 1s var(--ease); }
.still:hover img { transform: scale(1.02); }

.next-project { display: grid; gap: 6px; padding: clamp(56px, 8vw, 120px) 0; margin-top: 48px; border-top: 1px solid var(--line); }
.next-project span { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.next-project strong {
  font-family: var(--font-display); font-size: clamp(40px, 7vw, 104px); font-weight: 500; letter-spacing: -0.035em; line-height: 1;
  transition: transform 0.6s var(--ease);
}
.next-project em { font-style: normal; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.next-project:hover strong { transform: translateX(12px); }
.project-missing { padding-block: 140px; display: grid; gap: 20px; justify-items: start; }

@media (max-width: 760px) {
  .project-intro { grid-template-columns: 1fr; }
  .stills { columns: 1; }
  .video-frame { margin-inline: calc(var(--gutter) * -1); }
}

/* ---------------------------------------------------------------- modals */
.modal {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  padding: clamp(16px, 5vw, 64px); background: rgba(6, 6, 6, 0.96); color: #f2efe9;
  animation: fade-in 0.3s var(--ease);
}
.modal .video-frame { width: min(100%, 1400px, calc((100svh - 120px) * 16 / 9)); }
.modal-close {
  position: absolute; top: 16px; right: var(--gutter); height: 32px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
}
.lightbox { grid-template-columns: auto 1fr auto; grid-template-rows: 1fr auto; gap: 12px; }
.lb-img { max-height: calc(100svh - 120px); width: auto; margin: auto; }
.lb-count { grid-column: 1 / -1; text-align: center; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.1em; color: #9a968f; }
.lb-nav { width: 48px; height: 48px; font-family: var(--font-mono); font-size: 18px; opacity: 0.7; }
.lb-nav:hover { opacity: 1; }
@media (max-width: 600px) {
  .lightbox { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr auto auto; }
  .lb-img { grid-column: 1 / -1; grid-row: 1; }
  .lb-count { grid-row: 2; }
  .lb-prev { justify-self: start; } .lb-next { justify-self: end; }
}

/* ---------------------------------------------------------------- footer */
.site-footer { border-top: 1px solid var(--line); margin-top: clamp(80px, 10vw, 160px); padding: clamp(56px, 8vw, 104px) 0 28px; }
.footer-inner { display: grid; gap: clamp(48px, 7vw, 96px); }
.footer-lead { display: grid; gap: 14px; }
.footer-mail {
  justify-self: start; font-size: clamp(20px, 6.2vw, 88px); font-weight: 500; letter-spacing: -0.04em; line-height: 1;
  overflow-wrap: anywhere; background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size 0.6s var(--ease); padding-bottom: 6px;
}
.footer-mail:hover { background-size: 100% 1px; }
.footer-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; border-top: 1px solid var(--line); padding-top: 20px; }
.footer-cols h2 { font-family: var(--font-mono); font-size: 11px; font-weight: 400; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.footer-cols a { display: block; font-size: 15px; padding: 3px 0; opacity: 0.88; }
.footer-cols a:hover { opacity: 1; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.footer-legal {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
@media (max-width: 640px) { .footer-cols { grid-template-columns: 1fr 1fr; } }

/* ---------------------------------------------------------------- page transitions */
::view-transition-old(root) { animation: 0.2s var(--ease) both fade-out; }
::view-transition-new(root) { animation: 0.4s var(--ease) both fade-in; }
::view-transition-group(site-header) { animation-duration: 0.35s; }
.js-fade main { animation: fade-in 0.4s var(--ease) both; }
.js-fade.is-leaving main, .js-fade.is-leaving .site-footer { opacity: 0; transition: opacity 0.18s; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
    animation-duration: 0.01ms !important; transition-duration: 0.01ms !important;
  }
  .js [data-reveal] { opacity: 1; transform: none; }
}
