/* JSYM Practice — "Marathi devotional print": paper ground, ink, saffron rules.
   Offline-first: system Devanagari + serif faces, no webfont fetch. */

:root {
  --paper:    #f4ecdf;
  --paper-2:  #fbf6ee;
  --card:     #fffdf8;
  --ink:      #241c14;
  --ink-soft: #6b5c4a;
  --rule:     #ddd0b9;
  --saffron:  #d1741d;
  --vermil:   #9d2f1f;
  --maroon:   #6d1f1a;
  --leaf:     #4a6b4f;
  --shadow:   0 1px 2px rgba(60,40,20,.07), 0 8px 24px -12px rgba(60,40,20,.22);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E");
  --dev: "Shree Devanagari 714", "Kohinoor Devanagari", "Devanagari Sangam MN", serif;
  --serif: "Iowan Old Style", "Charter", "Palatino", Georgia, serif;
  --ui: "Avenir Next", "Optima", "Gill Sans", sans-serif;
}
:root[data-theme="dark"] {
  --paper:    #16120e;
  --paper-2:  #1c1712;
  --card:     #221c16;
  --ink:      #ece1d1;
  --ink-soft: #a2917c;
  --rule:     #392f25;
  --saffron:  #e0912f;
  --vermil:   #d2603f;
  --maroon:   #b9754a;
  --leaf:     #86a980;
  --shadow:   0 1px 2px rgba(0,0,0,.4), 0 10px 28px -14px rgba(0,0,0,.7);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--ui);
  background: var(--paper);
  background-image: var(--grain);
  color: var(--ink);
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; }
:lang(mr), .mr { font-family: var(--dev); }

/* ── top bar ─────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mark {
  font-family: var(--dev); font-size: 22px; line-height: 1;
  color: var(--card); background: var(--maroon);
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--saffron) 55%, transparent);
}
.wordmark { display: flex; flex-direction: column; min-width: 0; }
.wordmark b { font-family: var(--dev); font-size: 17px; line-height: 1.15; }
.wordmark i {
  font-style: normal; font-size: 10.5px; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── buttons ─────────────────────────────────────────── */
button { font: inherit; cursor: pointer; border-radius: 10px; }
.ghost {
  background: transparent; color: var(--ink);
  border: 1px solid var(--rule); padding: 7px 11px;
}
.ghost:active { background: var(--card); }
.primary {
  background: var(--maroon); color: #fdf6ea; border: 0;
  padding: 12px 18px; font-weight: 600; letter-spacing: .01em;
  box-shadow: var(--shadow);
}
.primary:active { transform: translateY(1px); }
.back {
  background: none; border: 0; color: var(--ink-soft);
  padding: 14px 16px 6px; font-size: 15px;
}

/* ── views ───────────────────────────────────────────── */
.view { max-width: 940px; margin: 0 auto; padding: 4px 16px 32px; }
.view > h1 { font-size: 26px; margin: 18px 0 4px; }
.lede { color: var(--ink-soft); margin: 0 0 18px; max-width: 60ch; line-height: 1.5; }

