/* ============================================================
   PPUZZL.party v2 — Tidewrack Conservatory
   A seapunk pressed-herbarium / sepia field-journal
   Specimen reveal uses IntersectionObserver (see script.js).
   ============================================================ */

:root {
  /* Palette */
  --tea-vellum:       #F1E7CE; /* primary background */
  --iodine-sepia:     #5B3A1F; /* primary text / stroke */
  --tobacco-bronze:   #A87644; /* secondary text / specimen-code */
  --conch-mint:       #7AB7A8; /* seapunk accent / wash-fill */
  --faded-coral:      #D9728F; /* marginalia / active state */
  --pressed-iris:     #B89AC4; /* hover / focus / soft glow */
  --burnt-ink:        #3A2A1C; /* deep shadow */

  /* Fonts */
  --font-display: "Fraunces", "Cormorant Garamond", "Times New Roman", serif;
  --font-body:    "Cormorant Garamond", "lora", "Times New Roman", serif;
  --font-margin:  "Reenie Beanie", "inter", "Helvetica", cursive;
  --font-mono:    "DM Mono", "space", "Courier New", monospace;

  /* Cursor pos */
  --cursor-x: 50vw;
  --cursor-y: 50vh;

  /* Variable-axis defaults */
  --heading-soft: 0;
  --heading-wght: 300;
  --heading-opsz: 144;
}

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

html, body {
  min-height: 100%;
  background: var(--tea-vellum);
  color: var(--iodine-sepia);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.72;
  overflow-x: hidden;
}

body {
  position: relative;
  /* Single root-level sepia + saturate atmosphere */
  filter: sepia(0.04) saturate(0.92);
}

/* ============================================================
   Pressed-paper vellum background + foxing
   ============================================================ */
.vellum-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--tea-vellum);
}

.paper-grain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.85;
}

.foxing-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.foxing-spot {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(168, 118, 68, 0.32) 0%, rgba(168, 118, 68, 0.06) 70%, transparent 100%);
  pointer-events: none;
  transition: filter 600ms ease-out, transform 600ms ease-out;
}

.foxing-spot.is-glow {
  filter: brightness(1.15);
  transform: scale(1.08);
}

/* ============================================================
   Specimen spine (left rail)
   ============================================================ */
.specimen-spine {
  position: fixed;
  top: 0;
  left: 0;
  width: 16.6667vw; /* 2 of 12 columns */
  height: 100vh;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
  border-right: 1px dashed rgba(91, 58, 31, 0.18);
}

.spine-inner {
  position: relative;
  width: 100%;
  padding: 6vh 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32vh;
  will-change: transform;
  transition: transform 0.05s linear;
}

.spine-specimen {
  width: 78px;
  height: auto;
  opacity: 0;
  transform-origin: center center;
  pointer-events: auto;
  transition:
    transform 1100ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 1.4s ease-out;
}

.spine-specimen.is-drawn {
  opacity: 0.92;
}

.spine-specimen .ink-stroke {
  stroke-dasharray: 320;
  stroke-dashoffset: 320;
  transition: stroke-dashoffset 1.2s ease-in-out;
}

.spine-specimen.is-drawn .ink-stroke {
  stroke-dashoffset: 0;
}

/* slow jelly tentacle drift */
.jelly-tentacle {
  animation: tentacleSway 6s ease-in-out infinite;
  transform-origin: top center;
}
.spine-specimen .jelly-tentacle:nth-child(5) { animation-delay: 0s; }
.spine-specimen .jelly-tentacle:nth-child(6) { animation-delay: 0.6s; }
.spine-specimen .jelly-tentacle:nth-child(7) { animation-delay: 1.2s; }
.spine-specimen .jelly-tentacle:nth-child(8) { animation-delay: 1.8s; }

@keyframes tentacleSway {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  50%      { transform: translateX(2px) rotate(1.5deg); }
}

/* ============================================================
   Layout / sweeps (F-pattern)
   ============================================================ */
.content {
  position: relative;
  z-index: 1;
  margin-left: 16.6667vw; /* leave the spine */
  width: 83.3333vw;
}

.sweep {
  position: relative;
  padding: 6rem 5rem 5rem 5rem;
  width: 100%;
}

