/* ==========================================================================
   VisualVerse Studios — "Afterimage" identity
   Paper ground, ink type, Instrument Serif with the italic turn,
   DM Mono exposure notes, and heat used only as soft light.
   ========================================================================== */

:root {
  /* Neutrals */
  --paper: #EFEBE3;
  --bone: #DDD7CC;
  --silver: #A9A59E;
  --umber: #2A2522;
  --ink: #141110;

  /* Heat ramp — only ever as soft-edged gradients, never flat fills */
  --ghost: #3EE0E8;
  --violet: #7B3CFF;
  --magenta: #FF2E88;
  --infrared: #FF7A1A;
  --core: #FFF4E0;

  /* Theme tokens (light = paper ground, dark = ink ground) */
  --bg: var(--paper);
  --fg: var(--ink);
  --surface: var(--bone);
  --nav-bg: rgba(239, 235, 227, .88);
  --ground-dark: var(--ink);
  --rule: rgba(20, 17, 16, .14);
  --text-soft: rgba(20, 17, 16, .68);
  color-scheme: light;

  --serif: "Instrument Serif", "Times New Roman", serif;
  --sans: "Instrument Sans", system-ui, -apple-system, sans-serif;
  --mono: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Book margins: generous and asymmetric */
  --margin-l: clamp(16px, 6vw, 112px);
  --margin-r: clamp(16px, 4vw, 72px);
  --gap: clamp(14px, 1.6vw, 28px);
}

/* Dark mode: follows the device setting unless the visitor picks one with the toggle */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--ink);
    --fg: var(--paper);
    --surface: var(--umber);
    --nav-bg: rgba(20, 17, 16, .86);
    --ground-dark: var(--umber);
    --rule: rgba(239, 235, 227, .14);
    --text-soft: rgba(239, 235, 227, .62);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: var(--ink);
  --fg: var(--paper);
  --surface: var(--umber);
  --nav-bg: rgba(20, 17, 16, .86);
  --ground-dark: var(--umber);
  --rule: rgba(239, 235, 227, .14);
  --text-soft: rgba(239, 235, 227, .62);
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  transition: background-color .5s ease, color .5s ease;
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

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

button { font: inherit; color: inherit; }

::selection { background: var(--fg); color: var(--bg); }

:focus-visible { outline: 1.5px solid var(--fg); outline-offset: 3px; }

.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 100;
  background: var(--ink); color: var(--paper); padding: 8px 12px;
  font-family: var(--mono); font-size: 12px;
}
.skip-link:focus { left: 8px; }

/* --- Type ---------------------------------------------------------------- */

.mono {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: .12em;
  text-transform: uppercase;
  line-height: 1.5;
}

.serif { font-family: var(--serif); font-weight: 400; }

em, .italic { font-style: italic; }

.display {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -.015em;
  line-height: .95;
  margin: 0;
}

/* --- Layout -------------------------------------------------------------- */

.page { padding-left: var(--margin-l); padding-right: var(--margin-r); }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  color: var(--text-soft);
}

/* --- Wordmark + trace mark ---------------------------------------------- */

.wordmark {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1;
  letter-spacing: -.01em;
  white-space: nowrap;
  display: inline-block;
}
.wordmark em { font-style: italic; }

/* In motion it leaves a trace: a warm blurred afterimage that fades in ~1s.
   The type itself is never distorted. */
@keyframes afterimage {
  0%   { text-shadow: 10px 0 10px rgba(255, 46, 136, .55), 22px 0 22px rgba(123, 60, 255, .45); }
  100% { text-shadow: 0 0 0 rgba(255, 46, 136, 0), 0 0 0 rgba(123, 60, 255, 0); }
}
.wordmark { animation: afterimage 1.2s ease-out both; }
.wordmark.is-replaying { animation: none; }

.trace {
  display: inline-block;
  width: 1.6em;
  height: 1em;
  flex: none;
  vertical-align: -.12em;
}

