/* Ashta Studio — opening motion.
   1. The Infinity Weave: the woven A is traced in gold in the dark, then two temple doors
      open onto the page.
   2. Story Mode: behind the doors the hero painting plays the six artworks once, like an
      Instagram Story, with an eight-petal mandala turning slowly behind it.
   Plus a band of gold light across the six deities and the Manhwa cover unrolling.

   Safety rules used throughout:
   - The <head> script sets data-motion and data-intro only for visitors who have NOT asked
     for reduced motion; reduced-motion and no-JavaScript visitors get the still page.
   - Every start state that hides something lives under html[data-intro]:not(.intro-skip),
     so a tap, a key or a scroll (intro.js adds .intro-skip) shows the finished page at once.
     The doors also play once a visit.
   - The doors run on CSS alone: if intro.js never loads they still open by themselves.
   - Only transform, opacity and clip-path move. Paintings always settle whole (scale 1). */

:root {
  --ease-enter: cubic-bezier(.22, 1, .36, 1);
  --ease-door: cubic-bezier(.7, 0, .2, 1);
}

.intro-doors { display: none; }

html[data-motion] .hero { overflow-x: clip; }   /* the mandala never widens the page */
.hero-art { position: relative; isolation: isolate; }
.hero-frame picture { display: block; height: 100%; overflow: hidden; }
.hero-frame img { transform-origin: 50% 60%; }

@keyframes i-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes i-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes i-settle { from { transform: scale(1.05); } to { transform: none; } }

/* The page's own hero "rise" makes way for the opening. */
html[data-intro] .hero h1, html[data-intro] .hero-frame { animation: none; }

/* =====================================================================
   1. THE INFINITY WEAVE — the mark is woven in gold, then the temple doors open.
   ===================================================================== */
