/* ═══════════════════════════════════════════════════════════
   For Fasila — kasavu
   The page is a length of handloom cloth. The gold border
   stripe runs down the selvedge and carries the story.
   ═══════════════════════════════════════════════════════════ */

:root {
  /* cloth */
  --cloth:      #F7F4ED;
  --cloth-deep: #EFEADE;
  --ink:        #26221C;
  --ink-soft:   #6B6459;
  --ink-faint:  #A79E90;

  /* the border */
  --gold:       #C9A227;
  --gold-lit:   #E8C766;
  --leaf:       #1F4D3A;
  --marigold:   #E8A317;
  --rose:       #B0304A;

  /* before colour arrives */
  --grey:       #9A968E;

  --measure: 34rem;
  --stripe-x: 2.25rem;   /* left edge of the page to the thread */
  --indent: 1.6rem;      /* the thread to the start of the text */
  --gap: clamp(5.5rem, 13vh, 9rem);

  --ease: cubic-bezier(.22, .61, .36, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--cloth);
  color: var(--ink);
  font-family: Manjari, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: clamp(1.0625rem, 0.98rem + 0.42vw, 1.1875rem);
  line-height: 1.72;
  overflow-x: hidden;

  /* the weave: two whisper-fine thread directions */
  background-image:
    repeating-linear-gradient(90deg, rgba(38,34,28,.022) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(0deg,  rgba(38,34,28,.018) 0 1px, transparent 1px 3px);
}

.skip {
  position: absolute; left: -9999px;
  background: var(--ink); color: var(--cloth);
  padding: .7rem 1.1rem; z-index: 100; border-radius: 2px;
}
.skip:focus { left: 1rem; top: 1rem; }

:focus-visible {
  outline: 2px solid var(--leaf);
  outline-offset: 4px;
  border-radius: 2px;
}

/* ── Opening ─────────────────────────────────────────────── */

.opening {
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: 4rem var(--stripe-x) 3rem calc(var(--stripe-x) + var(--indent));
  position: relative;
}

/* the selvedge: gold border of the cloth, always present */
.opening::before,
.timeline::before {
  content: "";
  position: absolute;
  left: calc(var(--stripe-x) - 1px);
  top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg,
    transparent, rgba(201,162,39,.16) 12%, rgba(201,162,39,.16) 88%, transparent);
}

/* min-width:0 so the headline can wrap instead of pushing past the cloth */
.opening-inner { width: 100%; min-width: 0; max-width: var(--measure); }

.opening-for {
  margin: 0 0 2.25rem;
  font-size: .95rem;
  letter-spacing: .12em;
  color: var(--gold);
  font-weight: 700;
}

