/* ============================================================
   Indian Heritage Learning Hub — stylesheet
   Soft yellow page, warm orange sidebar, gentle on the eyes.
   ============================================================ */

:root {
  --bg: #fdf4cf;            /* soft butter yellow */
  --bg-panel: rgba(255, 251, 236, 0.90);
  --bg-card: rgba(255, 253, 245, 0.94);
  --sidebar-top: #f2ad6b;   /* muted marigold orange */
  --sidebar-bottom: #e99a57;
  --sidebar-text: #3d2312;
  --sidebar-active: #fff4e2;
  --text: #3b2a1a;
  --text-soft: #5e4a36;
  --heading: #a8461a;       /* deep saffron, not glaring */
  --accent: #c8611f;
  --green: #3f7a5a;
  --line: #ead9a8;
  --tag-bg: #fbe6c4;
  --shadow: 0 2px 10px rgba(120, 80, 20, 0.08);
  --radius: 14px;
  --sidebar-w: 270px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Mukta", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 1.08rem;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
}

/* --- Faint national flower & national bird in the background --- */
.bg-art {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    url("../images/peacock-bg.svg"),
    url("../images/lotus-bg.svg"),
    url("../images/lotus-bg.svg");
  background-repeat: no-repeat;
  background-size: min(46vw, 560px), min(30vw, 360px), min(18vw, 220px);
  background-position: right -40px top 30px, right 4vw bottom -30px, left calc(var(--sidebar-w) + 2vw) bottom 10px;
  opacity: 0.16;
}

/* ---------------- Sidebar ---------------- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-top), var(--sidebar-bottom));
  color: var(--sidebar-text);
  overflow-y: auto;
  z-index: 20;
  box-shadow: 2px 0 14px rgba(140, 70, 10, 0.12);
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 16px;
  text-decoration: none;
  color: var(--sidebar-text);
  border-bottom: 1px solid rgba(90, 40, 10, 0.15);
}
.brand img { width: 46px; height: 46px; }
.brand-title { font-family: "Marcellus", Georgia, serif; font-size: 1.15rem; line-height: 1.2; }
.brand-title small { display: block; font-family: "Mukta", sans-serif; font-size: 0.78rem; opacity: 0.8; letter-spacing: 0.04em; }

.nav { list-style: none; margin: 0; padding: 12px 10px 20px; }
.nav li { margin: 2px 0; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.98rem;
  line-height: 1.3;
  transition: background 0.15s ease;
}
.nav a:hover { background: rgba(255, 244, 226, 0.45); }
.nav a.active {
  background: var(--sidebar-active);
  color: #8a3511;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(120, 60, 10, 0.12);
}
.nav .num {
  flex: 0 0 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 248, 235, 0.6);
  font-size: 0.8rem;
  font-weight: 600;
}
.nav a.active .num { background: #f6c58f; }

.sidebar-foot {
  margin-top: auto;
  padding: 14px 20px 22px;
  font-size: 0.82rem;
  opacity: 0.85;
  border-top: 1px solid rgba(90, 40, 10, 0.15);
}

/* Mobile top bar */
.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--sidebar-top);
  color: var(--sidebar-text);
  padding: 10px 16px;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(120, 60, 10, 0.15);
}
.menu-btn {
  background: var(--sidebar-active);
  border: 0;
  border-radius: 8px;
  padding: 6px 12px;
  font: inherit;
  font-weight: 600;
  color: #7a3210;
  cursor: pointer;
}
.scrim { display: none; }

/* ---------------- Main ---------------- */
.main {
  position: relative;
  z-index: 1;
  margin-left: var(--sidebar-w);
  padding: 34px clamp(18px, 4vw, 56px) 60px;
  max-width: calc(var(--sidebar-w) + 1060px);
}

.page-banner {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 28px;
  align-items: center;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 32px;
  box-shadow: var(--shadow);
  margin-bottom: 28px;
}
.page-banner img { width: 100%; height: auto; border-radius: 14px; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--green);
  margin: 0 0 6px;
}

