/* =========================================================
   DAVE KO — Motion Design Portfolio
   Dark · minimal · monochrome · editorial sans+serif
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
  --bg:        #0a0a0b;
  --bg-raise:  #121214;
  --bg-tile:   #0e0e10;
  --fg:        #f3f1ea;
  --fg-dim:    #9a9a93;
  --fg-faint:  #5e5e57;
  --line:      rgba(243, 241, 234, 0.14);
  --line-soft: rgba(243, 241, 234, 0.07);

  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --sans:  'Space Grotesk', system-ui, -apple-system, sans-serif;
  --mono:  'IBM Plex Mono', ui-monospace, 'SFMono-Regular', monospace;

  --pad: clamp(20px, 4.5vw, 64px);
  --maxw: 1680px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* tunables (driven by Tweaks) */
  --grid-cols: 2;
  --tile-radius: 2px;
  --reveal: 1;        /* 1 = scroll reveals on, 0 = off */
}

/* ---------- Vibe: GALLERY (worship-style dense wall) ---------- */
html[data-vibe="gallery"] {
  --bg: #060607;
  --bg-tile: #0a0a0c;
  --fg: #ededea;
  --grid-cols: 3;
  --tile-radius: 0px;
}
/* ---------- Vibe: CINEMATIC (big stacked, max black) ---------- */
html[data-vibe="cinematic"] {
  --bg: #050505;
  --bg-tile: #0b0b0c;
  --grid-cols: 1;
  --tile-radius: 0px;
}

/* ---------- 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(--sans);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img, video { display: block; max-width: 100%; }
::selection { background: var(--fg); color: var(--bg); }

/* film-grain veil over everything */
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9000;
  opacity: 0.035;
  mix-blend-mode: screen;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Utility ---------- */
.shell { max-width: var(--maxw); margin: 0 auto; padding-left: var(--pad); padding-right: var(--pad); }
.mono  { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; }
.dim   { color: var(--fg-dim); }
.faint { color: var(--fg-faint); }
.serif { font-family: var(--serif); }
.hr { height: 1px; background: var(--line-soft); border: 0; margin: 0; }

/* ---------- Top nav ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px var(--pad);
  mix-blend-mode: difference;     /* stays legible over any tile */
  color: #fff;
}
.nav__brand { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.nav__mark {
  font-family: var(--serif);
  font-size: 1.18rem; font-weight: 500; letter-spacing: 0.02em;
}
.nav__brand .mono { color: #fff; opacity: 0.7; }
.nav__links { display: flex; gap: clamp(14px, 2vw, 30px); align-items: center; }
.nav__links a {
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase;
  position: relative; padding: 4px 0; color: #fff;
}
.nav__links a::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 1px; width: 100%;
  background: currentColor; transform: scaleX(0); transform-origin: left;
  transition: transform 0.5s var(--ease);
}
.nav__links a:hover::after, .nav__links a.is-active::after { transform: scaleX(1); }
.nav__links a.is-active { opacity: 1; }

/* ---------- Hero ---------- */
.hero { padding-top: clamp(120px, 22vh, 240px); padding-bottom: clamp(40px, 7vh, 90px); }
.hero__eyebrow {
  display: flex; gap: 16px; align-items: center; color: var(--fg-dim);
  margin-bottom: clamp(24px, 5vh, 56px);
}
.hero__eyebrow .line { flex: 1; height: 1px; background: var(--line-soft); }
.hero__title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(64px, 15vw, 248px);
  line-height: 0.86;
  letter-spacing: -0.02em;
  margin: 0;
}
.hero__title em { font-style: italic; }
.hero__role {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 24px; margin-top: clamp(24px, 4vh, 48px);
}
.hero__role h2 {
  margin: 0; font-family: var(--sans); font-weight: 400;
  font-size: clamp(15px, 1.5vw, 21px); letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--fg); white-space: nowrap;
}
.hero__role p {
  margin: 0; max-width: 44ch; color: var(--fg-dim);
  font-size: clamp(15px, 1.4vw, 19px); line-height: 1.45;
  font-family: var(--serif); font-style: italic;
}