/* --- Navigation ---------------------------------------------------------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-top: 18px;
  padding-bottom: 16px;
  background: var(--nav-bg);
  transition: background-color .5s ease, border-color .5s ease;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Light / dark toggle: the Trace mark. The form and its trace swap places
   when the theme flips — solid on the left in light, on the right in dark. */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 32px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg);
  cursor: pointer;
}
.theme-toggle svg { width: 30px; height: 19px; overflow: visible; }
.theme-toggle circle { transition: transform .6s cubic-bezier(.65, 0, .35, 1); }
.theme-toggle:hover .t-ring { transform: translateX(2px); }
:root[data-theme="dark"] .theme-toggle .t-solid { transform: translateX(11px); }
:root[data-theme="dark"] .theme-toggle .t-ring { transform: translateX(-11px); }
:root[data-theme="dark"] .theme-toggle:hover .t-ring { transform: translateX(-13px); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .t-solid { transform: translateX(11px); }
  :root:not([data-theme="light"]) .theme-toggle .t-ring { transform: translateX(-11px); }
}

.nav-links {
  display: flex;
  gap: clamp(16px, 2.4vw, 36px);
  font-size: 15px;
}

.nav-links a { position: relative; padding: 4px 0; }
.nav-links a::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 1px; background: currentColor;
  transform: scaleX(0); transform-origin: left;
  transition: transform .4s cubic-bezier(.2, .7, .2, 1);
}
.nav-links a:hover::after,
.nav-links a[aria-current="page"]::after { transform: scaleX(1); }

/* --- Hero ---------------------------------------------------------------- */

.hero {
  padding-top: clamp(48px, 9vw, 140px);
  padding-bottom: clamp(32px, 5vw, 72px);
}

.hero-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--text-soft);
  margin-bottom: clamp(20px, 3vw, 40px);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 8fr) minmax(0, 3fr);
  gap: var(--gap) calc(var(--gap) * 2);
  align-items: end;
}

.hero h1 {
  font-size: clamp(56px, 10.4vw, 188px);
}
.hero h1[data-heat] { font-size: clamp(50px, 10vw, 190px); }
.hero h1 em { display: block; padding-left: .55em; }

.hero-aside p {
  margin: 0 0 18px;
  font-size: 18px;
  color: var(--text-soft);
  max-width: 30ch;
}

/* --- Showreel ------------------------------------------------------------ */

.reel { padding-bottom: clamp(56px, 8vw, 128px); }

.reel-frame {
  position: relative;
  background: var(--ink);
  aspect-ratio: 16 / 9;
  max-height: 86vh;
  width: 100%;
  overflow: hidden;
}
.reel-frame video { width: 100%; height: 100%; object-fit: cover; }

.reel-caption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-top: 12px;
  color: var(--text-soft);
}

.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 0;
  padding: 4px 0;
  cursor: pointer;
  color: var(--fg);
}
.sound-toggle .trace circle:first-child { transition: fill .3s; }
.sound-toggle[aria-pressed="false"] .trace circle:first-child { fill: transparent; }

/* --- Work ---------------------------------------------------------------- */

.work { padding-bottom: clamp(56px, 8vw, 128px); }

.work-intro {
  display: grid;
  grid-template-columns: minmax(0, 8fr) minmax(0, 3fr);
  gap: var(--gap) calc(var(--gap) * 2);
  align-items: end;
  margin: clamp(28px, 4vw, 56px) 0 clamp(24px, 3vw, 40px);
}

.work-intro h2 { font-size: clamp(44px, 6.6vw, 112px); }
.work-intro p { margin: 0; color: var(--text-soft); max-width: 32ch; }

/* Filter tabs: mono labels, the trace mark as the active bullet */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 26px;
  padding: 16px 0;
  margin-bottom: clamp(20px, 2.6vw, 36px);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 0;
  padding: 6px 0;
  cursor: pointer;
  color: var(--text-soft);
  transition: color .25s;
}
.filter:hover { color: var(--fg); }
.filter .trace { width: 0; opacity: 0; transition: width .35s cubic-bezier(.2, .7, .2, 1), opacity .25s; }
.filter.is-active { color: var(--fg); }
.filter.is-active .trace { width: 1.6em; opacity: 1; }
.filter .count { opacity: .55; }
.filter[hidden] { display: none; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(36px, 4vw, 64px) var(--gap);
  grid-auto-flow: row dense;
}

