/* =========================================================
   persona.css  —  additive visual-personality layer
   Pure CSS, no JS, CSP-safe. Dark + gold preserved.
   Progressive enhancement: gated with @supports and
   prefers-reduced-motion so nothing ever gets stuck hidden.
   ========================================================= */

/* ---------- HERO: living gold glow ---------- */
body { overflow-x: clip; }

.hero {
  position: relative; isolation: isolate;
  padding-block: clamp(1.4rem, 3.4vw, 2.4rem) clamp(0.3rem, 1vw, 0.7rem);
}
.hero::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -40% -15% auto -15%;
  height: 580px;
  background:
    radial-gradient(56% 56% at var(--gx, 26%) var(--gy, 30%), color-mix(in srgb, var(--accent) 40%, transparent), transparent 66%),
    radial-gradient(46% 46% at 80% 16%, color-mix(in srgb, var(--accent-deep) 34%, transparent), transparent 68%),
    radial-gradient(40% 40% at 62% 82%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%);
  filter: blur(52px);
  opacity: .92;
  pointer-events: none;
  animation: persona-hero-drift 13s ease-in-out infinite alternate;
}
@keyframes persona-hero-drift {
  from { transform: translate3d(-4%, -2%, 0) scale(1);    opacity: .62; }
  to   { transform: translate3d(5%, 4%, 0)  scale(1.12);  opacity: .98; }
}
/* page-wide ambient backdrop: grid + faint gold blooms, fixed behind everything */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(46% 32% at 50% -2%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 60%),
    radial-gradient(34% 30% at 88% 52%, color-mix(in srgb, var(--accent-deep) 9%, transparent), transparent 64%),
    radial-gradient(32% 30% at 8% 82%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 64%),
    linear-gradient(color-mix(in srgb, var(--accent) 7%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--accent) 7%, transparent) 1px, transparent 1px);
  background-size: auto, auto, auto, 50px 50px, 50px 50px;
}

/* ---- Gold glow on the bottom contact section (mirrors the hero) ---- */
#contact { position: relative; isolation: isolate; }
#contact::before {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  inset: -6% -12% 0 -12%;
  background:
    radial-gradient(48% 60% at var(--gx, 50%) var(--gy, 72%), color-mix(in srgb, var(--accent) 30%, transparent), transparent 66%),
    radial-gradient(40% 50% at 78% 26%, color-mix(in srgb, var(--accent-deep) 22%, transparent), transparent 70%);
  filter: blur(50px);
  opacity: .85;
  animation: persona-hero-drift 14s ease-in-out infinite alternate;
}

/* ---------- HERO: entrance on load ---------- */
.hero .eyebrow { opacity: 0; animation: persona-rise .7s var(--ease) .05s both; }
.hero__title   { opacity: 0; text-wrap: balance; animation: persona-rise .8s var(--ease) .18s both; }
.hero__sub     { opacity: 0; animation: persona-rise .8s var(--ease) .34s both; }
@keyframes persona-rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- HERO: accent word draws a gold underline ---------- */
.hero__title em {
  font-style: italic;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-position: 0 96%;
  background-size: 0% 2px;
  animation: persona-underline 1s var(--ease) 1.05s forwards;
}
@keyframes persona-underline { to { background-size: 100% 2px; } }

/* ---------- Scroll progress bar (top) ---------- */
@supports (animation-timeline: scroll()) {
  .scroll-progress {
    position: fixed; inset: 0 0 auto 0;
    height: 2px; width: 100%;
    transform-origin: 0 50%; transform: scaleX(0);
    background: linear-gradient(90deg, var(--accent-deep), var(--accent));
    z-index: 100; pointer-events: none;
    animation: persona-progress linear both;
    animation-timeline: scroll(root);
  }
  @keyframes persona-progress { to { transform: scaleX(1); } }
}