/* ============================================================
   Sweep 1 — hero / salutation
   ============================================================ */
.sweep--hero {
  min-height: 88vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: 12vh;
  padding-bottom: 8vh;
}

.opening-rule-wrap {
  position: absolute;
  top: 32%;
  left: 4%;
  right: 4%;
  height: 4px;
}

.opening-rule {
  width: 100%;
  height: 100%;
}

.opening-rule .rule-line {
  stroke-dasharray: 1200;
  stroke-dashoffset: 1200;
  animation: drawRule 1.5s ease-in-out 0.3s forwards;
}

@keyframes drawRule {
  to { stroke-dashoffset: 0; }
}

.hero-inner {
  position: relative;
  max-width: 920px;
  margin-top: 4vh;
}

.hero-titlewrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.brand-display {
  flex: 1;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(40px, 5.8vw, 88px);
  letter-spacing: -0.012em;
  color: var(--iodine-sepia);
  line-height: 1;
  font-variation-settings: "opsz" var(--heading-opsz), "wght" var(--heading-wght), "SOFT" var(--heading-soft);
}

.brand-svg {
  width: 100%;
  height: auto;
  display: block;
}

.brand-svg-text {
  font-family: var(--font-display);
  font-size: 120px;
  font-weight: 500;
  fill: none;
  stroke: var(--iodine-sepia);
  stroke-width: 1.6;
  stroke-dasharray: 2400;
  stroke-dashoffset: 2400;
  animation: inkLetters 4s ease-in-out 1.7s forwards;
  letter-spacing: -0.012em;
  font-variation-settings: "opsz" 144, "wght" 500, "SOFT" 30;
}

@keyframes inkLetters {
  to {
    stroke-dashoffset: 0;
    fill: var(--iodine-sepia);
  }
}

.wax-seal {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  opacity: 0;
  transform: rotate(-6deg);
  animation: sealStamp 600ms ease-out 5.5s forwards;
}

@keyframes sealStamp {
  0%   { opacity: 0; transform: rotate(-6deg) scale(1.2); }
  100% { opacity: 0.92; transform: rotate(-6deg) scale(1); }
}

.hero-subtitle {
  margin-top: 1.4rem;
  font-family: var(--font-margin);
  font-weight: 400;
  font-size: clamp(22px, 2.4vw, 30px);
  color: var(--faded-coral);
  line-height: 1.3;
  letter-spacing: 0.02em;
  min-height: 1.4em;
}

.hero-subtitle::after {
  content: "|";
  margin-left: 4px;
  opacity: 0.6;
  animation: caretBlink 0.9s steps(2) infinite;
}

.hero-subtitle.is-done::after { display: none; }

@keyframes caretBlink {
  50% { opacity: 0; }
}

.hero-meta {
  margin-top: 1.6rem;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--tobacco-bronze);
  display: flex;
  gap: 0.7rem;
  align-items: center;
  flex-wrap: wrap;
}

.hero-meta .bullet { color: var(--iodine-sepia); }

.catalogue-code,
.catalogue-loc {
  white-space: nowrap;
}

/* ============================================================
   Decorative diagonal rules between sections
   ============================================================ */
.decorative-rule {
  position: relative;
  margin: 3.5rem auto 0 auto;
  display: block;
  width: 78%;
  height: 40px;
  transform-origin: center;
}

.rule-deg-neg7 { transform: rotate(-7deg); }
.rule-deg-pos4 { transform: rotate(4deg); }
.rule-deg-neg3 { transform: rotate(-3deg); }

.decorative-rule .dash-rule {
  stroke-dasharray: 600;
  stroke-dashoffset: 600;
  transition: stroke-dashoffset 1.4s ease-in-out;
}

.decorative-rule.is-drawn .dash-rule {
  stroke-dashoffset: 0;
}

.decorative-rule .tail-piece {
  opacity: 0;
  transition: opacity 0.6s ease 1s;
}

.decorative-rule.is-drawn .tail-piece {
  opacity: 1;
}

/* ============================================================
   Sweep headers
   ============================================================ */
.sweep-header {
  max-width: 720px;
  margin-bottom: 3rem;
}

