/* lewisdn.com homepage. Text lives in content.js.

   The system, so additions stay consistent:
   Colour: --bg, --surface, --line, --fg, --muted, plus one --accent.
   Type:   one family. Sizes are --t-s, --t-m, --t-l, --t-xl, plus the hero.
   Radius: --r-s (buttons, thumbnails), --r-m (media), --r-l (cards).
   Motion: --out for things arriving, --move for things travelling. Exits are 20% shorter than entrances. */

:root {
  --bg: #131210;
  --surface: #1b1a17;
  --line: #34322d;
  --fg: #f0ede6;
  --muted: #a5a095;
  --accent: oklch(0.82 0.12 25);

  --sans: 'Schibsted Grotesk', system-ui, sans-serif;
  --t-s: 14px;
  --t-m: 16px;
  --t-l: 20px;
  --t-xl: clamp(40px, 5.2vw, 76px);

  --r-s: 8px;
  --r-m: 12px;
  --r-l: 20px;

  --out: cubic-bezier(0.2, 0, 0, 1);
  --move: cubic-bezier(0.65, 0, 0.35, 1);
  --gut: 4vw;
}

* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--sans); }
h1, h2, p { margin: 0; font: inherit; }
a { color: inherit; text-decoration: none; }
button { color: inherit; font-family: inherit; }
a, button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
img, video { -webkit-user-drag: none; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 4px; }

#root { background: var(--bg); color: var(--fg); font-family: var(--sans); }

/* ── Shared controls ─────────────────────────────────────────────────────── */
.btn {
  display: inline-block; align-self: flex-start;
  font: 600 var(--t-m) var(--sans); padding: 12px 20px; border-radius: var(--r-s);
  background: var(--fg); color: var(--bg);
  transition: background-color 0.15s, transform 0.1s var(--out);
}
.link {
  font: 500 var(--t-s) var(--sans); background: none; border: none; padding: 8px 0; cursor: pointer;
  color: var(--muted); transition: color 0.15s, transform 0.1s var(--out);
}
.btn:active, .link:active, .clip-btn:active, .plans-btn:active { transform: scale(0.97); }
@media (hover: hover) {
  .btn:hover, .card:hover .btn { background: #fff; }
  .link:hover { color: var(--fg); }
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px var(--gut); font: 500 var(--t-s) var(--sans); background: var(--bg);
}
.logo {
  font: 600 var(--t-m) var(--sans); background: none; border: none; padding: 0; cursor: pointer;
  user-select: none; -webkit-user-select: none;
}
.tb-left { display: flex; align-items: center; gap: 16px; }
.adminpill {
  font: 500 var(--t-s) var(--sans); background: none; border: none; padding: 0;
  color: var(--accent); cursor: pointer;
}
.adminpill[hidden] { display: none; }
.navlabel { color: var(--muted); white-space: nowrap; transition: opacity 0.12s; }
.navlabel.swap { opacity: 0; }

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
  height: 100vh; height: 100svh; display: flex; flex-direction: column; justify-content: center;
  padding: 0 var(--gut); overflow: hidden; position: relative;
}
.hero-lines { display: block; }
.hero-line {
  display: block; font: 600 clamp(52px, 10.5vw, 190px)/1 var(--sans); letter-spacing: -0.02em; white-space: nowrap;
}
.hero-foot {
  position: absolute; bottom: 28px; left: var(--gut); right: var(--gut);
  display: flex; justify-content: space-between; font: 400 var(--t-s) var(--sans); color: var(--muted);
}

/* ── Card stack ──────────────────────────────────────────────────────────── */
.stack { position: relative; height: calc(var(--n, 5) * 100vh); height: calc(var(--n, 5) * 100svh); }
.stack-sticky { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; }
.stack-cards { position: absolute; inset: 0; }

.card {
  position: absolute; left: 50%; top: 53%;
  width: min(1240px, 92vw); height: 76vh; height: 76svh;
  padding: 40px; border-radius: var(--r-l);
  display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.5fr); gap: 40px;
  overflow: hidden; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -50%) translateY(100vh);
  will-change: transform;
}
.card.next { cursor: default; }
/* Darkening layer for cards further back. Used on touch screens and narrow windows instead of a CSS filter
   (Safari can mis-draw videos inside filtered elements). Black at opacity (1 - b) == brightness(b). */