.card { grid-column: span 1; transition: opacity .35s ease; }
.card.is-wide { grid-column: span 2; }
.card.is-hidden { display: none; }
.card.is-fading { opacity: 0; }

.card-link {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.card-media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--surface);
  overflow: visible;
  isolation: isolate;
}
.card.is-reel .card-media { aspect-ratio: 4 / 5; }

.card-media video,
.card-media img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .9s cubic-bezier(.2, .7, .2, 1);
}

/* The trace on hover: a soft heat afterimage drifts out behind the frame */
.card-media::before {
  content: "";
  position: absolute;
  inset: 6% -2% 6% 8%;
  z-index: -1;
  background: linear-gradient(90deg, var(--infrared), var(--magenta) 45%, var(--violet));
  filter: blur(28px);
  opacity: 0;
  transform: translateX(0);
  transition: opacity .5s ease, transform .7s cubic-bezier(.2, .7, .2, 1);
}
.card-link:hover .card-media::before,
.card-link:focus-visible .card-media::before { opacity: .55; transform: translateX(14px); }

.card-frame { position: absolute; inset: 0; overflow: hidden; background: var(--surface); }
.card-link:hover .card-frame video { transform: scale(1.025); }

.card-play {
  position: absolute;
  left: 14px; bottom: 12px;
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--core);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .35s, transform .35s;
  text-shadow: 0 1px 8px rgba(20, 17, 16, .5);
}
.card-link:hover .card-play,
.card-link:focus-visible .card-play { opacity: 1; transform: none; }

.card-caption {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding-top: 14px;
}

.card-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(24px, 2.1vw, 34px);
  line-height: 1.05;
}
.card.is-wide .card-title { font-size: clamp(28px, 3vw, 46px); }

.card-note { color: var(--text-soft); text-align: right; white-space: nowrap; }
.card-note span { display: block; }

.work-more {
  display: flex;
  justify-content: flex-end;
  margin-top: clamp(36px, 4vw, 64px);
}

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--serif);
  font-size: clamp(26px, 2.6vw, 40px);
  border-bottom: 1px solid var(--fg);
  padding-bottom: 4px;
}
.link-arrow em { transition: letter-spacing .4s; }
.link-arrow:hover em { letter-spacing: .02em; }

/* --- Call to action (ink ground, heat glow) ----------------------------- */

.cta {
  position: relative;
  overflow: hidden;
  background: var(--ground-dark);
  color: var(--paper);
  transition: background-color .5s ease;
  padding-top: clamp(72px, 11vw, 180px);
  padding-bottom: clamp(48px, 6vw, 96px);
}

.cta-glow {
  position: absolute;
  right: 8%;
  top: 50%;
  width: clamp(220px, 30vw, 520px);
  aspect-ratio: 1.6;
  transform: translateY(-50%);
  pointer-events: none;
}
.cta-glow::before,
.cta-glow::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 62.5%;
  border-radius: 50%;
}
.cta-glow::before {
  left: 0;
  z-index: 1;
  background: radial-gradient(circle at 42% 40%, var(--core) 0%, var(--infrared) 32%, var(--magenta) 72%, rgba(255, 46, 136, 0) 100%);
  filter: blur(2px);
}
.cta-glow::after {
  right: 0;
  background: radial-gradient(circle, var(--magenta) 0%, var(--violet) 55%, rgba(123, 60, 255, 0) 75%);
  filter: blur(22px);
  opacity: .9;
  animation: drift 6s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translateX(-10%); opacity: .6; } }

.cta-inner { position: relative; z-index: 2; }

.cta .mono { color: rgba(239, 235, 227, .6); }

.cta h2 {
  font-size: clamp(56px, 9vw, 160px);
  margin: clamp(16px, 2vw, 28px) 0 clamp(28px, 4vw, 56px);
}
.cta h2 em { display: block; padding-left: .55em; }