.sweep-heading {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(36px, 4.6vw, 64px);
  letter-spacing: -0.008em;
  color: var(--iodine-sepia);
  line-height: 1.05;
  margin-bottom: 0.9rem;
  font-variation-settings: "opsz" var(--heading-opsz), "wght" var(--heading-wght), "SOFT" var(--heading-soft);
  transition: font-variation-settings 0.2s linear;
  will-change: font-variation-settings;
}

.sweep-subtitle {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.06em;
  color: var(--tobacco-bronze);
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
}

.sweep-subtitle .bullet { color: var(--iodine-sepia); }

.sweep-subtitle .latin-italic {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 18px;
  letter-spacing: 0;
  font-variation-settings: "opsz" 24, "wght" 500, "SOFT" 80, "slnt" -4;
  color: var(--iodine-sepia);
}

.sweep-lede {
  font-family: var(--font-body);
  font-size: clamp(15px, 1.05vw, 17px);
  line-height: 1.72;
  color: var(--iodine-sepia);
  max-width: 56ch;
}

/* ============================================================
   Sweep 2 — Program marquee
   ============================================================ */
.sweep--program {
  min-height: 60vh;
  padding-left: 16.6667%; /* columns 3-9 */
  padding-right: 5%;
}

.marquee-track-wrap {
  position: relative;
  width: 100%;
  height: 240px;
  overflow: hidden;
  mask-image: linear-gradient(to right, transparent 0, #000 4%, #000 96%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 4%, #000 96%, transparent 100%);
}

.marquee-track {
  position: absolute;
  top: 24px;
  left: 0;
  display: flex;
  gap: 24px;
  will-change: transform;
}

.dance-card {
  position: relative;
  flex: 0 0 auto;
  width: 280px;
  height: 180px;
  background: var(--tea-vellum);
  border: 1px solid var(--iodine-sepia);
  padding: 16px 22px 16px 22px;
  /* Envelope notch */
  clip-path: polygon(0 0, 100% 0, 100% 100%, 18px 100%, 0 calc(100% - 18px));
  box-shadow:
    4px 4px 0 -1px var(--burnt-ink),
    6px 6px 0 -2px rgba(58, 42, 28, 0.4);
  transition:
    transform 300ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 300ms ease;
}

.dance-card:hover {
  transform: scale(1.05) translateY(-4px);
  box-shadow:
    6px 6px 0 -1px var(--burnt-ink),
    10px 10px 18px -4px rgba(58, 42, 28, 0.32);
  z-index: 3;
}

.card-flower {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 48px;
  height: 48px;
  opacity: 0.85;
}

.card-date {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16px;
  color: var(--tobacco-bronze);
  font-variation-settings: "opsz" 24, "wght" 400, "SOFT" 70, "slnt" -8;
  margin-bottom: 0.4rem;
}

.card-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 18px;
  color: var(--iodine-sepia);
  line-height: 1.2;
  margin-bottom: 0.4rem;
  font-variation-settings: "opsz" 36, "wght" 500, "SOFT" 30;
  max-width: 14em;
}

.card-desc {
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.45;
  color: var(--iodine-sepia);
  opacity: 0.85;
  max-width: 18em;
}

.card-code {
  position: absolute;
  bottom: 10px;
  left: 22px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--tobacco-bronze);
}

.wax-seal-mini {
  position: absolute;
  bottom: 8px;
  right: 14px;
  width: 22px;
  height: 22px;
  opacity: 0.85;
}

/* ============================================================
   Sweep 3 — Glossary
   ============================================================ */
.sweep--glossary {
  min-height: 70vh;
  padding-left: 16.6667%;
}

.glossary-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 28px;
  margin-top: 1.5rem;
  max-width: 1100px;
}

.gloss-card {
  position: relative;
  width: 100%;
  min-height: 160px;
  padding: 16px 18px 28px 18px;
  background: var(--tea-vellum);
  border: 1px solid var(--iodine-sepia);
  transform: rotate(var(--tilt, 0deg));
  box-shadow:
    -3px 4px 0 -1px rgba(58, 42, 28, 0.5),
    -4px 6px 8px -2px rgba(58, 42, 28, 0.18);
  transition:
    transform 320ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 320ms ease;
  background-image:
    radial-gradient(circle at 22% 30%, rgba(168, 118, 68, 0.10) 0px, transparent 4px),
    radial-gradient(circle at 78% 64%, rgba(91, 58, 31, 0.08) 0px, transparent 3px);
}

