/* ─────────────────────────────────────────────
   styles.css  –  Deveney portfolio (tighter wave, video masking)
   ───────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Modak&display=swap');

/* ── Tokens ── */
:root {
  --bg:           #000;
  --fg:           #fff;
  --muted:        rgba(255, 255, 255, 0.75);
  --accent:       #ffdd57;
  --accent-color: #ff3f7b;  /* overridden by JS based on chosen video */
  --glass:        rgba(255, 255, 255, 0.06);
  --nav-height:   72px;
  --max-width:    1200px;
  --ease:         cubic-bezier(0.2, 0.9, 0.2, 1);
  --duration:     300ms;
  --img-duration: 360ms;
}

[data-theme="light"] {
  --bg:    #fff;
  --fg:    #0b0b0b;
  --muted: rgba(11, 11, 11, 0.7);
  --glass: rgba(0, 0, 0, 0.04);
}

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

html, body { height: 100%; }

body {
  font-family: Inter, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--duration) var(--ease),
              color      var(--duration) var(--ease);
  /* Hide default cursor everywhere */
  cursor: none;
}

/* Hide cursor on all interactive elements too */
a, button, input, label, select, textarea, [tabindex] {
  cursor: none !important;
}

/* ── Custom cursor ── */
#cursor-dot,
#cursor-ring {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  will-change: left, top;
}

#cursor-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-color);
  mix-blend-mode: difference;
  opacity: 0;
  transition: opacity 200ms ease;
}

#cursor-ring {
  width: 36px;
  height: 36px;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  background: transparent;
  mix-blend-mode: difference;
  opacity: 0;
  transition: width 200ms var(--ease),
              height 200ms var(--ease),
              border-color 200ms ease,
              opacity 200ms ease;
}

/* Ring grows on hover over interactive elements */
body:has(a:hover) #cursor-ring,
body:has(button:hover) #cursor-ring,
body:has(.case:hover) #cursor-ring,
body:has(.liq-char:hover) #cursor-ring {
  width: 60px;
  height: 60px;
  border-color: var(--accent-color);
}

/* Trail dots */
.cursor-trail {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9998;
  background: var(--accent-color);
  will-change: left, top, opacity;
}

/* ── Nav ── */
.nav {
  position: fixed;
  inset: 0 0 auto;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 36px;
  gap: 16px;
  z-index: 40;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.12), transparent);
  transition: background var(--duration) var(--ease);
}

[data-theme="light"] .nav {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.6), transparent);
}

.logo {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 2px;
}

.nav a {
  color: var(--fg);
  text-decoration: none;
  font-size: 0.95rem;
  letter-spacing: 1px;
  margin-left: 22px;
  transition: opacity 160ms var(--ease);
}
.nav a:hover { opacity: 0.6; }

/* ── Theme toggle ── */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-left: 18px;
  border: 0;
  border-radius: 8px;
  background: var(--glass);
  color: var(--fg);
  transition: background var(--duration) var(--ease),
              transform  160ms var(--ease);
}
.theme-toggle:active { transform: scale(0.98); }

/* ── Hero ── */
.hero {
  position: relative;
  height: 100vh;
  min-height: 640px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/*
 * Wave masking — clean approach.
 *
 * The .hero-bg container is clipped by an inline SVG clipPath
 * injected by JS (see script.js). This avoids the black triangle
 * artefacts caused by CSS mask tiling gaps.
 *
 * The clip shape is: full rectangle down to ~92% height, then a
 * smooth sinusoidal wave that matches the pink .hero::after divider.
 *
 * No CSS mask properties here — all masking is done via clip-path
 * set on .hero-bg by the JS after the viewport size is known.
 */
.hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  /* clip-path is set dynamically by JS to match viewport */
}

.bg-still,
.bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bg-video {
  transform: scale(1.05);
  transition: transform 1s var(--ease);
  will-change: transform;
}

.hero-inner {
  position: relative;
  z-index: 5;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  text-align: center;
}

.headline {
  display: block;
  width: 100%;
  font-family: 'Modak', cursive;
  font-size: clamp(64px, 18vw, 240px);
  text-shadow: 0 2px 5px rgba(255, 195, 241, 0.4);
  will-change: transform, opacity;
  transform-origin: center;
  transition: opacity 60ms linear;
  color: #ffffff;
}

/* Each character span injected by the liquid warp script */
.liq-char {
  display: inline-block;
  transition: transform 220ms cubic-bezier(0.15, 1.4, 0.4, 1), color 220ms linear;
  color: inherit;
  will-change: transform, color;
  pointer-events: auto;
}

.tagline {
  margin-top: -30px;
  font-size: 1.05rem;
  color: var(--muted);
  will-change: transform, opacity;
}

.scroll-indicator {
  position: absolute;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  letter-spacing: 2px;
}

/* ── Work ── */
.work {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 80px 20px;
}

.section-title {
  margin-bottom: 28px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 2px;
}

.case-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 28px;
}

/* ── Case card ── */
.case {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 18px;
  min-height: 140px;
  padding: 18px;
  border-radius: 12px;
  background: var(--glass);
  overflow: hidden;
  transition: transform 260ms var(--ease),
              box-shadow 260ms var(--ease);
}

.case-media {
  position: relative;
  flex: 0 0 220px;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  z-index: 1;
}