.cta .link-arrow { border-color: var(--paper); }

/* --- Footer -------------------------------------------------------------- */

.footer {
  background: var(--ground-dark);
  transition: background-color .5s ease;
  color: rgba(239, 235, 227, .6);
  padding-top: 20px;
  padding-bottom: 28px;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
  border-top: 1px solid rgba(239, 235, 227, .14);
  padding-top: 20px;
}
.footer a:hover { color: var(--paper); }
.footer .wordmark { color: var(--paper); font-size: 24px; animation: none; }

/* --- Lightbox ------------------------------------------------------------ */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 5vw, 72px);
  background: rgba(20, 17, 16, .94);
}
.lightbox.is-open { display: flex; animation: fade .35s ease both; }
@keyframes fade { from { opacity: 0; } }

.lightbox-inner { width: min(1280px, 100%); }

.lightbox-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: 78vh;
  margin: 0 auto;
  background: #000;
}
.lightbox-frame.is-reel { aspect-ratio: 9 / 16; height: 78vh; max-width: 100%; }
.lightbox-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.lightbox-caption {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 14px;
  color: rgba(239, 235, 227, .7);
}
.lightbox-caption .serif { font-size: 26px; color: var(--paper); letter-spacing: 0; text-transform: none; }

.lightbox-close {
  position: absolute;
  top: 18px; right: var(--margin-r);
  background: none;
  border: 0;
  color: var(--paper);
  cursor: pointer;
  padding: 8px 0;
}

/* --- Contact page -------------------------------------------------------- */

