/* ═════════════════════════════════════════════════════════════════════════
   PIXEL HEAVEN — PREMIUM POLISH LAYER
   Sits on top of style.css + theme.css. Provides:
     1. Grain overlay (film texture across the site)
     2. Custom cursor (dot + delayed ring)
     3. Magnetic CTA support (.btn-magnetic)
     4. Scroll choreography hooks (.reveal-* classes)
     5. Editorial typography utilities (drop-caps, hand annotations, pull quotes)
     6. Browser-frame component for client screenshots
   ════════════════════════════════════════════════════════════════════════ */


/* ── 1. GRAIN OVERLAY ─────────────────────────────────────────────────────
   Fixed-position SVG noise at 4% opacity. Adds analog warmth, fights the
   AI-aesthetic. Pointer-events:none so it never blocks interaction.
   Disabled on light themes (beauty) because it darkens the cream surfaces.
   ──────────────────────────────────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
  opacity: 0.04;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 1 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/></svg>");
  background-size: 200px 200px;
}
:root[data-theme="beauty"] body::before { opacity: 0.025; mix-blend-mode: multiply; }


/* ── 2. CUSTOM CURSOR ─────────────────────────────────────────────────────
   Two-element cursor: a tiny dot that follows the mouse precisely + a
   larger ring that follows with delayed easing. Standard cursor stays
   visible on text inputs (we don't hijack typing).
   ──────────────────────────────────────────────────────────────────────── */
@media (pointer: fine) {
  body { cursor: none; }
  /* Restore default cursor on inputs / textareas where typing matters */
  input, textarea, select, [contenteditable="true"] { cursor: text; }

  .cursor-dot,
  .cursor-ring {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    will-change: transform;
  }
  .cursor-dot {
    width: 6px;
    height: 6px;
    background: var(--text);
    border-radius: 50%;
    mix-blend-mode: difference;
    transition: width 0.18s, height 0.18s, background 0.2s;
  }
  .cursor-ring {
    width: 32px;
    height: 32px;
    border: 1.5px solid var(--text);
    border-radius: 50%;
    mix-blend-mode: difference;
    opacity: 0.4;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                height 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.25s,
                opacity 0.2s;
  }
  /* On hover over interactive elements, the ring expands and the dot vanishes */
  body.cursor-hover .cursor-dot { opacity: 0; transform: translate(-50%, -50%) scale(0); }
  body.cursor-hover .cursor-ring {
    width: 52px;
    height: 52px;
    opacity: 0.8;
    border-width: 1px;
  }
  /* On click, momentary collapse for tactile feel */
  body.cursor-down .cursor-ring { width: 24px; height: 24px; }
}
/* Touch devices: hide custom cursor, restore native */
@media (pointer: coarse), (hover: none) {
  .cursor-dot, .cursor-ring { display: none !important; }
  body { cursor: auto !important; }
}


/* ── 3. MAGNETIC CTA ──────────────────────────────────────────────────────
   Buttons with .btn-magnetic gently pull toward the cursor when approached.
   Combined with the CSS transition below, the JS just sets --mx and --my
   custom properties on hover-near.
   ──────────────────────────────────────────────────────────────────────── */
.btn-magnetic {
  --mx: 0;
  --my: 0;
  transform: translate(var(--mx), var(--my));
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.2, 1.1),
              box-shadow 0.25s, background-color 0.3s;
  will-change: transform;
}
.btn-magnetic:hover {
  transition-duration: 0.15s;
}


/* ── 4. SCROLL CHOREOGRAPHY — HERO ENTRANCE ──────────────────────────────
   Word-by-word hero reveal on page load. JS adds .reveal-fired to body
   after first paint, which triggers the staggered entrance via CSS only
   (no JS per element).
   ──────────────────────────────────────────────────────────────────────── */

/* Initial hidden state — only applied before reveal fires */
body:not(.reveal-fired) .hero .eyebrow,
body:not(.reveal-fired) .hero .hero-eyebrow-row .hand,
body:not(.reveal-fired) .hero h1 .reveal-word,
body:not(.reveal-fired) .hero p.lead,
body:not(.reveal-fired) .hero-actions,
body:not(.reveal-fired) .hero-card,
body:not(.reveal-fired) .hero-variant {
  opacity: 0;
}

@keyframes reveal-up {
  from { opacity: 0; transform: translateY(14px); filter: blur(6px); }
  to   { opacity: 1; transform: translateY(0);    filter: blur(0); }
}
@keyframes reveal-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