.case-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  transform-origin: center;
  pointer-events: none;
  transition: transform var(--img-duration) var(--ease),
              opacity   120ms linear;
}

.case-media img + img {
  transform: translateY(8px) scale(0.98);
  opacity: 0.95;
  filter: saturate(0.98);
}

.case-content {
  flex: 1;
  position: relative;
  z-index: 6;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.case-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--fg);
  white-space: nowrap;
  position: relative;
  z-index: 9;
}

.case-desc {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
  transition: opacity 120ms linear, transform 120ms linear;
}

/* Card hover */
.case:hover,
.case:focus-within {
  transform: translateY(-6px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.case:hover .case-media,
.case:focus-within .case-media {
  position: absolute;
  inset: 0;
  min-width: 100%;
  max-width: 100%;
  height: 100%;
  border-radius: 0;
  z-index: 2;
}

.case:hover .case-media img,
.case:focus-within .case-media img {
  transform: scale(1.12);
  opacity: 1;
  border-radius: 0;
}

.case:hover .case-media img + img,
.case:focus-within .case-media img + img {
  transform: scale(1.12) translateY(0);
}

.case:hover .case-title,
.case:focus-within .case-title {
  position: absolute;
  top: 21px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  font-size: 1.495rem;
  letter-spacing: 1px;
  color: #fff;
  text-align: center;
  white-space: nowrap;
  -webkit-text-stroke: 0.8px #000;
  text-shadow: 0.8px 0.8px 0 #000, -0.8px -0.8px 0 #000;
}

.case:hover .case-desc,
.case:focus-within .case-desc {
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
}

/* Overlay scrim */
.case::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  background: transparent;
  pointer-events: none;
  transition: background 200ms var(--ease);
}

.case:hover::before,
.case:focus-within::before {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.28));
}

/* ── Mobile ── */
@media (max-width: 768px) {
  .bg-video { display: none; }

  /* Restore default cursor on mobile */
  body { cursor: auto; }
  a, button, input, label, select, textarea, [tabindex] { cursor: auto !important; }
  #cursor-dot, #cursor-ring, .cursor-trail { display: none; }

  /* Undo inline-block so characters reflow naturally without JS */
  .liq-char {
    display: inline !important;
    transform: none !important;
    transition: none !important;
    color: inherit !important;
  }
}

/* ── Tablet / small desktop card layout ── */
@media (max-width: 900px) {
  .case {
    flex-direction: column;
    gap: 12px;
    min-height: 220px;
  }

  .case-media {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    height: 180px;
  }

  .case-media img + img { transform: translateY(6px) scale(0.99); }

  .case:hover .case-media,
  .case:focus-within .case-media {
    inset: 0;
    height: 100%;
    border-radius: 0;
    z-index: 2;
  }

  .case:hover .case-title,
  .case:focus-within .case-title {
    top: 14px;
    font-size: 1.05rem;
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .case,
  .case-media img,
  .liq-char { transition: none !important; }
}

/* ── Headline per-character color control ── */
.headline { --char-color: #ffffff; color: var(--char-color); transition: color 220ms linear; }
.liq-char { color: inherit; }

/* ── Wavy pink divider under hero ── */
/*
 * The wave stroke colour is driven by --accent-color via a separate
 * ::after pseudo-element that reads the variable at paint time.
 * Because data URIs can't reference CSS vars directly, the wave SVG
 * is regenerated by JS (buildWavePath already rebuilds on resize —
 * accent colour is applied there too via the ::after override below).
 * For browsers that support @property or Houdini we use a direct
 * approach: the JS injects a tiny <style> block that overrides the
 * background-image with the current colour encoded into the SVG URI.
 */
.hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 24px;
  pointer-events: none;
  z-index: 4;
  background-repeat: repeat-x;
  background-position: center bottom;
  background-size: 40px 24px;
  /* default wave — JS overrides via #wave-color-style */
  background-image: url("data:image/svg+xml;utf8,\
    <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 24' preserveAspectRatio='none'>\
      <path d='M0 12 Q10 0 20 12 T40 12' fill='none' stroke='%23ff3f7b' stroke-width='3' stroke-linecap='round'/>\
    </svg>");
}

/* ── Accent utility class ── */
/*
 * Add class="accent" (or "accent" alongside other classes) to any
 * element — text, SVG path, hr, border, etc. — to have it pick up
 * the same colour as the current video's theme.
 *
 * color        → text and SVG fill
 * border-color → borders and outlines
 * stroke        → inline SVG strokes (set via currentColor cascade)
 * background-color is intentionally NOT set so it doesn't clobber
 * backgrounds; use accent-bg for that if needed.
 */
.accent {
  color: var(--accent-color) !important;
  border-color: var(--accent-color) !important;
  stroke: var(--accent-color) !important;
  text-decoration-color: var(--accent-color) !important;
}

/* Separate modifier for backgrounds */
.accent-bg {
  background-color: var(--accent-color) !important;
}

.hero-bg { z-index: 0; }
.hero-inner { z-index: 5; }

/* Reduced motion overrides */
@media (prefers-reduced-motion: reduce) {
  .headline,
  .liq-char { transition: none !important; }
  .hero::after { background-image: none; border-bottom: 4px solid var(--accent-color); height: 4px; }
  #cursor-dot, #cursor-ring, .cursor-trail { display: none; }
  body { cursor: auto; }
  a, button, input, label, select, textarea, [tabindex] { cursor: auto !important; }
}