h1, h2, h3, h4 { font-family: "Marcellus", Georgia, serif; color: var(--heading); line-height: 1.25; font-weight: 400; }
h1 { font-size: clamp(1.8rem, 3.2vw, 2.6rem); margin: 0 0 12px; }
h2 { font-size: 1.65rem; margin: 0 0 12px; }
h3 { font-size: 1.28rem; margin: 22px 0 8px; }
h4 { font-size: 1.08rem; margin: 16px 0 6px; color: #8a4a1c; }
p { margin: 0 0 14px; }
a { color: #a0481a; }
a:hover { color: #7a3210; }
.lead { font-size: 1.16rem; color: var(--text-soft); }

.section {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 30px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.section > h2:first-child { margin-top: 0; }
.section-num {
  display: inline-block;
  font-family: "Mukta", sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--tag-bg);
  color: #8a4a1c;
  padding: 1px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
}

ul.clean { padding-left: 1.2em; margin: 0 0 14px; }
ul.clean li { margin-bottom: 6px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
}
.card h3, .card h4 { margin-top: 0; }
.card .spot { width: 64px; height: 64px; float: right; margin: 0 0 8px 10px; }

.note {
  border-left: 4px solid var(--green);
  background: rgba(230, 242, 228, 0.75);
  padding: 12px 16px;
  border-radius: 0 10px 10px 0;
  margin: 14px 0;
  font-size: 0.98rem;
}
.activity {
  border-left: 4px solid var(--accent);
  background: rgba(253, 232, 205, 0.75);
  padding: 12px 16px;
  border-radius: 0 10px 10px 0;
  margin: 14px 0;
}
.activity strong:first-child, .note strong:first-child { color: #7a3210; }

.quote {
  font-family: "Marcellus", Georgia, serif;
  font-size: 1.2rem;
  color: #7a4a22;
  text-align: center;
  padding: 18px 10%;
  margin: 0;
}

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.tag {
  background: var(--tag-bg);
  color: #7a3f16;
  font-size: 0.8rem;
  padding: 2px 10px;
  border-radius: 20px;
}

.btn {
  display: inline-block;
  background: #d9733a;
  color: #fffaf0;
  padding: 10px 18px;
  border-radius: 30px;
  text-decoration: none;
  font-weight: 600;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.btn:hover { background: #c4612b; color: #fff; }
.btn.ghost { background: transparent; color: #a0481a; border: 2px solid #e0a06a; }
.btn.ghost:hover { background: #fbe6c4; }

.topic-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.topic-buttons a {
  background: var(--bg-card);
  border: 1px solid #e6c78f;
  color: #8a3b12;
  padding: 8px 16px;
  border-radius: 30px;
  text-decoration: none;
  font-weight: 600;
}
.topic-buttons a:hover { background: #fbe0b8; }

table.paths { width: 100%; border-collapse: collapse; margin: 10px 0 16px; background: var(--bg-card); border-radius: 12px; overflow: hidden; }
table.paths th, table.paths td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.paths th { background: #f8dcae; color: #6b3112; font-weight: 600; }
table.paths tr:last-child td { border-bottom: 0; }

/* Timeline */
.timeline { position: relative; margin: 10px 0 8px; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 4px; bottom: 4px; width: 3px; background: #efc88f; border-radius: 3px; }
.tl-item { position: relative; margin-bottom: 14px; }
.tl-item::before { content: ""; position: absolute; left: -24px; top: 7px; width: 13px; height: 13px; border-radius: 50%; background: #d9733a; border: 3px solid #fff4e0; }
.tl-date { font-weight: 600; color: var(--green); }

/* In-page table of contents */
.toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 0; padding: 0; list-style: none; }
.toc a { display: inline-block; background: var(--bg-card); border: 1px solid var(--line); padding: 4px 12px; border-radius: 20px; font-size: 0.9rem; text-decoration: none; }
.toc a:hover { background: #fbe6c4; }

/* Details / accordions */
details.lesson {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 10px 0;
  padding: 0 18px;
}
details.lesson summary {
  cursor: pointer;
  padding: 14px 0;
  font-family: "Marcellus", Georgia, serif;
  font-size: 1.18rem;
  color: var(--heading);
  list-style: none;
}
details.lesson summary::-webkit-details-marker { display: none; }
details.lesson summary::before { content: "＋"; display: inline-block; width: 1.4em; color: var(--accent); }
details.lesson[open] summary::before { content: "－"; }
details.lesson[open] { padding-bottom: 12px; }

/* Festivals compass */
.month-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.month-tabs button, .filters button {
  border: 1px solid #e6c78f;
  background: var(--bg-card);
  color: #7a3f16;
  border-radius: 20px;
  padding: 5px 13px;
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
}
.month-tabs button.on, .filters button.on { background: #d9733a; color: #fffaf0; border-color: #d9733a; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 14px; align-items: center; }
.filters span { font-weight: 600; margin-right: 4px; }
.fest-card { display: none; }
.fest-card.show { display: block; }
.fest-card .meta { font-size: 0.92rem; color: var(--text-soft); }
.fest-empty { display: none; font-style: italic; color: var(--text-soft); }

/* State tile map */
.tilemap {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 5px;
  max-width: 560px;
  margin: 10px auto 16px;
}
.tile {
  aspect-ratio: 1 / 1;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  color: #3b2a1a;
  display: grid;
  place-items: center;
  padding: 2px;
  transition: transform 0.12s ease;
}
.tile:hover, .tile.on { transform: scale(1.08); outline: 3px solid #a8461a; }
.tile.ut { border: 2px dashed rgba(60, 40, 20, 0.45); }
.r-north { background: #f7c98b; }
.r-south { background: #b9dfb3; }
.r-east  { background: #f4b7a3; }
.r-west  { background: #f9e08a; }
.r-central { background: #d9c6ee; }
.r-ne    { background: #a9d6e5; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; font-size: 0.85rem; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 4px; }
.state-panel { min-height: 160px; }

/* Quiz */
.quiz { background: var(--bg-card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin: 14px 0; }
.quiz .q { font-weight: 600; margin-bottom: 8px; }
.quiz .opts { display: grid; gap: 8px; margin-bottom: 8px; }
.quiz .opts button {
  text-align: left;
  border: 1px solid #e6c78f;
  background: #fffdf6;
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
  color: var(--text);
}
.quiz .opts button:hover { background: #fdf0d8; }
.quiz .opts button.right { background: #d8eed6; border-color: #7fb784; }
.quiz .opts button.wrong { background: #f8dcd3; border-color: #d99a86; }
.quiz .fb { min-height: 1.5em; font-size: 0.96rem; color: var(--text-soft); }
.quiz .score { font-weight: 600; color: var(--green); }

/* Coming soon */
.soon { opacity: 0.7; cursor: not-allowed; }
.badge-soon { font-size: 0.72rem; background: #e7dcc4; color: #6b5a3a; padding: 1px 8px; border-radius: 12px; margin-left: 6px; vertical-align: 2px; }
select.lang { font: inherit; padding: 6px 10px; border-radius: 8px; border: 1px solid #e6c78f; background: #fffdf6; color: var(--text); }

.page-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 30px; flex-wrap: wrap; }

footer.site-foot { text-align: center; color: var(--text-soft); font-size: 0.92rem; margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line); }
footer.site-foot .motto { font-family: "Marcellus", Georgia, serif; color: #8a4a1c; font-size: 1.1rem; }

/* Responsive */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .topbar { display: flex; }
  .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(60, 30, 5, 0.3); z-index: 15; }
  .main { margin-left: 0; padding-top: 20px; }
  .page-banner { grid-template-columns: 1fr; padding: 22px; }
  .page-banner img { max-width: 420px; justify-self: center; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .section { padding: 20px; }
  .bg-art { background-position: right -60px top 60px, right -20px bottom -20px, left 0 bottom 0; background-size: 80vw, 50vw, 30vw; }
}

@media print {
  .sidebar, .topbar, .bg-art, .page-nav { display: none !important; }
  .main { margin: 0; }
  details.lesson { display: block; }
}

/* ---------- Cross-platform polish (Windows, Android, iOS) ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: rgba(217, 115, 58, 0.18); overflow-x: hidden; }
img, svg { max-width: 100%; }
button, a, .tile { touch-action: manipulation; }
:focus-visible { outline: 3px solid #a8461a; outline-offset: 2px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* iPhone notch / home-bar safe areas */
.sidebar { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
.topbar { padding-top: calc(10px + env(safe-area-inset-top)); padding-left: calc(16px + env(safe-area-inset-left)); padding-right: calc(16px + env(safe-area-inset-right)); }
.main { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }

@media (max-width: 860px) {
  /* Comfortable 44px+ touch targets */
  .nav a { padding: 12px 14px; min-height: 46px; }
  .month-tabs button, .filters button { padding: 8px 14px; min-height: 40px; }
  .quiz .opts button { padding: 12px 14px; min-height: 46px; }
  .menu-btn { min-height: 40px; min-width: 44px; }
  .tilemap { gap: 3px; }
  .tile { font-size: 0.62rem; border-radius: 6px; }
  .sidebar { width: min(84vw, 300px); }
  h2 { font-size: 1.45rem; }
  .quote { padding: 14px 2%; }
}
@media (hover: none) {
  .tile:hover { transform: none; outline: none; }
  .tile.on { transform: scale(1.06); outline: 3px solid #a8461a; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Additions: helpers, map tiles, stories, letters, colouring ---------- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tile { aspect-ratio: auto; height: clamp(34px, 5.4vw, 56px); }
[lang="hi"], [lang="ta"], [lang="te"], [lang="bn"], [lang="gu"], [lang="ml"], [lang="pa"], [lang="ur"] {
  font-family: "Mukta", "Nirmala UI", "Noto Sans", "Kohinoor Devanagari", "Tamil Sangam MN", "Telugu Sangam MN", "Bangla Sangam MN", "Gujarati Sangam MN", "Malayalam Sangam MN", sans-serif;
}
.story-img { display: block; width: 110px; height: 110px; margin: 6px auto 10px; }
.story-text { min-height: 7.5em; }
.story-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.story-nav button:disabled { opacity: 0.4; cursor: default; }
.story-count { font-size: 0.9rem; color: var(--text-soft); }
.flash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; margin: 10px 0 18px; }
.flash { background: var(--bg-card); border: 1px solid #e6c78f; border-radius: 12px; min-height: 96px; cursor: pointer; font: inherit; color: var(--text); display: grid; place-items: center; padding: 6px; }
.flash .glyph { font-size: 2.4rem; line-height: 1.1; color: var(--heading); }
.flash .say { display: none; font-size: 1rem; font-weight: 600; color: var(--green); }
.flash.flip .glyph { font-size: 1.6rem; }
.flash.flip .say { display: block; }
.quiz .opts button.glyph-opt { font-size: 1.6rem; text-align: center; }
#letterQuiz .opts { grid-template-columns: repeat(4, 1fr); }
.palette { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 2px solid #c9b48a; cursor: pointer; }
.swatch.on { outline: 3px solid #a8461a; outline-offset: 2px; }
.colour-box { max-width: 360px; margin: 0 auto; }
.colour-box svg { width: 100%; height: auto; display: block; }
.colour-box .fillable { cursor: pointer; }
.print-card { text-align: center; text-decoration: none; color: var(--text); }
.print-card img { width: 100%; height: 150px; object-fit: contain; background: #fff; border-radius: 8px; }
.print-card span { display: block; margin-top: 6px; font-weight: 600; }
p.meta, .meta { font-size: 0.92rem; color: var(--text-soft); }
@media (max-width: 860px) { #letterQuiz .opts { grid-template-columns: repeat(2, 1fr); } .story-text { min-height: 0; } }

/* Fixes after device testing */
:root { --bg-panel: rgba(255, 251, 236, 0.80); --bg-card: rgba(255, 253, 245, 0.90); }
.bg-art { opacity: 0.22; }
@media (max-width: 860px) {
  .sidebar { z-index: 50; }
  body.nav-open .scrim { z-index: 45; }
}
.card h4[lang] { font-size: 1.6rem; margin-bottom: 2px; }
