/* ===========================================================
   hinagiku.date — leather journal scroll
   Palette:
     #0d0a08 Tanned Hide Black   #1a1410 Worn Crease
     #f4ede0 Bone Ink            #3aa39b Cold Star Cyan-Green
     #d92e7a Brand Magenta       #7a6e5e Stitch Thread
     #000000 Pure Void
   Fonts: Caveat (display hand), Homemade Apple (secondary hand),
          Special Elite (stamp/mono)
   =========================================================== */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --hide:        #0d0a08;
  --crease:      #1a1410;
  --bone:        #f4ede0;
  --star:        #3aa39b;
  --magenta:     #d92e7a;
  --thread:      #7a6e5e;
  --void:        #000000;
  --scroll:      0;
  --side:        clamp(2rem, 8vw, 8rem);
}

html { scroll-behavior: smooth; }

body {
  background: var(--hide);
  color: var(--bone);
  font-family: "Caveat", cursive;
  overflow-x: hidden;
  position: relative;
  min-height: 100vh;
}

/* ----------------- LEATHER HIDE BACKGROUND ----------------- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  background-color: var(--hide);
  background-image:
    radial-gradient(35vw 35vw at 12% 18%, rgba(26,20,16,0.6), transparent 60%),
    radial-gradient(38vw 38vw at 82% 30%, rgba(26,20,16,0.55), transparent 62%),
    radial-gradient(30vw 30vw at 40% 70%, rgba(26,20,16,0.6), transparent 60%),
    radial-gradient(34vw 34vw at 70% 88%, rgba(26,20,16,0.5), transparent 60%),
    radial-gradient(26vw 26vw at 8% 92%, rgba(26,20,16,0.55), transparent 60%),
    repeating-conic-gradient(from 0deg at 50% 50%,
       rgba(244,237,224,0.015) 0deg 1.5deg,
       transparent 1.5deg 3deg);
  background-blend-mode: normal;
}
/* edge vignette */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: radial-gradient(120% 120% at 50% 50%, transparent 55%, rgba(0,0,0,0.45) 100%);
}

/* fixed SVG turbulence grain */
.grain-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  opacity: 0.08;
  pointer-events: none;
  mix-blend-mode: overlay;
}

/* ----------------- STAR DUST (drift + parallax) ----------------- */
.stardust {
  position: fixed;
  inset: -10vh -10vw;
  z-index: 0;
  pointer-events: none;
  transform: translate3d(0, calc(var(--scroll) * -0.2rem), 0);
  animation: dustDrift 14s linear infinite;
}
.stardust .dust {
  position: absolute;
  background: var(--star);
  width: 2px; height: 2px;
}
@keyframes dustDrift {
  from { transform: translate3d(0, calc(var(--scroll) * -0.2rem), 0) translateX(0); }
  to   { transform: translate3d(0, calc(var(--scroll) * -0.2rem), 0) translateX(18px); }
}

/* ----------------- GENERIC ----------------- */
main { position: relative; z-index: 1; }

.sec {
  position: relative;
  padding: 0 var(--side);
  width: 100%;
}

/* monospace stamp */
.date-stamp {
  font-family: "Special Elite", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--thread);
}

/* handwriting bleed for headline ink */
.ink-bleed {
  text-shadow: 0 0 0.4px rgba(244,237,224,0.5), 0 0 1px rgba(244,237,224,0.2);
}

/* =========================================================
   SECTION 1 — COVER PLATE
   ========================================================= */
