/* ==========================================================================
   নীলাশা | বর্ষা সংখ্যা ২০২৬ — ডিজাইন সিস্টেম
   Palette: monsoon-night indigo, aged paper cream, banana-leaf teal, brass gold
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Tiro+Bangla:ital@0;1&family=Hind+Siliguri:wght@300;400;500;600;700&display=swap');

:root {
  --ink: #21201c;
  --ink-soft: #4a463e;
  --paper: #f2ecdd;
  --paper-warm: #ece3cd;
  --night: #17233b;
  --night-2: #1f3153;
  --teal: #2d4a3e;
  --teal-light: #446b58;
  --brass: #c1972f;
  --brass-light: #d9b869;
  --rain: #97a7bd;
  --rule: rgba(33, 32, 28, 0.14);
  --shadow: 0 18px 45px rgba(15, 20, 35, 0.35);

  --font-display: 'Tiro Bangla', 'Noto Serif Bengali', serif;
  --font-serif: 'Noto Serif Bengali', 'Tiro Bangla', serif;
  --font-body: 'Hind Siliguri', 'Noto Sans Bengali', sans-serif;

  --page-radius: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--night);
  color: var(--ink);
  font-family: var(--font-body);
  height: 100%;
  overflow: hidden;
}

body.scroll-ok { overflow: auto; }

a { color: inherit; }

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* ---------- background atmosphere ---------- */
#app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background:
    radial-gradient(ellipse at 20% -10%, rgba(58, 84, 122, 0.55), transparent 55%),
    radial-gradient(ellipse at 85% 110%, rgba(45, 74, 62, 0.35), transparent 50%),
    linear-gradient(180deg, #101a2c 0%, #17233b 55%, #121c30 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.rain-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  mix-blend-mode: screen;
}
.rain-layer .drop {
  position: absolute;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(200, 215, 235, 0.5), transparent);
  animation: fall linear infinite;
}
@keyframes fall {
  0% { transform: translateY(-10vh); }
  100% { transform: translateY(110vh); }
}

/* ================= COVER SCREEN ================= */
#cover-screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
#cover-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.cover-card {
  width: min(92vw, 420px);
  aspect-ratio: 3 / 4.3;
  background:
    radial-gradient(circle at 30% 20%, rgba(193, 151, 47, 0.18), transparent 45%),
    linear-gradient(165deg, #1a2740 0%, #101a2c 70%);
  border: 1px solid rgba(217, 184, 105, 0.25);
  border-radius: var(--page-radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  overflow: hidden;
  padding: 8%;
}
.cover-card::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(180deg, transparent 0%, transparent 96%, rgba(217,184,105,0.25) 96%),
    repeating-linear-gradient(100deg, transparent 0 38px, rgba(151, 167, 189, 0.06) 38px 39px);
}
.cover-eyebrow {
  font-family: var(--font-body);
  letter-spacing: 0.35em;
  font-size: 0.68rem;
  color: var(--brass-light);
  text-transform: uppercase;
  margin-bottom: 1.2rem;
  z-index: 1;
}
.cover-title {
  font-family: var(--font-display);
  font-size: clamp(3.2rem, 13vw, 4.6rem);
  color: var(--paper);
  line-height: 1;
  z-index: 1;
  text-shadow: 0 2px 24px rgba(0,0,0,0.4);
}
.cover-issue {
  font-family: var(--font-serif);
  font-size: clamp(1.2rem, 4.5vw, 1.6rem);
  color: var(--rain);
  margin-top: 0.9rem;
  z-index: 1;
}
.cover-tagline {
  margin-top: 1.6rem;
  font-size: 0.85rem;
  color: rgba(242, 236, 221, 0.55);
  letter-spacing: 0.12em;
  z-index: 1;
}
.open-btn {
  margin-top: 2.6rem;
  z-index: 1;
  padding: 0.85rem 2.2rem;
  border: 1px solid var(--brass-light);
  border-radius: 999px;
  color: var(--paper);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  transition: background 0.25s ease, transform 0.2s ease;
  background: rgba(217, 184, 105, 0.08);
}
.open-btn:hover { background: rgba(217, 184, 105, 0.22); transform: translateY(-2px); }
.open-btn:active { transform: translateY(0); }