/* ── search + filters ────────────────────────────────── */
.searchwrap { padding: 14px 0 6px; }
#search {
  width: 100%; font: inherit; font-size: 16px;
  padding: 13px 15px; color: var(--ink);
  background: var(--card); border: 1px solid var(--rule);
  border-radius: 12px; box-shadow: var(--shadow);
}
#search:focus { outline: 2px solid color-mix(in srgb, var(--saffron) 60%, transparent); outline-offset: 1px; }
.filters { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none; background: transparent; color: var(--ink-soft);
  border: 1px solid var(--rule); padding: 6px 13px; font-size: 13.5px;
}
.chip.active { background: var(--maroon); border-color: var(--maroon); color: #fdf6ea; }
.count { color: var(--ink-soft); font-size: 13px; margin: 12px 2px 8px; letter-spacing: .02em; }

/* ── gallery ─────────────────────────────────────────── */
.grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
}
.card {
  position: relative; text-align: left; padding: 0; overflow: hidden;
  background: var(--card); border: 1px solid var(--rule);
  border-radius: 14px; box-shadow: var(--shadow);
  animation: rise .38s cubic-bezier(.2,.7,.3,1) backwards;
  transition: transform .16s ease, box-shadow .16s ease;
}
.card:active { transform: scale(.985); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.card .thumb {
  aspect-ratio: 4/3; width: 100%; object-fit: cover; display: block;
  background: linear-gradient(160deg, var(--paper-2), var(--rule));
}
.card .body { padding: 9px 11px 12px; }
.card .name-mr { font-family: var(--dev); font-size: 17px; line-height: 1.25; }
.card .name-en { font-size: 12px; color: var(--ink-soft); margin-top: 2px; line-height: 1.3; }
.card .tags { display: flex; gap: 5px; margin-top: 8px; flex-wrap: wrap; }
.tag {
  font-size: 10px; letter-spacing: .05em; text-transform: uppercase;
  padding: 3px 6px; border-radius: 5px;
  background: color-mix(in srgb, var(--saffron) 16%, transparent);
  color: color-mix(in srgb, var(--vermil) 88%, var(--ink));
}
.tag.seq { background: color-mix(in srgb, var(--leaf) 18%, transparent); color: var(--leaf); }
.empty { color: var(--ink-soft); padding: 40px 0; text-align: center; }

/* ── detail ──────────────────────────────────────────── */
.detail-head { padding: 2px 0 14px; border-bottom: 1px solid var(--rule); margin-bottom: 16px; }
.detail-head h1 { font-family: var(--dev); font-size: 30px; margin: 0; }
.detail-head p { margin: 4px 0 0; color: var(--ink-soft); font-size: 15px; }
.player {
  position: relative; background: #0d0a07; border-radius: 14px;
  overflow: hidden; box-shadow: var(--shadow); aspect-ratio: 16/9;
}
.player video { width: 100%; height: 100%; object-fit: contain; display: block; }
.novideo { position: absolute; inset: 0; display: grid; place-items: center; color: #c8b79f; font-size: 14px; }
.sources { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.sources::-webkit-scrollbar { display: none; }
.src {
  flex: none; text-align: left; background: var(--card); color: var(--ink);
  border: 1px solid var(--rule); padding: 8px 12px; min-width: 132px;
  border-radius: 10px; line-height: 1.3;
}
.src.active { border-color: var(--maroon); box-shadow: inset 0 0 0 1px var(--maroon); }
.src b { display: block; font-size: 12.5px; font-weight: 600; }
.src span { display: block; font-size: 10.5px; color: var(--ink-soft); margin-top: 3px; letter-spacing: .04em; text-transform: uppercase; }

.strip-sec { margin-top: 22px; }
.strip-sec h2 { font-size: 17px; margin: 0 0 10px; display: flex; align-items: baseline; gap: 8px; }
.strip-sec h2 em { font-style: normal; font-size: 12px; color: var(--ink-soft); font-family: var(--ui); }
.strip { display: flex; gap: 9px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; }
.strip::-webkit-scrollbar { height: 4px; }
.strip::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; }
.step {
  flex: none; width: 132px; scroll-snap-align: start; padding: 0;
  border: 1px solid var(--rule); border-radius: 10px; overflow: hidden;
  background: var(--card); position: relative;
}
.step img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.step .n {
  position: absolute; top: 6px; left: 6px; font-family: var(--dev);
  background: color-mix(in srgb, var(--maroon) 92%, transparent); color: #fdf6ea;
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; line-height: 1;
}
.hint { font-size: 12px; color: var(--ink-soft); margin: 6px 2px 0; }
.actions { margin: 22px 0 6px; }
.actions .primary { width: 100%; }

.teaching { margin-top: 26px; }
.teaching h2 {
  font-size: 15px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--vermil); font-family: var(--ui); font-weight: 600;
  margin: 24px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--rule);
}
.teaching ul { margin: 0; padding-left: 20px; }
.teaching li { margin-bottom: 9px; line-height: 1.55; }
.teaching .notes {
  font-family: var(--serif); font-size: 16.5px; line-height: 1.6;
  border-left: 3px solid var(--saffron); padding: 4px 0 4px 14px; color: var(--ink);
}
.teaching .src-note { font-size: 12px; color: var(--ink-soft); margin-top: 18px; }

/* ── practice ────────────────────────────────────────── */
.cards { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; margin: 14px 0 22px; }
.bigcard {
  text-align: left; padding: 18px 16px; border-radius: 14px;
  background: var(--maroon); color: #fdf6ea; border: 0; box-shadow: var(--shadow);
}
.bigcard.alt { background: var(--card); color: var(--ink); border: 1px solid var(--rule); }
.bigcard b { font-family: var(--dev); font-size: 21px; display: block; }
.bigcard span { display: block; font-size: 13px; opacity: .82; margin-top: 3px; }
.bigcard em { display: block; font-style: normal; font-size: 11.5px; opacity: .7; margin-top: 12px; letter-spacing: .04em; }

.editor h2 { font-size: 16px; margin: 8px 0 10px; }
.editor ol { padding-left: 22px; margin: 0 0 14px; }
.editor li { margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }
.editor li span { flex: 1; }
.editor li .mini { padding: 3px 8px; font-size: 12px; }