body.reveal-fired .hero .eyebrow                       { animation: reveal-up 700ms cubic-bezier(0.2, 0.9, 0.2, 1) 0ms both; }
body.reveal-fired .hero .hero-eyebrow-row .hand        { animation: reveal-up 700ms cubic-bezier(0.2, 0.9, 0.2, 1) 200ms both; }
body.reveal-fired .hero h1 .reveal-word                {
  display: inline-block;
  animation: reveal-up 750ms cubic-bezier(0.2, 0.9, 0.2, 1) calc(280ms + var(--i, 0) * 80ms) both;
}
body.reveal-fired .hero p.lead                         { animation: reveal-up 700ms cubic-bezier(0.2, 0.9, 0.2, 1) 700ms both; }
body.reveal-fired .hero-actions                        { animation: reveal-up 700ms cubic-bezier(0.2, 0.9, 0.2, 1) 850ms both; }
body.reveal-fired .hero-card,
body.reveal-fired .hero-variant                        { animation: reveal-in 800ms cubic-bezier(0.2, 0.9, 0.2, 1) 950ms both; }


/* ── 5. EDITORIAL TYPOGRAPHY UTILITIES ───────────────────────────────────
   Used sparingly. One per page max for the editorial moment to land.
   ──────────────────────────────────────────────────────────────────────── */

/* Drop-cap on the first paragraph of a section */
.drop-cap::first-letter {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 5.2em;
  line-height: 0.85;
  float: left;
  padding: 0.06em 0.12em 0 0;
  margin-bottom: -0.08em;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
:root[data-theme="beauty"] .drop-cap::first-letter,
:root[data-theme="solicitor"] .drop-cap::first-letter {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 500;
  font-size: 5.6em;
}

/* Big pull quote — for About / case study pages */
.pull-quote {
  display: block;
  max-width: 22ch;
  margin: 64px auto;
  font-family: 'Cormorant Garamond', 'Times New Roman', serif;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(36px, 5.5vw, 72px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
  text-align: center;
  position: relative;
}
.pull-quote::before,
.pull-quote::after {
  content: '"';
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1.4em;
  color: var(--brand-2);
  line-height: 0;
  vertical-align: -0.2em;
  margin: 0 0.05em;
}
.pull-quote-attribution {
  display: block;
  margin-top: 24px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-style: normal;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* Hand-written annotation — one per page, rotated slightly */
.hand-note {
  font-family: 'Caveat', cursive;
  font-weight: 500;
  font-size: 28px;
  color: var(--brand-2);
  display: inline-block;
  transform: rotate(-4deg);
  position: relative;
  white-space: nowrap;
}
.hand-note-arrow {
  display: inline-block;
  vertical-align: middle;
  margin-left: 4px;
  width: 32px;
  height: 24px;
  position: relative;
}
.hand-note-arrow::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 24'><path d='M2 14 Q12 4 20 14 T28 20 M22 14 L28 20 L24 22' fill='none' stroke='%23a855f7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
}


/* ── 6. BROWSER-FRAME COMPONENT (for client screenshots in hero) ─────────
   Realistic browser chrome wrapper around a client-site screenshot.
   3° hover tilt + subtle gradient glow underneath.
   ──────────────────────────────────────────────────────────────────────── */
.browser-frame {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow:
    0 30px 80px -20px rgba(0,0,0,0.5),
    0 0 0 1px rgba(255,255,255,0.04) inset;
  transition: transform 0.5s cubic-bezier(0.2, 0.9, 0.2, 1), box-shadow 0.5s;
  transform-style: preserve-3d;
  will-change: transform;
}
.browser-frame:hover {
  transform: perspective(1400px) rotateX(2deg) rotateY(-3deg) translateY(-4px);
  box-shadow:
    0 50px 120px -20px rgba(0,0,0,0.6),
    0 0 80px -10px var(--brand-soft),
    0 0 0 1px rgba(255,255,255,0.06) inset;
}
.browser-frame::before {
  content: '';
  position: absolute;
  inset: -3px;
  z-index: -1;
  background: linear-gradient(135deg, var(--brand), transparent 50%, var(--brand-2));
  border-radius: 16px;
  opacity: 0.3;
  filter: blur(20px);
  pointer-events: none;
}
.browser-chrome {
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-2) 90%, white 10%), var(--surface-2));
  padding: 11px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}
.browser-chrome .traffic {
  display: flex;
  gap: 6px;
}
.browser-chrome .traffic .dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}
.browser-chrome .traffic .dot:nth-child(1) { background: #ff5f56; }
.browser-chrome .traffic .dot:nth-child(2) { background: #ffbd2e; }
.browser-chrome .traffic .dot:nth-child(3) { background: #27c93f; }
.browser-chrome .url {
  margin-left: 14px;
  padding: 5px 14px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-3);
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--line);
  border-radius: 6px;
  flex: 1;
  max-width: 280px;
}
.browser-body {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--bg);
  overflow: hidden;
}
.browser-body img,
.browser-body iframe {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

/* Accessibility — honour reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  body::before { display: none; }
  .cursor-dot, .cursor-ring { display: none !important; }
  body { cursor: auto !important; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}