/* ---------- Section heading ---------- */
.sec-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 20px; padding: clamp(36px,7vh,84px) 0 clamp(20px,3vh,34px);
  border-top: 1px solid var(--line-soft);
}
.sec-head h3 {
  margin: 0; font-family: var(--serif); font-weight: 400;
  font-size: clamp(22px, 3vw, 38px); letter-spacing: -0.01em;
}
.sec-head .count { color: var(--fg-faint); }

/* ---------- Work grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-cols), 1fr);
  gap: clamp(14px, 1.6vw, 26px) clamp(14px, 1.6vw, 26px);
  padding-bottom: clamp(40px, 8vh, 120px);
}
/* feature the first tile when 3-col */
html[data-vibe="gallery"] .grid > .tile:first-child { grid-column: span 2; }

.tile {
  position: relative;
  display: block;
  background: var(--bg-tile);
  border-radius: var(--tile-radius);
  overflow: hidden;
  isolation: isolate;
  cursor: pointer;
}
.tile__media {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background:
    repeating-linear-gradient(135deg, rgba(255,255,255,0.022) 0 2px, transparent 2px 9px),
    radial-gradient(120% 120% at 50% 30%, #171719 0%, var(--bg-tile) 70%);
}
.tile__media video, .tile__media .tile__poster {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 0.6s var(--ease);
}
.tile__media .tile__poster { opacity: 1; }
.tile.has-media:hover .tile__poster { opacity: 0; }
.tile.has-media:hover video { opacity: 1; }

/* placeholder centerpiece */
.tile__ph {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  color: var(--fg-faint);
  transition: opacity 0.5s var(--ease), transform 0.7s var(--ease);
}
.tile__ph .play {
  width: 54px; height: 54px; border-radius: 50%;
  border: 1px solid var(--line);
  display: grid; place-items: center;
  transition: border-color 0.4s var(--ease), background 0.4s var(--ease), color 0.4s var(--ease);
}
.tile__ph .play svg { width: 16px; height: 16px; transform: translateX(1px); }
.tile:hover .tile__ph .play { border-color: var(--fg); color: var(--fg); }
.tile__ph .label { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.22em; text-transform: uppercase; }

/* moving scanline on hover (reads as 'playing') */
.tile__scan {
  position: absolute; left: 0; right: 0; height: 32%;
  top: -32%;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,0.05), transparent);
  opacity: 0; pointer-events: none;
}
.tile:hover .tile__scan { opacity: 1; animation: scan 2.4s linear infinite; }
@keyframes scan { from { top: -32%; } to { top: 100%; } }

/* progress + timecode bar */
.tile__bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: linear-gradient(0deg, rgba(0,0,0,0.55), transparent);
  font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.12em;
  color: var(--fg-dim);
  opacity: 0; transform: translateY(6px);
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}
.tile:hover .tile__bar { opacity: 1; transform: translateY(0); }
.tile__track { flex: 1; height: 1px; background: rgba(255,255,255,0.18); position: relative; overflow: hidden; }
.tile__track::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: var(--fg);
}
.tile:hover .tile__track::after { animation: fill 6s linear forwards; }
@keyframes fill { from { width: 0%; } to { width: 100%; } }

/* caption */
.tile__cap {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 14px 2px 4px;
}
.tile__cap .ttl {
  font-family: var(--serif); font-size: clamp(17px, 1.5vw, 23px); font-weight: 400;
  letter-spacing: -0.01em;
}
.tile__cap .ttl b { font-weight: 600; }
.tile__cap .desc { color: var(--fg-dim); font-style: italic; font-family: var(--serif); }
.tile__cap .idx { font-family: var(--mono); font-size: 0.66rem; color: var(--fg-faint); letter-spacing: 0.1em; white-space: nowrap; }
.tile:hover .tile__cap .ttl { text-decoration: none; }
.tile__cap .arr { display: inline-block; transition: transform 0.45s var(--ease); }
.tile:hover .tile__cap .arr { transform: translate(4px, -4px); }

/* ---------- Info / About panel (slide-in) ---------- */
.info-toggleable { }
.scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(2px);
  z-index: 1100; opacity: 0; pointer-events: none; transition: opacity 0.5s var(--ease);
}
.scrim.open { opacity: 1; pointer-events: auto; }
.panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(560px, 92vw);
  background: var(--bg-raise);
  border-left: 1px solid var(--line);
  z-index: 1200;
  transform: translateX(100%);
  transition: transform 0.62s var(--ease);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.panel.open { transform: translateX(0); }
