/* Class board - the style sheet every page shares. Nothing comes from the internet: the school may have none.
   Each page adds its own file (station.css, teacher.css, screen.css) for what only it needs. */

/* The font of the whole board, served by the board itself: Vazirmatn (SIL Open Font License 1.1, see fonts/OFL.txt), one variable file for
   every weight from 100 to 900. A page that is open while the file arrives shows the system font for a moment and then swaps. */
@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f3f5fa;
  --sheet: #ffffff;
  --ink: #17203a;
  --ink-2: #4b5675;
  --rule: #d5dbea;
  --accent: #2740c9;
  --accent-dark: #1c31a6;
  --accent-wash: #e8ecfb;
  --ok: #17703a;
  --ok-wash: #e3f4e9;
  --warn: #8a5300;
  --warn-wash: #fff1d6;
  --bad: #a3231b;
  --bad-wash: #fde7e5;
  --code-bg: #0f1730;
  --code-ink: #e8ecfb;
  --radius: 14px;
  --font: "Vazirmatn", Tahoma, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 17px; font-synthesis: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); line-height: 1.8; }
h1, h2, h3, p { margin-block: 0; }
h1 { font-size: 1.6rem; line-height: 1.4; }
h2 { font-size: 1.15rem; line-height: 1.5; margin-block-end: 8px; }
h3 { font-size: 1rem; line-height: 1.5; margin-block-end: 6px; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- controls ---------- */
button, .button {
  font: inherit; font-weight: 700; min-height: 44px; padding: 6px 18px; border-radius: 12px;
  border: 2px solid var(--ink); background: var(--sheet); color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .4em; text-decoration: none;
}
button:hover:not(:disabled), .button:hover { background: var(--accent-wash); }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover:not(:disabled) { background: var(--accent-dark); }
.danger { border-color: var(--bad); color: var(--bad); }
.big { min-height: 56px; font-size: 1.15rem; padding-inline: 28px; }
.small { min-height: 34px; padding: 2px 12px; font-size: .9rem; border-width: 1px; }
input[type="text"], input[type="password"], select, textarea {
  font: inherit; width: 100%; padding: 8px 12px; border: 2px solid var(--rule); border-radius: 12px;
  background: var(--sheet); color: var(--ink);
}
textarea { resize: vertical; line-height: 1.8; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
/* BUTTONS SIT ON THE LEFT (the teacher's wish, for every page). The pages are right to left, so the left edge is the END of a row: a row of buttons
   is packed to the end, and a lone button in a centred or full-width box is moved there too. */
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; margin-block: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; margin-block: 12px 2px; }
.row label { display: inline-flex; align-items: center; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { min-height: 48px; min-width: 64px; font-size: 1.1rem; border-radius: 999px; }
.chip[aria-checked="true"], .chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.mono { direction: ltr; text-align: left; font-family: var(--mono); }

/* ---------- layout pieces ---------- */
.card { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 18px; margin-block-end: 16px; }
.hint { color: var(--ink-2); font-size: .95rem; margin-block: 6px; }
.empty { color: var(--ink-2); padding: 10px 2px; }
.notice { padding: 10px 14px; border-radius: 10px; background: var(--accent-wash); margin-block: 10px; }
.notice.warn { background: var(--warn-wash); color: #5b3600; }
.notice.bad { background: var(--warn-wash); color: #5b3600; }                    /* a program that does not match is information, not an alarm: amber, never red */
.notice.ok { background: var(--ok-wash); color: var(--ok); }
.bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 12px 18px; background: var(--sheet); border-bottom: 1px solid var(--rule); margin-block-end: 16px; }
.sticky { position: sticky; top: 0; z-index: 10; }
.page { max-width: 880px; margin: 0 auto; padding: 28px 20px; }
.lead { color: var(--ink-2); margin-block: 6px 18px; }
.links { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 12px; }
.count { color: var(--ink-2); font-weight: 400; }
.count:empty { display: none; }
.form-grid { display: grid; gap: 10px; }
.form-grid label { display: grid; gap: 4px; font-weight: 700; }
.form-grid input, .form-grid textarea { font-weight: 400; }
.table-wrap { overflow-x: auto; }

/* ---------- badges: a coloured dot AND the words, so colour is never the only signal ---------- */
.badge { display: inline-flex; align-items: center; gap: .45em; padding: 1px 12px; border-radius: 999px; font-size: .88rem; font-weight: 700; border: 1px solid currentColor; }
.badge::before { content: ""; width: .6em; height: .6em; border-radius: 50%; background: currentColor; }
.badge-waiting { color: var(--warn); background: var(--warn-wash); }
.badge-approved { color: var(--accent); background: var(--accent-wash); }
.badge-compiled { color: var(--ok); background: var(--ok-wash); }
.badge-returned { color: var(--warn); background: var(--warn-wash); }
.who { font-weight: 700; }

/* ---------- a problem statement (station, projector, teacher's preview) ---------- */
.problem { border: 2px solid var(--accent); }
.problem h2 { margin-block-end: 4px; }
.concepts { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 4px 8px; padding: 0; list-style: none; }
.concept { padding: 0 12px; border-radius: 999px; background: var(--accent-wash); color: var(--accent-dark); font-size: .85rem; font-weight: 700; }
.statement { white-space: pre-wrap; overflow-wrap: anywhere; }
code.inline { direction: ltr; unicode-bidi: isolate; font-family: var(--mono); font-size: .92em; background: var(--accent-wash); color: var(--accent-dark); padding: 0 .35em; border-radius: 5px; white-space: pre-wrap; }
.spec { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; margin-block: 10px; }
.spec dt { font-weight: 700; color: var(--ink-2); }
.spec dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.examples { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-block: 8px 0; }
.example { border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; background: var(--paper); }
.example h3 { margin: 0; padding: 2px 12px; background: var(--accent-wash); font-size: .85rem; color: var(--accent-dark); }
.example pre { margin: 0; padding: 6px 12px; font-family: var(--mono); font-size: .95rem; white-space: pre-wrap; overflow-wrap: anywhere; text-align: start; min-height: 2em; unicode-bidi: plaintext; }
.example .label { display: block; font-family: var(--font); font-size: .85rem; color: var(--ink-2); }

/* ---------- a program with the compiler's marks ---------- */
.codeview { direction: ltr; text-align: left; background: var(--code-bg); color: var(--code-ink); border-radius: 10px; padding: 8px 0; overflow: auto; font-family: var(--mono); font-size: .95rem; line-height: 1.7; max-height: 60vh; }
.codeview .cl { display: flex; align-items: flex-start; min-width: max-content; padding-right: 14px; }
.codeview .no { flex: 0 0 3.4em; text-align: right; padding-right: .9em; color: #a3acd0; user-select: none; }
.codeview code { white-space: pre; background: none; padding: 0; color: inherit; font-family: inherit; }
.codeview .cl.bad { background: rgba(255, 99, 85, .24); box-shadow: inset 4px 0 0 #ff6355; }
.codeview .cl.warn { background: rgba(255, 190, 70, .2); box-shadow: inset 4px 0 0 #ffb946; }
.codeview .cl-note { direction: rtl; text-align: right; font-family: var(--font); margin: 0 14px 6px 3.4em; padding: 2px 12px; border-radius: 0 0 8px 8px; font-size: .88rem; line-height: 1.6; white-space: normal; }
.codeview .cl-note.bad { background: #5a1d19; color: #ffd7d3; }
.codeview .cl-note.warn { background: #5a4310; color: #ffe8b0; }
.codeview .py { display: block; direction: ltr; text-align: left; font-family: var(--mono); font-size: .85rem; opacity: .85; margin-top: 2px; }

/* how close to valid syntax: twenty boxes, five percent each */
.meter-bar { display: inline-flex; gap: 2px; direction: ltr; vertical-align: middle; }
.meter-bar i { width: 9px; height: 18px; border-radius: 2px; background: var(--rule); }
.meter-bar.low i.on { background: #b45f06; }
.meter-bar.mid i.on { background: #d98a00; }
.meter-bar.high i.on { background: var(--ok); }
.closeness { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-weight: 700; }

/* the whole report on one try (Board.report): Python's part, the program, the machine's part, the verdict */
.report { display: grid; gap: 10px; }
.py-box { display: grid; gap: 4px; }
.py-box h3, .machine h3 { margin: 0; }
.machine { border: 1px solid var(--rule); border-radius: 10px; padding: 8px 12px; display: grid; gap: 4px; background: var(--paper); }
.machine ul { margin: 0; padding-inline-start: 22px; }
.coach { border: 1px solid var(--rule); border-inline-start: 4px solid var(--accent, #3a6ea5); border-radius: 10px; padding: 8px 12px; display: grid; gap: 4px; background: var(--paper); }
.coach h3, .coach h4 { margin: 0; }
.coach h4 { margin-block-start: 6px; font-size: 1rem; }
.coach ul, .coach ol { margin: 0; padding-inline-start: 22px; }
.cases { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.cases li { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.cases code { direction: ltr; unicode-bidi: isolate; font-family: var(--mono); background: var(--accent-wash); padding: 0 .45em; border-radius: 5px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- tables of results ---------- */
table.results { border-collapse: collapse; width: 100%; }
table.results th, table.results td { border-bottom: 1px solid var(--rule); padding: 6px 10px; text-align: start; }
table.results th { color: var(--ink-2); font-size: .85em; font-weight: 700; }
table.results tr.done td { background: var(--ok-wash); }
table.results tr.trying td { color: var(--ink-2); }
table.results td.num { white-space: nowrap; }
.awards { display: flex; flex-wrap: wrap; gap: 10px; margin-block: 8px; }
.award { background: var(--warn-wash); color: #5b3600; border-radius: 12px; padding: 4px 14px; font-weight: 700; }

/* ---------- feedback ---------- */
.toast { position: fixed; inset-inline: 0; bottom: 22px; margin-inline: auto; width: fit-content; max-width: 92vw; padding: 12px 22px; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 700; z-index: 60; }
.toast.bad { background: var(--bad); }
.offline { position: fixed; inset-block-start: 0; inset-inline: 0; padding: 8px 14px; text-align: center; background: var(--bad); color: #fff; font-weight: 700; z-index: 70; }
.lightbox { position: fixed; inset: 0; background: rgba(8, 12, 24, .92); display: grid; place-items: center; z-index: 50; cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 96vh; }

/* ---------- setup / plain pages ---------- */
.pin { font-size: 3rem; font-weight: 800; letter-spacing: .25em; font-family: var(--mono); text-align: center; }
.address-list { margin: 0; padding-inline-start: 22px; line-height: 2.1; }
.slips { list-style: none; padding: 0; margin: 18px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.slip { border: 1px dashed var(--ink-2); padding: 14px 16px; display: grid; gap: 2px; text-align: center; break-inside: avoid; }
.slip-label { font-weight: 700; font-size: 1.1rem; }
.slip-code { font-family: var(--mono); font-size: 2rem; font-weight: 800; letter-spacing: .2em; }
@media print { .no-print { display: none !important; } body { background: #fff; } }

/* ---------- the camera of the page (media.js: Board.pickPhoto) ----------
   A full-screen layer: the live picture in the middle, the buttons under it. It is a <dialog> when the browser has one, so it sits above
   any other dialog and the page behind it stays still. The picture of a front camera is shown mirrored (as in a mirror) and is saved as
   the camera saw it. In the square mode (a face) the middle square of the picture is what is saved, and that is what is shown. */
html.cam-open { overflow: hidden; }
.cam {
  position: fixed; inset: 0; z-index: 1000; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; border: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: #000; color: #fff; direction: rtl; flex-direction: column; overflow: hidden; touch-action: manipulation;
}
dialog.cam:not([open]) { display: none; }
dialog.cam[open], div.cam { display: flex; }
.cam::backdrop { background: #000; }
.cam-top { flex: none; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 6px 12px; }
.cam .cam-x { flex: none; width: 46px; height: 46px; min-height: 46px; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .16); color: #fff; font-size: 1.15rem; }
.cam-title { flex: 1 1 auto; min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
.cam-side { flex: none; padding: 2px 12px; border-radius: 999px; background: rgba(255, 255, 255, .16); font-size: .85rem; font-weight: 500; }
.cam-stage { position: relative; flex: 1 1 auto; min-height: 0; display: grid; place-items: center; overflow: hidden; container-type: size; }
.cam-frame { position: relative; width: 100%; height: 100%; overflow: hidden; background: #000; }
.cam.square .cam-frame { width: 92vmin; height: 92vmin; width: min(100cqw, 100cqh); height: min(100cqw, 100cqh); }
.cam.sheet .cam-frame { --ratio: 1.333; width: min(100cqw, calc(100cqh * var(--ratio))); height: min(100cqh, calc(100cqw / var(--ratio))); }
.cam-video, .cam-still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.cam.square .cam-video, .cam.square .cam-still { object-fit: cover; }
.cam-video.mirror { transform: scaleX(-1); }
.cam-frame::after { content: ""; position: absolute; pointer-events: none; }
.cam.square .cam-frame::after { inset: 7%; border: 3px dashed rgba(255, 255, 255, .8); border-radius: 50%; }
.cam.sheet .cam-frame::after { inset: 5%; border: 2px solid rgba(255, 255, 255, .55); border-radius: 10px; }
.cam-note { position: absolute; inset-inline: 12px; bottom: 6px; margin: 0; padding: 6px 12px; border-radius: 10px; background: rgba(0, 0, 0, .6); font-size: .95rem; line-height: 1.7; text-align: center; }
.cam-note:empty { display: none; }
.cam-note.bad { background: #8c1d18; }
.cam-bar { flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 14px 16px 18px; }
.cam-review, .cam-error { grid-template-columns: repeat(3, 1fr); }
.cam-error { grid-template-columns: repeat(2, 1fr); }
.cam .cam-side-btn { min-height: 52px; padding: 4px 14px; border: 0; border-radius: 14px; background: rgba(255, 255, 255, .16); color: #fff; font-weight: 600; gap: 8px; }
.cam .cam-side-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .26); }
.cam .cam-use, .cam .cam-phone { background: #fff; color: #111; }
.cam .cam-use:hover:not(:disabled), .cam .cam-phone:hover:not(:disabled) { background: #e8ecfb; }
.cam .cam-side-btn svg { flex: none; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cam .cam-shutter { width: 76px; height: 76px; min-height: 76px; padding: 0; border: 5px solid #fff; border-radius: 50%; background: transparent; display: grid; place-items: center; }
.cam .cam-shutter::after { content: ""; width: 54px; height: 54px; border-radius: 50%; background: #fff; }
.cam .cam-shutter:hover:not(:disabled) { background: rgba(255, 255, 255, .15); }
.cam .cam-shutter:active:not(:disabled)::after { transform: scale(.88); }
.cam .cam-shutter:disabled { opacity: .4; }
.cam :focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
@media (max-height: 480px) {
  .cam-top { min-height: 48px; padding-block: 2px; }
  .cam-bar { padding-block: 8px; }
}
.join-picks { display: flex; gap: .6em; flex-wrap: wrap; justify-content: center; margin-bottom: .8em; }
.closed-page { max-width: 36rem; margin: 15vh auto; padding: 0 16px; text-align: center; }
.closed-page .closed-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }      /* buttons on the left, like every button row */
/* the way back to the front page: the same small link on every inner page (a house, then the words) */
.home-link { display: inline-flex; align-items: center; gap: .4em; min-height: 44px; padding: 0 10px; border-radius: 10px; font-weight: 600; color: inherit; text-decoration: none; white-space: nowrap; }
.home-link:hover, .home-link:focus-visible { background: rgba(0, 0, 0, .06); text-decoration: none; }
.home-link .home-ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.home-link.on-dark:hover, .home-link.on-dark:focus-visible { background: rgba(255, 255, 255, .16); }
/* the teacher's messenger ids: two chips with an icon each */
.contact-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.contact-chip { display: inline-flex; align-items: center; gap: .35em; min-height: 40px; padding: 0 12px; border-radius: 999px; background: rgba(58, 63, 209, .1); color: #2a2ca3; font-weight: 600; text-decoration: none; }
.contact-chip:hover { background: rgba(58, 63, 209, .18); }
.ct-ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.contact-id { color: var(--ink-2); font-size: .9rem; }
.page-nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px 10px; margin: 0 0 8px; }      /* RTL: flex-end is the left, where the page is empty; the home link sits there on every page */


/* the copy buttons of the setup page: one per line, on the left like every lone button */
.addr-list li > button { margin-inline-start: auto; }
