/*
  hero.css — Refactor (R2)
  Goals:
  - Clean, component-scoped styles (no page spacing rules)
  - Consistent gold/glass identity (matches catalog/reader)
  - Performance tiering (mobile/coarse pointer + reduced motion)

  Notes:
  - Hero is intended to be a reusable component.
  - Page-level spacing (margins above/below hero) should live in page-*.css.
*/

/* ─────────────────────────────────────────────────────────────────────────────
   0) Tap highlight / basic hygiene
   ───────────────────────────────────────────────────────────────────────────── */

.hero *{ -webkit-tap-highlight-color: transparent; }
.hero a, .hero button{ -webkit-tap-highlight-color: transparent; -webkit-touch-callout:none; }

/* ─────────────────────────────────────────────────────────────────────────────
   1) Tokens (fallbacks)
   ───────────────────────────────────────────────────────────────────────────── */

:root{
  /* Fonts */
  --hero-ff-ui: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial;
  --hero-ff-serif: "Garamond", "Times New Roman", serif;

  /* Motion */
  --hero-motion-fast: 140ms;
  --hero-motion-normal: 240ms;
  --hero-motion-slow: 360ms;
  --hero-ease: cubic-bezier(.16, .84, .44, 1);

  /* Geometry */
  --hero-radius-lg: 28px;
  --hero-radius-md: 18px;
  --hero-radius-pill: 999px;

  /* Gold glass (fallbacks, will be overridden by page-catalog/page-reader variables when present) */
  --hero-glass-bg: var(--glass-bg, rgba(255, 214, 140, 0.22));
  --hero-glass-bg-2: var(--glass-bg-2, rgba(255, 214, 140, 0.14));
  --hero-glass-border: var(--glass-border, rgba(255, 232, 190, 0.22));
  --hero-glass-inset: var(--glass-inset, inset 0 1px 8px rgba(255,255,255,.18));

  --hero-glass-blur: var(--glass-blur, 10px);
  --hero-glass-sat: var(--glass-sat, 1.20);

  /* Hero sizing */
  --hero-stage-h: 75svh;
  --hero-stage-min: 540px;

  /* Cover */
  --hero-cover-w: clamp(260px, 28vw, 420px);
  --hero-cover-radius: 33px;

  /* Read button */
  --hero-btn-radius: 12px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   2) Component layout
   ───────────────────────────────────────────────────────────────────────────── */

.hero{
  margin: 0;
  overflow: visible;
}

.hero .frame{
  position: relative;
  border-radius: var(--hero-radius-lg);
  overflow: hidden;
  background: none;
}

.hero .hstage{
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  justify-content: center;

  height: var(--hero-stage-h);
  min-height: var(--hero-stage-min);

  padding: 0;
  overflow: hidden;
  border-radius: 16px;

  /* subtle scale for desktop “camera” effect */
  transform: scale(.985);
  transform-origin: center;
  will-change: transform;
  transition: transform 450ms var(--hero-ease);
}

.hero .hslides{
  position: absolute;
  inset: 0;
  display: flex;
  will-change: transform;
  transition: transform 800ms cubic-bezier(.22,.61,.36,1);
}

.hero .hslide{
  min-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 3vw, 42px);
  padding: 16px 28px;

  /* only current slide should be interactive */
  pointer-events: none;
  opacity: 1;
  transform-origin: center;
}

.hero .hslide.is-current{
  pointer-events: auto;
  z-index: 2;
}