html[data-intro] .intro-doors {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 90;
  visibility: hidden;
  pointer-events: none;   /* only the doors themselves block: the page is usable as they part */
}
.door { pointer-events: auto; cursor: pointer; }
.door {
  position: absolute;
  top: 0; bottom: 0;
  width: 50.5%;
  background: var(--bg);
}
.door-l { left: 0; }
.door-r { right: 0; }
.door-l::after, .door-r::after {           /* the gold seam where the doors meet */
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, rgba(214, 182, 120, 0), rgba(214, 182, 120, .85) 50%, rgba(214, 182, 120, 0));
  transform: scaleY(0);
}
.door-l::after { right: 0; }
.door-r::after { left: 0; }
.door-l::before, .door-r::before {         /* faint carved panels on each door */
  content: "";
  position: absolute;
  top: 9%; bottom: 9%;
  width: min(30vw, 260px);
  border: 1px solid rgba(214, 182, 120, .12);
  outline: 1px solid rgba(214, 182, 120, .06);
  outline-offset: 10px;
}
.door-l::before { right: max(6vw, 32px); }
.door-r::before { left: max(6vw, 32px); }
.door-mark {
  position: absolute;
  left: 50%; top: 50%;
  width: min(36vmin, 280px);
  height: min(36vmin, 280px);
  color: var(--gold);
  transform: translate(-50%, -50%);
  overflow: visible;
}
.door-glow {
  position: absolute;
  left: 50%; top: 50%;
  width: min(90vmin, 720px);
  height: min(90vmin, 720px);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(214, 182, 120, .22), rgba(169, 100, 63, .08) 50%, rgba(16, 17, 16, 0));
  transform: translate(-50%, -50%);
  opacity: 0;
}
@keyframes doors-life { 0%, 99.9% { visibility: visible; } 100% { visibility: hidden; } }
@keyframes door-l { from { transform: none; } to { transform: translateX(-101%); } }
@keyframes door-r { from { transform: none; } to { transform: translateX(101%); } }
@keyframes seam { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes glow-up { 0% { opacity: 0; } 55% { opacity: 1; } 100% { opacity: 0; } }
@keyframes mark-out {
  from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  to { opacity: 0; transform: translate(-50%, -50%) scale(1.18); }
}
/* The woven A is traced, then filled. Stroke and dash settings pass into the shared
   <symbol> through <use>. */
@keyframes weave-draw {
  0% { stroke: var(--gold); stroke-width: .7; stroke-dasharray: 200 1000; stroke-dashoffset: 200; color: rgba(214, 182, 120, 0); }
  72% { stroke: var(--gold); stroke-width: .7; stroke-dasharray: 200 1000; stroke-dashoffset: 0; color: rgba(214, 182, 120, 0); }
  100% { stroke: var(--gold); stroke-width: .2; stroke-dasharray: 200 1000; stroke-dashoffset: 0; color: var(--gold); }
}

/* The timeline (seconds): mark woven .1–1.0, seam .8, doors open 1.05–1.85,
   the Story starts as the doors part, the words arrive 1.0–1.9.
   intro.js keeps DOORS_OPEN_MS and OPENING_MS in step with these numbers. */
html[data-intro]:not(.intro-skip) .intro-doors { animation: doors-life 1.85s both; }
html[data-intro]:not(.intro-skip) .door-mark use { animation: weave-draw .9s .1s ease-in-out both; }
html[data-intro]:not(.intro-skip) .door-glow { animation: glow-up 1.3s .25s ease-in-out both; }
html[data-intro]:not(.intro-skip) .door-mark { animation: mark-out .45s 1s ease-in both; }
html[data-intro]:not(.intro-skip) .door-l::after,
html[data-intro]:not(.intro-skip) .door-r::after { animation: seam .35s .8s var(--ease-enter) both; }
html[data-intro]:not(.intro-skip) .door-l { animation: door-l .8s 1.05s var(--ease-door) both; }
html[data-intro]:not(.intro-skip) .door-r { animation: door-r .8s 1.05s var(--ease-door) both; }
html[data-intro]:not(.intro-skip) .hero-copy > * { animation: i-rise .7s var(--ease-enter) both; }
html[data-intro]:not(.intro-skip) .hero-copy > :nth-child(1) { animation-delay: 1s; }
html[data-intro]:not(.intro-skip) .hero-copy > :nth-child(2) { animation-delay: 1.04s; }
html[data-intro]:not(.intro-skip) .hero-copy > :nth-child(3) { animation-delay: 1.1s; }
html[data-intro]:not(.intro-skip) .hero-copy > :nth-child(4) { animation-delay: 1.14s; }
html[data-intro]:not(.intro-skip) .hero-copy > :nth-child(5) { animation-delay: 1.2s; }
html[data-intro]:not(.intro-skip) .hero-mandala { animation: i-fade 1.6s 1.2s ease-out both, turn 240s linear infinite; }

/* An eight-petal mandala (ashta: eight) turning once every four minutes behind the painting,
   with a soft warm glow: a halo round the art, like the prabhavali behind a temple deity. */
.hero-mandala {
  position: absolute;
  z-index: -1;
  left: 50%;
  top: 0;
  width: 215%;
  max-width: none;                         /* the site caps svg at 100% wide */
  aspect-ratio: 1;
  margin-top: 88.9%;                       /* half the 9:16 frame's height: centred on it */
  translate: -50% -50%;
  color: var(--gold);
  opacity: .95;
  pointer-events: none;
  animation: turn 240s linear infinite;
}
@keyframes turn { to { transform: rotate(360deg); } }
html[data-motion] .hero-art::before {
  content: "";
  position: absolute;
  z-index: -2;
  left: 50%;
  top: 0;
  width: 150%;
  aspect-ratio: 1;
  margin-top: 88.9%;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(214, 182, 120, .16), rgba(169, 100, 63, .06) 55%, rgba(16, 17, 16, 0));
  pointer-events: none;
}
html[data-intro]:not(.intro-skip) .hero-art::before { animation: i-fade 1.6s 1.2s ease-out both; }

/* The halo is wide; the words always sit above it, with a dark edge on the letters so a
   gold line passing behind them never cuts through. */
html[data-motion] .hero-copy { position: relative; z-index: 1; }
html[data-motion] .hero-copy p,
html[data-motion] .hero-actions .text-link,
html[data-motion] .story-caption { text-shadow: 0 0 2px var(--bg), 0 0 6px var(--bg), 0 0 12px var(--bg); }
@media (min-width: 768px) and (max-width: 1023px) {
  .hero-mandala { width: 165%; }   /* tablets: the copy column is narrow, keep the halo off it */
}

/* =====================================================================
   2. STORY MODE — the hero plays like an Instagram Story (interface built by intro.js).
   ===================================================================== */
