/* Tales That Never Fade — stories.sawan.me
   Night-sky wonder wrapping warm book-paper. RTL-first. */

:root {
  --night: #191333;
  --night-2: #241b4d;
  --night-3: #2f2566;
  --ink: #2d2418;
  --cream: #f6efe2;
  --paper: #fffdf7;
  --gold: #c99a4a;
  --gold-dark: #7a4a1f;
  --gold-text: #b8863b;
  --muted: #a08c6a;
  --teal: #2a9d8f;
  --coral: #e76f51;
  --berry: #b5548b;
  --leaf: #6a994e;
  --sky: #4d7fd1;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(45, 36, 24, 0.18);
  --shadow-lg: 0 24px 60px rgba(25, 19, 51, 0.35);
  --f-display: "Aref Ruqaa", serif;
  --f-ui: "Baloo Bhaijaan 2", "Geeza Pro", sans-serif;
  --f-body: "Noto Naskh Arabic", "Geeza Pro", serif;
  --f-en: Georgia, "Iowan Old Style", serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--f-body);
  color: var(--ink);
  background: var(--cream);
  line-height: 1.75;
  overflow-x: hidden;
}
[lang="en"], .en { font-family: var(--f-en); }
img { max-width: 100%; display: block; }
a { color: var(--gold-dark); text-decoration: none; }
button { font-family: var(--f-ui); cursor: pointer; border: 0; }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 22px;
  background: rgba(25, 19, 51, 0.92);
  backdrop-filter: blur(10px);
  color: var(--cream);
}
.nav .brand {
  font-family: var(--f-display); font-size: 1.35rem; color: #f3d8a8;
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.nav .brand .flame { font-size: 1.2rem; animation: flicker 2.6s infinite; }
.nav .links { display: flex; gap: 4px; margin-inline-start: auto; flex-wrap: wrap; }
.nav .links a {
  color: #e8ddc4; font-family: var(--f-ui); font-size: 0.95rem;
  padding: 6px 12px; border-radius: 999px; transition: background 0.2s;
}
.nav .links a:hover, .nav .links a.active { background: rgba(201, 154, 74, 0.25); color: #fff; }
.player-chip {
  display: flex; align-items: center; gap: 8px;
  background: rgba(201, 154, 74, 0.18); border: 1px solid rgba(201, 154, 74, 0.5);
  border-radius: 999px; padding: 4px 12px; font-family: var(--f-ui);
  font-size: 0.9rem; color: #f3d8a8; white-space: nowrap;
}
.player-chip .pts { color: #ffd98a; font-weight: 700; }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden; color: var(--cream);
  background: radial-gradient(ellipse 1200px 700px at 50% -10%, var(--night-3), var(--night-2) 45%, var(--night) 80%);
  padding: 72px 20px 0; text-align: center;
}
.stars, .stars2 { position: absolute; inset: 0; pointer-events: none; }
.stars span, .stars2 span {
  position: absolute; width: 3px; height: 3px; border-radius: 50%;
  background: #fff; opacity: 0.8; animation: twinkle 3s infinite;
}
.stars2 span { width: 2px; height: 2px; opacity: 0.5; }
@keyframes twinkle { 0%, 100% { opacity: 0.15; } 50% { opacity: 0.9; } }
@keyframes flicker { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.08); opacity: 0.85; } }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
.lantern { font-size: 3.2rem; display: inline-block; animation: floaty 4.5s ease-in-out infinite; filter: drop-shadow(0 0 22px rgba(255, 200, 100, 0.55)); }
.hero h1 {
  font-family: var(--f-display); font-size: clamp(2.6rem, 7vw, 4.6rem);
  color: #f3d8a8; margin: 10px 0 4px; text-shadow: 0 4px 30px rgba(201, 154, 74, 0.35);
}
.hero .sub {
  font-family: var(--f-ui); font-size: clamp(1.05rem, 2.6vw, 1.45rem);
  color: #d9cfae; max-width: 720px; margin: 0 auto 8px;
}
.hero .sub-en { font-family: var(--f-en); font-style: italic; color: #b7ab8d; font-size: 1.02rem; margin-bottom: 26px; }
.cta-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-bottom: 40px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--f-ui); font-size: 1.08rem; font-weight: 700;
  padding: 13px 30px; border-radius: 999px; transition: transform 0.15s, box-shadow 0.15s;
}
.btn:hover { transform: translateY(-2px) scale(1.02); }
.btn-gold { background: linear-gradient(135deg, #e9b96a, var(--gold)); color: #3a2508; box-shadow: 0 8px 26px rgba(201, 154, 74, 0.45); }
.btn-ghost { background: rgba(255, 253, 247, 0.1); color: var(--cream); border: 1.5px solid rgba(243, 216, 168, 0.5); }
.btn-dark { background: var(--gold-dark); color: #fdf6e9; box-shadow: var(--shadow); }
.btn-light { background: var(--paper); color: var(--gold-dark); border: 2px solid var(--gold); }

/* cover marquee */
.marquee-wrap { position: relative; padding: 8px 0 56px; }
.marquee { display: flex; gap: 16px; width: max-content; animation: slide 70s linear infinite; }
.marquee.rev { animation: slide-rev 84s linear infinite; margin-top: 16px; }
.marquee:hover { animation-play-state: paused; }
@keyframes slide { from { transform: translateX(0); } to { transform: translateX(50%); } }
@keyframes slide-rev { from { transform: translateX(50%); } to { transform: translateX(0); } }
.marquee img {
  width: 210px; height: 140px; object-fit: cover; border-radius: 12px;
  border: 3px solid rgba(255, 253, 247, 0.85); outline: 1px solid var(--gold);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s;
}
.marquee a:hover img { transform: scale(1.06) rotate(-1deg); }

/* ---------- Sections ---------- */
.section { max-width: 1120px; margin: 0 auto; padding: 64px 22px; }
.section-head { text-align: center; margin-bottom: 36px; }
.section-head h2 { font-family: var(--f-display); font-size: clamp(1.7rem, 4.5vw, 2.5rem); color: var(--gold-dark); }
.section-head p { color: var(--muted); font-family: var(--f-ui); font-size: 1.05rem; }
.section-head .en { font-size: 0.95rem; font-style: italic; }

.pillars { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; }
.pillar {
  background: var(--paper); border: 1px solid rgba(201, 154, 74, 0.4);
  border-radius: var(--radius); padding: 26px 22px; text-align: center;
  box-shadow: var(--shadow); transition: transform 0.2s;
}
.pillar:hover { transform: translateY(-5px); }
.pillar .ico { font-size: 2.3rem; margin-bottom: 8px; }
.pillar h3 { font-family: var(--f-ui); color: var(--gold-dark); font-size: 1.25rem; margin-bottom: 6px; }
.pillar p { font-size: 1rem; color: #5a4c37; }

/* ---------- Story cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: 22px; }
.card {
  background: var(--paper); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid rgba(201, 154, 74, 0.35);
  transition: transform 0.2s, box-shadow 0.2s; position: relative;
}
.card:hover { transform: translateY(-6px); box-shadow: 0 18px 42px rgba(45, 36, 24, 0.28); }
.card .cov { position: relative; }
.card img { width: 100%; height: 158px; object-fit: cover; }
.card .chip {
  position: absolute; top: 10px; inset-inline-start: 10px;
  background: rgba(25, 19, 51, 0.82); color: #f3d8a8;
  font-family: var(--f-ui); font-size: 0.78rem; padding: 3px 11px; border-radius: 999px;
}
.card .gem-chip {
  position: absolute; bottom: -12px; inset-inline-end: 12px;
  background: var(--paper); border: 2px solid var(--gold);
  border-radius: 999px; padding: 2px 12px; font-family: var(--f-ui);
  font-size: 0.82rem; color: var(--gold-dark); box-shadow: var(--shadow);
}
.card .body { padding: 18px 16px 14px; }
.card h3 { font-family: var(--f-ui); font-size: 1.12rem; color: var(--ink); line-height: 1.45; }
.card .en-title { font-family: var(--f-en); font-style: italic; font-size: 0.86rem; color: var(--muted); margin-bottom: 8px; }
.card .meta { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.card .stars-row { color: var(--gold); font-size: 1rem; letter-spacing: 2px; }
.card .play {
  font-family: var(--f-ui); font-size: 0.9rem; font-weight: 700;
  background: var(--gold-dark); color: #fdf6e9; padding: 6px 16px; border-radius: 999px;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 26px; }
.filters button {
  background: var(--paper); border: 1.5px solid rgba(201, 154, 74, 0.5);
  color: var(--gold-dark); border-radius: 999px; padding: 7px 16px; font-size: 0.95rem;
}
.filters button.on { background: var(--gold-dark); color: #fdf6e9; border-color: var(--gold-dark); }
.search {
  display: block; width: min(420px, 90%); margin: 0 auto 22px;
  font-family: var(--f-body); font-size: 1.05rem;
  padding: 11px 20px; border-radius: 999px; border: 1.5px solid var(--gold);
  background: var(--paper); color: var(--ink); text-align: center;
}
.search:focus { outline: 2px solid var(--gold); }

/* ---------- Story page ---------- */
.story-hero { position: relative; color: var(--cream); overflow: hidden; padding: 46px 20px 30px; text-align: center; }
.story-hero .bg {
  position: absolute; inset: -40px; background-size: cover; background-position: center;
  filter: blur(26px) brightness(0.42) saturate(1.1); transform: scale(1.15);
}
.story-hero .inner { position: relative; max-width: 980px; margin: 0 auto; }
.story-hero img.main {
  width: min(640px, 92%); border-radius: 16px; margin: 0 auto 18px;
  border: 5px solid rgba(255, 253, 247, 0.9); outline: 2px solid var(--gold);
  box-shadow: var(--shadow-lg);
}
.story-hero h1 { font-family: var(--f-display); font-size: clamp(1.9rem, 5vw, 3rem); color: #f7e3bb; }
.story-hero .en-t { font-family: var(--f-en); font-style: italic; color: #cfc3a2; margin-bottom: 6px; }
.story-hero .chips { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 10px 0 4px; }
.story-hero .chips span {
  background: rgba(255, 253, 247, 0.14); border: 1px solid rgba(243, 216, 168, 0.45);
  font-family: var(--f-ui); font-size: 0.88rem; padding: 4px 14px; border-radius: 999px;
}

.video-box { max-width: 880px; margin: -8px auto 0; padding: 0 20px; position: relative; z-index: 2; }
.video-frame {
  position: relative; padding-top: 56.25%; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-lg); border: 4px solid var(--paper); background: #000;
}
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.premiere-note {
  text-align: center; font-family: var(--f-ui); color: var(--gold-dark);
  background: var(--paper); border: 1.5px dashed var(--gold); border-radius: 12px;
  padding: 10px 18px; margin-top: 12px; font-size: 1rem;
}

/* word bank */
.bank { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.bank .wcard {
  perspective: 600px; cursor: pointer; min-width: 150px;
}
.bank .winner { position: relative; transform-style: preserve-3d; transition: transform 0.5s; min-height: 74px; }
.bank .wcard.flip .winner { transform: rotateY(180deg); }
.bank .face {
  position: absolute; inset: 0; backface-visibility: hidden;
  display: flex; align-items: center; justify-content: center; text-align: center;
  border-radius: 14px; padding: 10px 16px;
}
.bank .front { background: var(--paper); border: 2px solid var(--gold); font-family: var(--f-ui); font-size: 1.15rem; color: var(--gold-dark); }
.bank .back { background: var(--gold-dark); color: #fdf6e9; transform: rotateY(180deg); font-size: 0.9rem; line-height: 1.5; }

/* ---------- Quiz ---------- */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 26px; }
.tabs button {
  font-size: 1rem; font-weight: 700; padding: 10px 20px; border-radius: 999px;
  background: var(--paper); color: var(--gold-dark); border: 2px solid rgba(201, 154, 74, 0.5);
}
.tabs button.on { background: var(--night); color: #f3d8a8; border-color: var(--night); }
.tabs button .done-mark { color: var(--leaf); }
.quiz-panel { display: none; max-width: 760px; margin: 0 auto; }
.quiz-panel.on { display: block; }
.q-card {
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid rgba(201, 154, 74, 0.4); padding: 24px 26px; margin-bottom: 20px;
}
.q-card .q-num { font-family: var(--f-ui); color: var(--gold); font-size: 0.9rem; }
.q-card h4 { font-size: 1.22rem; line-height: 1.8; margin: 4px 0 16px; }
.q-card h4.en { font-family: var(--f-en); }
.opts { display: grid; gap: 10px; }
.opts button {
  text-align: start; font-family: var(--f-body); font-size: 1.08rem; line-height: 1.7;
  padding: 12px 18px; border-radius: 12px; background: var(--cream);
  border: 2px solid rgba(201, 154, 74, 0.35); color: var(--ink); transition: all 0.15s;
}
.opts button:hover:not(:disabled) { border-color: var(--gold); background: #fbf3df; }
.opts button.correct { background: #e7f2e3; border-color: var(--leaf); color: #33502a; font-weight: 700; }
.opts button.wrong { background: #fbe5e0; border-color: var(--coral); animation: shake 0.35s; }
.opts button:disabled { cursor: default; opacity: 0.85; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(6px); } 75% { transform: translateX(-6px); } }
.explain {
  display: none; margin-top: 14px; background: #f4ecdb; border-inline-start: 4px solid var(--gold);
  border-radius: 10px; padding: 12px 16px; font-size: 1rem; color: #5a4c37;
}
.explain.show { display: block; }
.pts-float {
  position: fixed; z-index: 99; font-family: var(--f-ui); font-weight: 800;
  color: var(--leaf); font-size: 1.4rem; pointer-events: none;
  animation: rise 1.2s ease-out forwards; text-shadow: 0 2px 8px rgba(255,255,255,0.8);
}
@keyframes rise { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-90px); } }

/* find the error — tappable words */
.err-sentence { font-size: 1.3rem; line-height: 2.3; text-align: center; margin-bottom: 6px; }
.err-sentence .w {
  cursor: pointer; padding: 2px 6px; border-radius: 8px; transition: background 0.15s;
  display: inline-block;
}
.err-sentence .w:hover { background: #f3e3c3; }
.err-sentence .w.bad { background: #fbe5e0; color: #8a2f1d; text-decoration: line-through; }
.err-sentence .w.good { background: #e7f2e3; color: #33502a; font-weight: 700; }
.err-fixed { text-align: center; font-family: var(--f-ui); color: var(--leaf); font-size: 1.05rem; display: none; }
.err-fixed.show { display: block; }

/* ---------- Gamification widgets ---------- */
.progress-band {
  background: var(--night); color: var(--cream); border-radius: var(--radius);
  padding: 26px; display: flex; gap: 26px; align-items: center; flex-wrap: wrap;
  justify-content: center; box-shadow: var(--shadow-lg);
}
.level-badge { text-align: center; }
.level-badge .ring {
  width: 108px; height: 108px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 2.6rem;
  background: conic-gradient(var(--gold) calc(var(--p, 0) * 1%), rgba(255,255,255,0.12) 0);
  padding: 6px;
}
.level-badge .ring > div { background: var(--night-2); width: 100%; height: 100%; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.level-badge .lvl-name { font-family: var(--f-ui); color: #f3d8a8; margin-top: 8px; font-size: 1.05rem; }
.gems-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.gem {
  font-family: var(--f-ui); font-size: 0.9rem; border-radius: 999px; padding: 6px 14px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(243, 216, 168, 0.4);
}
.gem b { color: #ffd98a; }

/* leaderboard */
.lb-table { width: 100%; max-width: 680px; margin: 0 auto; border-collapse: collapse; }
.lb-table tr { background: var(--paper); }
.lb-table tr.me { outline: 2px solid var(--gold); }
.lb-table td { padding: 12px 16px; border-bottom: 8px solid var(--cream); font-family: var(--f-ui); }
.lb-table td:first-child { border-radius: 0 12px 12px 0; width: 54px; text-align: center; font-weight: 800; color: var(--gold-dark); }
.lb-table td:last-child { border-radius: 12px 0 0 12px; text-align: end; color: var(--gold-dark); font-weight: 800; }
.lb-name { color: var(--ink); }
.lb-medal { font-size: 1.2rem; }

/* name modal */
.modal-back { position: fixed; inset: 0; background: rgba(25,19,51,0.7); z-index: 90; display: none; align-items: center; justify-content: center; }
.modal-back.show { display: flex; }
.modal {
  background: var(--paper); border-radius: var(--radius); padding: 30px; width: min(430px, 92%);
  text-align: center; box-shadow: var(--shadow-lg); border: 2px solid var(--gold);
}
.modal h3 { font-family: var(--f-ui); color: var(--gold-dark); font-size: 1.3rem; margin-bottom: 10px; }
.modal input {
  width: 100%; font-family: var(--f-body); font-size: 1.1rem; text-align: center;
  padding: 11px; border-radius: 12px; border: 2px solid var(--gold); margin: 12px 0;
  background: var(--cream);
}

/* store strip */
.store-strip {
  background: linear-gradient(135deg, var(--night-2), var(--night));
  border-radius: var(--radius); color: var(--cream); padding: 34px 30px;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap; justify-content: center;
  text-align: center; box-shadow: var(--shadow-lg);
}
.store-strip h3 { font-family: var(--f-display); font-size: 1.6rem; color: #f3d8a8; width: 100%; }
.store-strip p { color: #d9cfae; font-family: var(--f-ui); width: 100%; margin-top: -8px; }

/* footer */
footer {
  background: var(--night); color: #b7ab8d; margin-top: 70px;
  padding: 44px 22px 30px; text-align: center; font-family: var(--f-ui);
}
footer .foot-brand { font-family: var(--f-display); color: #f3d8a8; font-size: 1.5rem; margin-bottom: 8px; }
footer .foot-links { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin: 14px 0; }
footer .foot-links a { color: #d9cfae; font-size: 0.95rem; }
footer .credit { font-size: 0.85rem; opacity: 0.75; margin-top: 10px; line-height: 1.9; }

/* reveal on scroll */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.6s, transform 0.6s; }
.reveal.in { opacity: 1; transform: none; }

/* confetti canvas */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 98; }

@media (max-width: 640px) {
  .nav { padding: 8px 12px; }
  .nav .links a { padding: 5px 8px; font-size: 0.85rem; }
  .marquee img { width: 150px; height: 100px; }
  .section { padding: 44px 16px; }
}
