/* ===== Bright Path — styles ===== */

/* Self-hosted Nastaliq (cached by the service worker for offline use) */
@font-face {
  font-family: 'Noto Nastaliq Urdu';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/NotoNastaliqUrdu-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Noto Nastaliq Urdu';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/NotoNastaliqUrdu-Bold.woff2') format('woff2');
}

:root {
  --bg: #fff8ee;
  --card: #ffffff;
  --ink: #2a2440;
  --ink-soft: #625b7a;
  --line: #ece3d3;
  --accent: #5b6cff;
  --good: #1f9d55;
  --good-bg: #e3f7ea;
  --bad: #d64545;
  --bad-bg: #fdeaea;
  --warm: #ff8a3d;
  --sun: #ffc94d;
  --radius: 18px;
  --shadow: 0 2px 0 rgba(42, 36, 64, .06), 0 8px 24px rgba(42, 36, 64, .06);
  --font: ui-rounded, 'SF Pro Rounded', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --tabbar: 68px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
a { color: var(--accent); }

/* ===== Urdu (Nastaliq) — never below 18px ===== */
.ur {
  font-family: 'Noto Nastaliq Urdu', serif;
  direction: rtl;
  line-height: 1.95;
  unicode-bidi: isolate;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0;
  word-spacing: .05em;
}
.ur.big { font-size: 34px; }
.ur.mid { font-size: 26px; }
.ur.verse { font-size: 26px; display: block; white-space: pre-line; text-align: center; }
.roman { font-weight: 800; font-size: 1.15em; color: var(--accent); letter-spacing: .01em; }
.roman.big { font-size: 26px; }
.item-ur { display: inline-flex; flex-direction: column; align-items: center; gap: 0; }
.item-ur .roman { font-size: 17px; line-height: 1.2; }
.item-ur .en { font-size: 14px; color: var(--ink-soft); }

/* ===== app shell ===== */
.app-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(255, 248, 238, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.app-header h1 { font-size: 20px; margin: 0; flex: 1; letter-spacing: -.01em; }
.app-header .back { border: 0; background: none; font-size: 26px; padding: 0 6px 0 0; cursor: pointer; }
.streak-pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 12px; font-weight: 800;
}
main#view { padding: 16px 16px calc(var(--tabbar) + 28px + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--ink-soft); font-size: 12px; font-weight: 700;
}
.tabbar a span.i { font-size: 22px; line-height: 1; }
.tabbar a.on { color: var(--accent); }