.hero .visual{
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero .copy{
  flex: 0 0 55%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  padding: 20px;
}

/* Slide copy reveal (kept simple and deterministic) */
.hero .hslide .copy{
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 600ms ease, transform 600ms ease;
}

.hero .hslide.is-current .copy{
  opacity: 1;
  transform: translateY(0);
}

/* ─────────────────────────────────────────────────────────────────────────────
   3) Cover card (slot-23)
   ───────────────────────────────────────────────────────────────────────────── */

.hero .visual .slot-23{
  width: var(--hero-cover-w);
  aspect-ratio: 2 / 3;
  transform-origin: center;
}

.hero .slot-23{
  position: relative;
  aspect-ratio: 2 / 3;
  display: block;
  margin: auto;
  border-radius: var(--hero-cover-radius);
  overflow: hidden;

  border: 0.5px solid rgba(50, 50, 50, 0.50);

  /* Gold glow – moderate by default */
  box-shadow:
    0 0 10px rgba(255,210,100,.22),
    0 0 20px rgba(255,220,130,.18),
    0 0 30px rgba(255,200,0,.12);
}

.hero .slot-23 img{
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
}

/* Blur-up on cover (JS toggles .is-loaded) */
.hero .hslide .slot-23 img{
  will-change: transform, opacity, filter;
  transform: translateZ(0) scale(1.0);
  opacity: 0;
  filter: blur(10px);
  transition:
    opacity 350ms ease-out,
    filter 350ms ease-out,
    transform 700ms ease;
}

.hero .hslide .slot-23 img.is-loaded{
  opacity: 1;
  filter: blur(0);
}

/* micro zoom only when current + loaded */
.hero .hslide.is-current .slot-23 img.is-loaded{
  transform: scale(1.03);
}

/* ─────────────────────────────────────────────────────────────────────────────
   4) Typography
   ───────────────────────────────────────────────────────────────────────────── */

.hero .title{
  font-family: var(--hero-ff-serif);
  font-size: clamp(28px, 4.2vw, 50px);
  line-height: 1.08;
  margin: 0 0 6px;
  text-transform: uppercase;
  font-weight: 900;
  letter-spacing: .02em;
  color: #383731;

  text-shadow:
    0 0 6px rgba(255,215,80,.45),
    0 0 12px rgba(255,220,100,.30),
    0 0 18px rgba(255,230,130,.22);
}

.hero .subtitle{
  font-family: var(--hero-ff-serif);
  font-size: clamp(20px, 2.2vw, 30px);
  margin: 6px 0 0;
  text-transform: uppercase;
  letter-spacing: .06em;
  opacity: .92;
  color: #383731;

  text-shadow:
    0 0 6px rgba(255,215,80,.45),
    0 0 12px rgba(255,220,100,.30),
    0 0 18px rgba(255,230,130,.22);

  /* one-line stable box */
  display: block;
  line-height: 1.4;
  height: 1.4em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}

.hero .copy .sub{
  margin-top: 4px;
  font: 400 .9rem/1.45 var(--hero-ff-ui);
  letter-spacing: .3px;
  color: rgba(255,255,255, 0.90);
  text-shadow: 0 1px 2px rgba(0,0,0,.40);
}

/* ─────────────────────────────────────────────────────────────────────────────
   5) Subtitle marquee (only when JS sets .is-hero-marquee)
   ───────────────────────────────────────────────────────────────────────────── */

.hero .subtitle.is-hero-marquee{
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: clip;
}

.hero .subtitle .hero-marquee-inner{
  display: inline-flex;
  gap: var(--hero-marquee-gap, 10px);
  white-space: nowrap;
  animation-name: hero-marquee;
  animation-duration: var(--hero-marquee-duration, 8s);
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-play-state: running;
  will-change: transform;
}

.hero .subtitle .hero-marquee-segment{
  display: inline-block;
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
}

.hero .subtitle:not(.is-hero-marquee) .hero-marquee-inner{
  animation-name: none;
  animation-duration: 0s;
}

@keyframes hero-marquee{
  0%   { transform: translateX(0); }
  100% { transform: translateX(calc(var(--hero-marquee-distance) * -1)); }
}

/* ─────────────────────────────────────────────────────────────────────────────
   6) CTA (Read)
   ───────────────────────────────────────────────────────────────────────────── */

.hero .read-btn{
  display: inline-block;
  margin-top: 10px;
  padding: 8px 26px;
  border-radius: var(--hero-btn-radius);

  background-color: rgba(255,255,255,.38);
  border: 1px solid rgba(255,255,255,.50);

  color: #2b2a27;
  -webkit-text-fill-color: #2b2a27;
  text-decoration: none;

  font-family: var(--hero-ff-serif);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;

  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);

  box-shadow:
    0 6px 18px rgba(0,0,0,.15),
    inset 0 1px 8px rgba(255,255,255,.25);

  transition:
    transform var(--hero-motion-normal) var(--hero-ease),
    box-shadow var(--hero-motion-normal) var(--hero-ease),
    background-color var(--hero-motion-normal) var(--hero-ease),
    border-color var(--hero-motion-normal) var(--hero-ease),
    opacity var(--hero-motion-fast) var(--hero-ease);

  will-change: transform, opacity;
}