.runner { text-align: center; }
.runner-video { position: relative; margin: 8px auto 14px; border-radius: 16px; overflow: hidden; background: #0d0a07; aspect-ratio: 16/9; }
.runner-video video { width: 100%; height: 100%; object-fit: contain; }
.ring { position: absolute; top: 10px; right: 10px; width: 54px; height: 54px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,.22); stroke-width: 8; }
.ring-fg { fill: none; stroke: var(--saffron); stroke-width: 8; stroke-linecap: round;
           stroke-dasharray: 339.29; transition: stroke-dashoffset .25s linear; }
.runner-count {
  position: absolute; top: 10px; right: 10px; width: 54px; height: 54px;
  display: grid; place-items: center; color: #fff; font-size: 15px; font-weight: 600;
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
}
.runner h2 { font-family: var(--dev); font-size: 28px; margin: 4px 0 0; }
.runner .sub { color: var(--ink-soft); margin: 3px 0 0; }
.runner .next { color: var(--ink-soft); font-size: 13px; margin: 12px 0 0; letter-spacing: .03em; }
.runner-controls { display: flex; gap: 10px; justify-content: center; margin: 16px 0 20px; }
.runner-controls .primary { min-width: 120px; }
.runlist { text-align: left; max-width: 420px; margin: 0 auto; padding-left: 22px; color: var(--ink-soft); line-height: 1.8; }
.runlist .done { opacity: .45; text-decoration: line-through; }
.runlist .now { color: var(--vermil); font-weight: 600; }

/* ── course ──────────────────────────────────────────── */
.day { border: 1px solid var(--rule); border-radius: 12px; background: var(--card); margin-bottom: 10px; overflow: hidden; }
.day > summary { padding: 13px 15px; cursor: pointer; display: flex; align-items: baseline; gap: 10px; list-style: none; }
.day > summary::-webkit-details-marker { display: none; }
.day .dn { font-family: var(--serif); font-size: 15px; font-weight: 600; }
.day .dc { font-size: 12px; color: var(--ink-soft); margin-left: auto; }
.day ol { margin: 0; padding: 0 16px 14px 34px; }
.day li { margin-bottom: 6px; line-height: 1.45; }
.day li b { font-family: var(--dev); font-weight: 500; }
.day li i { font-style: normal; color: var(--ink-soft); font-size: 12px; }

/* learning-order list */
.dayhead {
  font-family: var(--ui); font-size: 12px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--vermil);
  margin: 22px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--rule);
}
.lrow {
  display: flex; align-items: center; gap: 12px; width: 100%;
  text-align: left; background: var(--card); color: var(--ink);
  border: 1px solid var(--rule); border-radius: 11px;
  padding: 10px 12px; margin-bottom: 7px;
}
.lrow:active { transform: scale(.99); }
.lrow .ln {
  font-family: var(--dev); flex: none; width: 27px; height: 27px;
  border-radius: 50%; display: grid; place-items: center; font-size: 13px;
  background: color-mix(in srgb, var(--saffron) 18%, transparent);
  color: var(--vermil);
}
.lrow .lname { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lrow .lname b { font-family: var(--dev); font-size: 16px; font-weight: 500; }
.lrow .lname i { font-style: normal; font-size: 12px; color: var(--ink-soft); }
.lrow .lmeta { font-size: 11px; color: var(--ink-soft); flex: none; }
.bigcard.wide { grid-column: 1 / -1; }

/* ── tab bar ─────────────────────────────────────────── */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  border-top: 1px solid var(--rule);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  background: none; border: 0; border-radius: 0; color: var(--ink-soft);
  padding: 9px 4px 11px; font-size: 11px; letter-spacing: .05em;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tabs button span { font-size: 17px; line-height: 1; }
.tabs button.active { color: var(--vermil); }

@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); }
  .detail-head h1 { font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* credits */
.crow {
  display: flex; align-items: center; gap: 12px; width: 100%;
  text-decoration: none; color: var(--ink);
  background: var(--card); border: 1px solid var(--rule);
  border-radius: 11px; padding: 11px 13px; margin-bottom: 7px;
}
.crow .lmeta { color: var(--vermil); font-size: 11px; flex: none; }
.crow .lname b { font-family: var(--ui); font-size: 14px; font-weight: 600; }
.crow .lname i { display: block; font-style: normal; font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.origin { margin: 10px 2px 0; }
.origin a { color: var(--vermil); font-size: 13px; text-decoration: none; }
.origin a:hover { text-decoration: underline; }
.sitefoot {
  border-top: 1px solid var(--rule); color: var(--ink-soft);
  font-size: 12px; line-height: 1.7; text-align: center;
  padding: 18px 22px 26px; max-width: 940px; margin: 0 auto;
}
.sitefoot a { color: var(--vermil); }
.linkish {
  background: none; border: 0; color: var(--vermil); font-size: 12px;
  text-decoration: underline; cursor: pointer; padding: 0;
}
