/* ============ LETTERS ============
   Three letters on one sheet of paper. A segmented switcher picks the
   letter, words ink in as she reads, a rail beside the paper fills with
   her progress, and the signature is underlined (and, on the newest
   letter, sealed) once the last word is read. Logic in letters.js. */

.lt { max-width: 720px; margin: 0 auto; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- Switcher ---- */
.lt-tabs {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  max-width: 600px;
  margin: 0 auto 1.5rem;
  padding: 0.35rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(217, 108, 138, 0.16);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: 0 16px 40px -20px rgba(61, 44, 51, 0.28);
}
.lt-glider {
  --at: 0;
  position: absolute;
  top: 0.35rem;
  bottom: 0.35rem;
  left: 0.35rem;
  width: calc((100% - 0.7rem) / 5);
  border-radius: 999px;
  background: linear-gradient(160deg, #4A3540, var(--ink));
  box-shadow: 0 10px 24px -10px rgba(61, 44, 51, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  transform: translateX(calc(var(--at) * 100%));
  transition: transform 0.28s var(--ease-in-out-strong);
}
.lt-tab {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.72rem 0.3rem;
  border: 0;
  border-radius: 999px;
  background: none;
  font: inherit;
  color: var(--ink-soft);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.3s ease, transform 0.16s var(--ease-out-strong);
}
.lt-tab:active { transform: scale(0.96); }
.lt-tab[aria-selected="true"] { color: var(--cream); }
.lt-tab:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; }
.lt-tab-num {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  opacity: 0.55;
}
.lt-tab-label { font-size: 0.9rem; font-weight: 700; }
.lt-new {
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rose);
  flex-shrink: 0;
}
.lt-new::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--rose);
  animation: lt-ping 1.9s var(--ease-out-strong) infinite;
}
.lt-tab[aria-selected="true"] .lt-new,
.lt-tab[aria-selected="true"] .lt-new::after { background: var(--rose-soft); }
.lt-new.is-read { display: none; }
@keyframes lt-ping {
  0% { transform: scale(1); opacity: 0.6; }
  80%, 100% { transform: scale(2.8); opacity: 0; }
}

/* ---- Paper ---- */
.lt-shell {
  background: rgba(217, 108, 138, 0.06);
  border: 1px solid rgba(217, 108, 138, 0.12);
  border-radius: var(--radius-xl);
  padding: 0.5rem;
}
.lt-paper {
  position: relative;
  isolation: isolate;
  border-radius: calc(var(--radius-xl) - 0.5rem);
  padding: clamp(2.3rem, 7vw, 3.8rem) clamp(1.7rem, 6.4vw, 3.8rem) clamp(2.2rem, 6vw, 3.4rem);
  background:
    radial-gradient(120% 40% at 50% 0%, #FFFFFF 0%, rgba(255, 255, 255, 0) 70%),
    linear-gradient(180deg, #FFFDFB 0%, #FCF3EE 100%);
  box-shadow: var(--shadow-ambient), inset 0 1px 1px rgba(255, 255, 255, 0.95);
}
/* inner frame */
.lt-paper::before {
  content: '';
  position: absolute;
  inset: 0.7rem;
  border: 1px solid rgba(217, 108, 138, 0.15);
  border-radius: calc(var(--radius-xl) - 1.2rem);
  pointer-events: none;
}
/* paper tooth */
.lt-paper::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  opacity: 0.05;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* reading rail on the frame line */
.lt-rail {
  position: absolute;
  left: calc(0.7rem - 0.5px);
  top: 3.2rem;
  bottom: 3.2rem;
  width: 2px;
  border-radius: 2px;
  overflow: hidden;
  pointer-events: none;
}
.lt-rail i {
  display: block;
  height: 100%;
  background: linear-gradient(180deg, var(--rose-soft), var(--rose) 60%, var(--maroon-soft));
  transform: scaleY(0);
  transform-origin: 50% 0;
  transition: transform 0.6s var(--ease-out-strong);
}

/* ---- Letter page ---- */
.lt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.lt-kicker { color: var(--rose); }
.lt-read {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  letter-spacing: 0.1em;
  font-variant-numeric: tabular-nums;
}
.lt-read svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}
.lt-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin: 1.7rem 0 1.9rem;
  color: var(--rose);
}
.lt-ornament svg { width: 0.85rem; height: 0.85rem; fill: currentColor; }
.lt-ornament span {
  width: 3.4rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(217, 108, 138, 0.55));
}
.lt-ornament span:last-child { transform: scaleX(-1); }