.hero .read-btn:hover{
  background-color: rgba(255,255,255,.48);
  border-color: rgba(255,255,255,.60);
  transform: translateY(-1px);
  box-shadow:
    0 8px 24px rgba(0,0,0,.22),
    inset 0 1px 10px rgba(255,255,255,.28);
}

/* Delay entrance with slide copy (matches current JS timing) */
.hero .copy .read-btn,
.hero .copy .sub{
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 600ms ease, transform 600ms ease;
  transition-delay: 1.8s;
}

.hero .hslide.is-current .copy .read-btn,
.hero .hslide.is-current .copy .sub{
  opacity: 1;
  transform: translateY(0);
  transition-delay: 2.1s;
}

.hero .hslide:not(.is-current) .copy .read-btn,
.hero .hslide:not(.is-current) .copy .sub{
  opacity: 0;
  transform: translateY(6px);
  transition-delay: 0s;
}

/* ─────────────────────────────────────────────────────────────────────────────
   7) Controls (arrows)
   ───────────────────────────────────────────────────────────────────────────── */

.hero .controls{
  position: absolute;
  inset: auto 0 50% 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transform: translateY(50%);
  z-index: 5;
  pointer-events: none;
}

.hero .btn{
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--hero-radius-pill);

  background:
    linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.02)),
    var(--hero-glass-bg);

  border: 1px solid var(--hero-glass-border);

  backdrop-filter: blur(var(--hero-glass-blur)) saturate(var(--hero-glass-sat));
  -webkit-backdrop-filter: blur(var(--hero-glass-blur)) saturate(var(--hero-glass-sat));

  box-shadow: 0 2px 6px rgba(0,0,0,.08), var(--hero-glass-inset);

  color: #111;
  font-weight: 900;

  transition:
    transform 180ms ease,
    box-shadow 250ms ease,
    border-color 250ms ease,
    background 250ms ease;
}

.hero .btn:hover{
  border-color: rgba(255,255,255,.35);
  box-shadow:
    0 12px 16px rgba(0,0,0,.24),
    0 0 10px rgba(255,209,60,.52);
  transform: translateY(-1px);
}

.hero .btn:active{ transform: translateY(0); }

/* ─────────────────────────────────────────────────────────────────────────────
   8) Ink-write (title/subtitle reveal)
   ───────────────────────────────────────────────────────────────────────────── */

