/*
 * Manara for Schools: interactive demo.
 * Token values are copied inline from site/assets/css/tokens.css (the build hashes
 * stylesheet names, so this page cannot link it). Additions are marked "demo".
 */
:root {
  --brand: #01b151;
  --brand-strong: #008a3f;
  --ink: #1b1b2e;
  --ink-soft: #3d3d57;
  --muted: #5d6275;
  --bg: #f3f8fb;
  --surface: #ffffff;
  --line: #dde5ec;
  --focus: #1a73e8;
  --danger: #b42318;
  --ok: #067647;
  --warn: #b54708;
  --accent: #2f3f8f;
  --accent-ink: #ffffff;
  --accent-soft: #eceffb;
  --accent-2: #c7791c;
  --font-sans: "Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-arabic: "Noto Naskh Arabic", "Geeza Pro", "Al Nile", serif;
  --radius-s: 8px; --radius-m: 14px; --radius-l: 22px; --radius-pill: 999px;
  --shadow-1: 0 1px 2px rgb(27 27 46 / 6%), 0 2px 8px rgb(27 27 46 / 6%);
  --shadow-2: 0 10px 30px rgb(27 27 46 / 12%);

  /* demo additions */
  --ok-soft: #e3f4ea;
  --danger-soft: #fdeceb;
  --warn-soft: #fdf1e3;
  --field-line: #7d879a;   /* 3:1 against white for input borders */
  --sample-bg: #fff3d6;
  --sample-ink: #6b3f00;
  --sample-line: #efd08a;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 1rem/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.vh {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }

.app { max-width: 1080px; margin: 0 auto; padding: 12px 16px 28px; }

/* ---------------------------------------------------------- top bar */
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; }
.org { display: flex; align-items: center; gap: 10px; min-width: 0; }
.org-mark {
  flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
}
.org-name { font-weight: 700; line-height: 1.2; }
.org-sub { font-size: .875rem; color: var(--muted); }
.bar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sample {
  display: inline-flex; align-items: center; gap: 7px; min-height: 32px; padding: 0 12px;
  border-radius: var(--radius-pill); background: var(--sample-bg); color: var(--sample-ink);
  border: 1px solid var(--sample-line); font-size: .875rem; font-weight: 700;
}
.sample .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); }

/* ---------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1.5px solid transparent;
  font-weight: 700; cursor: pointer; text-align: center; line-height: 1.2;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn.small { min-height: 40px; padding: 0 14px; font-size: .9375rem; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: #26357a; }
.btn.ghost { background: var(--surface); color: var(--accent); border-color: var(--accent); }
.btn.ghost:hover:not(:disabled) { background: var(--accent-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.link { background: none; border: 0; min-height: 40px; padding: 0 8px; color: var(--accent); text-decoration: underline; font-weight: 600; }

/* ---------------------------------------------------------- role switch */
.roles-row { display: flex; align-items: center; gap: 12px; margin: 14px 0 16px; flex-wrap: wrap; }
.roles-label { font-size: .875rem; color: var(--muted); font-weight: 600; }
.roles { display: inline-flex; padding: 4px; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-pill); box-shadow: var(--shadow-1); }
.role {
  min-height: 44px; min-width: 104px; padding: 0 20px; border: 0; border-radius: var(--radius-pill);
  background: transparent; color: var(--ink-soft); font-weight: 700; cursor: pointer;
}
.role:hover { background: var(--accent-soft); }
.role[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }

/* ---------------------------------------------------------- teacher shell */
.classhead { margin-bottom: 14px; }
.classhead h1 { font-size: clamp(1.3rem, 1.1rem + 1vw, 1.7rem); line-height: 1.2; }
.classhead p { color: var(--muted); font-size: .9375rem; margin-top: 2px; }