/* ================= READER SHELL ================= */
#reader {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; visibility: hidden;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
#reader.visible { opacity: 1; visibility: visible; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 1rem;
  background: rgba(16, 26, 44, 0.85);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(217,184,105,0.15);
  z-index: 20;
  flex-shrink: 0;
}
.topbar-group { display: flex; align-items: center; gap: 0.35rem; }
.icon-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  color: var(--paper);
  border-radius: 8px;
  opacity: 0.85;
  transition: background 0.2s ease, opacity 0.2s;
}
.icon-btn:hover { background: rgba(217,184,105,0.15); opacity: 1; }
.icon-btn svg { width: 18px; height: 18px; }
.brand-mini {
  font-family: var(--font-display);
  color: var(--brass-light);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}
.page-indicator {
  color: var(--rain);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  min-width: 3.5rem;
  text-align: center;
}

.stage {
  flex: 1;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  perspective: 2200px;
  padding: 1rem;
}

.page-frame {
  position: relative;
  width: min(94vw, 640px);
  height: min(80vh, 860px);
  max-height: 100%;
}

.page {
  position: absolute; inset: 0;
  background: var(--paper);
  border-radius: var(--page-radius);
  box-shadow: var(--shadow);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  transform-origin: left center;
  backface-visibility: hidden;
  transition: transform 0.55s cubic-bezier(.45,.05,.15,1), opacity 0.4s ease;
}
.page::-webkit-scrollbar { width: 5px; }
.page::-webkit-scrollbar-thumb { background: rgba(33,32,28,0.2); border-radius: 3px; }

.page.current { z-index: 3; transform: rotateY(0deg); opacity: 1; }
.page.leaving-next { z-index: 4; transform: rotateY(-140deg); opacity: 0.4; }
.page.leaving-prev { z-index: 4; transform: rotateY(140deg); opacity: 0.4; }
.page.entering { z-index: 2; transform: rotateY(0deg); opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .page { transition: opacity 0.2s ease; }
  .page.leaving-next, .page.leaving-prev { transform: none; }
}

.page-inner {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 9% 8% 7%;
  position: relative;
}

.page-number {
  position: absolute;
  bottom: 0.55rem;
  left: 0; right: 0;
  text-align: center;
  font-size: 0.7rem;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  font-family: var(--font-body);
}
.page-number .mast { color: var(--brass); font-family: var(--font-display); }

/* ---- cover-type page (rendered in reader too, if navigated back) ---- */
.p-cover { background: linear-gradient(165deg, #1a2740, #101a2c); color: var(--paper); justify-content: center; align-items: center; text-align: center; }
.p-cover .cover-title { font-size: clamp(2.6rem, 11vw, 3.6rem); }

/* ---- editorial ---- */
.p-editorial .kicker, .p-article .kicker, .p-contact .kicker {
  font-size: 0.72rem; letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--teal-light); margin-bottom: 0.6rem; font-family: var(--font-body);
}
.p-editorial h1, .p-article h1, .p-contact h1 {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 6vw, 2.3rem);
  margin: 0 0 1.1rem;
  color: var(--night);
  line-height: 1.2;
}
.editorial-body, .article-body {
  font-family: var(--font-serif);
  font-size: 1.02rem;
  line-height: 1.95;
  color: var(--ink);
  white-space: pre-wrap;
}
.editorial-body p, .article-body p { margin: 0 0 1.15em; }
.signoff {
  margin-top: 1.6rem;
  font-family: var(--font-display);
  font-style: italic;
  color: var(--ink-soft);
  white-space: pre-line;
  border-top: 1px solid var(--rule);
  padding-top: 1rem;
  font-size: 0.95rem;
}

/* ---- contents ---- */
.p-contents h1 {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 6vw, 2.2rem);
  margin: 0 0 1rem;
  color: var(--night);
}
.toc-section { margin-bottom: 1.1rem; }
.toc-section-label {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.35rem;
  margin-bottom: 0.45rem;
}
.toc-item {
  display: flex; align-items: baseline; gap: 0.5rem;
  width: 100%; text-align: left;
  padding: 0.32rem 0.1rem;
  font-size: 0.92rem;
  border-radius: 4px;
}
.toc-item:hover { background: rgba(45,74,62,0.08); }
.toc-item .t-title { font-family: var(--font-serif); color: var(--ink); flex-shrink: 1; }
.toc-item .t-author { color: var(--ink-soft); font-size: 0.82rem; white-space: nowrap; }
.toc-item .t-dots { flex: 1; border-bottom: 1px dotted var(--rule); margin-bottom: 0.3em; }
.toc-item .t-page { color: var(--teal-light); font-variant-numeric: tabular-nums; font-size: 0.82rem; }