.shade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 3; border-radius: inherit; }
.card:focus-visible { outline-offset: -6px; }
.card-left { position: relative; display: flex; flex-direction: column; justify-content: flex-end; min-width: 0; }
.card-body { display: flex; flex-direction: column; gap: 16px; }
.card-name { font: 600 clamp(36px, 4.2vw, 60px)/1.04 var(--sans); letter-spacing: -0.02em; text-wrap: balance; }
.card-desc { font: 400 var(--t-l)/1.4 var(--sans); max-width: 26em; text-wrap: pretty; color: var(--muted); }
.card-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; margin-top: 8px; }
.card-meta { font: 400 var(--t-s) var(--sans); color: var(--muted); }
.card-right { position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; }
.frame { position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: 100%; will-change: transform; }
.frame video, .frame img {
  width: 100%; height: 100%; object-fit: cover; border-radius: var(--r-m); display: block; background: #000;
}

.dots {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 40;
}
.dots span {
  width: 4px; height: 4px; border-radius: 2px; background: var(--fg); opacity: 0.3;
  transition: height 0.2s var(--out), opacity 0.2s;
}
.dots span.on { height: 20px; opacity: 1; }

/* ── All projects list ───────────────────────────────────────────────────── */
.everything { padding: 120px var(--gut) 96px; display: flex; flex-direction: column; gap: 32px; }
.ev-title { font: 600 var(--t-xl)/1.05 var(--sans); letter-spacing: -0.02em; }