.story-ui {
  position: absolute;
  inset: 0;
  z-index: 2;
  transition: opacity .8s ease;
}
.story-ui.is-ended { opacity: 0; visibility: hidden; transition: opacity .8s ease, visibility 0s .8s; }
.story-ui::before {                        /* soft scrim so the bars read on any painting */
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 22%;
  background: linear-gradient(180deg, rgba(16, 17, 16, .62), rgba(16, 17, 16, 0));
  pointer-events: none;
}
.story-bars {
  position: absolute;
  left: 10px; right: 10px; top: 10px;
  display: flex;
  gap: 4px;
}
.story-bars span {
  position: relative;
  flex: 1;
  height: 2px;
  border-radius: 2px;
  overflow: hidden;
  background: rgba(238, 233, 221, .3);
}
.story-bars i {
  position: absolute;
  inset: 0;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: left;
}
.story-head {
  position: absolute;
  left: 10px; top: 22px;
  display: flex;
  align-items: center;
  gap: 8px;
  font: 500 12px/1.2 var(--sans);
  color: var(--text);
  pointer-events: none;
}
.story-avatar {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border: 1px solid var(--gold-soft);
  border-radius: 50%;
  background: var(--bg);
  color: var(--gold);
}
.story-avatar svg { width: 18px; height: 18px; }
.story-head small { font-weight: 300; color: var(--muted); }
.story-tap {
  position: absolute;
  top: 0; bottom: 0;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
.story-tap:focus-visible { outline-offset: -4px; }
.story-prev { left: 0; width: 32%; }
.story-next { right: 0; width: 68%; }
.story-pause {
  position: absolute;
  right: 12px; bottom: 12px;
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border: 1px solid var(--gold-soft);
  border-radius: 50%;
  padding: 0;
  background: rgba(16, 17, 16, .6);
  color: var(--gold);
  cursor: pointer;
}
.story-pause::before {                     /* pause glyph: two bars */
  content: "";
  width: 9px; height: 11px;
  border-inline: 3px solid currentColor;
}
.story-pause[aria-pressed="true"]::before { /* play glyph */
  width: 0; height: 0;
  margin-left: 3px;
  border-style: solid;
  border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent currentColor;
}
.story-slides { position: absolute; inset: 0; }
.story-slides picture {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity .7s ease;
}
.story-slides picture.is-on { opacity: 1; }
.story-slides img { width: 100%; height: 100%; }
.is-drifting { animation: drift var(--slide, 2.8s) linear both; }
@keyframes drift { from { transform: scale(1.035); } to { transform: none; } }
.story-caption { display: flex; align-items: center; }
.story-replay { margin-left: 18px; padding: 0; border: 0; background: none; cursor: pointer; }
.story-replay[hidden] { display: none; }

/* =====================================================================
   Shared layer: gold light across the six deities, the Manhwa cover unrolls.
   ===================================================================== */
/* A band of gold light travels across the six paintings in turn, like a lamp carried
   past them. Each painting has its own band, so the light stays on the art. */
html[data-motion] .art-open::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  background: linear-gradient(100deg, rgba(255, 226, 160, 0) 25%, rgba(255, 226, 160, .2) 45%, rgba(255, 240, 205, .32) 50%, rgba(255, 226, 160, .2) 55%, rgba(255, 226, 160, 0) 75%);
  mix-blend-mode: screen;
  transform: translateX(-130%);
  pointer-events: none;
}
html[data-motion] .frieze.is-revealed .art-open::before { animation: sweep 1.5s cubic-bezier(.45, 0, .25, 1) both; }
html[data-motion] .frieze.is-revealed .frieze-item:nth-child(2) .art-open::before { animation-delay: .3s; }
html[data-motion] .frieze.is-revealed .frieze-item:nth-child(3) .art-open::before { animation-delay: .6s; }
html[data-motion] .frieze.is-revealed .frieze-item:nth-child(4) .art-open::before { animation-delay: .9s; }
html[data-motion] .frieze.is-revealed .frieze-item:nth-child(5) .art-open::before { animation-delay: 1.2s; }
html[data-motion] .frieze.is-revealed .frieze-item:nth-child(6) .art-open::before { animation-delay: 1.5s; }
@keyframes sweep { from { transform: translateX(-130%); } to { transform: translateX(130%); } }

/* On a computer, a slower glint passes over the figure under the pointer. */
@media (hover: hover) and (pointer: fine) {
  html[data-motion] .art-open::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, rgba(255, 226, 160, 0) 30%, rgba(255, 236, 196, .2) 50%, rgba(255, 226, 160, 0) 70%);
    mix-blend-mode: screen;
    transform: translateX(-120%);
    pointer-events: none;
  }
  html[data-motion] .art-open:hover::after { transform: translateX(120%); transition: transform 1.3s cubic-bezier(.45, 0, .25, 1); }
}

html.reveal-ready .manhwa-cover:not(.is-revealed) { clip-path: inset(-12px -12px 100% -12px); }
html.reveal-ready .manhwa-cover.is-revealed { animation: unroll 1.8s var(--ease-enter) both; }
html.reveal-ready .manhwa-cover.is-revealed img { animation: i-settle 2.2s var(--ease-enter) both; }
@keyframes unroll {
  from { clip-path: inset(-12px -12px 100% -12px); }
  to { clip-path: inset(-12px -12px -12px -12px); }
}

/* Belt and braces: the head script never sets data-intro under reduced motion, but if a
   setting changes mid-visit everything still comes to rest. */
@media (prefers-reduced-motion: reduce) {
  .intro-doors, .hero-mandala { display: none !important; }
  html.reveal-ready .manhwa-cover:not(.is-revealed) { clip-path: none; }
}