.panel__head { display: flex; justify-content: space-between; align-items: center; padding: 22px var(--pad); border-bottom: 1px solid var(--line-soft); position: sticky; top: 0; background: var(--bg-raise); }
.panel__close { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--fg-dim); cursor: pointer; background: none; border: 0; padding: 6px; }
.panel__close:hover { color: var(--fg); }
.panel__body { padding: clamp(28px,5vh,52px) var(--pad) 60px; }
.panel__portrait {
  width: 116px; height: 116px; border-radius: 50%;
  margin: 0 0 26px; display: block;
  background: var(--bg-tile);
}
.panel__body .lede {
  font-family: var(--serif); font-size: clamp(24px, 3.4vw, 38px);
  line-height: 1.16; letter-spacing: -0.01em; margin: 0 0 1.2em;
}
.panel__body .lede em { font-style: italic; }
.blk { padding: 22px 0; border-top: 1px solid var(--line-soft); }
.blk .k { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--fg-faint); margin-bottom: 10px; }
.blk .v { font-size: 0.96rem; color: var(--fg); line-height: 1.6; }
.blk .v a { border-bottom: 1px solid var(--line); padding-bottom: 1px; }
.blk .v a:hover { border-color: var(--fg); }
.clients { display: flex; flex-wrap: wrap; gap: 6px 0; }
.clients span { font-size: 0.92rem; color: var(--fg-dim); }
.clients span::after { content: "·"; padding: 0 10px; color: var(--fg-faint); }
.clients span:last-child::after { content: ""; }