.opening-title {
  font-family: Eczar, Georgia, serif;
  font-weight: 500;
  font-size: clamp(1.85rem, 1.05rem + 3.9vw, 4.25rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 1.5rem;
  overflow-wrap: break-word;
}

.opening-sub {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1.15rem;
}

.opening-cue {
  display: inline-flex;
  align-items: center;
  gap: .9rem;
  margin-top: 3.5rem;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: .95rem;
  letter-spacing: .06em;
}
.opening-cue-line {
  display: block; width: 3rem; height: 1px;
  background: var(--gold);
  transform-origin: left;
  animation: reach 2.6s var(--ease) infinite;
}
.opening-cue-word { transition: color .3s; }
.opening-cue:hover .opening-cue-word { color: var(--ink); }

@keyframes reach {
  0%, 100% { transform: scaleX(1);   opacity: .55; }
  50%      { transform: scaleX(1.7); opacity: 1; }
}

/* ── Timeline ────────────────────────────────────────────── */

.timeline {
  position: relative;
  padding: 2rem var(--stripe-x) 6rem;
}

/* the drawn thread — sits on the selvedge and grows with scroll */
.thread {
  position: absolute;
  left: calc(var(--stripe-x) - 1px);
  width: 2px;
  top: 0; height: 0;              /* measured in story.js */
  pointer-events: none;
}
.thread-fill {
  width: 100%; height: 0%;
  background: linear-gradient(180deg, var(--gold-lit), var(--gold));
  box-shadow: 0 0 10px rgba(201,162,39,.4);
  transition: height .12s linear;
}

.chapters {
  list-style: none;
  margin: 0;
  padding: 0 0 0 var(--indent);
  max-width: calc(var(--measure) + var(--indent));
}

.chapter {
  position: relative;
  padding-bottom: var(--gap);
  opacity: 0;
  transition: opacity 1.1s var(--ease);
}
.chapter.is-visible { opacity: 1; }
.chapter:last-child { padding-bottom: 3rem; }

/* the knot tied onto the thread at each chapter */
.knot {
  position: absolute;
  left: calc(var(--indent) * -1);
  top: .55rem;
  width: 11px; height: 11px;
  margin-left: -4.5px;
  border-radius: 50%;
  background: var(--cloth);
  border: 2px solid var(--gold);
  transform: scale(0);
  transition: transform .5s var(--ease) .1s;
}
.chapter.is-visible .knot { transform: scale(1); }
.chapter--grey .knot { border-color: var(--grey); }

.chapter-mark {
  display: block;
  font-family: Eczar, Georgia, serif;
  font-size: .9rem;
  color: var(--gold);
  margin-bottom: .35rem;
}
.chapter--grey .chapter-mark { color: var(--grey); }

.chapter-title {
  font-family: Eczar, Georgia, serif;
  font-weight: 500;
  font-size: clamp(1.6rem, 1.2rem + 1.7vw, 2.35rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 1.1rem;
  text-wrap: balance;
}
.chapter--grey .chapter-title { color: var(--grey); }

.chapter-body { margin: 0; max-width: 33rem; }
.chapter-body + .chapter-body { margin-top: 1.1rem; }
.chapter--grey .chapter-body { color: var(--ink-faint); }

/* illustrations */
.scene {
  color: var(--ink-soft);
  display: block;
  width: min(100%, 22rem);
  height: auto;
  margin: 1.9rem 0 0;
  overflow: visible;
}
.scene .draw {
  stroke-dasharray: var(--len, 600);
  stroke-dashoffset: var(--len, 600);
  transition: stroke-dashoffset 1.9s var(--ease);
}
.chapter.is-visible .scene .draw { stroke-dashoffset: 0; }
.chapter--grey .scene { color: var(--grey); }
.scene .pop {
  opacity: 0;
  transform: scale(.6);
  transform-box: fill-box;
  transform-origin: center;
  transition: opacity .7s var(--ease) 1s, transform .7s var(--ease) 1s;
}
.chapter.is-visible .scene .pop { opacity: 1; transform: scale(1); }

/* the one chapter where the thread becomes two */
.split {
  position: absolute;
  left: calc(var(--indent) * -1);
  margin-left: -21px;
  top: 1.6rem;
  width: 42px;
  height: 210px;
  pointer-events: none;
}
.split path {
  fill: none;
  stroke: var(--gold);
  stroke-width: 2;
  stroke-dasharray: 240;
  stroke-dashoffset: 240;
  transition: stroke-dashoffset 1.8s var(--ease) .2s;
}
.split .strand-alias { stroke: var(--ink-faint); stroke-dasharray: 6 5; }
.chapter.is-visible .split path { stroke-dashoffset: 0; }

/* ── The question ────────────────────────────────────────── */

.question {
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: 5rem var(--stripe-x) 5rem calc(var(--stripe-x) + var(--indent));
  background: var(--cloth-deep);
  border-top: 1px solid rgba(201,162,39,.28);
}
.question[hidden] { display: none; }
.question-inner { width: 100%; min-width: 0; max-width: var(--measure); }

.question-title {
  font-family: Eczar, Georgia, serif;
  font-weight: 500;
  font-size: clamp(1.9rem, 1.25rem + 3.1vw, 3.4rem);
  line-height: 1.16;
  margin: 0 0 3rem;
  text-wrap: balance;
}
.question-title em { font-style: italic; color: var(--rose); }

.answers {
  position: relative;
  min-height: 15rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem;
}

.btn {
  font-family: Manjari, system-ui, sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  padding: .95rem 2.4rem;
  min-height: 3.25rem;
  border-radius: 999px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform .28s var(--ease), background-color .3s, color .3s, font-size .3s, padding .3s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn-yes {
  background: var(--leaf);
  color: #F7F4ED;
}
.btn-yes:hover { background: #163B2C; }
.btn-no {
  background: transparent;
  color: var(--ink-soft);
  border-color: rgba(38,34,28,.25);
}
.btn-no.is-loose {
  position: absolute;
  margin: 0;
  z-index: 2;
  white-space: nowrap;   /* it keeps its pill shape however it protests */
}
.btn-no.is-done {
  background: var(--leaf);
  color: #F7F4ED;
  border-color: transparent;
}

.question-note {
  margin: 1.5rem 0 0;
  min-height: 1.7rem;
  color: var(--ink-faint);
  font-size: .98rem;
}

/* ── Celebration ─────────────────────────────────────────── */

.celebration {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: 5rem var(--stripe-x) 5rem calc(var(--stripe-x) + var(--indent));
  background: var(--cloth);
  overflow: hidden;
}
.celebration[hidden] { display: none; }

.petals {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

.celebration-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  min-width: 0;
  max-width: var(--measure);
}

.celebration-eyebrow {
  margin: 0 0 1rem;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: .1em;
}
.celebration-title {
  font-family: Eczar, Georgia, serif;
  font-weight: 500;
  font-size: clamp(2.1rem, 1.35rem + 3.6vw, 3.8rem);
  line-height: 1.14;
  margin: 0 0 1.6rem;
  color: var(--rose);
  text-wrap: balance;
}
.celebration-body { margin: 0 0 2.4rem; max-width: 31rem; }
.celebration-sign {
  margin: 0;
  font-family: Eczar, Georgia, serif;
  font-size: 1.35rem;
}
.celebration-alias { color: var(--ink-faint); font-size: 1rem; }
.celebration-date {
  margin: .4rem 0 2.5rem;
  color: var(--ink-faint);
  font-size: .95rem;
}

.link-btn {
  background: none; border: 0;
  padding: .5rem 0;
  color: var(--ink-soft);
  font-family: inherit; font-size: .98rem;
  cursor: pointer;
  border-bottom: 1px solid var(--gold);
}
.link-btn:hover { color: var(--ink); }

/* ── Wider screens ───────────────────────────────────────── */

@media (min-width: 46rem) {
  :root { --stripe-x: 6.5rem; --indent: 2.25rem; }
}

@media (min-width: 64rem) {
  :root { --stripe-x: 11vw; --indent: 2.75rem; --measure: 40rem; }
  .opening-title, .question-title, .celebration-title, .chapter-title { text-wrap: balance; }
  .scene { width: min(100%, 26rem); }
}

/* Wide enough to hang the cloth properly: a selvedge down each side
   with the story in the field between them. */
@media (min-width: 82rem) {
  :root {
    --stripe-x: calc((100vw - var(--measure) - var(--indent) - 4rem) / 2);
  }
  body::after {
    content: "";
    position: fixed;
    right: var(--stripe-x); top: 0; bottom: 0;
    width: 2px;
    background: linear-gradient(180deg,
      transparent, rgba(201,162,39,.16) 12%, rgba(201,162,39,.16) 88%, transparent);
    pointer-events: none;
  }
}

/* ── Reduced motion ──────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .opening-cue-line { animation: none; }
  .chapter { opacity: 1; transition: none; }
  .knot { transform: scale(1); transition: none; }
  .scene .draw { stroke-dashoffset: 0; transition: none; }
  .scene .pop { opacity: 1; transform: none; transition: none; }
  .split path { stroke-dashoffset: 0; transition: none; }
  .thread-fill { transition: none; }
  .btn { transition: none; }
}
