/* Prayag Thinking Lab — shared styles. Phone first (360 px), works up to tablets and laptops. */

/* ---------- Fonts: self-hosted Noto subsets (Latin, Devanagari, Bengali script for Assamese) ---------- */
@font-face { font-family: "TL Sans"; font-weight: 400; font-display: swap; src: url("../fonts/noto-sans-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-21FF, U+2212, U+2215; }
@font-face { font-family: "TL Sans"; font-weight: 700; font-display: swap; src: url("../fonts/noto-sans-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-21FF, U+2212, U+2215; }
@font-face { font-family: "TL Sans"; font-weight: 400; font-display: swap; src: url("../fonts/noto-sans-devanagari-devanagari-400-normal.woff2") format("woff2");
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FF; }
@font-face { font-family: "TL Sans"; font-weight: 700; font-display: swap; src: url("../fonts/noto-sans-devanagari-devanagari-700-normal.woff2") format("woff2");
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FF; }
/* U+0980-09FE includes the Assamese letters ৰ (U+09F0) and ৱ (U+09F1). */
@font-face { font-family: "TL Sans"; font-weight: 400; font-display: swap; src: url("../fonts/noto-sans-bengali-bengali-400-normal.woff2") format("woff2");
  unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+1CD0-1CF7, U+200C-200D, U+20B9, U+25CC, U+A8F1; }
@font-face { font-family: "TL Sans"; font-weight: 700; font-display: swap; src: url("../fonts/noto-sans-bengali-bengali-700-normal.woff2") format("woff2");
  unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+1CD0-1CF7, U+200C-200D, U+20B9, U+25CC, U+A8F1; }

:root {
  --bg: #fff8ef;
  --bg-top: #fff0d9;
  --card: #ffffff;
  --ink: #1d2633;
  --muted: #5a6573;
  --brand: #2563eb;
  --brand-dark: #1d4fc4;
  --brand-soft: #e8efff;
  --brand-ink: #ffffff;
  --accent: #f2a900;
  --accent-soft: #fff3d1;
  --good: #16a34a;
  --warn-bg: #fff4dc;
  --line: #e7dfd2;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(29, 38, 51, .06), 0 6px 18px rgba(29, 38, 51, .07);
  --shadow-lift: 0 2px 4px rgba(29, 38, 51, .08), 0 10px 24px rgba(29, 38, 51, .12);
  --gutter: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
  --font: "TL Sans", "Noto Sans", "Noto Sans Devanagari", "Noto Sans Bengali", system-ui, sans-serif;
  --text: 1rem;
}

/* ---------- Accessibility options (per child) ---------- */
.text-large { --text: 1.15rem; }
.text-xlarge { --text: 1.3rem; }
.high-contrast {
  --bg: #000000; --bg-top: #000000; --card: #000000; --ink: #ffffff; --muted: #e6e6e6;
  --brand: #ffd400; --brand-dark: #ffd400; --brand-soft: #222222; --brand-ink: #000000;
  --accent: #ffd400; --accent-soft: #222222; --line: #ffffff; --warn-bg: #222222; --shadow: none; --shadow-lift: none;
}
.high-contrast .card, .high-contrast .tile { border: 2px solid var(--line); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; color: var(--ink); font: var(--text)/1.55 var(--font);
  background: linear-gradient(180deg, var(--bg-top) 0, var(--bg) 220px) var(--bg) no-repeat;
  min-height: 100vh; min-height: 100dvh;
}
.page { max-width: 640px; margin: 0 auto; padding: 16px var(--gutter) calc(24px + env(safe-area-inset-bottom)); }
a, button, input, select, label { touch-action: manipulation; }
a { color: var(--brand); }
.card { background: var(--card); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .875em; }
.lead { font-size: 1.1em; }
.is-hidden { display: none !important; }
h1 { font-size: clamp(1.3em, 5.4vw, 1.6em); line-height: 1.25; margin: 0 0 10px; }
h2 { font-size: 1.1em; margin: 22px 0 10px; }
h3 { font-size: 1em; margin: 14px 0 6px; }
.card > h2:first-child { margin-top: 0; }
.list { list-style: none; margin: 0 0 12px; padding: 0; }
.list li { margin-bottom: 8px; }
.alert { background: var(--warn-bg); border-left: 5px solid var(--accent); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 14px; }
.alert ul { margin: 6px 0 0; padding-left: 1.2em; }
.block { display: block; font-weight: 400; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Buttons: press feedback, a clear "not yet" state, 48 px minimum ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 12px 20px;
  border: 0; border-radius: var(--radius-sm); background: var(--brand); color: var(--brand-ink);
  font: inherit; font-weight: 700; line-height: 1.2; text-decoration: none; cursor: pointer; text-align: center;
  box-shadow: 0 2px 0 var(--brand-dark); transition: transform .08s ease, box-shadow .08s ease, background .15s ease;
}
.btn:active { transform: translateY(2px); box-shadow: 0 0 0 var(--brand-dark); }
.btn:disabled, .btn[aria-disabled=true] { background: var(--line); color: var(--muted); box-shadow: none; cursor: not-allowed; transform: none; }
.btn-block { display: flex; width: 100%; margin-top: 10px; }
.btn-big { min-height: 60px; font-size: 1.12em; padding: 14px 26px; border-radius: 16px; }
.btn-quiet { background: var(--brand-soft); color: var(--brand); box-shadow: none; }
.btn-quiet:active { background: #d9e5ff; }
.btn-small { min-height: 40px; padding: 6px 12px; font-size: .92em; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.actions form { margin: 0; }
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.actions-grid > :first-child { grid-column: 1 / -1; }
.actions-grid form, .actions-grid form .btn { margin: 0; width: 100%; }
.link-list { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: center; margin-top: 18px; }
.link-list form { margin: 0; }
.link-btn { background: none; border: 0; padding: 10px 4px; min-height: 44px; color: var(--brand); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }

/* ---------- Page header and language switcher (a tick and a ring show the choice, not colour alone) ---------- */
.bar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.bar h1 { margin: 0; }
.lang-switch { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; }
.lang-switch .small { width: 100%; }
.pill {
  min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 2px solid var(--line); background: var(--card);
  color: var(--ink); font: inherit; font-size: .95em; cursor: pointer; text-decoration: none;
}
.pill.is-on { border-color: var(--brand); background: var(--brand-soft); font-weight: 700; }
/* A row of equal buttons (one language per child) */
.seg { display: flex; gap: 4px; padding: 4px; margin: 10px 0 0; border-radius: 999px; background: var(--bg); }
.seg .pill { flex: 1; min-width: 0; padding: 6px 4px; border-color: transparent; background: transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg .pill.is-on { background: var(--card); border-color: var(--brand); box-shadow: var(--shadow); }
.seg-label { display: block; margin-top: 12px; }

/* ---------- Pick your child ---------- */
.children { list-style: none; margin: 14px 0; padding: 0; }
.child-head { display: flex; gap: 12px; align-items: center; min-width: 0; }
.child-head > div { display: flex; flex-direction: column; min-width: 0; }
.child-name { font-size: 1.15em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: #1d2633; font-weight: 700; font-size: 1.25em;
}

/* ---------- Forms ---------- */
.form label { display: block; margin: 12px 0; }
.form input[type=password], .form input[type=time], .form input[type=email], .form select {
  display: block; width: 100%; min-height: 48px; margin-top: 4px; padding: 8px 12px;
  border: 2px solid var(--line); border-radius: var(--radius-sm); font: inherit; background: var(--card); color: var(--ink);
}
.form input:focus, .form select:focus { border-color: var(--brand); outline: none; }
.form .check { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; }
.form .check input { width: 24px; height: 24px; flex: none; margin-top: 2px; accent-color: var(--brand); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); margin: 12px 0; }
.size-large { font-size: 1.2em; } .size-xlarge { font-size: 1.4em; }

/* ---------- Child mode: sticky top bar, time, tiles ---------- */
.child-bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; justify-content: space-between;
  margin: -16px calc(-1 * var(--gutter)) 12px; padding: calc(10px + env(safe-area-inset-top)) var(--gutter) 10px;
  background: rgba(255, 248, 239, .92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.high-contrast .child-bar { background: #000; }
.child-who { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.child-who strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.child-bar .avatar { width: 40px; height: 40px; font-size: 1.1em; }
.coins { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); font-weight: 700; white-space: nowrap; }
.coplay { background: var(--warn-bg); border-radius: var(--radius-sm); padding: 10px 14px; margin: 0 0 14px; }

.time-left { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.time-track { flex: 1; height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.time-fill { display: block; height: 100%; background: var(--good); border-radius: 999px; transition: width 1s linear; }
.time-text { font-weight: 700; font-size: .92em; white-space: nowrap; }

.tiles { list-style: none; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tiles-few { grid-template-columns: 1fr; }
@media (min-width: 560px) { .tiles:not(.tiles-few) { grid-template-columns: repeat(3, 1fr); } }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center;
  min-height: 112px; padding: 12px 8px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow);
  border: 2px solid transparent;
}
a.tile { color: var(--ink); text-decoration: none; transition: transform .08s ease, box-shadow .15s ease; }
a.tile:active { transform: scale(.96); box-shadow: var(--shadow-lift); }
.tile.is-assigned { border-color: var(--accent); background: var(--accent-soft); }
.tile-icon { font-size: 2.4em; line-height: 1.1; }
.tile-name { font-weight: 700; line-height: 1.25; }
.tile .small { line-height: 1.3; }
.stage-foundational .tile { min-height: 128px; }
.stage-foundational .tile-icon { font-size: 3em; }
.soon { margin: 4px 0 0; font-size: .9em; color: var(--muted); }

/* A row that scrolls sideways (family games, teacher's classes): one swipe instead of a wall of buttons */
.scroll-row {
  list-style: none; display: flex; gap: 8px; overflow-x: auto; padding: 4px var(--gutter) 10px; margin: 0 calc(-1 * var(--gutter));
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.scroll-row::-webkit-scrollbar { display: none; }
.scroll-row > * { flex: none; scroll-snap-align: start; }
.scroll-row .btn { white-space: nowrap; }

/* Always-visible bottom action (I'm finished, Check, Go), clear of the phone's home bar */
.bottom-bar {
  position: sticky; bottom: 0; z-index: 15; margin: 16px calc(-1 * var(--gutter)) calc(-24px - env(safe-area-inset-bottom));
  padding: 14px var(--gutter) calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(255, 248, 239, 0) 0, var(--bg) 40%);
}
.high-contrast .bottom-bar { background: #000; }
.bottom-bar form { margin: 0; }
.bottom-bar .btn { width: 100%; }

/* ---------- Parent button and PIN pad ---------- */
.parent-lock { flex: none; }
.hold-btn {
  position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 48px; padding: 4px 12px; border-radius: var(--radius-sm); border: 2px solid var(--line); background: var(--card);
  color: var(--ink); font: inherit; cursor: pointer; -webkit-user-select: none; user-select: none; touch-action: none; line-height: 1.2;
}
.hold-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); opacity: .45; }
.hold-label { position: relative; font-weight: 700; font-size: .92em; }
.hold-hint { position: relative; font-size: .7em; color: var(--muted); }

.pin-dialog { border: 0; border-radius: 22px; padding: 22px; width: min(340px, 92vw); max-height: 92vh; overflow-y: auto; background: var(--card); color: var(--ink); box-shadow: var(--shadow-lift); }
.pin-dialog::backdrop { background: rgba(10, 15, 25, .6); }
.pin-dialog h2 { margin-top: 0; }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 16px 0 8px; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--ink); }
.pin-dots span.is-on { background: var(--ink); }
.pin-message { min-height: 1.5em; text-align: center; font-weight: 700; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pin-pad button { min-height: 60px; border-radius: 16px; border: 0; background: var(--bg); color: var(--ink); font: inherit; font-size: 1.45em; font-weight: 700; cursor: pointer; }
.pin-pad button:active { background: var(--line); }

/* ---------- "Show your parent" card, badges, boards ---------- */
.summary-card { text-align: center; }
.big-number { font-size: 1.3em; font-weight: 700; }
.badges { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.badges li { background: var(--accent-soft); border: 2px solid var(--accent); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: .92em; }
.ask { background: var(--warn-bg); border-radius: var(--radius-sm); padding: 4px 16px 12px; margin-top: 16px; }
.check-card { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink); border: 2px solid var(--accent); background: var(--accent-soft); }
.check-card .tile-icon { font-size: 2.4em; }
.check-card::after { content: "›"; margin-left: auto; font-size: 2em; color: var(--muted); }
.board { list-style: none; padding: 0; margin: 0 0 8px; counter-reset: board; }
.board li { counter-increment: board; display: flex; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.board li::before { content: counter(board) "."; font-weight: 700; color: var(--muted); margin-right: 8px; }
.board li > span { flex: 1; }
.board li.is-mine { font-weight: 700; background: var(--accent-soft); border-radius: var(--radius-sm); border-bottom-color: transparent; }

/* ---------- Parent progress: radar, tip, levels ---------- */
.radar { width: 100%; max-width: 320px; height: auto; }
.radar-ring { fill: none; stroke: var(--line); stroke-width: 1.5; }
.radar-axis { stroke: var(--line); stroke-width: 1; }
.radar-ring-label { font-size: 10px; fill: var(--muted); }
.radar-icon { font-size: 20px; }
.radar-shape { fill: var(--brand); fill-opacity: .22; stroke: var(--brand); stroke-width: 3; }
.radar-dot { fill: var(--brand); stroke: var(--card); stroke-width: 2; }
.tip-card { border-left: 6px solid var(--accent); }
.levels { width: 100%; border-collapse: collapse; }
.levels th, .levels td { text-align: left; vertical-align: top; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.levels td { white-space: nowrap; }
/* On a phone each strand becomes a small card: name and description, then level and change on one line */
@media (max-width: 520px) {
  .levels-stack thead { display: none; }
  .levels-stack tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .levels-stack th, .levels-stack td { display: block; padding: 0; border: 0; }
  .levels-stack th { grid-column: 1 / -1; }
  .levels-stack td { font-weight: 700; }
}

/* ---------- Teacher and principal pages ---------- */
.page:has(.heatmap) { max-width: 900px; }
.class-tabs { display: flex; gap: 6px; margin: 8px calc(-1 * var(--gutter)) 14px; padding: 2px var(--gutter) 6px; overflow-x: auto; scrollbar-width: none; }
.class-tabs::-webkit-scrollbar { display: none; }
.class-tabs a { flex: none; display: inline-flex; align-items: center; text-decoration: none; }
.table-scroll { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.heatmap { border-collapse: collapse; width: 100%; }
.heatmap th, .heatmap td { padding: 6px 4px; text-align: center; border-bottom: 1px solid var(--line); }
.heatmap th[scope=row] { text-align: left; white-space: nowrap; position: sticky; left: 0; background: var(--card); z-index: 1; }
.lvl { display: inline-block; min-width: 30px; padding: 4px 6px; border-radius: 8px; font-weight: 700; border: 2px solid var(--line); }
.lvl-0 { color: var(--muted); }
.lvl-1 { background: #fde2c8; } .lvl-2 { background: #fdf0b0; } .lvl-3 { background: #cfeec0; } .lvl-4 { background: #a8dcf0; }
.high-contrast .lvl { background: transparent; color: var(--ink); }
.row-inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.row-inline form { margin: 0; }