/* ---------- Brand marquee (two looping rows) ---------- */
.marquee {
  display: flex; flex-direction: column;
  gap: clamp(5px, 1.2vh, 17px);
  margin: clamp(12px, 3vh, 36px) 0 clamp(30px, 6vh, 90px);
  /* full-bleed: span the whole viewport, centered */
  width: 100vw;
  margin-left: calc(50% - 50vw);
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.mq-row {
  display: flex; width: max-content;
  will-change: transform;
}

.mq-cell {
  flex: 0 0 auto;
  width: auto;
  height: clamp(110px, 13vw, 170px);
  display: grid; place-items: center;
  padding: 0 clamp(44px, 5.6vw, 92px);
}

.mq-cell .logo {
  --s: 1;
  width: auto; height: auto;
  max-width: calc(clamp(67px, 8.4vw, 111px) * var(--s));
  max-height: calc(clamp(25px, 3.2vw, 41px) * var(--s));
  object-fit: contain;
  opacity: 0.45;
  transition: opacity 0.45s var(--ease);
}
.mq-cell .logo:hover { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .mq-row { transform: none !important; flex-wrap: wrap; width: 100%; justify-content: center; }
  .mq-cell:nth-child(even), .mq-cell:nth-child(odd) { transform: none; }
  .mq-cell .logo { opacity: 0.85; }
}

/* ---------- Entrance & micro-motion ---------- */
.hero__mask {
  overflow: hidden;
  font-size: clamp(64px, 15vw, 248px);
  padding-top: 0.14em;
  margin-top: -0.14em;
}
/* scroll-linked CTA line reveal (right → left, line by line) */
.foot__cta .u { display: block; }
.foot__cta .cta-line {
  display: block;
}
.foot__cta .cta-line__in {
  display: inline-block;
  white-space: nowrap;
  transform: translateX(var(--cta-x, 100px));
  opacity: var(--cta-o, 0);
  will-change: transform, opacity;
}
@media (prefers-reduced-motion: reduce) {
  .foot__cta .cta-line__in { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: no-preference) {
  html.enter .hero__title { animation: dk-rise 1.15s var(--ease) 0.12s both; }
  html.enter .hero__eyebrow { animation: dk-fade 0.9s var(--ease) both; }
  html.enter .hero__eyebrow .line { animation: dk-draw 1.3s var(--ease) 0.25s both; transform-origin: left; }
  html.enter .hero__role { animation: dk-fadeup 0.95s var(--ease) 0.6s both; }
}
@keyframes dk-rise { from { transform: translateY(108%); } }
@keyframes dk-fade { from { opacity: 0; } }
@keyframes dk-draw { from { transform: scaleX(0); } }
@keyframes dk-fadeup { from { opacity: 0; transform: translateY(18px); } }

/* ---------- Mission ---------- */
.mission { border-top: 1px solid var(--line-soft); text-align: center; }
.mission__in {
  padding-top: clamp(96px, 19vh, 200px);
  padding-bottom: clamp(96px, 19vh, 200px);
  display: flex; flex-direction: column; align-items: center;
}
.mission__eyebrow {
  color: var(--fg-faint); letter-spacing: 0.24em; white-space: nowrap;
  margin: 0 0 clamp(30px, 5vh, 56px);
}
.mission__title {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(34px, 5.4vw, 88px);
  line-height: 1.04; letter-spacing: -0.02em;
  margin: 0; max-width: 17ch; text-wrap: balance;
  color: var(--fg);
}
.mission__title em { font-style: italic; color: var(--fg-dim); }
.mission__sub {
  margin: clamp(28px, 4.5vh, 46px) 0 0;
  max-width: 48ch; text-wrap: balance;
  color: var(--fg-dim);
  font-size: clamp(15px, 1.3vw, 20px); line-height: 1.65;
}
.mission__cta {
  margin-top: clamp(40px, 7vh, 76px);
  display: inline-flex; align-items: center; gap: 12px;
  background: var(--fg); color: var(--bg);
  font-family: var(--sans); font-weight: 500;
  font-size: 0.95rem; letter-spacing: 0.01em;
  padding: 16px 30px; border-radius: 999px;
  text-decoration: none;
  transition: transform 0.5s var(--ease), background 0.4s var(--ease);
}
.mission__cta-arrow { transition: transform 0.5s var(--ease); }
.mission__cta:hover { background: #ffffff; }
.mission__cta:hover .mission__cta-arrow { transform: translateX(5px); }

/* ---------- Footer / Contact ---------- */
.foot { border-top: 1px solid var(--line-soft); padding: clamp(60px,12vh,150px) 0 clamp(40px,7vh,96px); }
.foot__cta {
  font-family: var(--serif); font-weight: 400; letter-spacing: -0.02em;
  font-size: clamp(32px, 6vw, 96px); line-height: 0.92; margin: 0 0 0.3em;
}
.foot__cta a { display: inline-block; }
.foot__cta a .u { background-image: linear-gradient(currentColor, currentColor); background-size: 0% 1px; background-repeat: no-repeat; background-position: 0 100%; transition: background-size 0.6s var(--ease); }
.foot__cta a:hover .u { background-size: 100% 1px; }
.foot__grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 28px 24px;
  padding-top: clamp(40px,7vh,80px);
}
.foot__grid .col .k { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--fg-faint); margin-bottom: 12px; }
.foot__grid .col .v { font-size: 0.95rem; color: var(--fg); line-height: 1.7; }
.foot__grid .col .v a:hover { color: var(--fg-dim); }
.foot__legal { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-top: clamp(50px,9vh,90px); color: var(--fg-faint); }
.foot__legal .mono { color: var(--fg-faint); }
@media (max-width: 760px) {
  .foot__grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Scroll reveal (opt-in; never hides content by default) ---------- */
.reveal { opacity: 1; transform: none; }
html[data-reveal="1"] .reveal { transition: opacity 0.85s var(--ease), transform 0.85s var(--ease); }
html[data-reveal="1"] .reveal:not(.in) { opacity: 0; transform: translateY(22px); }
@media (prefers-reduced-motion: reduce) {
  html[data-reveal="1"] .reveal:not(.in) { opacity: 1 !important; transform: none !important; }
  .tile:hover .tile__scan, .tile:hover .tile__track::after { animation: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  :root { --grid-cols: 1 !important; }
  html[data-vibe="gallery"] .grid > .tile:first-child { grid-column: auto; }
  .grid { grid-template-columns: 1fr; }
  .nav__links a:not(.nav__cta) { display: none; }
}
@media (max-width: 560px) {
  .hero__role { flex-direction: column; align-items: flex-start; }
}