.sec-cover {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: clamp(4rem, 12vh, 9rem);
}
.date-stamp-corner {
  position: absolute;
  top: clamp(1.4rem, 4vh, 3rem);
  right: var(--side);
  color: rgba(122,110,94,0.8);
  text-shadow: 0 1px 0 rgba(0,0,0,0.6), 0 -1px 0 rgba(244,237,224,0.04);
}
.cover-inner {
  margin-left: 0;
  width: min(62%, 900px);
}
.daisy-cover {
  width: 28px;
  height: 28px;
  display: block;
  transform: rotate(14deg);
  margin: 0 0 0 6%;
  opacity: 0.9;
}
.cover-title {
  font-family: "Caveat", cursive;
  font-weight: 700;
  font-size: clamp(3rem, 9vw, 7rem);
  line-height: 1;
  letter-spacing: 0.04em;
  margin-top: 0.4rem;
  color: var(--bone);
  text-shadow: 0 0 0.4px rgba(244,237,224,0.5), 0 0 1px rgba(244,237,224,0.2), 0 2px 0 rgba(0,0,0,0.5);
}
.cover-sub {
  font-family: "Caveat", cursive;
  font-weight: 400;
  font-size: clamp(1.1rem, 2.4vw, 1.7rem);
  line-height: 1.85;
  color: rgba(244,237,224,0.62);
  margin-top: 0.8rem;
  max-width: 34ch;
}
.drift-star-cover {
  position: absolute;
  bottom: 8vh;
  left: clamp(1.2rem, 5vw, 5rem);
  width: clamp(34px, 5vw, 52px);
  height: clamp(34px, 5vw, 52px);
  transform: translate3d(0, calc(var(--scroll) * -0.4rem), 0);
  animation: coverStarDrift 14s linear infinite;
}
@keyframes coverStarDrift {
  0%   { rotate: 0deg; }
  100% { rotate: 360deg; }
}
.scroll-hint {
  position: absolute;
  bottom: clamp(1.4rem, 3vh, 2.4rem);
  right: var(--side);
  font-family: "Special Elite", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: rgba(244,237,224,0.3);
  animation: hintPulse 3s ease-in-out infinite;
}
@keyframes hintPulse { 0%,100%{opacity:0.18;} 50%{opacity:0.5;} }

/* =========================================================
   SECTION 2 — THE CONSTELLATION (sticky parallax)
   ========================================================= */
.sec-constellation {
  min-height: 220vh;
}
.constellation-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  align-items: center;
  gap: clamp(2rem, 6vw, 6rem);
}
.asterism {
  flex: 0 0 auto;
  width: clamp(220px, 34vw, 460px);
  height: clamp(220px, 34vw, 460px);
  filter: drop-shadow(0 0 6px rgba(58,163,155,0.25));
}
.asterism .aline {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  /* set precisely via JS using getTotalLength */
}
.sec-constellation.entered .asterism .aline {
  animation: drawLine 1.4s ease-out forwards;
}
@keyframes drawLine { to { stroke-dashoffset: 0; } }
.asterism .astar {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}
.sec-constellation.entered .asterism .astar {
  animation: starPop 0.9s ease-out forwards;
}
.asterism .astar-core { filter: drop-shadow(0 0 4px rgba(58,163,155,0.7)); }
@keyframes starPop {
  0%   { opacity: 0; transform: scale(0.2); }
  60%  { opacity: 1; transform: scale(1.25); }
  100% { opacity: 1; transform: scale(1); }
}

.constellation-text {
  width: min(38%, 520px);
  margin-left: auto;
}
.constellation-text .cline {
  font-family: "Caveat", cursive;
  font-size: clamp(1.4rem, 3vw, 2.3rem);
  line-height: 1.75;
  margin-bottom: 1.4rem;
  color: var(--bone);
  opacity: 0;
  transform: translate3d(0, 24px, 0);
  transition: opacity 0.9s ease, transform 0.9s ease;
}
.constellation-text .cline:nth-child(odd) {
  color: var(--star);
}
.constellation-text .cline:nth-child(even) {
  text-shadow: 0 0 0.4px rgba(244,237,224,0.5), 0 0 1px rgba(244,237,224,0.2);
}
.sec-constellation.entered .constellation-text .cline {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}
.sec-constellation.entered .constellation-text .cline:nth-child(1){ transition-delay: 0.05s; }
.sec-constellation.entered .constellation-text .cline:nth-child(2){ transition-delay: 0.20s; }
.sec-constellation.entered .constellation-text .cline:nth-child(3){ transition-delay: 0.35s; }
.sec-constellation.entered .constellation-text .cline:nth-child(4){ transition-delay: 0.50s; }
.sec-constellation.entered .constellation-text .cline:nth-child(5){ transition-delay: 0.65s; }

/* =========================================================
   SECTION 3 — THE DATE LEDGER (differential scroll)
   ========================================================= */