.grid { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.row {
  position: relative; display: grid; align-items: center; gap: 24px;
  grid-template-columns: 136px minmax(0, 1fr) minmax(0, 1.4fr) auto 24px;
  padding: 16px 0; border-bottom: 1px solid var(--line); cursor: pointer;
  opacity: 0; transform: translateY(12px);
  transition: opacity 0.3s var(--out), transform 0.3s var(--out), background-color 0.15s;
  transition-delay: var(--d, 0ms), var(--d, 0ms), 0ms;
}
.grid.seen .row { opacity: 1; transform: none; }
.grid.settled .row { transition-delay: 0ms; }
.rthumb {
  width: 136px; height: auto; aspect-ratio: 16 / 9; object-fit: cover; display: block;
  border-radius: var(--r-s); background: var(--surface);
}
.rname { font: 600 var(--t-l)/1.2 var(--sans); }
.rdesc { font: 400 var(--t-m)/1.4 var(--sans); color: var(--muted); text-wrap: pretty; }
.rmeta { font: 400 var(--t-s) var(--sans); color: var(--muted); white-space: nowrap; }
.rarrow { color: var(--muted); transition: transform 0.2s var(--out), color 0.15s; }
@media (hover: hover) {
  .row:hover .rarrow { color: var(--fg); transform: translateX(4px); }
  .row:hover .rname { color: var(--accent); }
}
.rname { transition: color 0.15s; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.foot {
  padding: 32px var(--gut); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px;
  font: 400 var(--t-s) var(--sans); color: var(--muted);
}
.foot-links { display: flex; gap: 24px; flex-wrap: wrap; }
.foot-links:empty { display: none; }
.foot-links a { color: var(--fg); transition: color 0.15s; }
@media (hover: hover) { .foot-links a:hover { color: var(--accent); } }

/* ── Detail overlay ──────────────────────────────────────────────────────── */
.detail {
  position: fixed; inset: 0; z-index: 60; background: var(--bg); overflow: auto;
  overscroll-behavior: contain;
  opacity: 0; transform: translateY(24px); pointer-events: none; visibility: hidden;
  transition: opacity 0.24s, transform 0.32s var(--out), visibility 0s linear 0.32s;
}
.detail.open {
  opacity: 1; transform: none; pointer-events: auto; visibility: visible;
  transition: opacity 0.3s, transform 0.4s var(--out), visibility 0s;
}
/* A View Transition is animating the change, so the overlay's own slide stands down. */
.vt .detail, .vt .detail.open { transition: none; }
.detail-inner { box-sizing: content-box; max-width: 1240px; margin: 0 auto; padding: 24px var(--gut) 80px; display: flex; flex-direction: column; gap: 40px; }
.detail-top { display: flex; justify-content: space-between; align-items: center; }
.detail-steps { display: flex; gap: 24px; }
.detail-main { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 48px; align-items: center; }
.detail-media { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.detail-screen { aspect-ratio: 16 / 9; border-radius: var(--r-m); overflow: hidden; background: #000; }
#dVideo, #dImage { width: 100%; height: 100%; object-fit: cover; display: block; }
#dVideo[hidden], #dImage[hidden] { display: none; }
.detail-media[hidden], .gallery[hidden] { display: none; }
.clip-toggles { display: flex; gap: 16px; flex-wrap: wrap; }
.clip-toggles:empty { display: none; }
.clip-btn {
  font: 500 var(--t-s) var(--sans); padding: 4px 0; border: none; border-bottom: 1px solid transparent;
  cursor: pointer; background: none; color: var(--muted);
  transition: color 0.15s, border-color 0.15s, transform 0.1s var(--out);
}
.clip-btn.on { color: var(--fg); border-bottom-color: var(--fg); }
@media (hover: hover) { .clip-btn:hover { color: var(--fg); } }
.detail-text { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.d-name { font: 600 clamp(36px, 4.2vw, 60px)/1.04 var(--sans); letter-spacing: -0.02em; text-wrap: balance; }
.d-desc { font: 400 var(--t-l)/1.4 var(--sans); color: var(--muted); text-wrap: pretty; }
.d-meta { font: 400 var(--t-s) var(--sans); color: var(--muted); }
.d-launch { margin-top: 8px; }
.gallery { display: flex; flex-direction: column; gap: 16px; }
.g-label { font: 600 var(--t-l) var(--sans); }
.g-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 12px; }
.g-item { display: block; padding: 0; border: none; background: none; border-radius: var(--r-s); cursor: zoom-in; overflow: hidden; }
.g-item img {
  width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; display: block;
  transition: opacity 0.15s;
}
@media (hover: hover) { .g-item:hover img { opacity: 0.85; } }

/* ── View Transitions: the clicked project's media travels into the detail page ─────── */
::view-transition-group(*) { animation-duration: 0.4s; animation-timing-function: var(--move); }
::view-transition-old(*), ::view-transition-new(*) { animation-duration: 0.3s; }
::view-transition-image-pair(project-media) { isolation: isolate; }
::view-transition-old(project-media), ::view-transition-new(project-media) {
  height: 100%; width: 100%; object-fit: cover; border-radius: var(--r-m); overflow: hidden;
}
.vt-close::view-transition-group(*) { animation-duration: 0.32s; }
.vt-close::view-transition-old(*), .vt-close::view-transition-new(*) { animation-duration: 0.24s; }
.vt-quick::view-transition-group(*),
.vt-quick::view-transition-old(*), .vt-quick::view-transition-new(*) { animation-duration: 0.18s; }

/* ── Lightbox ────────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; z-index: 70; background: rgba(10, 9, 8, 0.92);
  display: flex; align-items: center; justify-content: center; padding: 4vw; cursor: zoom-out;
  opacity: 0; pointer-events: none; transition: opacity 0.16s;
}
.lightbox.open { opacity: 1; pointer-events: auto; transition: opacity 0.2s; }
.lightbox img {
  max-width: 100%; max-height: 100%; border-radius: var(--r-m); display: block;
  transform: scale(0.95); transition: transform 0.16s var(--out);
}
.lightbox.open img { transform: none; transition: transform 0.2s var(--out); }
.lightbox img:not([src]) { display: none; }

/* ── Easter egg ──────────────────────────────────────────────────────────── */
.egg-pill {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%); z-index: 95;
  font: 600 var(--t-m) var(--sans); background: var(--fg); color: var(--bg); padding: 12px 20px; border-radius: var(--r-s);
  white-space: nowrap;
}
.egg-pill[hidden] { display: none; }
.egg-layer { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.egg-layer span { position: absolute; top: -25vh; font-family: var(--sans); font-weight: 700; animation-name: eggfall; animation-fill-mode: forwards; animation-timing-function: cubic-bezier(.4, .1, .6, 1); }
@keyframes eggfall { to { transform: translateY(150vh) rotate(720deg); } }

/* ── Admin mode (unlocked by the easter egg): "Future updates" buttons + list ─ */
.plans-btn {
  display: none; position: absolute; z-index: 2; top: 16px; right: 16px;
  font: 500 var(--t-s) var(--sans); color: var(--fg);
  background: var(--bg); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: var(--r-s); cursor: pointer; white-space: nowrap;
  transition: background-color 0.15s, color 0.15s, transform 0.1s var(--out);
}
.admin-on .plans-btn { display: inline-block; }
@media (hover: hover) { .plans-btn:hover { background: var(--fg); color: var(--bg); } }
.row .plans-btn { position: static; grid-column: 4; grid-row: 1; justify-self: end; margin-right: 96px; }

.plans {
  position: fixed; inset: 0; z-index: 75; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(10, 9, 8, 0.78); opacity: 0; transition: opacity 0.2s;
}
.plans[hidden] { display: none; }
.plans.open { opacity: 1; }
.plans-card {
  position: relative; width: min(560px, 100%);
  max-height: calc(100vh - 48px); max-height: calc(100svh - 48px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 24px 32px 32px;
  transform: scale(0.95); transition: transform 0.2s var(--out);
}
.plans.open .plans-card { transform: none; }
.plans-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.plans-meta { font: 400 var(--t-s) var(--sans); color: var(--muted); }
.plans-title { font: 600 clamp(32px, 4vw, 40px)/1.05 var(--sans); letter-spacing: -0.02em; margin-bottom: 16px; }
.plans-list { list-style: none; margin: 0; padding: 0; }
.plans-list li { padding: 12px 0; border-top: 1px solid var(--line); font: 400 var(--t-m)/1.4 var(--sans); }
.plans-list li.empty { color: var(--muted); }

.nojs { padding: 24px var(--gut); font: 400 var(--t-m)/1.5 var(--sans); }
.nojs a { text-decoration: underline; }

/* ══ Phones (portrait), portrait tablets and narrow windows ════════════════════ */
@media (max-width: 760px), (max-width: 1100px) and (max-aspect-ratio: 4/5) {
  :root { --gut: max(16px, 4vw); --t-l: 18px; }
  .topbar { padding: 14px var(--gut); }
  .hero-line { font-size: 15vw; }
  .hero-foot { bottom: 24px; }

  .card {
    width: calc(100vw - 2 * var(--gut));
    height: min(calc(100vh - 112px), 720px); height: min(calc(100svh - 112px), 720px);
    padding: 16px; gap: 20px;
    grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
  }
  .card-left { display: contents; }
  .card-right { order: 0; align-items: flex-start; }
  .card-body { order: 1; gap: 12px; align-self: end; padding: 0 4px 4px; }
  .card-name { font-size: clamp(32px, 10vw, 56px); }
  .dots { right: 4px; }

  .everything { padding: 88px var(--gut) 72px; gap: 24px; }
  .ev-title { font-size: clamp(36px, 11vw, 64px); }
  .row { grid-template-columns: 96px minmax(0, 1fr) 16px; gap: 4px 16px; align-items: start; }
  .rthumb { width: 96px; grid-row: 1 / span 3; }
  .rname, .rdesc, .rmeta { grid-column: 2; }
  .rdesc { font-size: var(--t-s); }
  .rarrow { grid-column: 3; grid-row: 1; }
  .row .plans-btn { grid-column: 2; grid-row: auto; justify-self: start; margin: 4px 0 0; }
  .foot { padding: 28px var(--gut) calc(28px + env(safe-area-inset-bottom, 0px)); }

  .detail-inner { padding: 0 var(--gut) 56px; gap: 24px; }
  .detail-top {
    position: sticky; top: 0; z-index: 2; margin: 0 calc(-1 * var(--gut)); padding: 8px var(--gut);
    background: var(--bg);
  }
  .detail-main { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .d-name { font-size: clamp(36px, 10vw, 56px); }
  .g-grid { grid-template-columns: repeat(auto-fill, minmax(min(150px, 40%), 1fr)); gap: 8px; }
  .lightbox { padding: 12px; }
  .egg-pill { bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
  .plans { align-items: flex-end; padding: 12px; }
  .plans-card { padding: 20px 20px 24px; }
}

/* ══ Phones turned sideways (short, wide screens) ══════════════════════════ */
@media (max-height: 520px) and (min-width: 561px) {
  .topbar { padding: 10px 16px; }
  .hero-line { font-size: 17svh; }
  .hero-foot { bottom: 16px; }
  .card {
    height: calc(100vh - 72px); height: calc(100svh - 72px);
    padding: 16px 24px; gap: 24px; top: 54%;
  }
  .card-body { gap: 8px; }
  .card-name { font-size: clamp(26px, 10svh, 44px); }
  .card-desc { font-size: var(--t-s); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .card-foot { margin-top: 0; }
  .btn { padding: 8px 14px; font-size: var(--t-s); }
  .frame { width: auto; height: calc(100% - 12px); max-width: 100%; }
  .everything { padding-top: 72px; }
  .detail-top { position: sticky; top: 0; z-index: 2; background: var(--bg); }
  .detail-inner { padding-top: 0; }
  .plans-card { padding: 16px 24px 20px; }
  .plans-title { margin-bottom: 12px; }
  .plans-list li { padding: 8px 0; }
}

/* ── Reduced motion: scroll-linked movement stays, because it only moves as the visitor scrolls;
      things that animate on their own are calmed down. ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .row { opacity: 1; transform: none; transition: none; }
  .detail, .detail.open { transform: none; transition: opacity 0.2s, visibility 0s; }
  .plans-card, .plans.open .plans-card { transform: none; transition: none; }
  .lightbox img, .lightbox.open img { transform: none; transition: none; }
  .btn:active, .link:active, .clip-btn:active, .plans-btn:active { transform: none; }
}