/* ---------- Scroll reveals for cards + section heads ----------
   Uses the independent `translate` property so it never fights
   the hover `transform` lift below. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .work__head {
      animation: persona-reveal both linear;
      animation-timeline: view();
      animation-range: entry 2% cover 22%;
    }
    @keyframes persona-reveal {
      from { opacity: 0; translate: 0 28px; }
      to   { opacity: 1; translate: 0 0; }
    }
  }
}

/* ---------- Card hover articulation ---------- */
.project-bubble {
  --rx: 0deg; --ry: 0deg; --lift: 0px; --mx: 50%; --my: 50%;
  transform: translateY(var(--lift));
  transition: transform .2s var(--ease),
              box-shadow .42s var(--ease),
              border-color .42s var(--ease);
}
.project-bubble:hover {
  --lift: -6px;
  box-shadow: 0 30px 72px -28px color-mix(in srgb, var(--accent) 55%, transparent);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--rule));
}
.project-bubble .panel__eyebrow { transition: color var(--t-med) var(--ease); }
.project-bubble:hover .panel__eyebrow { color: var(--accent); }

/* cursor spotlight that follows the pointer (driven by persona.js) */
.project-bubble::after {
  content: ""; position: absolute; inset: 0; z-index: 0;
  border-radius: 14px; pointer-events: none; opacity: 0;
  transition: opacity .3s var(--ease);
  background: radial-gradient(260px circle at var(--mx) var(--my),
    color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%);
}
.project-bubble:hover::after { opacity: 1; }

/* ---------- Primary button: gold sheen on hover ---------- */
.btn--primary {
  position: relative; overflow: hidden;
  transform: translate(var(--bx, 0px), var(--by, 0px));
  transition: transform .18s var(--ease);
}
.btn--primary::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  transform: translateX(-120%);
  background: linear-gradient(110deg,
    transparent 30%,
    color-mix(in srgb, #ffffff 32%, transparent) 50%,
    transparent 70%);
}
.btn--primary:hover::after { animation: persona-sheen .85s var(--ease); }
@keyframes persona-sheen { to { transform: translateX(120%); } }

/* ---------- Respect reduced motion everywhere ---------- */
@media (prefers-reduced-motion: reduce) {
  .hero::before { animation: none; }
  .hero .eyebrow,
  .hero__title,
  .hero__sub { animation: none; opacity: 1; }
  .hero__title em { animation: none; background-size: 100% 2px; }
  .project-bubble:hover { transform: none; }
}

/* =========================================================
   EXTRAS  —  Framer-style flourishes (still pure CSS)
   ========================================================= */

/* ---- Subtle film grain over the whole page ---- */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  opacity: .04; mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---- Big ghost numerals behind each project card ---- */
.project-stack { counter-reset: persona-num; }
.project-bubble { position: relative; counter-increment: persona-num; }
.project-bubble > * { position: relative; z-index: 1; }
.project-bubble::before {
  content: counter(persona-num, decimal-leading-zero);
  position: absolute; top: .2rem; right: 1.2rem; z-index: 0;
  font-family: var(--mono); font-weight: 500; line-height: 1;
  font-size: clamp(2.8rem, 6vw, 4.6rem);
  color: var(--accent); opacity: .06;
  pointer-events: none;
}

/* ---- Project titles wipe in on scroll ---- */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .panel__title {
      animation: persona-wipe both linear;
      animation-timeline: view();
      animation-range: entry 8% cover 30%;
    }
    @keyframes persona-wipe {
      from { clip-path: inset(0 100% 0 0); }
      to   { clip-path: inset(0 0 0 0); }
    }
  }
}

/* ---- Kinetic marquee band ---- */
.marquee {
  position: relative;
  overflow: hidden; margin: 0.3rem 0 0;
  background: var(--paper);
  border-block: 1px solid var(--rule-soft);
  padding: .28rem 0;
}
.marquee::before,
.marquee::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 9%;
  z-index: 2; pointer-events: none;
}
.marquee::before { left: 0; background: linear-gradient(90deg, var(--paper), transparent); }
.marquee::after { right: 0; background: linear-gradient(270deg, var(--paper), transparent); }
.marquee__track {
  display: flex; align-items: center; gap: 2.6rem;
  width: max-content;
  animation: persona-marquee 42s linear infinite;
}
.marquee:hover .marquee__track { animation-play-state: paused; }
.marquee__track span {
  font-family: var(--mono); font-size: .72rem;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-soft); white-space: nowrap;
}
.marquee__track span::after {
  content: "\2022"; margin-left: 2.6rem; color: var(--accent);
}
@keyframes persona-marquee { to { transform: translateX(-50%); } }

