/* ==================================================================
   Sadia — design system
   Typography : Great Vibes (name) · Outfit (UI) · Noto Serif Bengali (letter)
   Theming    : registered custom properties → every chapter has its own
                colour world and the page cross-fades between them.
================================================================== */
@property --bg1    { syntax: '<color>'; inherits: true; initial-value: #0d1030; }
@property --bg2    { syntax: '<color>'; inherits: true; initial-value: #2a1b4d; }
@property --accent { syntax: '<color>'; inherits: true; initial-value: #c9a7ff; }
@property --ink    { syntax: '<color>'; inherits: true; initial-value: #efeaff; }

:root {
  --ease: cubic-bezier(.22, .8, .24, 1);
  --radius: 22px;
  --radius-sm: 14px;
  --nav-h: 58px;
  --serif: 'Noto Serif Bengali', serif;
  --ui: 'Outfit', system-ui, sans-serif;
  --script: 'Great Vibes', cursive;
}

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

body {
  --bg1: #0d1030; --bg2: #2a1b4d; --accent: #c9a7ff; --ink: #efeaff;
  margin: 0; min-height: 100vh; min-height: 100dvh; overflow-x: hidden;
  font-family: var(--serif); color: var(--ink);
  background: radial-gradient(120% 90% at 50% 0%, var(--bg2), var(--bg1) 64%) fixed;
  transition: --bg1 1.4s ease, --bg2 1.4s ease, --accent 1.4s ease, --ink 1.4s ease;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body.is-locked { overflow: hidden; }

/* one colour world per feeling */
body[data-mood='stars']     { --bg1: #0d1030; --bg2: #2a1b4d; --accent: #c9a7ff; --ink: #efeaff; }
body[data-mood='fog']       { --bg1: #12161d; --bg2: #323c4a; --accent: #a9bdd1; --ink: #eaf0f6; }
body[data-mood='rain']      { --bg1: #06121e; --bg2: #0f3150; --accent: #6cb6ff; --ink: #e7f3ff; }
body[data-mood='embers']    { --bg1: #1a0a0a; --bg2: #52190f; --accent: #ff8a5c; --ink: #fff0e8; }
body[data-mood='fireflies'] { --bg1: #0c1612; --bg2: #2f3a14; --accent: #f3d36b; --ink: #fff8e2; }
body[data-mood='drizzle']   { --bg1: #1a0f20; --bg2: #4a2250; --accent: #ff9ec7; --ink: #ffeaf3; }
body[data-mood='pulse']     { --bg1: #060607; --bg2: #240810; --accent: #ff4d6d; --ink: #fff1f3; }

#c-fx, #c-grain { position: fixed; inset: 0; pointer-events: none; }
#c-fx { z-index: 1; }
#c-grain { z-index: 4; opacity: .035; mix-blend-mode: overlay; width: 100%; height: 100%; }

::selection { background: color-mix(in srgb, var(--accent) 45%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 4px; }

#progress {
  position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 9995; background: var(--accent);
  transform-origin: left; transform: scaleX(0);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 70%, transparent);
}

/* ================= splash ================= */
#splash {
  position: fixed; inset: 0; z-index: 99999; cursor: pointer; user-select: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px 28px;
  background: radial-gradient(ellipse at 50% 80%, #1a1020 0%, #07060c 72%);
  transition: opacity 1.2s ease, visibility 1.2s ease;
}
#splash.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.sp-orn { font-size: .55rem; letter-spacing: .7em; margin: 0 0 34px; color: rgba(201,167,255,.28); animation: fi 1s .2s both; }
.sp-pre { font-weight: 300; font-size: .74rem; letter-spacing: .34em; margin: 0 0 30px; color: rgba(201,167,255,.5); animation: fi 1s .4s both; }
.sp-name {
  font-weight: 400; margin: 0 0 10px; line-height: 1; font-size: clamp(5.2rem, 27vw, 9rem); color: #efeaff;
  text-shadow: 0 0 50px rgba(201,167,255,.4), 0 0 120px rgba(255,158,199,.16); animation: fi 1.6s .6s both;
}
.sp-bn { margin: 0 0 46px; font-size: .86rem; letter-spacing: .12em; color: rgba(239,234,255,.55); animation: fi 1s .95s both; }
.sp-enter { display: flex; flex-direction: column; align-items: center; gap: 16px; animation: fi .9s 1.6s both; }
.sp-enter-t { margin: 0; font-weight: 300; font-size: .82rem; letter-spacing: .22em; color: rgba(239,234,255,.55); }
.sp-hint { margin: 6px 0 0; font-size: .8rem; color: rgba(239,234,255,.35); }
.sp-pulse {
  position: relative; width: 50px; height: 50px; border-radius: 50%;
  border: 1px solid rgba(201,167,255,.3); display: grid; place-items: center; animation: pRing 2.2s ease-in-out infinite;
}
.sp-pulse::after { content: ''; width: 12px; height: 12px; border-radius: 50%; background: radial-gradient(circle, #efeaff, #c9a7ff); animation: pDot 2.2s ease-in-out infinite; }
@keyframes pRing { 0%,100% { box-shadow: 0 0 0 0 rgba(201,167,255,.22); transform: scale(1); } 50% { box-shadow: 0 0 0 14px rgba(201,167,255,0); transform: scale(1.06); } }
@keyframes pDot { 0%,100% { opacity: .5; } 50% { opacity: 1; transform: scale(1.3); } }
@keyframes fi { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ================= music button ================= */
#music-btn {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); z-index: 9990;
  width: 48px; height: 48px; border-radius: 50%; cursor: pointer; display: grid; place-items: center;
  color: var(--accent); background: color-mix(in srgb, var(--bg1) 80%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: transform .3s var(--ease), border-color .3s ease;
}
#music-btn:hover { transform: scale(1.06); }
#music-btn .bars { display: none; gap: 2.5px; align-items: center; height: 16px; }
#music-btn .bars i { width: 2.5px; height: 100%; border-radius: 2px; background: currentColor; transform-origin: center; animation: eq 1s ease-in-out infinite alternate; }
#music-btn .bars i:nth-child(2) { animation-delay: .15s; } #music-btn .bars i:nth-child(3) { animation-delay: .3s; }
#music-btn .bars i:nth-child(4) { animation-delay: .1s; } #music-btn .bars i:nth-child(5) { animation-delay: .25s; }
#music-btn[aria-pressed='true'] .note { display: none; }
#music-btn[aria-pressed='true'] .bars { display: flex; }
@keyframes eq { from { transform: scaleY(.3); } to { transform: scaleY(1); } }

/* ================= navbar ================= */
#navbar {
  position: fixed; inset: 0 0 auto 0; z-index: 9980; height: var(--nav-h); padding: 0 22px;
  background: color-mix(in srgb, var(--bg1) 72%, transparent); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 14%, transparent);
  transform: translateY(-100%); transition: transform .6s var(--ease);
}
#navbar.show { transform: none; }
.nav-inner { max-width: 1100px; height: 100%; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.nav-logo { font-size: 1.7rem; color: var(--accent); line-height: 1; }
.nav-links { display: flex; gap: 6px; }
.nav-link {
  padding: .45rem 1rem; border-radius: 99px; font-size: .78rem; letter-spacing: .14em; text-transform: uppercase;
  color: color-mix(in srgb, var(--ink) 60%, transparent); transition: color .3s ease, background .3s ease;
}
.nav-link:hover { color: var(--ink); }
.nav-link.active { color: var(--ink); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.nav-burger { display: none; width: 44px; height: 44px; background: none; border: 0; cursor: pointer; flex-direction: column; justify-content: center; align-items: center; gap: 5px; }
.nav-burger span { width: 22px; height: 1.5px; background: var(--ink); transition: transform .3s var(--ease), opacity .3s ease; }
.nav-burger[aria-expanded='true'] span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-burger[aria-expanded='true'] span:nth-child(2) { opacity: 0; }
.nav-burger[aria-expanded='true'] span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }
@media (max-width: 640px) {
  .nav-burger { display: flex; }
  .nav-links {
    position: absolute; top: var(--nav-h); left: 0; right: 0; flex-direction: column; gap: 2px; padding: 10px 18px 16px;
    background: color-mix(in srgb, var(--bg1) 94%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--accent) 14%, transparent);
    visibility: hidden; opacity: 0; transform: translateY(-8px); transition: opacity .3s ease, transform .3s var(--ease), visibility .3s;
  }
  .nav-links.open { visibility: visible; opacity: 1; transform: none; }
  .nav-link { padding: .8rem 1rem; }
}

/* ================= pages ================= */
#pages { position: relative; z-index: 2; padding-top: var(--nav-h); }
.page { display: none; min-height: calc(100dvh - var(--nav-h)); }
.page.active { display: block; animation: pgIn .7s var(--ease) both; }
@keyframes pgIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.site-foot { position: relative; z-index: 2; padding: 28px 20px 90px; text-align: center; font-size: .7rem; letter-spacing: .2em; color: color-mix(in srgb, var(--ink) 38%, transparent); }

/* ================= buttons ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 48px; padding: .65rem 1.6rem;
  border-radius: 99px; cursor: pointer; font: 500 .98rem/1.2 var(--serif); color: var(--ink);
  background: color-mix(in srgb, var(--accent) 18%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
  transition: background .3s ease, transform .3s var(--ease), border-color .3s ease;
}
.btn:hover { background: color-mix(in srgb, var(--accent) 32%, transparent); transform: translateY(-1px); }
.btn-ghost { background: transparent; border-color: color-mix(in srgb, var(--ink) 26%, transparent); }
.btn-ghost:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.btn-quiet { background: transparent; border-color: transparent; color: color-mix(in srgb, var(--ink) 62%, transparent); }
.btn[disabled] { opacity: .35; pointer-events: none; }

/* ================= home ================= */
.hero { min-height: calc(100dvh - var(--nav-h)); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 24px 70px; }
.hero-eyebrow { margin: 0 0 22px; font-family: var(--ui); font-weight: 300; font-size: .72rem; letter-spacing: .32em; text-transform: uppercase; color: var(--accent); }
.hero-name {
  margin: 0; font: 400 clamp(5.4rem, 28vw, 10rem)/.95 var(--script); color: var(--ink);
  text-shadow: 0 0 50px color-mix(in srgb, var(--accent) 45%, transparent);
}
.hero-bn { margin: 14px 0 0; font-weight: 300; font-size: .95rem; letter-spacing: .3em; color: color-mix(in srgb, var(--ink) 60%, transparent); }
.hero-div { display: flex; align-items: center; gap: 12px; margin: 34px 0; }
.hero-div i { width: 56px; height: 1px; background: color-mix(in srgb, var(--accent) 45%, transparent); }
.hero-div b { width: 6px; height: 6px; transform: rotate(45deg); background: var(--accent); }
.hero-quote { max-width: 24rem; margin: 0 0 40px; font-size: 1.12rem; line-height: 2.1; color: color-mix(in srgb, var(--ink) 86%, transparent); }
.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

.index-wrap { max-width: 56rem; margin: 0 auto; padding: 10px 22px 70px; }
.index-title { margin: 0 0 22px; font-weight: 500; font-size: 1.25rem; text-align: center; }
.index-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.index-card {
  display: block; height: 100%; padding: 20px 20px 22px; border-radius: var(--radius-sm); position: relative; overflow: hidden;
  background: linear-gradient(160deg, color-mix(in srgb, var(--m-bg2) 78%, #000), color-mix(in srgb, var(--m-bg1) 92%, #000));
  border: 1px solid color-mix(in srgb, var(--m-accent) 28%, transparent);
  transition: transform .4s var(--ease), border-color .3s ease;
}
.index-card:hover { transform: translateY(-3px); border-color: var(--m-accent); }
.index-card .tag { display: inline-block; margin-bottom: 14px; padding: .1rem .75rem; border-radius: 99px; font-size: .82rem; color: var(--m-accent); border: 1px solid color-mix(in srgb, var(--m-accent) 55%, transparent); }
.index-card h4 { margin: 0; font-size: 1.1rem; font-weight: 500; line-height: 1.6; color: var(--m-ink); }
.index-card .dot { position: absolute; right: -22px; bottom: -22px; width: 84px; height: 84px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--m-accent) 55%, transparent), transparent 70%); }

/* ================= reader ================= */
.reader { max-width: 46rem; margin: 0 auto; padding: 0 18px 40px; }
.tabs-wrap { position: sticky; top: var(--nav-h); z-index: 20; margin: 0 -18px; padding: 12px 18px; background: linear-gradient(color-mix(in srgb, var(--bg1) 85%, transparent), transparent); }
.tabs { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; min-width: 42px; height: 40px; padding: 0 .95rem; border-radius: 99px; cursor: pointer;
  font: 400 .9rem/1 var(--serif); color: color-mix(in srgb, var(--ink) 65%, transparent); background: transparent;
  border: 1px solid color-mix(in srgb, var(--ink) 20%, transparent); transition: all .3s ease;
}
.tab:hover { color: var(--ink); border-color: var(--accent); }
.tab[aria-selected='true'] { color: var(--ink); background: color-mix(in srgb, var(--accent) 22%, transparent); border-color: var(--accent); }
.tab.done:not([aria-selected='true'])::after { content: '·'; margin-left: 4px; color: var(--accent); }

.letter {
  margin-top: 10px; padding: 44px 26px 40px; border-radius: var(--radius); position: relative;
  background: color-mix(in srgb, var(--bg1) 62%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 30px 80px -40px color-mix(in srgb, var(--accent) 35%, #000);
  transition: opacity .35s ease, transform .35s var(--ease);
}
.letter.leaving { opacity: 0; transform: translateY(10px); }
@media (min-width: 640px) { .letter { padding: 56px 52px 52px; } }

.chip { display: inline-block; padding: .15rem .95rem; border-radius: 99px; font-size: .92rem; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent); }
.letter h2 { margin: 18px 0 30px; font-weight: 600; line-height: 1.35; font-size: clamp(1.8rem, 6vw, 2.7rem); }

.prose { max-width: 36rem; font-size: 1.12rem; line-height: 2.15; }
.prose p { margin: 0 0 1.6rem; }
.line { opacity: .3; transition: opacity .7s ease, filter .9s ease, text-shadow .7s ease; }
.line.is-read { opacity: .6; }
.line.is-focus { opacity: 1; }
body[data-mood='fog'] .line:not(.is-focus) { filter: blur(1.4px); }
body[data-mood='embers'] .prose { font-weight: 500; }
body[data-mood='embers'] .line.is-focus { text-shadow: 0 0 22px color-mix(in srgb, var(--accent) 55%, transparent); }
body[data-mood='rain'] .prose { border-left: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); padding-left: 1.2rem; }

.ask {
  margin: 34px 0 26px; padding: .3rem 0 .3rem 1.3rem; border-left: 3px solid var(--accent);
  font-weight: 600; font-size: clamp(1.35rem, 4.6vw, 1.8rem); line-height: 1.65;
}
.decor { width: 112px; height: 112px; margin-bottom: 14px; color: var(--accent); display: block; }
.decor .orbit-a { transform-origin: 64px 64px; animation: spin 22s linear infinite; }
.decor .orbit-b { transform-origin: 64px 64px; animation: spin 34s linear infinite reverse; }
@keyframes spin { to { transform: rotate(360deg); } }
.decor .drip { animation: drip 2.4s ease-in infinite; }
.decor .drip:nth-of-type(2) { animation-delay: .8s; } .decor .drip:nth-of-type(3) { animation-delay: 1.6s; }
@keyframes drip { 0% { transform: translateY(-6px); opacity: 0; } 30% { opacity: .9; } 100% { transform: translateY(14px); opacity: 0; } }

.reply { max-width: 34rem; }
.reply label { display: block; margin-bottom: 10px; font-size: .98rem; color: color-mix(in srgb, var(--ink) 78%, transparent); }
textarea.field {
  display: block; width: 100%; min-height: 8rem; resize: vertical; padding: 1rem 1.1rem; font: 400 1rem/1.9 var(--serif); color: var(--ink);
  background: color-mix(in srgb, var(--ink) 7%, transparent); border: 1px solid color-mix(in srgb, var(--ink) 22%, transparent); border-radius: var(--radius-sm);
  transition: border-color .3s ease, background .3s ease;
}
textarea.field::placeholder { color: color-mix(in srgb, var(--ink) 42%, transparent); }
textarea.field:focus { outline: none; border-color: var(--accent); background: color-mix(in srgb, var(--ink) 11%, transparent); }
.saved { display: inline-block; margin-top: 8px; font-size: .86rem; color: var(--accent); opacity: 0; transition: opacity .4s ease; }
.saved.on { opacity: 1; }

/* the last chapter: everything left unsaid */
.letter.is-final { text-align: center; }
.letter.is-final .prose { max-width: none; font-size: clamp(1.2rem, 4.8vw, 1.6rem); line-height: 1.95; }
.letter.is-final .prose p { margin: 0 0 2.2rem; }
.letter.is-final .line { display: block; margin-bottom: .45rem; }
.letter.is-final .line.is-focus { text-shadow: 0 0 28px color-mix(in srgb, var(--accent) 50%, transparent); }
.letter.is-final .reply { margin-inline: auto; text-align: left; margin-top: 36px; }
.line.tremble.is-focus { animation: tremble .16s linear infinite; }
@keyframes tremble { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-1.2px); } 75% { transform: translateX(1.2px); } }

.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 22px; }

/* ================= replies ================= */
.replies { max-width: 44rem; margin: 0 auto; padding: 60px 20px 40px; }
.replies .hero-eyebrow { text-align: center; }
.replies-title { margin: 0; text-align: center; font-weight: 600; font-size: clamp(1.9rem, 6vw, 2.6rem); }
.replies-sub { margin: 10px 0 36px; text-align: center; color: color-mix(in srgb, var(--ink) 65%, transparent); }
.r-item { margin-bottom: 22px; padding: 22px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--bg1) 62%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent); }
.r-item h3 { margin: 0 0 6px; font-size: .92rem; font-weight: 400; color: var(--accent); }
.r-item p { margin: 0 0 14px; font-weight: 600; line-height: 1.7; font-size: 1.1rem; }
.replies .actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 30px; }

#toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 99990; transform: translate(-50%, 24px); opacity: 0; pointer-events: none;
  padding: .7rem 1.3rem; border-radius: 99px; font-size: .95rem; max-width: 90vw; text-align: center;
  background: color-mix(in srgb, var(--bg1) 88%, #000); color: var(--ink); border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
  transition: opacity .35s ease, transform .35s var(--ease);
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .page.active, .sp-orn, .sp-pre, .sp-name, .sp-bn, .sp-enter { animation: none; }
  .line, .line.is-read { opacity: 1; filter: none !important; transition: none; }
  .decor *, .line.tremble, .sp-pulse, .sp-pulse::after, #music-btn .bars i { animation: none !important; }
  body { transition: none; }
}

/* utility fallbacks (work even if the Tailwind CDN is unreachable) */
.font-script { font-family: var(--script); }
.font-ui { font-family: var(--ui); }