.hero .title.ink-write,
.hero .subtitle.ink-write{
  -webkit-mask: linear-gradient(#000 0 0) left / 0% 100% no-repeat;
  mask: linear-gradient(#000 0 0) left / 0% 100% no-repeat;
  animation: ink-reveal var(--ink-dur, 1.8s) steps(40, end) forwards;
  animation-delay: var(--ink-delay, 0s);
  position: relative;
}

.hero .subtitle.ink-write{
  animation-duration: var(--ink-dur, 1.6s);
  animation-delay: var(--ink-delay, .25s);
}

.hero .hslide:not(.is-current) .title.ink-write,
.hero .hslide:not(.is-current) .subtitle.ink-write{
  -webkit-mask: none;
  mask: none;
  animation: none;
  opacity: 0;
  transition: opacity 800ms ease;
}

.hero .hslide.is-current .title.ink-write,
.hero .hslide.is-current .subtitle.ink-write{
  opacity: 1;
  transition: opacity 800ms ease 100ms;
}

@keyframes ink-reveal{
  to{
    -webkit-mask-size: 100% 100%;
    mask-size: 100% 100%;
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   9) Responsive
   ───────────────────────────────────────────────────────────────────────────── */

/* Very small phones: hero becomes stacked; arrows hidden */
@media (max-width: 399px){
  .hero .hstage{
    height: auto;
    min-height: 0;
    overflow: visible;
    transform: none;
    display: block;
    padding-bottom: 2px;
  }

  .hero .hslides{
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    overflow: visible;
  }

  .hero .hslide{
    flex-direction: column;
    gap: 20px;
    padding: 0;
  }

  .hero .controls{ display:none !important; }

  .hero .visual{ flex: unset; width: 90%; margin: 0 auto; }
  .hero .visual .slot-23{ width: 80%; margin: 0 auto; }

  .hero .copy{ flex: unset; width: 85%; text-align:center; }

  .hero .slot-23{ box-shadow: none !important; border: 1px solid rgba(0,0,0,.18); }
  .hero .hslide .slot-23 img{ transform:none !important; }

  .hero .title{ 
    font-size: 1.5rem;
    margin-bottom: 0.2rem;
    line-height: 1.3;
  }
  .hero .subtitle{ 
    font-size: 1.25rem;
    letter-spacing: 0.08em;
    max-width: 92vw;
    width: 100%;
  }
  .hero .copy .sub{ 
    font-size: 0.7rem;
    margin-bottom: 18px;
  }
  .hero .read-btn{ 
    padding: 6px 18px;
    font-size: 0.78rem;
    letter-spacing: 0.10em;
  }
}

/* Phones: hero becomes stacked; arrows hidden */
@media (min-width: 400px) and (max-width: 767px){
  .hero .hstage{
    height: auto;
    min-height: 0;
    overflow: visible;
    transform: none;
    display: block;
    padding-bottom: 2px;
  }

  .hero .hslides{
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    overflow: visible;
  }

  .hero .hslide{
    flex-direction: column;
    gap: 0px;
    padding: 0;
  }

  .hero .controls{ display:none !important; }

  .hero .visual{ flex: unset; width: 90%; margin: 0 auto; }
  .hero .visual .slot-23{ width: 80%; margin: 0 auto; }

  .hero .copy{ flex: unset; width: 85%; text-align:center; }

  .hero .slot-23{ box-shadow: none !important; border: 1px solid rgba(0,0,0,.18); }
  .hero .hslide .slot-23 img{ transform:none !important; }
}

/* Tablets: stacked layout (no arrows), larger type */
@media (min-width: 768px) and (max-width: 1024px){
  .hero .hslides{ position: relative; inset:auto; width:100%; height:auto; overflow:visible; }

  .hero .hslide{ flex-direction: column; gap: 20px; padding: 0; }

  .hero .hstage{
    height: auto;
    min-height: 520px;
    overflow: visible;
    padding-bottom: 2px;
    display: block;
  }

  .hero .controls{ display:none !important; }

  .hero .visual{ flex: unset; width: 100%; margin: 0 auto; }
  .hero .visual .slot-23{ width: clamp(500px, 50vw, 550px); }

  .hero .copy{ padding: 14px; width: 70%; flex: unset; text-align:center; }

  .hero .title{ font-size: 2.7rem; margin-top: .4rem; margin-bottom: .2rem; line-height: 1.3; }
  .hero .subtitle{ font-size: 2.33rem; padding-bottom: 7px; }
  .hero .copy .sub{ font-size: 1.2rem; }
  .hero .read-btn{ font-size: 1.4rem; }

  .hero .slot-23{ box-shadow: none !important; border: 1px solid rgba(0,0,0,.18); }
  .hero .hslide .slot-23 img{ transform:none !important; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   10) Performance tiering
   ───────────────────────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce){
  .hero *{ animation: none !important; transition: none !important; }
  html{ scroll-behavior: auto !important; }
  .hero .hstage{ transform: none !important; }
  .hero .subtitle{ white-space: nowrap; text-overflow: ellipsis; height: 1.4em; }
  .hero .subtitle .hero-marquee-inner{ animation: none !important; }
  .hero .title.ink-write,
  .hero .subtitle.ink-write{ -webkit-mask:none; mask:none; animation:none; }
}

/* Mobile/coarse pointer: disable expensive backdrop-filter and mimic glass */
@media (max-width: 900px), (pointer: coarse){
  :root{
    --hero-glass-blur: 0px;
    --hero-glass-sat: 1.00;
  }

  .hero .read-btn,
  .hero .btn{
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;

    background:
      radial-gradient(120% 80% at 30% 20%, rgba(255,255,255,.16), rgba(255,255,255,0) 55%),
      linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.03)),
      rgba(255, 214, 140, 0.30);

    box-shadow: 0 10px 26px rgba(0,0,0,.14), var(--hero-glass-inset);
  }
}