.contact-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}
.contact-list li {
  display: grid;
  grid-template-columns: minmax(110px, 3fr) minmax(0, 8fr);
  gap: 16px;
  align-items: baseline;
  padding: 22px 0;
  border-bottom: 1px solid var(--rule);
}
.contact-list .mono { color: var(--text-soft); }
.contact-list .value {
  font-family: var(--serif);
  font-size: clamp(26px, 3.4vw, 52px);
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.contact-list a.value { transition: font-style .2s; }
.contact-list a.value:hover { font-style: italic; }

/* --- Trace cursor ---------------------------------------------------------
   A solid form and its trace: the core follows the pointer exactly, the
   outline ring lags behind like a memory of where it was. Over the hero
   headline it turns into the heat state. Mouse/trackpad only. */

.has-trace-cursor,
.has-trace-cursor a,
.has-trace-cursor button { cursor: none; }

.cursor { display: none; }

.has-trace-cursor .cursor {
  display: block;
  position: fixed;
  left: 0; top: 0;
  z-index: 300;
  pointer-events: none;
}

.cursor-core,
.cursor-trace {
  position: fixed;
  left: 0; top: 0;
  border-radius: 50%;
  will-change: transform;
}

.cursor-core {
  width: 12px; height: 12px;
  margin: -6px 0 0 -6px;
  background: var(--fg);
  transition: width .45s cubic-bezier(.2, .7, .2, 1), height .45s cubic-bezier(.2, .7, .2, 1),
              margin .45s cubic-bezier(.2, .7, .2, 1), background .45s, opacity .3s, filter .45s;
}

.cursor-trace {
  width: 12px; height: 12px;
  margin: -6px 0 0 -6px;
  border: 1.3px solid var(--fg);
  transition: width .45s cubic-bezier(.2, .7, .2, 1), height .45s cubic-bezier(.2, .7, .2, 1),
              margin .45s cubic-bezier(.2, .7, .2, 1), border-color .45s, background .45s, opacity .3s, filter .45s;
}

/* Over links, buttons and films: the ring opens up */
.cursor.is-link .cursor-trace { width: 44px; height: 44px; margin: -22px 0 0 -22px; }
.cursor.is-link .cursor-core { width: 8px; height: 8px; margin: -4px 0 0 -4px; }

/* On dark grounds (showreel, call to action, footer, lightbox) */
.cursor.is-dark .cursor-core { background: var(--paper); }
.cursor.is-dark .cursor-trace { border-color: var(--paper); }

/* Heat state over the headline: glowing core, magenta/violet trace.
   The cursor drops behind the headline so the letters sit on the light. */
.has-trace-cursor .cursor.is-heat { z-index: 1; }

.cursor.is-heat .cursor-core {
  width: 150px; height: 150px;
  margin: -75px 0 0 -75px;
  background: radial-gradient(circle at 42% 40%, #FFB27A 0%, var(--infrared) 24%, var(--magenta) 64%, rgba(255, 46, 136, 0) 72%);
  filter: blur(1px);
}
.cursor.is-heat .cursor-trace {
  width: 150px; height: 150px;
  margin: -75px 0 0 -75px;
  border-color: transparent;
  background: radial-gradient(circle, var(--magenta) 0%, var(--violet) 52%, rgba(123, 60, 255, 0) 70%);
  filter: blur(18px);
  opacity: .8;
}

/* Inside the glowing circle the headline inverts to white:
   a white copy of the headline, masked to the circle under the cursor */
@property --inv-r {
  syntax: "<length>";
  inherits: true;
  initial-value: 0px;
}

.hero h1[data-heat] { position: relative; z-index: 2; }

.heat-invert {
  position: absolute;
  inset: 0;
  color: #fff;
  pointer-events: none;
  user-select: none;
  --mx: -999px;
  --my: -999px;
  --inv-r: 0px;
  -webkit-mask-image: radial-gradient(circle var(--inv-r) at var(--mx) var(--my), #000 calc(100% - 1.5px), transparent 100%);
  mask-image: radial-gradient(circle var(--inv-r) at var(--mx) var(--my), #000 calc(100% - 1.5px), transparent 100%);
  transition: --inv-r .45s cubic-bezier(.2, .7, .2, 1);
}
.hero h1.is-heat .heat-invert { --inv-r: 54px; }
.heat-invert .heat-char { text-shadow: none; transition: none; }

.cursor.is-hidden .cursor-core,
.cursor.is-hidden .cursor-trace { opacity: 0; }

/* Headline letters keep a warm afterimage where the light has passed.
   The letterforms are never moved or distorted — only the trace is. */
.heat-char {
  display: inline-block;
  --hx: 0px;
  --hy: 0px;
  --h: 0;
  text-shadow:
    calc(var(--hx) * .5) calc(var(--hy) * .5) 6px rgba(255, 122, 26, calc(var(--h) * .75)),
    var(--hx) var(--hy) 14px rgba(255, 46, 136, calc(var(--h) * .6)),
    calc(var(--hx) * 1.8) calc(var(--hy) * 1.8) 24px rgba(123, 60, 255, calc(var(--h) * .45));
  transition: text-shadow 1.1s ease-out;
}
.heat-char.is-hot { transition-duration: .12s; }

/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 860px) {
  .hero-grid,
  .work-intro { grid-template-columns: 1fr; }
  .hero h1 em,
  .cta h2 em { padding-left: .3em; }
  .cta-glow { right: -12%; top: 22%; opacity: .7; }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  .grid { grid-template-columns: 1fr; }
  .card.is-wide { grid-column: span 1; }
  .card-caption { flex-direction: column; gap: 6px; }
  .card-note { text-align: left; white-space: normal; }
  .card-note span { display: inline; }
  .card-note span + span::before { content: " · "; }
  .card-play { opacity: 1; transform: none; }
  .wordmark { font-size: 26px; }
  .nav-links { font-size: 14px; gap: 14px; }
  .nav-brand { gap: 4px; }
  .theme-toggle { width: 32px; }
  .theme-toggle svg { width: 24px; height: 15px; }
  .hero-meta .hide-sm,
  .reel-caption .hide-sm { display: none; }
  .contact-list li { grid-template-columns: 1fr; gap: 4px; }
}

@media (max-width: 420px) {
  .nav .wordmark { font-size: 23px; }
  .nav-links { font-size: 13px; gap: 11px; }
  .nav { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