/* ===== cards and buttons ===== */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin: 0 0 14px; border: 1px solid var(--line);
}
.card h2, .card h3 { margin: 0 0 8px; }
.muted { color: var(--ink-soft); }
.small { font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px; padding: 14px 20px; min-height: 50px;
  font-weight: 800; font-size: 17px; cursor: pointer;
  background: var(--accent); color: #fff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .15);
  transition: transform .08s ease;
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, .15); }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--ink); border: 2px solid var(--line); box-shadow: none; }
.btn.good { background: var(--good); }
.btn[disabled] { opacity: .45; cursor: default; }
.iconbtn { border: 1px solid var(--line); background: #fff; border-radius: 12px; min-width: 44px; min-height: 44px; cursor: pointer; font-size: 20px; }

/* ===== Today ===== */
.hello { font-size: 26px; font-weight: 900; margin: 4px 0 2px; letter-spacing: -.01em; }
.streak-hero {
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(135deg, #ffe7c2, #ffd3a8); border: 0;
}
.streak-hero .flame { font-size: 46px; line-height: 1; }
.streak-hero .num { font-size: 34px; font-weight: 900; line-height: 1; }
.plan-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; border-radius: 16px; background: #fff; border: 2px solid var(--line);
  margin-bottom: 10px; text-decoration: none; color: inherit;
}
.plan-item .ic {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 24px;
  background: color-mix(in srgb, var(--c, #5b6cff) 16%, white); flex: none;
}
.plan-item .t { font-weight: 800; }
.plan-item .s { font-size: 14px; color: var(--ink-soft); }
.plan-item.done { border-color: var(--good); background: var(--good-bg); }
.plan-item .tick { margin-left: auto; font-size: 22px; }
.level-badge {
  display: inline-block; font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--c, #5b6cff) 16%, white); color: var(--c, #5b6cff);
}
.ring { width: 64px; height: 64px; flex: none; }

/* ===== lesson ===== */
.lesson-top { border-top: 6px solid var(--c, var(--accent)); }
.lesson-top h2 { font-size: 24px; line-height: 1.2; }
.block { margin: 0 0 14px; }
.block p { margin: 0 0 10px; }
.arrow { color: var(--warm); font-weight: 900; padding: 0 4px; }
.callout { background: #fff7d6; border: 2px dashed #f0cf6a; }
.callout h3 { font-size: 16px; }
.svgbox { background: #fff; border-radius: var(--radius); border: 1px solid var(--line); padding: 10px; text-align: center; }
.svgbox svg { width: 100%; height: auto; max-height: 340px; }
.svgbox .cap { font-size: 14px; color: var(--ink-soft); margin-top: 6px; }

.word-card .w { font-size: 30px; font-weight: 900; letter-spacing: -.01em; }
.word-card .say { font-weight: 800; color: var(--warm); }
.word-card .pos { font-style: italic; color: var(--ink-soft); font-size: 15px; }
.word-card .ex { border-left: 4px solid var(--sun); padding-left: 10px; margin-top: 8px; }
.urdu-card { text-align: center; }
.urdu-card .en { font-size: 18px; color: var(--ink-soft); margin-top: 4px; }
.urdu-card .ex { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.proverb-card { text-align: center; background: linear-gradient(180deg, #fbf7ff, #fff); }
.proverb-card .kind { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: #8a5cf6; }
.proverb-card .roman { display: block; white-space: pre-line; margin: 6px 0 10px; }
.proverb-card .why { text-align: left; background: #f4efff; border-radius: 12px; padding: 10px 12px; margin-top: 10px; }
.poem { font-size: 19px; line-height: 1.7; padding: 8px 0; }
.poem .st { margin-bottom: 14px; }
.example { border-left: 6px solid var(--c, var(--accent)); }
.example .steps { list-style: none; padding: 0; margin: 8px 0; }
.example .steps li { padding: 6px 0 6px 30px; position: relative; }
.example .steps li::before { content: '→'; position: absolute; left: 4px; color: var(--warm); font-weight: 900; }
.example .ans { font-weight: 900; background: var(--good-bg); border-radius: 10px; padding: 8px 12px; display: inline-block; }

/* ===== practice ===== */
.qhead { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar { height: 12px; border-radius: 999px; background: #efe6d6; overflow: hidden; flex: 1; }
.bar > i { display: block; height: 100%; background: var(--c, var(--accent)); border-radius: 999px; transition: width .3s ease; }
.qtext { font-size: 20px; font-weight: 700; margin: 6px 0 16px; }
.qtext .item-ur { width: 100%; }
.opts { display: grid; gap: 10px; }
.opt {
  text-align: left; padding: 14px 16px; min-height: 54px; border-radius: 14px;
  border: 2px solid var(--line); background: #fff; cursor: pointer; font-size: 18px; font-weight: 700;
  box-shadow: 0 3px 0 var(--line);
}
.opt.ur-opt { text-align: center; }
.opt.sel { border-color: var(--accent); background: #eef0ff; }
.opt.right { border-color: var(--good); background: var(--good-bg); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt[disabled] { cursor: default; }
.blank { display: inline-block; min-width: 90px; border-bottom: 3px solid var(--accent); text-align: center; padding: 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 8px 14px; cursor: pointer; font-weight: 800; font-size: 17px; box-shadow: 0 3px 0 var(--line); }
.chip.right { border-color: var(--good); background: var(--good-bg); }
.chip.wrong { border-color: var(--bad); background: var(--bad-bg); }
.feedback { border-radius: 14px; padding: 12px 14px; margin-top: 14px; font-weight: 700; }
.feedback.good { background: var(--good-bg); color: #13603a; }
.feedback.bad { background: var(--bad-bg); color: #8d2323; }

/* fix-the-sentence */
.fix { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 2px 0; font-size: 22px; line-height: 1.4; margin-bottom: 14px; }
.fix .w { border: 0; background: #f6f1e8; border-radius: 8px; padding: 4px 8px; cursor: pointer; font-size: 22px; font-weight: 700; }
.fix .w.cap { background: #e6e9ff; color: var(--accent); }
.fix .dot { border: 0; background: none; width: 26px; height: 40px; cursor: pointer; font-size: 30px; line-height: 1; color: #d9cfbd; padding: 0; }
.fix .dot.on { color: var(--ink); font-weight: 900; }
.fix .w.miss { outline: 3px solid var(--bad); }
.fix .dot.miss { color: var(--bad); }

/* match */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match .col { display: grid; gap: 10px; align-content: start; }
.match .m { border: 2px solid var(--line); background: #fff; border-radius: 14px; padding: 10px; min-height: 58px; cursor: pointer; font-weight: 700; font-size: 17px; box-shadow: 0 3px 0 var(--line); }
.match .m.sel { border-color: var(--accent); background: #eef0ff; }
.match .m.done { border-color: var(--good); background: var(--good-bg); cursor: default; opacity: .9; }
.match .m.shake { animation: shake .3s; border-color: var(--bad); }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* finish */
.finish { text-align: center; }
.finish .stars { font-size: 46px; letter-spacing: 6px; }
.finish .score { font-size: 40px; font-weight: 900; }
.pop { animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }

/* papers */
.timer { font-weight: 900; font-variant-numeric: tabular-nums; padding: 4px 12px; border-radius: 999px; background: #eef0ff; color: var(--accent); }
.timer.low { background: var(--bad-bg); color: var(--bad); }
.qdots { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.qdots button { width: 34px; height: 34px; border-radius: 10px; border: 2px solid var(--line); background: #fff; font-weight: 800; cursor: pointer; }
.qdots button.ans { background: #eef0ff; border-color: var(--accent); }
.qdots button.cur { outline: 3px solid var(--sun); }
.qdots button.right { background: var(--good-bg); border-color: var(--good); }
.qdots button.wrong { background: var(--bad-bg); border-color: var(--bad); }

/* sims */
.sim { background: #f2fbff; border: 2px solid #cdeaf7; }
.sim .stage { background: #fff; border-radius: 14px; border: 1px solid var(--line); touch-action: none; user-select: none; -webkit-user-select: none; overflow: hidden; }
.sim .stage svg, .sim .stage canvas { display: block; width: 100%; height: auto; }
.sim .controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.sim .toggle { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 8px 14px; font-weight: 800; cursor: pointer; }
.sim .toggle.on { background: var(--good-bg); border-color: var(--good); }
.sim .readout { font-weight: 800; margin-top: 8px; }
.sim input[type=range] { width: 100%; accent-color: var(--warm); height: 32px; }

/* progress */
.subj-row { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; }
.subj-row .ic { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; background: color-mix(in srgb, var(--c, #5b6cff) 16%, white); }
.days14 { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; }
.days14 i { aspect-ratio: 1; border-radius: 6px; background: #efe6d6; display: block; }
.days14 i.on { background: var(--warm); }
.stat { text-align: center; }
.stat b { display: block; font-size: 26px; }

/* settings */
.switch { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.switch:last-child { border-bottom: 0; }
.switch .lbl { flex: 1; }
.switch input { width: 52px; height: 30px; accent-color: var(--good); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + 18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; z-index: 50; max-width: 92vw;
}
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 3px; animation: fall 1.6s ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); opacity: .8; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

#print-root { display: none; }

/* ===== Print: clean A4 worksheet ===== */
@media print {
  @page { size: A4; margin: 18mm 18mm 20mm; }
  html, body { background: #fff !important; color: #000; font-size: 12.5pt; line-height: 1.55; }
  .app-header, .tabbar, main#view, .toast, .confetti { display: none !important; }
  #print-root { display: block; }

  .ws { font-family: var(--font); }
  .ws-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #000; padding-bottom: 6pt; margin-bottom: 14pt; }
  .ws-head h1 { font-size: 20pt; margin: 0; }
  .ws-head .meta { font-size: 10.5pt; text-align: right; }
  .ws-line { display: inline-block; width: 45mm; border-bottom: 1px solid #000; }
  .ws h2 { break-after: avoid; page-break-after: avoid; font-size: 14pt; margin: 18pt 0 8pt; border-bottom: 1px solid #999; padding-bottom: 3pt; }
  .ws-block { margin: 0 0 12pt; break-inside: avoid; page-break-inside: avoid; }
  .ws-block p { margin: 0 0 6pt; }
  .ws-word { border: 1px solid #bbb; border-radius: 6pt; padding: 8pt 10pt; margin-bottom: 8pt; break-inside: avoid; }
  .ws-word .w { font-size: 15pt; font-weight: 800; }
  .ws svg { max-width: 120mm; max-height: 70mm; height: auto; display: block; margin: 4pt auto; }
  .ws .ur { font-size: 22px; line-height: 1.95; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ws .ur.big { font-size: 30px; }
  .ws .ur.verse { font-size: 24px; }
  .ws .roman { color: #000; font-weight: 800; }
  .ws-q { margin: 0 0 18pt; break-inside: avoid; page-break-inside: avoid; }
  .ws-q .n { font-weight: 800; margin-right: 4pt; }
  .ws-opts { list-style: none; padding: 0; margin: 6pt 0 0 14pt; columns: 2; column-gap: 12mm; }
  .ws-opts li { margin: 0 0 6pt; break-inside: avoid; }
  .ws-opts li::before { content: '◯'; margin-right: 6pt; }
  .ws-bank { border: 1px dashed #000; border-radius: 6pt; padding: 6pt 10pt; margin: 6pt 0 0; display: inline-block; }
  .ws-bank span { margin: 0 8pt; display: inline-block; }
  .ws-write { border-bottom: 1px solid #777; height: 11mm; }
  .ws-match { display: grid; grid-template-columns: 1fr 30mm 1fr; gap: 8pt 0; align-items: center; margin-top: 6pt; }
  .ws-match .dot { display: flex; justify-content: space-between; padding: 0 4mm; }
  .ws-example { border-left: 3pt solid #000; padding-left: 8pt; }
  .ws-example ol { margin: 4pt 0; padding-left: 16pt; }
  .ws-poem { font-size: 13pt; line-height: 1.7; }
  .ws-poem .st { margin-bottom: 10pt; }
  .ws-answers { break-before: page; page-break-before: always; }
  .ws-answers li { margin-bottom: 4pt; }
  .ws-foot { margin-top: 20pt; font-size: 10pt; color: #555; text-align: center; }
  a { color: #000; text-decoration: none; }
}

.app-header .back.home, .app-header .back.close { font-size: 17px; font-weight: 800; background: rgba(255,255,255,.18); border: 2px solid currentColor; border-radius: 999px; padding: 4px 12px; margin-right: 8px; color: inherit; min-height: 40px; }