.gloss-card::before {
  /* paper-grain micro spot */
  content: "";
  position: absolute;
  top: -6px; left: 50%;
  transform: translateX(-50%);
  width: 14px; height: 14px;
  background: radial-gradient(circle, rgba(217, 114, 143, 0.4) 0%, rgba(217, 114, 143, 0.1) 60%, transparent 90%);
  border-radius: 50%;
}

.gloss-card:hover {
  transform: rotate(0deg) translateY(-6px);
  box-shadow:
    0 6px 10px -1px rgba(58, 42, 28, 0.16),
    0 12px 22px -6px rgba(58, 42, 28, 0.22);
}

.gloss-card:hover .gloss-latin {
  transform: translateY(3px);
}

.gloss-latin {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 17px;
  color: var(--iodine-sepia);
  font-variation-settings: "opsz" 24, "wght" 500, "SOFT" 80, "slnt" -4;
  margin-bottom: 0.6rem;
  transition: transform 320ms ease;
}

.gloss-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14.5px;
  color: var(--tobacco-bronze);
  margin-bottom: 0.5rem;
  font-variation-settings: "opsz" 18, "wght" 500, "SOFT" 30;
}

.gloss-def {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  color: var(--iodine-sepia);
  opacity: 0.92;
}

.gloss-code {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--tobacco-bronze);
}

/* ============================================================
   Marginalia (handwritten notes)
   ============================================================ */
.marginalia {
  position: absolute;
  font-family: var(--font-margin);
  font-size: 20px;
  color: var(--faded-coral);
  line-height: 1.2;
  pointer-events: none;
  max-width: 260px;
  transform: rotate(-3deg);
  opacity: 0;
  transition: opacity 1.4s ease 0.6s;
}

.sweep.is-visible .marginalia {
  opacity: 0.92;
}

.margin-1 { top: 28%; right: 6%; transform: rotate(-5deg); }
.margin-2 { top: 18%; right: 4%; transform: rotate(4deg); }
.margin-3 { bottom: 18%; right: 8%; transform: rotate(-2deg); }

/* ============================================================
   Coda
   ============================================================ */
.sweep--coda {
  min-height: 60vh;
  padding: 7rem 5rem 8rem 5rem;
}

.coda-inner {
  max-width: 700px;
}

.coda-inner .sweep-heading {
  font-style: italic;
  font-variation-settings: "opsz" 144, "wght" 400, "SOFT" 60, "slnt" -4;
}

.coda-body {
  font-family: var(--font-body);
  font-size: clamp(15px, 1.05vw, 17px);
  line-height: 1.72;
  color: var(--iodine-sepia);
  margin-top: 1.5rem;
  max-width: 58ch;
}

.coda-signature {
  margin-top: 2rem;
  font-family: var(--font-margin);
  font-size: 20px;
  color: var(--faded-coral);
}

.coda-signature .latin-italic {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--iodine-sepia);
  font-size: 16px;
  margin-right: 0.5rem;
}

.coda-mark {
  margin-top: 2.5rem;
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 0.06em;
  color: var(--iodine-sepia);
  opacity: 0.72;
  font-variation-settings: "opsz" 24, "wght" 500, "SOFT" 60;
}

/* Conch ambient toggle */
.conch-toggle {
  margin-top: 3rem;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1rem 0.5rem 0.6rem;
  background: transparent;
  border: 1px dashed rgba(91, 58, 31, 0.35);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--tobacco-bronze);
  transition: background-color 300ms ease, border-color 300ms ease;
}

.conch-toggle svg {
  width: 22px; height: 22px;
}

.conch-toggle:hover {
  border-color: var(--pressed-iris);
  background-color: rgba(184, 154, 196, 0.10);
}

.conch-toggle.is-active {
  border-color: var(--faded-coral);
  color: var(--faded-coral);
}

.conch-label { text-transform: lowercase; }

/* ============================================================
   Phosphorescent jellyfish-jar (fixed corner)
   ============================================================ */
