/* AI Pathshala Apps — shared design system.
   Every app links this file. Use the tokens (var(--...)) and the classes below;
   use logical properties (margin-inline-start, padding-inline, inset-inline-end)
   so Urdu (right-to-left) lays out correctly. */

:root {
  --bg: #faf6f0;
  --surface: #ffffff;
  --surface-2: #f3ece2;
  --surface-3: #eadfd0;
  --text: #1b2a30;
  --muted: #5a6a70;
  --border: #e3d8c9;
  --primary: #0b4f5c;
  --primary-hover: #093f4a;
  --primary-ink: #ffffff;
  --primary-soft: #dcefef;
  --accent: #d9501c;
  --accent-soft: #fde6da;
  --success: #15803d;
  --success-soft: #dcfce7;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --warning: #a15c07;
  --warning-soft: #fef0c7;
  --info: #0b69a3;
  --info-soft: #e0f2fe;
  /* categorical palette for charts / groups (works on light + dark) */
  --c1: #0b7285; --c2: #e8590c; --c3: #5f3dc4; --c4: #2b8a3e; --c5: #c2255c; --c6: #b08900; --c7: #1971c2; --c8: #868e96;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 30, 35, .06), 0 4px 14px rgba(20, 30, 35, .06);
  --shadow-lg: 0 10px 30px rgba(20, 30, 35, .14);
  --font-script: "Noto Sans";
  --font: var(--font-script), "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Nirmala UI", "Mangal", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Consolas", "Noto Sans Mono", monospace;
  --maxw: 1180px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e181c; --surface: #15232a; --surface-2: #1b2d35; --surface-3: #233a44;
    --text: #e6eef0; --muted: #9bb0b6; --border: #2a414a;
    --primary: #5cc0cf; --primary-hover: #7dd0dc; --primary-ink: #052229; --primary-soft: #16363e;
    --accent: #ff7a45; --accent-soft: #3a2218;
    --success: #4ade80; --success-soft: #12301f; --danger: #f87171; --danger-soft: #3a1717;
    --warning: #fbbf24; --warning-soft: #33280e; --info: #60a5fa; --info-soft: #11263d;
    --c1: #3bc9db; --c2: #ff922b; --c3: #9775fa; --c4: #69db7c; --c5: #f06595; --c6: #ffd43b; --c7: #4dabf7; --c8: #adb5bd;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
    --shadow-lg: 0 10px 30px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e181c; --surface: #15232a; --surface-2: #1b2d35; --surface-3: #233a44;
  --text: #e6eef0; --muted: #9bb0b6; --border: #2a414a;
  --primary: #5cc0cf; --primary-hover: #7dd0dc; --primary-ink: #052229; --primary-soft: #16363e;
  --accent: #ff7a45; --accent-soft: #3a2218;
  --success: #4ade80; --success-soft: #12301f; --danger: #f87171; --danger-soft: #3a1717;
  --warning: #fbbf24; --warning-soft: #33280e; --info: #60a5fa; --info-soft: #11263d;
  --c1: #3bc9db; --c2: #ff922b; --c3: #9775fa; --c4: #69db7c; --c5: #f06595; --c6: #ffd43b; --c7: #4dabf7; --c8: #adb5bd;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.45);
  color-scheme: dark;
}
:root[lang="ur"] { --font: var(--font-script), "Noto Sans", system-ui, "Segoe UI", sans-serif; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 96px; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.55;
}
:root[lang="ur"] body { line-height: 1.9; }
/* Nastaliq needs taller lines; big numerals read better in a Latin face */
:root[lang="ur"] input, :root[lang="ur"] textarea, :root[lang="ur"] select, :root[lang="ur"] .btn { line-height: 2; }
:root[lang="ur"] .edu-title { line-height: 2; padding-block: 2px; }
:root[lang="ur"] .big-number, :root[lang="ur"] .mono, :root[lang="ur"] kbd { font-family: "Noto Sans", system-ui, "Segoe UI", sans-serif; }
img, svg, canvas, video { max-width: 100%; }
a { color: var(--primary); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }
code, kbd, pre, .mono { font-family: var(--mono); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- shell (built by EDU.init) ---------- */
.edu-top {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.edu-top-in {
  max-width: var(--maxw); margin: 0 auto; padding: 8px 16px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.edu-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 700; white-space: nowrap; }
.edu-brand img { width: 34px; height: 34px; border-radius: 9px; }
.edu-brand .edu-brand-txt { font-size: .95rem; }
.edu-back { font-size: .9rem; text-decoration: none; color: var(--muted); white-space: nowrap; padding: 4px 8px; border-radius: 8px; }
[dir="rtl"] .edu-back-arrow { display: inline-block; transform: scaleX(-1); }
.edu-back:hover { background: var(--surface-2); color: var(--text); }
.edu-title { font-size: 1.05rem; margin: 0; font-weight: 700; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.edu-tools { display: flex; align-items: center; gap: 6px; margin-inline-start: auto; }
.edu-lang { max-width: 9.5rem; padding: 6px 8px; font-size: .9rem; }
.edu-iconbtn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 1.05rem;
  display: inline-grid; place-items: center; padding: 0;
}
.edu-iconbtn:hover { background: var(--surface-2); }
.edu-wa { color: var(--success); text-decoration: none; }
.edu-wa svg { display: block; }
@media (max-width: 560px) {
  .edu-brand .edu-brand-txt { display: none; }
  .edu-top-in { gap: 8px; }
  .edu-back { padding: 4px 6px; }
  .edu-tools { gap: 4px; }
  .edu-tools .edu-iconbtn { width: 36px; height: 36px; }
  .edu-lang { max-width: 8.4rem; padding-inline: 6px; }
  .edu-title { order: 3; flex-basis: 100%; white-space: normal; font-size: 1rem; }
}

.edu-main { flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 18px 16px 32px; }
.edu-main.edu-wide { max-width: 1500px; }
.edu-wide-page .edu-top-in, .edu-wide-page .edu-foot-in { max-width: 1500px; }
.edu-intro { color: var(--muted); margin: 0 0 16px; max-width: 75ch; }

.edu-foot { border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .88rem; }
.edu-foot-in { max-width: var(--maxw); margin: 0 auto; padding: 14px 16px; display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; justify-content: space-between; }
.edu-foot a { color: var(--primary); text-decoration: none; font-weight: 600; }
.edu-foot-links { display: inline-flex; flex-wrap: wrap; gap: 6px 18px; }

/* ---------- "get updates" reminder (EDU shell, app pages only; see ctaInit in edu.js) ----------
   Never on first paint, never in full screen / projector mode, never over content: on wide screens a small pill in
   the header (it takes room from the title only), on phones and tablets a bar in the page flow above the footer. */
.edu-cta { display: flex; align-items: center; gap: 2px; min-width: 0; animation: edu-pop .25s ease-out; }
.edu-cta-link { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--text); text-decoration: none; font-weight: 700; }
.edu-cta-link:hover .edu-cta-txt { text-decoration: underline; }
.edu-cta-ic { flex: none; }
.edu-cta-txt { min-width: 0; }
.edu-cta-x { flex: none; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 999px; font: inherit; font-size: .95rem; line-height: 1; display: inline-grid; place-items: center; padding: 0; }
.edu-cta-x:hover { background: var(--surface); color: var(--text); }
.edu-top .edu-cta { flex: 0 1 auto; max-width: 21rem; border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--border)); background: var(--accent-soft); border-radius: 999px; padding: 2px 3px 2px 12px; }
.edu-top .edu-cta-link { font-size: .86rem; padding: 6px 0; }
.edu-top .edu-cta-txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.edu-top .edu-cta-x { width: 32px; height: 32px; }
.edu-cta-on .edu-title { flex-basis: 0; }   /* the title gives up room (ellipsis) so the header stays one line */
.edu-cta-row { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px 16px; }
.edu-wide-page .edu-cta-row { max-width: 1500px; }
.edu-cta-row .edu-cta { border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--border)); border-inline-start-width: 5px; background: var(--accent-soft); border-radius: 12px; padding: 4px 4px 4px 14px; }
.edu-cta-row .edu-cta-link { flex: 1 1 auto; min-height: 44px; padding: 6px 0; }
.edu-cta-row .edu-cta-x { width: 44px; height: 44px; }
:root[lang="ur"] .edu-cta-link { line-height: 2; }
.edu-fullscreen-on .edu-cta, .edu-fullscreen-on .edu-cta-row { display: none !important; }
body:has(.present, .presenting) .edu-cta, body:has(.present, .presenting) .edu-cta-row { display: none !important; }
@media print { .edu-cta, .edu-cta-row { display: none !important; } }