/* second row: counter-scrolling, dimmer, sits flush under the first */
.marquee--rev { margin-top: 0; border-top: 0; }
.marquee--rev .marquee__track { animation-name: persona-marquee-rev; animation-duration: 52s; }
@keyframes persona-marquee-rev { from { transform: translateX(-50%); } to { transform: translateX(0); } }

@media (prefers-reduced-motion: reduce) {
  .marquee__track { animation: none; }
  .panel__title { clip-path: none; }
}

/* =========================================================
   ADD-ONS  —  scroll-spy, staggered reveal, hero motif, scrollbar
   ========================================================= */

/* ---- Keep the project list clean above the page backdrop ---- */
.project-toc { background: var(--paper); }

/* ---- Scroll-spy: active TOC item (class set by persona.js) ---- */
.project-toc__list a.is-active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--paper-warm);
}
.project-toc__list a.is-active .project-toc__num { color: var(--accent); }
.project-toc__list a.is-active .project-toc__industry { color: var(--accent-deep); }

/* ---- Staggered card reveal: container fades, children cascade ---- */
.project-bubble { view-timeline-name: --card; }
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .project-bubble {
      animation: persona-fade both linear;
      animation-timeline: view();
      animation-range: entry 0% cover 16%;
    }
    @keyframes persona-fade { from { opacity: 0; } to { opacity: 1; } }

    .project-bubble > * {
      animation: persona-child both linear;
      animation-timeline: --card;
      animation-range: entry 6% cover 28%;
    }
    .project-bubble > *:nth-child(2) { animation-range: entry 9% cover 31%; }
    .project-bubble > *:nth-child(3) { animation-range: entry 12% cover 34%; }
    .project-bubble > *:nth-child(4) { animation-range: entry 15% cover 37%; }
    .project-bubble > *:nth-child(n+5) { animation-range: entry 18% cover 40%; }
    @keyframes persona-child {
      from { opacity: 0; translate: 0 16px; }
      to   { opacity: 1; translate: 0 0; }
    }
  }
}

/* ---- Signature hero motif: two lines meeting at a point ---- */
.hero__motif {
  position: absolute; z-index: -1; pointer-events: none;
  top: clamp(0.4rem, 2.5vw, 1.8rem);
  right: clamp(0.6rem, 4vw, 3.5rem);
  width: clamp(86px, 12vw, 170px); height: auto;
  color: var(--accent); opacity: .5;
}
.hero__motif .hm-line {
  stroke-dasharray: 260; stroke-dashoffset: 260;
  animation: persona-draw 1.7s var(--ease) .5s forwards;
}
.hero__motif .hm-line.b { animation-delay: .72s; }
.hero__motif .hm-dot { opacity: 0; animation: persona-dot .5s var(--ease) 2.15s forwards; }
@keyframes persona-draw { to { stroke-dashoffset: 0; } }
@keyframes persona-dot  { to { opacity: 1; } }

/* ---- Custom gold scrollbar ---- */
html { scrollbar-color: var(--accent-deep) var(--paper); scrollbar-width: thin; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--paper); }
::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--accent-deep), var(--accent));
  border-radius: 10px; border: 2px solid var(--paper);
}
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ---- Jump-to-project sidebar: cap to viewport + scroll ---- */
@media (min-width: 920px) {
  .project-toc {
    display: flex; flex-direction: column;
    max-height: calc(100vh - 6.5rem);
  }
  .project-toc__list {
    overflow-y: auto; min-height: 0; flex: 1 1 auto;
    padding-right: .5rem; overscroll-behavior: contain;
  }
  .project-toc__list::-webkit-scrollbar { width: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  .project-bubble > * { animation: none; opacity: 1; translate: none; }
  .hero__motif .hm-line { animation: none; stroke-dashoffset: 0; }
  .hero__motif .hm-dot { animation: none; opacity: 1; }
}

/* ---- Theme filter chips ---- */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1.8rem; }
.filter-chip {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-soft); background: transparent;
  border: 1px solid var(--rule); border-radius: 999px;
  padding: .45rem .95rem; cursor: pointer;
  transition: color .2s var(--ease), border-color .2s var(--ease), background .2s var(--ease);
}
.filter-chip:hover { color: var(--accent); border-color: var(--accent-deep); }
.filter-chip.is-active {
  color: var(--paper); background: var(--accent);
  border-color: var(--accent); font-weight: 600;
}
.project-bubble.is-hidden,
.project-toc__list li.is-hidden { display: none; }