.jelly-jar {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 96px;
  height: 120px;
  z-index: 50;
  pointer-events: auto;
  animation: jarBob 6s ease-in-out infinite;
  cursor: pointer;
}

.jelly-jar svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(2px 4px 6px rgba(58, 42, 28, 0.22));
}

@keyframes jarBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-2px); }
}

.jelly-bell {
  transform-origin: 48px 56px;
  animation: bellPulse 4.5s ease-in-out infinite;
}

.jelly-jar.is-accel .jelly-bell {
  animation-duration: 2.2s;
  transition: animation-duration 800ms ease;
}

@keyframes bellPulse {
  0%, 100% { transform: scaleY(1) scaleX(1); }
  50%      { transform: scaleY(1.08) scaleX(0.96); }
}

.jelly-tent {
  animation: tentWaver 3.7s ease-in-out infinite;
  transform-origin: top center;
}
.jelly-tent-1 { animation-delay: 0s; }
.jelly-tent-2 { animation-delay: 0.7s; }
.jelly-tent-3 { animation-delay: 1.4s; }

@keyframes tentWaver {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  25%      { transform: translateX(1.5px) rotate(2deg); }
  75%      { transform: translateX(-1.5px) rotate(-2deg); }
}

/* ============================================================
   Sweep reveal-on-scroll
   ============================================================ */
.sweep {
  opacity: 1;
}

.sweep > .sweep-header,
.sweep > .glossary-grid,
.sweep > .marquee-track-wrap,
.sweep > .coda-inner {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 1.2s ease-out, transform 1.2s ease-out;
}

.sweep.is-visible > .sweep-header,
.sweep.is-visible > .glossary-grid,
.sweep.is-visible > .marquee-track-wrap,
.sweep.is-visible > .coda-inner {
  opacity: 1;
  transform: translateY(0);
}

.sweep--hero .hero-inner {
  opacity: 0;
  transform: translateY(8px);
  animation: heroFade 1.4s ease-out 1s forwards;
}

@keyframes heroFade {
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
  .hero-inner { opacity: 1; transform: none; }
  .brand-svg-text { fill: var(--iodine-sepia); stroke-dashoffset: 0; }
  .wax-seal { opacity: 0.92; }
  .opening-rule .rule-line { stroke-dashoffset: 0; }
  .spine-specimen { opacity: 0.92; }
  .spine-specimen .ink-stroke { stroke-dashoffset: 0; }
  .sweep-heading { font-variation-settings: "opsz" 60, "wght" 500, "SOFT" 60; }
  .marquee-track { transform: none !important; flex-wrap: wrap; }
  .jelly-bell { transform: scaleY(1.04) scaleX(0.98); animation: none; }
  .sweep > * { opacity: 1 !important; transform: none !important; }
}

/* ============================================================
   Mobile (<720px)
   ============================================================ */
@media (max-width: 720px) {
  .specimen-spine {
    width: 36px;
  }
  .spine-specimen { width: 30px; }
  .spine-inner { gap: 18vh; padding: 4vh 0; }

  .content {
    margin-left: 36px;
    width: calc(100vw - 36px);
  }

  .sweep { padding: 3.5rem 1.25rem; }
  .sweep--program { padding-left: 1.25rem; }
  .sweep--glossary { padding-left: 1.25rem; }
  .sweep--coda { padding: 4rem 1.25rem; }

  .hero-titlewrap {
    flex-direction: column;
    align-items: flex-start;
  }

  .wax-seal { width: 56px; height: 56px; }

  .marquee-track-wrap {
    height: auto;
    overflow: visible;
    mask-image: none;
    -webkit-mask-image: none;
  }

  .marquee-track {
    position: relative;
    flex-direction: column;
    gap: 18px;
    transform: none !important;
  }

  .marquee-track .dup { display: none; }

  .dance-card {
    width: 100%;
    max-width: 320px;
  }

  .glossary-grid {
    grid-template-columns: 1fr;
  }

  .marginalia { display: none; }

  .jelly-jar {
    width: 72px;
    height: 90px;
    bottom: 12px;
    right: 12px;
  }

  .decorative-rule { width: 88%; }
}