.layout { display: grid; gap: 14px; }
.rail-title { font-size: .8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 8px; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; }
.tool {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 8px;
  border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--surface);
  color: var(--ink-soft); font-weight: 600; cursor: pointer;
}
.tool:hover { border-color: var(--accent); }
.tool .n {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: .875rem; font-weight: 800; flex: none;
}
.tool.done .n { background: var(--ok); color: #fff; }
.tool.done .n::before { content: "\2713"; }
.tool.done .n { font-size: 0; }
.tool.done .n::before { font-size: .95rem; }
.tool[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tool[aria-selected="true"] .n { background: #fff; color: var(--accent); }
.tool[aria-selected="true"].done .n { background: #fff; color: var(--ok); }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  box-shadow: var(--shadow-1); padding: 16px;
}
.panel h2 { font-size: 1.15rem; line-height: 1.25; }
.lead { color: var(--muted); font-size: .9375rem; margin: 4px 0 14px; }
.sub { font-size: .8125rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 20px 0 6px; }
.fine { color: var(--muted); font-size: .875rem; margin-top: 12px; }
.state { font-size: .9375rem; color: var(--muted); margin: 10px 0 8px; font-weight: 600; }
.state.on { color: var(--ok); }
.state::before { content: "\25CB\00a0"; }
.state.on::before { content: "\2713\00a0"; }

/* ---------------------------------------------------------- forms */
.field { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.field > label, .field > legend, .lbl {
  display: block; padding: 0; font-size: .875rem; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px;
}
.opt { font-weight: 500; color: var(--muted); }
input[type="text"], input[type="number"], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; background: var(--surface);
  border: 1.5px solid var(--field-line); border-radius: 10px; font-size: 1rem; line-height: 1.35;
}
textarea { resize: vertical; min-height: 96px; }
select { appearance: none; -webkit-appearance: none; padding-inline-end: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%233d3d57' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 12px 8px; background-position: right 14px center;
}
[dir="rtl"] select { background-position: left 14px center; }
input::placeholder, textarea::placeholder { color: #6b7386; }
.grid2 { display: grid; gap: 0 14px; }
.ayahs { display: flex; align-items: center; gap: 8px; }
.ayahs input { width: 5.2rem; text-align: center; }
.ayahs input:disabled { background: #eef1f5; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; margin-top: 8px; min-height: 32px; font-size: .9375rem; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.err { color: var(--danger); font-size: .9rem; font-weight: 600; margin: -4px 0 10px; }
.hint { color: var(--muted); font-size: .9rem; margin-top: 8px; }
.count { color: var(--ok); font-weight: 700; font-size: .9375rem; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; display: inline-block; }
.chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.chip span {
  display: inline-flex; flex-direction: column; justify-content: center; min-height: 44px; padding: 4px 14px;
  border: 1.5px solid var(--field-line); border-radius: 12px; background: var(--surface); font-weight: 600;
  line-height: 1.2; color: var(--ink-soft);
}
.chip span small { font-weight: 500; font-size: .8125rem; color: var(--muted); }
.chip:hover span { border-color: var(--accent); }
.chip input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.chip input:checked + span small { color: var(--ink-soft); }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin-top: 4px; }
.status { color: var(--ok); font-weight: 700; font-size: .9375rem; }
.status:empty { display: none; }

/* ---------------------------------------------------------- attendance */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.day { font-weight: 700; }
.list { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 14px; }
.arow {
  display: grid; grid-template-columns: auto 1fr; grid-template-areas: "av nm" "seg seg";
  gap: 8px 10px; align-items: center; padding: 10px 12px; background: var(--surface);
}
.arow + .arow { border-top: 1px solid var(--line); }
.av {
  grid-area: av; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; color: #fff; font-size: .95rem; flex: none;
}
.av.c0 { background: #2f3f8f; } .av.c1 { background: #067647; } .av.c2 { background: #a4570a; }
.av.c3 { background: #8a3a7a; } .av.c4 { background: #0d6e6e; } .av.c5 { background: #b2456a; }
.nm { grid-area: nm; font-weight: 700; }
.seg { grid-area: seg; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.seg button {
  min-height: 44px; padding: 0 4px; background: var(--surface); border: 1.5px solid var(--field-line);
  margin-inline-start: -1.5px; cursor: pointer; font-weight: 600; font-size: .9375rem; color: var(--ink-soft);
}
.seg button:first-child { border-start-start-radius: 10px; border-end-start-radius: 10px; margin-inline-start: 0; }
.seg button:last-child { border-start-end-radius: 10px; border-end-end-radius: 10px; }
.seg button:hover { background: var(--accent-soft); }
.seg button:focus-visible { position: relative; z-index: 2; }
.seg button[aria-pressed="true"] { color: #fff; border-color: transparent; position: relative; z-index: 1; }
.seg button[aria-pressed="true"]::before { content: "\2713\00a0"; }
.seg .s-present[aria-pressed="true"] { background: var(--ok); }
.seg .s-absent[aria-pressed="true"] { background: var(--danger); }
.seg .s-late[aria-pressed="true"] { background: var(--warn); }
.seg .s-excused[aria-pressed="true"] { background: var(--muted); }

/* ---------------------------------------------------------- points, records */
.totals { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.stat { flex: 1 1 140px; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); }
.stat b { display: block; font-size: 1.5rem; line-height: 1.15; color: var(--accent); }
.stat span { font-size: .875rem; color: var(--ink-soft); }
.rows li { display: flex; gap: 10px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--line); }
.rows li.empty { color: var(--muted); border: 0; }
.pt {
  flex: none; min-width: 2.5rem; text-align: center; padding: 1px 9px; border-radius: var(--radius-pill);
  background: var(--ok-soft); color: var(--ok); font-weight: 800; font-size: .9375rem;
}
.muted { color: var(--muted); }
.fresh { animation: fresh 1.4s ease-out; }
@keyframes fresh { from { background: #fff4c9; } to { background: transparent; } }

/* ---------------------------------------------------------- class story */
.attach { margin-bottom: 14px; }
.attach .thumb { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.thumb .art-sm { width: 112px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); flex: none; }
.art { display: block; width: 100%; height: auto; aspect-ratio: 8 / 5; }
.attach .cap { font-size: .875rem; color: var(--muted); flex: 1 1 140px; }
.posts { display: grid; gap: 12px; }
.post { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--surface); }
.post h2, .post h3 { font-size: 1rem; line-height: 1.3; margin-bottom: 2px; }
.post .meta { color: var(--muted); font-size: .875rem; margin-bottom: 8px; }
.post .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.post .pic { margin-top: 10px; max-width: 360px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.post.empty { color: var(--muted); border-style: dashed; }

/* ---------------------------------------------------------- lesson plan */
.from { display: inline-block; font-size: .875rem; font-weight: 700; padding: 3px 10px; border-radius: var(--radius-pill); background: var(--accent-soft); color: var(--accent); margin: -4px 0 12px; }

/* ---------------------------------------------------------- coach */
.coach {
  margin-top: 20px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 10px 14px; flex-wrap: wrap;
}
.coach p { flex: 1 1 220px; font-size: .9375rem; color: var(--ink); }
.btn.next { background: var(--surface); color: var(--accent); border-color: var(--accent); }
.btn.next:hover { background: #fff; border-color: #26357a; }
.coach.ready .btn.next { background: var(--accent); color: var(--accent-ink); }

/* ---------------------------------------------------------- parent portal */
.pgrid { display: grid; gap: 18px; }
.sampleparent { font-size: .875rem; color: var(--muted); margin-bottom: 8px; }
.portal {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  box-shadow: var(--shadow-2); overflow: hidden; max-width: 600px;
}
/* Local-only faces for Arabic-script glyphs, so Latin text (class name, surah names) stays in the sans stack. */
@font-face { font-family: "ArabicLocal"; src: local("Noto Naskh Arabic"), local("Geeza Pro"), local("Al Nile"), local("Segoe UI"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "UrduLocal"; src: local("Noto Nastaliq Urdu"), local("Noto Naskh Arabic"), local("Geeza Pro"), local("Al Nile"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
.portal[lang="ar"] { font-family: "ArabicLocal", var(--font-sans); }
.portal[lang="ur"] { font-family: "UrduLocal", var(--font-sans); line-height: 1.75; }
.portal[lang="ar"] .pbody, .portal[lang="ur"] .pbody { font-size: 1.05rem; }
.pbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--ink); color: #fff; }
.pname { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.lang { width: auto; min-width: 8.5rem; min-height: 40px; padding-block: 5px; border-color: #fff; background-color: #fff; color: var(--ink); font-size: .9375rem; }
.pbody { padding: 16px; }
.pgreet { font-weight: 700; font-size: 1.05rem; }
.psub { color: var(--muted); font-size: .9375rem; margin: 2px 0 14px; }
.pclass { font-size: 1.25rem; line-height: 1.25; margin-bottom: 12px; }
.ptabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.ptab { min-height: 44px; padding: 0 16px; border: 0; border-radius: var(--radius-pill); background: var(--accent-soft); color: var(--accent); font-weight: 700; cursor: pointer; }
.ptab:hover { background: #dfe4f7; }
.ptab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.portal .ph { font-size: .8125rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }
.portal .ph:first-child { margin-top: 0; }
.portal .post { box-shadow: var(--shadow-1); border: 0; }
.ptotal { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-weight: 700; }
.ptotal .v { color: var(--ok); font-size: 1.25rem; }
.qrows li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .9375rem; }
.qrows li b { text-transform: capitalize; }
.qnote { color: var(--muted); font-style: italic; }
.langnote { margin-top: 10px; font-size: .875rem; color: var(--muted); max-width: 600px; }

.aside { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px; align-self: start; }
.aside h2 { font-size: 1.05rem; margin-bottom: 8px; }
.ticks { display: grid; gap: 8px; margin-bottom: 4px; }
.ticks li { position: relative; padding-inline-start: 26px; font-size: .9375rem; }
.ticks li::before {
  content: "\2713"; position: absolute; inset-inline-start: 0; top: 1px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--ok); color: #fff; font-size: .7rem; font-weight: 800; display: grid; place-items: center;
}
.aside .btn { margin-top: 14px; }

.foot { margin-top: 20px; font-size: .8125rem; color: var(--muted); text-align: center; }

/* ---------------------------------------------------------- wider viewports */
@media (min-width: 560px) {
  .panel { padding: 22px; }
  .arow { grid-template-columns: auto 1fr auto; grid-template-areas: "av nm seg"; }
  .seg { grid-template-columns: repeat(4, 90px); }
  .grid2 { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 860px) {
  .app { padding: 18px 24px 32px; }
  .layout { grid-template-columns: 210px minmax(0, 1fr); gap: 22px; align-items: start; }
  .rail { position: sticky; top: 12px; }
  .tools { flex-direction: column; flex-wrap: nowrap; }
  .tool { border-radius: 12px; justify-content: flex-start; width: 100%; }
  .pgrid { grid-template-columns: minmax(0, 600px) minmax(0, 1fr); gap: 28px; }
}
@media (max-width: 420px) {
  .seg button { font-size: .875rem; padding: 0 2px; }
  .seg button[aria-pressed="true"]::before { content: none; }
}
@media (max-width: 359px) {
  .app { padding-inline: 12px; }
  .role { min-width: 88px; padding: 0 14px; }
  .seg button { font-size: .875rem; padding: 0 2px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