.lt-salute {
  font-size: clamp(1.4rem, 5.6vw, 1.85rem);
  font-weight: 900;
  line-height: 1.5;
  letter-spacing: -0.01em;
  margin-bottom: 1.1rem;
}
.lt-body p {
  font-size: clamp(1.06rem, 4.1vw, 1.26rem);
  line-height: 2.05;
  color: var(--ink);
  text-wrap: pretty;
  margin-bottom: 1.35em;
}
.lt-body p:last-child { margin-bottom: 0; }

/* ---- Illuminated drop cap (SVG, built in letters.js) ----
   final state is the default; .lt-ink hides it until .lit plays the sequence:
   frame draws (0–0.9s) → outline traced (0.2–1.5s) → ink rises (0.9–2s)
   → outline softens + tile blushes (1.6s) → one sheen (1.9–2.8s) */
.lt-drop {
  float: left;
  width: 4.35em;
  height: 4.35em;
  margin: 0.42em 0.85em 0.1em 0;
  font-size: 1rem;
}
.lt-drop-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.lt-drop-glyph {
  font-family: 'Thmanyah Sans', system-ui, sans-serif;
  font-size: 82px;
  font-weight: 900;
}
.lt-drop-inner {
  fill: none;
  stroke: rgba(217, 108, 138, 0.38);
  stroke-width: 0.9;
  stroke-dasharray: 0.012 0.012;
  opacity: 1;
}
.lt-drop-heart circle {
  fill: var(--rose);
  stroke: #FFFDFB;
  stroke-width: 2.5;
}
.lt-drop-heart use { fill: #fff; }
.lt-drop-heart {
  transform-box: fill-box;
  transform-origin: center;
}
.lt-drop-box {
  fill: #FBE3EA;
  fill-opacity: 0.6;
  stroke: rgba(217, 108, 138, 0.5);
  stroke-width: 1.4;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}
.lt-drop-line {
  fill: none;
  stroke: var(--rose);
  stroke-width: 1.3;
  stroke-linejoin: round;
  stroke-dasharray: 620;
  stroke-dashoffset: 0;
  stroke-opacity: 0.35;
}
.lt-drop-rise { transform: none; }
.lt-drop-sheen { transform: translateX(0); }

.lt-ink .lt-drop.w { opacity: 1; } /* the drawing is its reveal */
.lt-ink .lt-drop .lt-drop-box { stroke-dashoffset: 1; fill-opacity: 0; }
.lt-ink .lt-drop .lt-drop-line { stroke-dashoffset: 620; stroke-opacity: 1; }
.lt-ink .lt-drop .lt-drop-rise { transform: translateY(100px); }
.lt-ink .lt-drop .lt-drop-inner { opacity: 0; }
.lt-ink .lt-drop .lt-drop-heart { opacity: 0; transform: scale(0.4) rotate(-30deg); }
.lt-ink .lt-drop.lit .lt-drop-inner {
  opacity: 1;
  transition: opacity 0.9s ease 1.7s;
}
.lt-ink .lt-drop.lit .lt-drop-heart {
  opacity: 1;
  transform: rotate(-10deg);
  transition: transform 0.55s var(--ease-spring) 2.25s, opacity 0.2s ease 2.25s;
}

.lt-ink .lt-drop.lit .lt-drop-box {
  stroke-dashoffset: 0;
  fill-opacity: 0.6;
  transition: stroke-dashoffset 0.9s var(--ease-in-out-strong), fill-opacity 0.9s ease 1.6s;
}
.lt-ink .lt-drop.lit .lt-drop-line {
  stroke-dashoffset: 0;
  stroke-opacity: 0.35;
  transition: stroke-dashoffset 1.3s var(--ease-in-out-strong) 0.2s, stroke-opacity 0.8s ease 1.6s;
}
.lt-ink .lt-drop.lit .lt-drop-rise {
  transform: none;
  transition: transform 1.1s var(--ease-in-out-strong) 0.9s;
}
.lt-ink .lt-drop.lit .lt-drop-sheen {
  transform: translateX(170px);
  transition: transform 0.95s var(--ease-out-strong) 1.9s;
}

/* the short one-sentence paragraphs are the letter's turning points */
.lt-body p.lt-beat {
  max-width: 17em;
  margin: 2.3em auto;
  font-size: clamp(1.28rem, 5.3vw, 1.65rem);
  font-weight: 700;
  line-height: 1.6;
  text-align: center;
  text-wrap: balance;
  color: var(--maroon);
}
.lt-body p.lt-beat::before {
  content: '';
  display: block;
  width: 2.2rem;
  height: 1px;
  margin: 0 auto 1em;
  background: rgba(217, 108, 138, 0.5);
}

/* ---- Ink as she reads ---- */
.lt-ink .w { opacity: 0.17; transition: opacity 0.75s ease; }
.lt-ink .w.lit { opacity: 1; }

/* ---- Signature ---- */
.lt-sign {
  position: relative;
  margin-top: 2.7rem;
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.8;
  color: var(--rose);
}
.lt-sign-ar {
  font-size: clamp(1.2rem, 5vw, 1.45rem);
  line-height: 1.9;
  color: var(--maroon);
  text-align: right;
}
.lt-sign-ar strong { font-weight: 900; }
.lt-sign-love {
  margin-top: 0.5rem;
  font-size: 1.25em;
  font-weight: 900;
  background: linear-gradient(120deg, var(--rose), var(--maroon-soft));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.lt-ink .lt-sign.is-in > p.lt-sign-love { transition-delay: 0.45s; }
.lt-underline {
  display: block;
  width: min(15rem, 70%);
  height: 0.9rem;
  margin-top: 0.3rem;
  overflow: visible;
  fill: none;
  stroke: var(--rose-soft);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
.lt-sign-ar .lt-underline { margin-left: auto; transform: scaleX(-1); }
.lt-sign.is-in .lt-underline {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1.3s var(--ease-in-out-strong) 0.25s;
}
.lt-ink .lt-sign > p {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.8s ease, transform 0.8s var(--ease-out-strong);
}
.lt-ink .lt-sign.is-in > p { opacity: 1; transform: none; }

/* wax seal that stamps down on the newest letter */
.lt-seal {
  display: grid;
  place-items: center;
  width: 3.3rem;
  height: 3.3rem;
  margin: 1.6rem auto 0;
  border-radius: 50%;
  color: rgba(255, 222, 230, 0.9);
  background: radial-gradient(circle at 34% 28%, #B24E68 0%, #7C2B3F 48%, #521A28 100%);
  box-shadow:
    0 12px 26px -10px rgba(82, 26, 40, 0.7),
    inset 0 2px 3px rgba(255, 255, 255, 0.28),
    inset 0 -4px 7px rgba(0, 0, 0, 0.3);
}
.lt-seal::before {
  content: '';
  position: absolute;
  width: 2.55rem;
  height: 2.55rem;
  border-radius: 50%;
  border: 1px dashed rgba(255, 222, 230, 0.35);
}
.lt-seal { position: relative; }
.lt-seal svg { width: 1.25rem; height: 1.25rem; fill: currentColor; }
.lt-ink .lt-seal {
  opacity: 0;
  transform: scale(1.7) rotate(-24deg);
}
.lt-ink .lt-sign.is-in .lt-seal {
  opacity: 1;
  transform: rotate(-8deg);
  transition: transform 0.5s var(--ease-spring) 1.1s, opacity 0.15s ease 1.1s;
}

/* ---- Next letter ---- */
.lt-next {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 2.6rem;
  padding: 0.62rem 1rem 0.62rem 1.35rem;
  border: 1px solid rgba(217, 108, 138, 0.26);
  border-radius: 999px;
  background: rgba(217, 108, 138, 0.05);
  color: var(--rose);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.16s var(--ease-out-strong);
}
.lt-next:active { transform: scale(0.97); }
.lt-next svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
@media (hover: hover) and (pointer: fine) {
  .lt-next:hover { background: var(--rose-mist); }
  .lt-tab:not([aria-selected="true"]):hover { color: var(--ink); }
}

/* ============ THE BOX ============ */
.letter-section > .section-head,
.letter-section > .lt { position: relative; z-index: 1; }

/* ---- Stack: the other letters as sheets peeking behind ---- */
.lt-stack {
  position: relative;
  margin-top: 2.4rem;
  perspective: 1600px;
}
.lt-sheet {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 16rem;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(217, 108, 138, 0.18);
  transform-origin: 50% 0;
  pointer-events: none;
}
.lt-sheet-a {
  background: linear-gradient(180deg, #FFF8F6, #FBEDEA 60%);
  box-shadow: 0 -8px 26px -18px rgba(61, 44, 51, 0.3);
  transform: translate3d(0, -13px, 0) scale(0.962) rotate(-1.1deg);
}
.lt-sheet-b {
  background: linear-gradient(180deg, #FCEFF1, #F6E1E3 60%);
  box-shadow: 0 -8px 26px -18px rgba(61, 44, 51, 0.25);
  transform: translate3d(0, -25px, 0) scale(0.925) rotate(1.4deg);
}
.lt-shell {
  position: relative;
  z-index: 1;
  transform-origin: 50% 0;
}
.lt-shell::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(217, 108, 138, 0.45), 0 40px 110px -30px rgba(217, 108, 138, 0.75);
  opacity: 0;
}

/* ---- Deal: paper lays down, the sheets fan out behind it ---- */
.lt-anim .lt-shell {
  opacity: 0;
  transform: translate3d(0, 80px, 0) rotateX(11deg) scale(0.96);
}
.lt-anim .lt-sheet { opacity: 0; transform: translate3d(0, 0, 0) scale(0.99); }
.lt-anim.is-dealt .lt-shell {
  opacity: 1;
  transform: none;
  transition: transform 1.25s var(--ease-out-strong), opacity 0.7s ease;
}
.lt-anim.is-dealt .lt-sheet-a {
  opacity: 1;
  transform: translate3d(0, -13px, 0) scale(0.962) rotate(-1.1deg);
  transition: transform 0.9s var(--ease-out-strong) 0.45s, opacity 0.35s ease 0.45s;
}
.lt-anim.is-dealt .lt-sheet-b {
  opacity: 1;
  transform: translate3d(0, -25px, 0) scale(0.925) rotate(1.4deg);
  transition: transform 0.9s var(--ease-out-strong) 0.58s, opacity 0.35s ease 0.58s;
}

/* ---- One sheen across the top of the paper ---- */
.lt-shine {
  position: absolute;
  inset: 0 0 auto 0;
  height: min(40rem, 100%);
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}
.lt-shine i {
  position: absolute;
  top: -10%;
  bottom: -10%;
  left: 0;
  width: 36%;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.8) 50%, rgba(255, 255, 255, 0) 100%);
  transform: translateX(-120%) skewX(-14deg);
}

/* ---- Pen tip riding the reading rail ---- */
.lt-tip {
  position: absolute;
  left: calc(0.7rem - 5.5px);
  top: calc(3.2rem - 5px);
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--rose);
  box-shadow: 0 0 0 3px rgba(255, 253, 251, 0.95), 0 0 18px 3px rgba(217, 108, 138, 0.55);
  transition: transform 0.6s var(--ease-out-strong), background-color 0.4s ease;
  pointer-events: none;
  z-index: 3;
}
.lt-tip::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1.5px solid var(--rose-soft);
  animation: lt-tip-pulse 2.2s var(--ease-out-strong) infinite;
}
.lt-tip.is-done { background: var(--maroon-soft); }
.lt-tip.is-done::after { animation: none; opacity: 0; }
@keyframes lt-tip-pulse {
  0% { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* ---- Finished a letter: the box blooms ---- */
.lt-stack.is-bloom .lt-shell::after { animation: lt-bloom 2.6s var(--ease-out-strong) 0.6s both; }
@keyframes lt-bloom {
  0% { opacity: 0; }
  30% { opacity: 1; }
  100% { opacity: 0.35; }
}

/* ---- Ambient: breathing glow + falling rose petals (only while in view) ---- */
.lt-ambient {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  margin-bottom: -100vh;
  margin-bottom: -100svh;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.lt-aura {
  position: absolute;
  left: 50%;
  top: 46%;
  width: min(130vw, 980px);
  height: 70vh;
  translate: -50% -50%;
  background: radial-gradient(closest-side, rgba(232, 160, 176, 0.42), rgba(242, 196, 179, 0.16) 55%, transparent);
  animation: lt-breathe 7s ease-in-out infinite alternate;
}
@keyframes lt-breathe {
  from { opacity: 0.55; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1.06); }
}
.lt-gust {
  position: absolute;
  inset: 0;
  transition: transform 0.9s var(--ease-out-strong);
  will-change: transform;
}
.lt-petal {
  position: absolute;
  top: 0;
  left: var(--x);
  width: calc(18px * var(--k));
  height: calc(24px * var(--k));
  animation: lt-fall var(--s) linear var(--d) infinite;
}
.lt-petal i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 80% 0 80% 10%;
  background: linear-gradient(140deg, #F6C9D4 0%, #E8A0B0 45%, #D96C8A 100%);
  box-shadow: inset -2px -3px 5px rgba(110, 36, 54, 0.18), inset 2px 2px 4px rgba(255, 255, 255, 0.5);
  opacity: 0.8;
  animation: lt-tumble calc(var(--s) / 4) ease-in-out var(--d) infinite alternate;
}
@keyframes lt-fall {
  from { transform: translate3d(0, -12vh, 0); }
  to { transform: translate3d(var(--dx), 112vh, 0); }
}
@keyframes lt-tumble {
  from { transform: rotate(0deg) rotateX(0deg) translateX(-14px); }
  to { transform: rotate(var(--r)) rotateX(55deg) translateX(14px); }
}
.lt-ambient:not(.is-live) .lt-aura,
.lt-ambient:not(.is-live) .lt-petal,
.lt-ambient:not(.is-live) .lt-petal i { animation-play-state: paused; }

/* four tabs on a phone: tighten so "04 Newest" + dot still fit */
/* five tabs don't fit words on a phone: numbers only, a little bigger */
@media (max-width: 559px) {
  .lt-tab { gap: 0.3rem; padding-inline: 0.15rem; }
  .lt-tab-label { display: none; }
  .lt-tab-num { font-size: 0.86rem; letter-spacing: 0.04em; opacity: 0.8; }
  .lt-tab[aria-selected="true"] .lt-tab-num { opacity: 1; }
}

/* the Arabic letter: same paper, right-to-left rhythm */
.lt-page-ar .lt-salute { line-height: 1.75; }
.lt-page-ar .lt-body p { line-height: 2.2; }
.lt-page-ar .lt-body p.lt-beat { line-height: 1.9; max-width: 19em; }

@media (min-width: 768px) {
  .lt-tabs { margin-bottom: 2rem; }
  .lt-sheet { height: 20rem; }
  .lt-body p { line-height: 2.1; }
}

@media (prefers-reduced-motion: reduce) {
  .lt-new::after,
  .lt-tip::after { animation: none; }
  .lt-tip { transition: none; }
  .lt-underline { stroke-dashoffset: 0; }
}
