/* ISA Live - shared design system. ISA palette (from the ISA Hub), Readex Pro for Latin and Arabic
   (vendored, OFL - no font CDN at runtime). `.theme-dark` re-points the tokens for the projector. */
@font-face { font-family: 'Readex Pro'; font-weight: 400; font-display: swap; src: url('/vendor/fonts/readex-pro-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+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Readex Pro'; font-weight: 500 600; font-display: swap; src: url('/vendor/fonts/readex-pro-latin-600-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Readex Pro'; font-weight: 700 800; font-display: swap; src: url('/vendor/fonts/readex-pro-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+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Readex Pro'; font-weight: 400; font-display: swap; src: url('/vendor/fonts/readex-pro-arabic-400-normal.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Readex Pro'; font-weight: 500 600; font-display: swap; src: url('/vendor/fonts/readex-pro-arabic-600-normal.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Readex Pro'; font-weight: 700 800; font-display: swap; src: url('/vendor/fonts/readex-pro-arabic-700-normal.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }

:root {
  --navy: #152238;
  --navy-2: #1f3150;
  --navy-3: #22324f;
  --blue: #004a84;
  --teal: #107e7d;
  --teal-ink: #0c5f5e;
  --teal-bright: #2fb3ad;
  --teal-soft: #dff1ef;
  --sand: #e4dcc8;
  --sand-soft: #f4f0e6;
  --paper: #fbfaf6;
  --card: #ffffff;
  --ink: #152238;
  --muted: #4d5868;
  --line: #e2dccd;
  --line-strong: #cfc6b2;
  --ok: #107e7d;
  --warn: #8a5100;
  --warn-soft: #fbefd9;
  --amber: #c0812a;
  --danger: #a3262a;
  --danger-soft: #f6e1e1;
  --live: #c42b2b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(21, 34, 56, 0.06), 0 8px 24px rgba(21, 34, 56, 0.07);
  /* results: one calm colour, the leader highlighted */
  --bar: #8094b3;
  --bar-lead: var(--teal);
  --track: var(--sand-soft);
  /* word cloud / multi-series palette */
  --c0: #107e7d;
  --c1: #004a84;
  --c2: #a8691c;
  --c3: #6b4f9a;
  --c4: #2e7d4f;
  --c5: #b4483f;
  --c6: #3f6ea8;
  --c7: #7a5c24;
  --c8: #8b3f6f;
  --c9: #4c5d73;
  --font: 'Readex Pro', system-ui, -apple-system, 'Segoe UI', 'Geeza Pro', Tahoma, sans-serif;
}
.theme-dark {
  --ink: #ffffff;
  --muted: #d9d1bd;
  --card: #1f3150;
  --paper: var(--navy);
  --line: #2f4263;
  --line-strong: #3d5276;
  --sand-soft: #22324f;
  --track: #22324f;
  --bar: #6f8db8;
  --bar-lead: var(--teal-bright);
  --shadow: none;
  --c0: #2fb3ad;
  --c1: #8fb6e8;
  --c2: #e4b45f;
  --c3: #b9a1e3;
  --c4: #79cf9c;
  --c5: #f0948b;
  --c6: #9fc4ff;
  --c7: #e4dcc8;
  --c8: #e59acb;
  --c9: #c3cedd;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }
.hidden { display: none !important; }
[dir='auto'] { unicode-bidi: plaintext; }
.muted { color: var(--muted); }
.small { font-size: 0.875em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.eyebrow { font-size: 0.8em; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand img { width: 40px; height: 40px; flex-shrink: 0; }
.brand .name { font-weight: 700; letter-spacing: 0.01em; }
.brand .name em { font-style: normal; color: var(--teal); }
.brand .sub { color: var(--muted); font-size: 0.85em; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--card); font-weight: 600; line-height: 1.2; text-decoration: none; color: var(--ink);
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--navy); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, button:focus-visible {
  outline: 3px solid rgba(16, 126, 125, 0.4); outline-offset: 2px;
}
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-ink); border-color: var(--teal-ink); }
.btn.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.navy:hover { background: var(--navy-2); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--sand-soft); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 0.9em; border-radius: 8px; }
.btn.lg { min-height: 56px; padding: 0 22px; font-size: 1.08em; border-radius: 14px; }
.btn.block { display: flex; width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--sand-soft); color: var(--ink); }
.icon-btn:disabled { opacity: 0.35; cursor: default; background: transparent; }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }

/* ---------- form controls ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span, .label { font-size: 0.85em; font-weight: 600; color: var(--muted); }
.field small { color: var(--muted); }
input[type='text'], input[type='email'], input[type='password'], input[type='number'], input[type='search'], input:not([type]), select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; color: #152238;
}
textarea { resize: vertical; min-height: 44px; }
input::placeholder, textarea::placeholder { color: #8a92a0; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; min-height: 32px; }
.check input { width: 20px; height: 20px; accent-color: var(--teal); flex-shrink: 0; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 8px 14px; min-height: 38px; font-weight: 500; color: var(--muted); }
.seg button + button { border-inline-start: 1px solid var(--line); }
.seg button.on { background: var(--navy); color: #fff; }

/* ---------- chips, cards ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; font-size: 0.8em; font-weight: 600; background: var(--sand-soft); color: var(--muted); white-space: nowrap; }
.chip.open, .chip.ok { background: var(--teal-soft); color: var(--teal-ink); }
.chip.closed, .chip.bad { background: var(--danger-soft); color: var(--danger); }
.chip.live { background: var(--live); color: #fff; font-weight: 700; letter-spacing: 0.04em; }
.chip.live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: pulse 1.4s infinite; }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
@keyframes pulse { 50% { opacity: 0.3; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 100;
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: 0 10px 30px rgba(21, 34, 56, 0.3);
  max-width: calc(100vw - 32px); text-align: center; font-size: 15px;
}
.toast.bad { background: var(--danger); }

/* ---------- dialogs ---------- */
dialog { border: 0; border-radius: var(--radius); padding: 0; box-shadow: 0 24px 64px rgba(21, 34, 56, 0.32); max-width: min(560px, calc(100vw - 32px)); width: 100%; color: #152238; background: #fff; }
dialog::backdrop { background: rgba(21, 34, 56, 0.5); }
.dlg { padding: 24px; }
.dlg h2 { margin: 0 0 6px; font-size: 1.3em; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.err { color: var(--danger); min-height: 1.2em; margin: 6px 0 0; font-size: 0.92em; }

/* ---------- results visualisations (shared by presenter, phones, results page, editor preview) ---------- */
.viz { --vz: 1em; font-size: var(--vz); }
.bars { display: flex; flex-direction: column; gap: 0.85em; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.3em 0.8em; align-items: baseline; }
.bar-label { font-weight: 500; overflow-wrap: anywhere; }
.bar-num { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.bar-num b { color: var(--ink); font-size: 1.2em; font-weight: 700; }
.bar-track { grid-column: 1 / -1; height: 0.9em; background: var(--track); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--bar); border-radius: 999px; transition: width 0.9s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.4s; }
.bar-row.lead .bar-label { font-weight: 700; }
.bar-row.lead .bar-fill { background: var(--bar-lead); }

.scale-list { display: flex; flex-direction: column; gap: 1.2em; }
.scale-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.35em 1em; align-items: center; }
.scale-row .st { font-weight: 500; overflow-wrap: anywhere; }
.scale-row .avg { font-size: 1.6em; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1; }
.scale-row .avg small { font-size: 0.5em; color: var(--muted); font-weight: 400; }
.scale-track { grid-column: 1 / -1; position: relative; height: 0.7em; background: var(--track); border-radius: 999px; }
.scale-track .fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 999px; background: var(--bar-lead); transition: width 0.9s cubic-bezier(0.2, 0.8, 0.2, 1); }
html[dir='rtl'] .scale-track .fill { inset: 0 0 0 auto; }
.scale-dist { grid-column: 1 / -1; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; align-items: end; height: 2.4em; }
.scale-dist > div { background: var(--track); border-radius: 4px 4px 1px 1px; min-height: 3px; transition: height 0.9s, background 0.4s; }
.scale-dist > div.has { background: var(--bar); }
.scale-dist > div.top { background: var(--bar-lead); }
.scale-ends { grid-column: 1 / -1; display: flex; justify-content: space-between; color: var(--muted); font-size: 0.8em; gap: 1em; }

.rank-list { display: flex; flex-direction: column; gap: 0.7em; }
.rank-row { display: grid; grid-template-columns: 2em minmax(0, 1fr) auto; gap: 0.25em 0.8em; align-items: center; }
.rank-row .pos { font-weight: 700; font-size: 1.15em; color: var(--muted); text-align: center; width: 1.8em; height: 1.8em; line-height: 1.8em; border-radius: 50%; background: var(--track); }
.rank-row:first-child .pos { background: var(--bar-lead); color: #fff; }
.rank-row .txt { font-weight: 500; overflow-wrap: anywhere; }
.rank-row:first-child .txt { font-weight: 700; }
.rank-row .score { color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-row .bar-track { grid-column: 2 / -1; height: 0.6em; }
.rank-row:first-child .bar-fill { background: var(--bar-lead); }

.cloud { position: relative; width: 100%; height: 100%; min-height: 8em; }
.cloud span { position: absolute; white-space: nowrap; font-weight: 700; line-height: 1; transition: left 0.6s, top 0.6s, font-size 0.6s, opacity 0.4s; transform: translate(-50%, -50%); }

.wall { columns: 3 16em; column-gap: 0.9em; }
.wall .note { break-inside: avoid; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 0.7em; padding: 0.75em 0.95em; margin: 0 0 0.9em; overflow-wrap: anywhere; box-shadow: var(--shadow); white-space: pre-wrap; animation: pop-in 0.4s ease-out; }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } }

.qa-list { display: flex; flex-direction: column; gap: 0.6em; }
.qa-item { display: flex; gap: 0.8em; align-items: center; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 0.8em; padding: 0.75em 0.95em; }
.qa-item .q { flex: 1; overflow-wrap: anywhere; white-space: pre-wrap; }
.qa-item .up { display: inline-flex; flex-direction: column; align-items: center; min-width: 2.4em; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.1; }
.qa-item .up svg { color: var(--bar-lead); }
.qa-item .vote { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 52px; min-height: 56px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--paper); color: var(--blue); font-weight: 700; flex-shrink: 0; }
.qa-item .vote.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.qa-item.answered { opacity: 0.55; }
.qa-item.answered .q::after { content: ' ✓'; color: var(--teal); }

.empty-viz { color: var(--muted); text-align: center; padding: 1.5em 0; }