/* ---------- layout helpers ---------- */
.stack > * + * { margin-top: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.nowrap { flex-wrap: nowrap; }
.spread { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { display: grid; gap: 16px; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); align-items: start; }
@media (max-width: 860px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .split { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 620px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.tiny { font-size: .78rem; }
.big-number { font-size: clamp(2.2rem, 7vw, 4.5rem); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.mt0 { margin-top: 0 !important; } .mb0 { margin-bottom: 0 !important; }
.w100 { width: 100%; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card.flat { box-shadow: none; }
.card h2, .card h3 { margin-top: 0; }
.panel { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; }
.callout { border-inline-start: 4px solid var(--primary); background: var(--primary-soft); padding: 10px 14px; border-radius: var(--radius-sm); }
.callout.accent { border-color: var(--accent); background: var(--accent-soft); }
.callout.success { border-color: var(--success); background: var(--success-soft); }
.callout.danger { border-color: var(--danger); background: var(--danger-soft); }
.callout.warning { border-color: var(--warning); background: var(--warning-soft); }
.divider { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 15px; border-radius: 10px; font: inherit; font-weight: 600; font-size: .95rem;
  cursor: pointer; text-decoration: none; line-height: 1.2; min-height: 40px; user-select: none;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(1.05); background: var(--accent); }
/* WhatsApp share + YouTube subscribe buttons (white text on brand colours, AA contrast) */
.btn-wa { background: #0f7a41; border-color: #0f7a41; color: #fff; }
.btn-wa:hover { background: #0b6535; border-color: #0b6535; }
.btn-yt { background: #c4161c; border-color: #c4161c; color: #fff; }
.btn-yt:hover { background: #a51217; border-color: #a51217; }
.btn-wa svg, .btn-yt svg { flex: none; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: .85rem; border-radius: 8px; }
.btn-lg { padding: 13px 22px; min-height: 50px; font-size: 1.1rem; border-radius: 12px; }
.btn.active, .btn[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--text); }

input[type="text"], input[type="number"], input[type="search"], input[type="email"], input[type="url"],
input[type="password"], input[type="date"], input[type="time"], input:not([type]), select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 11px; min-height: 40px; max-width: 100%;
}
textarea { min-height: 90px; resize: vertical; width: 100%; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
input[type="range"] { accent-color: var(--primary); width: 100%; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 18px; height: 18px; }
input[type="color"] { width: 44px; height: 38px; border: 1px solid var(--border); border-radius: 8px; padding: 2px; background: var(--surface); }
label { font-weight: 600; font-size: .92rem; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span, .field > .hint { font-weight: 400; color: var(--muted); font-size: .84rem; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--text); padding: 8px 13px; font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; }
.seg button + button { border-inline-start: 1px solid var(--border); }
.seg button[aria-pressed="true"], .seg button.active { background: var(--primary); color: var(--primary-ink); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; padding: 9px 14px; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
@media (max-width: 560px) { .tabs { flex-wrap: wrap; overflow-x: visible; } }
.tabs button[aria-selected="true"], .tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .76rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: .88rem; cursor: pointer; color: var(--text); }
.chip[aria-pressed="true"], .chip.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

kbd { background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; font-size: .85em; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: start; vertical-align: top; }
.table th { background: var(--surface-2); font-weight: 700; position: sticky; top: 0; }
.table tr:hover td { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.table input, .table select { min-height: 34px; padding: 5px 8px; width: 100%; }

/* ---------- feedback ---------- */
.edu-toast-wrap { position: fixed; inset-inline: 0; bottom: 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 1000; pointer-events: none; padding: 0 16px; }
.edu-toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 600; max-width: 520px; animation: edu-pop .18s ease-out; }
@keyframes edu-pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.progress { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: inherit; transition: width .25s; }
.ok { color: var(--success); } .bad { color: var(--danger); }

/* ---------- modal ---------- */
.edu-modal-back { position: fixed; inset: 0; background: rgba(5, 15, 20, .55); display: grid; place-items: center; z-index: 900; padding: 16px; }
.edu-modal { background: var(--surface); color: var(--text); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: min(640px, 100%); max-height: 90vh; overflow: auto; padding: 20px; }

/* ---------- canvas / stage ---------- */
.stage { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; position: relative; }
.stage canvas { display: block; width: 100%; height: auto; touch-action: none; }

/* ---------- presentation (projector) mode ---------- */
.present { font-size: clamp(1.1rem, 2.2vw, 1.6rem); }
.edu-fullscreen-on .edu-top, .edu-fullscreen-on .edu-foot { display: none; }

/* ---------- print ---------- */
@media print {
  :root, :root[data-theme="dark"], :root:not([data-theme="light"]) {
    --bg: #fff; --surface: #fff; --surface-2: #f2f2f2; --surface-3: #e8e8e8; --text: #000; --muted: #444; --border: #bbb;
    --primary-soft: #eef6f7; --accent-soft: #fdf0ea; color-scheme: light;
  }
  .edu-top, .edu-foot, .no-print, .edu-toast-wrap { display: none !important; }
  body { background: #fff; color: #000; }
  .edu-main { max-width: none; padding: 0; }
  .card { box-shadow: none; border-color: #bbb; break-inside: avoid; }
  .print-only { display: block !important; }
  a { color: #000; text-decoration: none; }
}
.print-only { display: none; }

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