/* ---- section opener ---- */
.p-section-opener {
  justify-content: center; align-items: center; text-align: center;
  background: linear-gradient(165deg, var(--paper-warm), var(--paper));
}
.section-index { font-family: var(--font-body); color: var(--brass); letter-spacing: 0.3em; font-size: 0.75rem; margin-bottom: 1rem; }
.section-opener-label {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 10vw, 3.4rem);
  color: var(--night);
}
.section-opener-tagline { margin-top: 0.8rem; color: var(--ink-soft); font-family: var(--font-serif); font-style: italic; }
.section-opener-count { margin-top: 1.6rem; font-size: 0.8rem; color: var(--teal-light); letter-spacing: 0.08em; }
.section-rule { width: 46px; height: 2px; background: var(--brass); margin: 1.3rem auto; }

/* ---- article page ---- */
.p-article .byline { font-family: var(--font-body); color: var(--teal-light); font-size: 0.9rem; margin-bottom: 1.3rem; }
.p-article.kobita .article-body,
.p-article.chora .article-body { font-size: 1.12rem; line-height: 2.05; }
.p-article.kobita .page-inner,
.p-article.chora .page-inner { justify-content: center; }
.p-article.probondho h1 { font-size: clamp(1.4rem, 5.2vw, 1.9rem); }

/* ---- contact / back cover ---- */
.p-contact dl { display: grid; grid-template-columns: auto 1fr; gap: 0.5rem 1rem; font-size: 0.92rem; margin-top: 1rem; }
.p-contact dt { color: var(--ink-soft); }
.p-contact dd { margin: 0; font-family: var(--font-serif); }
.p-contact .masthead-title { font-family: var(--font-body); font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.78rem; color: var(--brass); margin: 1.6rem 0 0.5rem; }

.p-back-cover {
  background: linear-gradient(165deg, #1a2740, #101a2c); color: var(--paper);
  justify-content: center; align-items: center; text-align: center;
}
.p-back-cover .cover-title { font-size: clamp(2rem, 8vw, 2.6rem); font-family: var(--font-display); }
.p-back-cover .bc-meta { margin-top: 1.2rem; font-size: 0.85rem; color: var(--rain); }

/* ---------- nav controls ---------- */
.navbar {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; gap: 1.4rem;
  padding: 0.7rem 1rem calc(0.7rem + env(safe-area-inset-bottom));
  background: rgba(16, 26, 44, 0.85);
  backdrop-filter: blur(6px);
  border-top: 1px solid rgba(217,184,105,0.15);
  z-index: 20;
}
.nav-btn {
  color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(217,184,105,0.1);
  transition: background 0.2s ease, transform 0.15s ease;
}
.nav-btn:hover { background: rgba(217,184,105,0.22); }
.nav-btn:active { transform: scale(0.94); }
.nav-btn:disabled { opacity: 0.3; pointer-events: none; }
.nav-btn svg { width: 20px; height: 20px; }

/* ---------- TOC drawer ---------- */
#toc-drawer {
  position: absolute; inset: 0;
  z-index: 30;
  background: rgba(10, 15, 26, 0.55);
  display: flex; justify-content: flex-end;
  opacity: 0; visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
#toc-drawer.open { opacity: 1; visibility: visible; }
.toc-panel {
  width: min(88vw, 380px); height: 100%;
  background: var(--paper);
  padding: 1.4rem 1.2rem;
  overflow-y: auto;
  transform: translateX(20px);
  transition: transform 0.3s ease;
}
#toc-drawer.open .toc-panel { transform: translateX(0); }
.toc-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.toc-panel-head h2 { font-family: var(--font-display); font-size: 1.3rem; margin: 0; color: var(--night); }

/* ---------- toast ---------- */
#toast {
  position: absolute; bottom: 5rem; left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(20, 30, 48, 0.95);
  color: var(--paper);
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  font-size: 0.82rem;
  z-index: 50;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- light mode ---------- */
body.light .page { background: #fffdf7; }
body.light .p-section-opener { background: linear-gradient(165deg, #fff, #fbf6e9); }

/* ---------- responsive tweaks ---------- */
@media (max-width: 480px) {
  .page-frame { width: 100vw; height: calc(100dvh - 108px); }
  .page { border-radius: 0; }
  .navbar { gap: 0.9rem; }
  .icon-btn.hide-mobile { display: none; }
}

@media (min-width: 900px) {
  .page-frame { width: min(60vw, 640px); }
}

/* keyboard focus visibility */
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--brass-light);
  outline-offset: 2px;
}