.sec-ledger {
  min-height: 200vh;
}
.ledger-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.ledger-marker {
  position: absolute;
  top: clamp(1.4rem, 4vh, 3rem);
  left: var(--side);
  color: rgba(122,110,94,0.7);
}
.ledger-scroll {
  width: min(62%, 760px);
  margin-left: 6%;
  /* moves up faster than page: 1.4x equivalent => extra -0.4rem on top of natural scroll into the section.
     We drive a direct translate from JS-bound --ledger var instead. */
  transform: translate3d(0, calc(var(--ledger, 0) * -1px), 0);
  will-change: transform;
}
.ledger-scroll .lline {
  font-family: "Caveat", cursive;
  font-size: clamp(1.5rem, 3.5vw, 2.6rem);
  line-height: 1.6;
  letter-spacing: 0.02em;
  color: rgba(244,237,224,0.78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ledger-scroll .lline:nth-child(7n+1)  { color: var(--bone); }
.ledger-scroll .lline:nth-child(5n)    { color: rgba(58,163,155,0.65); }
.ledger-scroll .lline:nth-child(11n)   { color: rgba(217,46,122,0.5); }

/* =========================================================
   SECTION 4 — THE BRANDED MARK
   ========================================================= */
.sec-brand {
  min-height: 100vh;
  display: flex;
  align-items: center;
}
.brand-inner {
  width: min(62%, 820px);
  margin-left: 6%;
}
.brand-star {
  width: clamp(64px, 9vw, 110px);
  height: auto;
  display: block;
  clip-path: inset(100% 0 0 0);
  filter: drop-shadow(0 0 0 rgba(217,46,122,0));
}
.sec-brand.entered .brand-star {
  animation: brandIron 1.2s ease-out forwards;
}
@keyframes brandIron {
  0% {
    clip-path: inset(100% 0 0 0);
    filter: drop-shadow(0 0 18px rgba(217,46,122,0.9)) drop-shadow(0 0 40px rgba(217,46,122,0.5));
  }
  60% {
    filter: drop-shadow(0 0 22px rgba(217,46,122,0.8)) drop-shadow(0 0 48px rgba(217,46,122,0.45));
  }
  100% {
    clip-path: inset(0 0 0 0);
    filter: drop-shadow(0 0 0 rgba(217,46,122,0));
  }
}
.brand-declaration {
  font-family: "Homemade Apple", cursive;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  letter-spacing: 0.04em;
  line-height: 1.5;
  color: var(--magenta);
  margin-top: clamp(1.6rem, 4vh, 3rem);
  opacity: 0;
  transform: translate3d(0, 20px, 0);
  transition: opacity 1s ease 0.5s, transform 1s ease 0.5s;
  text-shadow: 0 0 2px rgba(217,46,122,0.4);
}
.sec-brand.entered .brand-declaration {
  opacity: 1;
  transform: translate3d(0,0,0);
}

/* =========================================================
   SECTION 5 — THE STITCHING
   ========================================================= */
.sec-stitch {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(2.4rem, 6vh, 5rem);
}
.stitch-line {
  width: min(100%, 900px);
  height: 20px;
}
#stitchPath {
  /* dashoffset animated in JS using length; start hidden */
  stroke-dashoffset: 1200;
  transition: stroke-dashoffset 0.9s ease;
}
.sec-stitch.entered #stitchPath {
  stroke-dashoffset: 0;
}
.stitch-close {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}
.daisy-close {
  width: 18px;
  height: 18px;
  opacity: 0.85;
}
.close-date {
  font-family: "Caveat", cursive;
  font-size: clamp(1.3rem, 3vw, 2rem);
  letter-spacing: 0.02em;
  color: rgba(244,237,224,0.7);
  text-transform: none;
}
/* the close date is handwritten per design ("a single closing date ... beside a daisy" / handwritten ink) */

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 760px) {
  .cover-inner, .constellation-text, .brand-inner, .ledger-scroll { width: 86%; margin-left: 0; }
  .constellation-sticky { flex-direction: column; justify-content: center; gap: 2rem; }
  .asterism { width: 56vw; height: 56vw; }
  .constellation-text { margin: 0; }
  .ledger-scroll .lline { white-space: normal; font-size: clamp(1.2rem,5vw,1.8rem); }
}
