/* Sicurezza sul lavoro — demo. Colours follow Italian safety signage logic
   (D.Lgs. 81/2008, Titolo V, All. XXV): red = prohibition/fire, yellow = warning,
   blue = mandatory action, green = safety / exit / first aid. Everything else neutral. */

:root {
  --sign-red: #c8102e;
  --sign-yellow: #f5b800;
  --sign-blue: #0057a8;
  --sign-green: #007a3d;

  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --ink: #15191e;
  --ink-2: #4a525c;
  --line: #d9dde2;
  --focus: #0057a8;

  --red-ink: #a50d26;
  --green-ink: #006632;
  --blue-ink: #0057a8;
  --yellow-soft: #fff4cc;
  --green-soft: #e3f4ea;
  --red-soft: #fde8eb;
  --blue-soft: #e4eefa;

  --i-ink: #2d3640;
  --i-soft: #e6e9ed;
  --i-mid: #b8c0c9;

  --font-script: "Noto Sans";
  --font: var(--font-script), "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --lh: 1.55;
  --fs: 1.125rem;      /* 18px base on phones */
  --fs-sm: 0.875rem;
  --fs-lg: 1.5rem;
  --fs-xl: 1.875rem;
  --radius: 18px;
  --gutter: 16px;
  --measure: 60ch;
  --dur: 220ms;
  --dir: 1;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101317;
    --surface: #1a1f25;
    --surface-2: #232a32;
    --ink: #eef1f4;
    --ink-2: #b3bcc6;
    --line: #333c46;
    --focus: #7cb6ff;
    --red-ink: #ff8a9a;
    --green-ink: #6fdc9e;
    --blue-ink: #8cc0ff;
    --yellow-soft: #3a3214;
    --green-soft: #12301f;
    --red-soft: #3a1820;
    --blue-soft: #15283f;
    --i-ink: #c9d2dc;
    --i-soft: #2a323b;
    --i-mid: #56616d;
  }
}

/* Script-specific fonts: only the selected one is downloaded (see app.js). */
html[lang="ar"] { --font-script: "Noto Sans Arabic"; --lh: 1.75; }
html[lang="ur"] { --font-script: "Noto Nastaliq Urdu"; --lh: 2.25; --fs: 1.1875rem; }
html[lang="hi"] { --font-script: "Noto Sans Devanagari"; --lh: 1.75; }
html[lang="pa"] { --font-script: "Noto Sans Gurmukhi"; --lh: 1.75; }
html[lang="bn"] { --font-script: "Noto Sans Bengali"; --lh: 1.75; }
html[lang="si"] { --font-script: "Noto Sans Sinhala"; --lh: 1.75; }
html[lang="zh"] { --font-script: "Noto Sans SC"; --lh: 1.7; }
html[dir="rtl"] { --dir: -1; }

*, *::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-family: var(--font);
  font-size: var(--fs);
  line-height: var(--lh);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-wrap: anywhere;
}
[lang="it"] { font-family: "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
html[lang="ur"] [lang="it"], html[lang="ar"] [lang="it"] { line-height: 1.5; }
img, svg { max-width: 100%; }
a { color: var(--blue-ink); text-underline-offset: 0.15em; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
html[lang="ur"] h1, html[lang="ur"] h2, html[lang="ur"] h3 { line-height: 1.9; }
p { margin: 0 0 0.75em; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; inset-inline-start: 8px; top: -60px; z-index: 50; background: var(--ink); color: var(--surface); padding: 10px 14px; border-radius: 10px; }
.skip:focus { top: 8px; }

/* ---------- Header ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.top-in {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 8px calc(var(--gutter) + var(--safe-r)) 8px calc(var(--gutter) + var(--safe-l));
  min-height: 60px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; min-width: 0; flex: 1; }
.brand-mark { width: 36px; height: 36px; flex: none; }
.brand-text { font-weight: 700; font-size: 1rem; line-height: 1.2; white-space: nowrap; }
html[lang="ur"] .brand-text { line-height: 1.5; }
.lang-pick { position: relative; display: flex; align-items: center; flex: none; }
.lang-pick .globe { position: absolute; inset-inline-start: 10px; width: 20px; height: 20px; pointer-events: none; color: var(--ink-2); }
.lang-pick select {
  appearance: none; -webkit-appearance: none;
  min-height: 44px; max-width: 46vw; min-width: min(9.5rem, 46vw);
  padding-block: 6px; padding-inline: 38px 30px;
  border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23778' stroke-width='2'/%3E%3C/svg%3E") no-repeat;
  background-size: 12px 8px;
  background-position: right 12px center;
  font-size: 1rem; cursor: pointer;
}
html[dir="rtl"] .lang-pick select { background-position: left 12px center; }

/* ---------- Layout ---------- */
main { flex: 1; width: 100%; outline: none; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 calc(var(--gutter) + var(--safe-r)) 0 calc(var(--gutter) + var(--safe-l)); }
.loading { padding: 40px; text-align: center; color: var(--ink-2); }

/* Disclaimer: always visible, every page, every language */
.notice {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line);
  border-inline-start: 5px solid var(--sign-blue);
  border-radius: 12px; padding: 10px 12px; margin: 12px 0;
  font-size: var(--fs-sm); line-height: 1.5; color: var(--ink-2);
}
html[lang="ur"] .notice { line-height: 2; }
.notice p { margin: 0 0 4px; }
.notice p:last-child { margin: 0; }
.notice strong { color: var(--ink); }
.notice .i { flex: none; width: 22px; height: 22px; margin-top: 1px; }
.mt { display: inline-block; font-size: 0.8125rem; font-weight: 600; background: var(--yellow-soft); color: var(--ink); border-radius: 6px; padding: 1px 7px; margin-inline-end: 6px; }

/* ---------- Home ---------- */
.hero { padding: 20px 0 8px; }
.hero h1 { font-size: var(--fs-xl); margin-bottom: 0.2em; }
.hero h1 .sub { display: block; color: var(--sign-green); font-size: 0.8em; }
html[lang="ur"] .hero h1 { line-height: 1.9; }
.hero p { color: var(--ink-2); max-width: var(--measure); }
.section-h { font-size: 1.25rem; margin: 28px 0 12px; display: flex; align-items: center; gap: 10px; }
.topic-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.topic-card {
  display: grid; grid-template-columns: 64px 1fr; gap: 4px 14px; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; color: var(--ink); text-decoration: none; position: relative;
  transition: border-color var(--dur), transform var(--dur);
}
.topic-card .ticon { width: 64px; height: 64px; grid-row: span 3; }
.topic-card .tnum { font-size: var(--fs-sm); color: var(--ink-2); font-weight: 600; }
.topic-card h3 { font-size: 1.1875rem; margin: 0; }
.topic-card p { margin: 4px 0 8px; color: var(--ink-2); font-size: 1rem; }
.topic-card .tfoot { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.topic-card .go { margin-inline-start: auto; }
@media (hover: hover) { .topic-card:hover { border-color: var(--ink-2); } }
.bar { flex: 1; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; width: 0; background: var(--sign-green); border-radius: 99px; transition: width 300ms ease; }
.status { font-size: var(--fs-sm); color: var(--ink-2); white-space: nowrap; }

.lang-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.lang-grid a {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; min-height: 56px;
  padding: 6px 14px; overflow-wrap: normal; word-break: keep-all; line-height: 1.3; border-radius: 12px; background: var(--surface); border: 1.5px solid var(--line);
  color: var(--ink); text-decoration: none; font-size: 1.0625rem; font-weight: 600;
}
.lang-grid a small { color: var(--ink-2); font-weight: 400; font-size: 0.75rem; font-family: "Noto Sans", system-ui, sans-serif; }
.lang-grid a[aria-current="true"] { border-color: var(--sign-green); box-shadow: inset 0 0 0 1.5px var(--sign-green); }
@media (hover: hover) { .lang-grid a:hover { border-color: var(--ink-2); } }
.enti-teaser { margin: 28px 0 8px; padding: 16px; border-radius: var(--radius); background: var(--surface-2); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.enti-teaser p { margin: 0; }
.foot { color: var(--ink-2); font-size: var(--fs-sm); padding: 20px 0 calc(28px + var(--safe-b)); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 10px 20px; border-radius: 14px; border: 2px solid transparent;
  background: var(--ink); color: var(--surface); font-weight: 700; text-decoration: none; cursor: pointer;
  transition: transform 120ms, background var(--dur), opacity var(--dur);
}
.btn:active { transform: scale(0.98); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.green { background: var(--sign-green); color: #fff; }
.btn[disabled] { opacity: 0.35; cursor: not-allowed; }
.btn svg { width: 22px; height: 22px; flex: none; }
html[dir="rtl"] .btn .flip { transform: scaleX(-1); }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 14px;
  border-radius: 99px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; font-size: 0.9375rem; font-weight: 600;
}
.chip-btn svg { width: 20px; height: 20px; }
.chip-btn[aria-pressed="true"], .chip-btn[aria-expanded="true"] { background: var(--blue-soft); border-color: var(--sign-blue); }
@media (hover: hover) { .btn:hover { opacity: 0.9; } .chip-btn:hover { border-color: var(--ink-2); } }

/* ---------- Player ---------- */
.player-layout { max-width: 1200px; margin: 0 auto; width: 100%; }
.side { display: none; }
.stage { display: flex; flex-direction: column; min-height: calc(100dvh - 61px); }
.stage-head { padding: 10px calc(var(--gutter) + var(--safe-r)) 0 calc(var(--gutter) + var(--safe-l)); }
.stage-head .crumb { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--ink-2); margin-bottom: 8px; }
.stage-head .crumb a { color: var(--ink-2); display: inline-flex; align-items: center; min-height: 32px; }
.stage-head .crumb .count { margin-inline-start: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }
.segs { display: flex; gap: 3px; height: 6px; }
.segs i { flex: 1; background: var(--surface-2); border-radius: 99px; position: relative; overflow: hidden; }
.segs i::after { content: ""; position: absolute; inset: 0; background: var(--sign-green); transform: scaleX(0); transform-origin: left; transition: transform 250ms ease; }
html[dir="rtl"] .segs i::after { transform-origin: right; }
.segs i.on::after { transform: scaleX(1); }
.segs i.cur::after { background: var(--ink); }

.card-area { flex: 1; padding: 14px calc(var(--gutter) + var(--safe-r)) 8px calc(var(--gutter) + var(--safe-l)); touch-action: pan-y; }
.card {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line);
  padding: 20px 18px; position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 14px;
}
.card::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 6px; background: var(--accent, var(--line)); }
.card.a-red { --accent: var(--sign-red); }
.card.a-yel { --accent: var(--sign-yellow); }
.card.a-blue { --accent: var(--sign-blue); }
.card.a-green { --accent: var(--sign-green); }
.card.a-ink { --accent: var(--ink-2); }
.card h2 { font-size: var(--fs-lg); outline: none; }
.card .kicker { font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); text-transform: none; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.card .kicker svg { width: 26px; height: 26px; }
.card-text { max-width: var(--measure); }
.card-text > p { margin-bottom: 0.6em; }
.card-text ol.lst, .card-text ul.lst { margin: 0 0 0.6em; padding-inline-start: 1.3em; }
.card-text .lst li { margin-bottom: 0.35em; padding-inline-start: 0.2em; }
.card-text .lst li::marker { font-weight: 700; color: var(--sign-blue); }
.card-art { margin: 0; display: flex; justify-content: center; align-items: center; }
.card-art svg { width: 100%; max-width: 300px; height: auto; }
.card-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.term {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  background: var(--blue-soft); border-radius: 12px; padding: 8px 12px; margin: 4px 0 8px;
}
.term .tl { font-size: 0.75rem; font-weight: 700; color: var(--blue-ink); text-transform: uppercase; letter-spacing: 0.04em; width: 100%; font-family: "Noto Sans", system-ui, sans-serif; }
html[lang="ur"] .term .tl, html[lang="ar"] .term .tl { text-transform: none; letter-spacing: 0; font-family: var(--font); }
.term .it { font-weight: 700; font-size: 1.125rem; }
.term .tr { color: var(--ink-2); }
.say { border: 0; background: transparent; color: var(--blue-ink); width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; cursor: pointer; flex: none; }
.say svg { width: 22px; height: 22px; }
.say[hidden] { display: none; }
.ref { font-size: var(--fs-sm); color: var(--ink-2); margin: 0; display: block; }
.ref a { font-weight: 600; }
.ref .lbl { font-weight: 700; white-space: nowrap; }

/* Example cards */
.sector { display: inline-flex; align-items: center; gap: 8px; background: var(--yellow-soft); border-radius: 99px; padding: 4px 12px 4px 6px; font-weight: 700; font-size: 0.9375rem; color: var(--ink); width: fit-content; }
.sector svg { width: 28px; height: 28px; }

/* Words */
.words { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.words li { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--surface); }
.words .w-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.words .it { font-weight: 700; font-size: 1.0625rem; }
.words .tr { color: var(--blue-ink); font-weight: 600; }
.words .tr::before { content: "— "; color: var(--ink-2); }
.words .def { color: var(--ink-2); font-size: 1rem; margin: 2px 0 0; }

/* Matrix R = P × D */
.matrix { display: grid; grid-template-columns: auto repeat(3, 1fr); gap: 5px; width: 100%; max-width: 300px; direction: ltr; font-family: "Noto Sans", system-ui, sans-serif; }
.matrix .ax { font-size: 0.75rem; color: var(--ink-2); display: grid; place-items: center; font-weight: 700; }
.matrix .cell { aspect-ratio: 1; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 1.25rem; color: #111; animation: pop 260ms both; }
.matrix .v1 { background: #7fd0a2; } .matrix .v2 { background: #b6e3a1; } .matrix .v3, .matrix .v4 { background: var(--sign-yellow); }
.matrix .v6 { background: #f08a24; } .matrix .v9 { background: var(--sign-red); color: #fff; }
.matrix-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.matrix-legend { display: flex; justify-content: space-between; width: 100%; max-width: 300px; font-size: 0.8125rem; color: var(--ink-2); }
.matrix-cap { font-size: 0.8125rem; color: var(--ink-2); text-align: center; }

/* Timeline (prescrizione) */
.timeline { list-style: none; margin: 4px 0 8px; padding: 0; display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 44px 1fr; gap: 12px; position: relative; padding-bottom: 14px; animation: rise 300ms both; }
.timeline li:nth-child(2) { animation-delay: 120ms; } .timeline li:nth-child(3) { animation-delay: 240ms; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 21px; top: 44px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .n { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--sign-blue); color: #fff; font-weight: 800; font-family: "Noto Sans", system-ui, sans-serif; }
.timeline li:last-child .n { background: var(--sign-green); }
.timeline strong { display: block; }
.timeline span { color: var(--ink-2); font-size: 1rem; }

/* RLS count */
.count-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; max-width: 320px; direction: ltr; }
.count-grid div { background: var(--surface-2); border-radius: 12px; padding: 10px 6px; text-align: center; animation: rise 300ms both; }
.count-grid div:nth-child(2) { animation-delay: 100ms; } .count-grid div:nth-child(3) { animation-delay: 200ms; }
.count-grid b { display: block; font-size: 2rem; line-height: 1.1; color: var(--sign-blue); font-family: "Noto Sans", system-ui, sans-serif; }
.count-grid small { font-size: 0.75rem; color: var(--ink-2); font-family: "Noto Sans", system-ui, sans-serif; }
.count-grid svg { height: 30px; width: auto; }

/* Quiz */
.q-text { font-size: 1.3125rem; font-weight: 700; line-height: 1.4; }
html[lang="ur"] .q-text { line-height: 2.1; }
.it-box { border: 1.5px dashed var(--sign-blue); background: var(--blue-soft); border-radius: 12px; padding: 10px 14px; font-size: 1rem; }
.it-box p { font-weight: 700; margin-bottom: 6px; }
.it-box ol { margin: 0; padding-inline-start: 1.6em; list-style: upper-alpha; }
.options { display: grid; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; text-align: start;
  padding: 10px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); cursor: pointer;
  transition: border-color var(--dur), background var(--dur);
}
.opt .k { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-weight: 800; font-family: "Noto Sans", system-ui, sans-serif; }
.opt .mark { margin-inline-start: auto; flex: none; width: 26px; height: 26px; }
@media (hover: hover) { .opt:not([disabled]):hover { border-color: var(--ink-2); } }
.opt[disabled] { cursor: default; }
.opt.ok { border-color: var(--sign-green); background: var(--green-soft); animation: glow 600ms ease; }
.opt.ok .k { background: var(--sign-green); color: #fff; }
.opt.no { border-color: var(--sign-red); background: var(--red-soft); }
.opt.no .k { background: var(--sign-red); color: #fff; }
.opt.dim { opacity: 0.6; }
.feedback { border-radius: 14px; padding: 12px 14px; animation: rise 220ms both; }
.feedback.ok { background: var(--green-soft); border-inline-start: 5px solid var(--sign-green); }
.feedback.no { background: var(--red-soft); border-inline-start: 5px solid var(--sign-red); }
.feedback h3 { font-size: 1.125rem; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.feedback.ok h3 { color: var(--green-ink); } .feedback.no h3 { color: var(--red-ink); }
.feedback h3 svg { width: 24px; height: 24px; }
.feedback p { margin: 0 0 6px; }

/* Result */
.score { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.ring { width: 132px; height: 132px; flex: none; }
.ring .bg { stroke: var(--surface-2); }
.ring .fg { stroke: var(--sign-green); transition: stroke-dashoffset 700ms ease; }
.ring.low .fg { stroke: var(--sign-yellow); }
.ring text { font-family: "Noto Sans", system-ui, sans-serif; fill: var(--ink); font-weight: 800; }
.ring .target { stroke: var(--ink); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.src-list { margin: 0; padding-inline-start: 1.2em; font-size: 0.9375rem; }
.src-list li { margin-bottom: 4px; }
details.src summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; }

/* Bottom navigation in the thumb zone */
.navbar {
  position: sticky; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px;
  padding: 10px calc(var(--gutter) + var(--safe-r)) calc(10px + var(--safe-b)) calc(var(--gutter) + var(--safe-l));
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.navbar .btn { width: 100%; padding-inline: 16px; line-height: 1.2; text-align: center; }
@media (max-width: 479px) {
  .navbar #prev { width: 56px; padding-inline: 0; }
  .navbar #prev span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
.hint { text-align: center; font-size: 0.8125rem; color: var(--ink-2); margin: 6px 0 0; }

/* Per enti */
.enti { max-width: 760px; }
.enti h1 { font-size: var(--fs-xl); margin-top: 20px; }
.enti h2 { font-size: 1.25rem; margin-top: 28px; }
.enti .lead { font-size: 1.125rem; color: var(--ink-2); }
.enti ul { padding-inline-start: 1.2em; }
.enti li { margin-bottom: 6px; }
.enti .contact { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 24px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; padding: 0; list-style: none; }
.badges li { background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; font-size: 0.9375rem; }

/* ---------- Motion ---------- */
.enter { animation: enter var(--dur) ease both; }
.enter.back { animation-name: enter-back; }
@keyframes enter { from { opacity: 0; transform: translateX(calc(24px * var(--dir))); } to { opacity: 1; transform: none; } }
@keyframes enter-back { from { opacity: 0; transform: translateX(calc(-24px * var(--dir))); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.7); } to { opacity: 1; transform: none; } }
@keyframes glow { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--sign-green) 50%, transparent); } 100% { box-shadow: 0 0 0 12px transparent; } }
.build > * { animation: rise 300ms both; }
.build > *:nth-child(2) { animation-delay: 90ms; } .build > *:nth-child(3) { animation-delay: 180ms; }
.build > *:nth-child(4) { animation-delay: 270ms; } .build > *:nth-child(5) { animation-delay: 360ms; }
svg .step-in { animation: rise 300ms both; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Landscape phones: two columns like tablet ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  .top-in { min-height: 48px; padding-block: 4px; }
  .stage { min-height: calc(100dvh - 49px); }
  .card { display: grid; grid-template-columns: 1.4fr 1fr; align-items: center; }
  .card-art svg { max-height: 58dvh; }
  .navbar { grid-template-columns: 1fr 1fr; }
}

/* ---------- Large phones ---------- */
@media (min-width: 390px) {
  .card-art svg { max-width: 320px; }
  .lang-grid { gap: 10px; }
}

/* ---------- Tablet ---------- */
@media (min-width: 768px) {
  :root { --gutter: 32px; --fs: 1.1875rem; --fs-lg: 1.75rem; --fs-xl: 2.25rem; }
  .brand-text { font-size: 1.125rem; }
  .lang-pick select { max-width: none; }
  .lang-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .topic-list { grid-template-columns: repeat(3, 1fr); }
  .topic-card { grid-template-columns: 1fr; }
  .topic-card .ticon { grid-row: auto; width: 72px; height: 72px; }
  .card-area { padding-top: 24px; display: flex; justify-content: center; }
  .card { width: 100%; max-width: 720px; padding: 28px 32px; }
  .card-art svg { max-width: 380px; }
  .stage { position: relative; }
  /* prev/next at the sides of the card */
  .navbar { position: static; background: none; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none; display: flex; justify-content: center; gap: 16px; padding-bottom: calc(24px + var(--safe-b)); }
  .navbar .btn { width: auto; min-width: 180px; }
}

/* ---------- Desktop: sidebar + card with text and art side by side ---------- */
@media (min-width: 1024px) {
  .player-layout { display: grid; grid-template-columns: 290px 1fr; gap: 28px; padding: 0 var(--gutter); }
  .side { display: block; position: sticky; top: 76px; align-self: start; padding: 24px 0; max-height: calc(100dvh - 76px); overflow: auto; }
  .side h2 { font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); margin: 0 0 10px; }
  html[lang="ur"] .side h2, html[lang="ar"] .side h2 { text-transform: none; letter-spacing: 0; }
  .side ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
  .side a { display: block; padding: 12px 14px; border-radius: 14px; color: var(--ink); text-decoration: none; border: 1.5px solid transparent; }
  .side a[aria-current="page"] { background: var(--surface); border-color: var(--line); }
  @media (hover: hover) { .side a:hover { background: var(--surface); } }
  .side .sn { font-size: 0.8125rem; color: var(--ink-2); font-weight: 600; }
  .side .st { font-weight: 700; display: block; margin: 2px 0 8px; line-height: 1.3; }
  html[lang="ur"] .side .st { line-height: 1.9; }
  .side .sb { display: flex; gap: 8px; align-items: center; }
  .side .home-link { display: inline-flex; margin-bottom: 14px; padding: 6px 0; font-weight: 600; color: var(--ink-2); }
  .side .notice { margin-top: 18px; }
  .stage { min-height: calc(100dvh - 61px); }
  .stage-head { padding: 24px 0 0; max-width: 900px; width: 100%; margin: 0 auto; }
  .card-area { padding: 20px 0 8px; }
  .card { max-width: 900px; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 32px; align-items: center; padding: 36px 40px; }
  .card.single { grid-template-columns: 1fr; }
  .card-art svg { max-width: 360px; }
  .navbar { max-width: 900px; width: 100%; margin: 0 auto; justify-content: space-between; padding-inline: 0; }
  .hint { display: none; }
  .hero { padding-top: 40px; }
  .home-grid { display: grid; grid-template-columns: 1fr; }
}
@media (min-width: 1440px) { :root { --fs: 1.25rem; } }

/* ---------- Illustration palette ---------- */
.f-ink { fill: var(--i-ink); } .f-soft { fill: var(--i-soft); } .f-soft2 { fill: var(--i-mid); opacity: .6; } .f-mid { fill: var(--i-mid); }
.f-yel { fill: var(--sign-yellow); } .f-blk { fill: #111; } .f-white { fill: #fff; } .f-none { fill: none; }
.f-red { fill: var(--sign-red); } .f-blue { fill: var(--sign-blue); } .f-blue2 { fill: #2f7fd0; } .f-blue-soft { fill: #8fb9e6; }
.f-green { fill: var(--sign-green); } .f-green2 { fill: #2b9a5e; }
.s-blk { stroke: #111; } .s-red { stroke: var(--sign-red); fill: none; } .s-ink { stroke: var(--i-ink); } .s-mid { stroke: var(--i-mid); fill: none; }
.s-blue { stroke: var(--sign-blue); fill: none; } .s-white { stroke: #fff; } .s-green { stroke: var(--sign-green); }
.t-num { font: 800 20px "Noto Sans", system-ui, sans-serif; text-anchor: middle; }
.t-big { font-family: "Noto Sans", system-ui, sans-serif; font-weight: 800; text-anchor: middle; fill: var(--i-ink); }
.t-lbl { font: 700 15px "Noto Sans", system-ui, sans-serif; fill: var(--ink); }
.t-lbl.t-on { fill: #fff; }
.card-art svg[aria-hidden] { overflow: visible; }
@media (min-width: 1024px) { .notice-mobile { display: none; } }
.notice-mobile .notice { margin-bottom: calc(20px + var(--safe-b)); }

/* Italian (and English) fragments inside RTL pages keep their own direction */
[lang="it"], [lang="en"] { unicode-bidi: isolate; }
html[dir="rtl"] p[lang="it"], html[dir="rtl"] .mt { direction: ltr; text-align: right; }
html[dir="rtl"] .ref a { direction: ltr; unicode-bidi: isolate; }
html[dir="rtl"] [dir="ltr"] .btn .flip { transform: none; }

/* ---------- v2: compact disclaimer, locked topics, trial ---------- */
.brand-text { font-family: "Noto Sans", system-ui, sans-serif; }
.ico { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.notice-full .notice { margin-bottom: calc(20px + var(--safe-b)); }
.notice-mini { margin: 8px 0 calc(16px + var(--safe-b)); }
.notice-mini > summary { list-style: none; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; }
.notice-mini > summary::-webkit-details-marker { display: none; }
.notice-mini > summary .i { width: 26px; height: 26px; margin: 0; }
@media (hover: hover) { .notice-mini > summary:hover { background: var(--surface-2); } }
.notice-mini[open] > summary { background: var(--blue-soft); }
.notice-mini > .notice { display: block; margin-top: 4px; }
.side .notice-mini { margin-top: 14px; }
.trial-bar { display: flex; gap: 10px; align-items: center; background: var(--green-soft); border-inline-start: 5px solid var(--sign-green); border-radius: 12px; padding: 10px 12px; font-size: var(--fs-sm); margin: 0 0 12px; }
.trial-bar .ico { width: 22px; height: 22px; color: var(--green-ink); }
.topic-card.locked { background: var(--surface-2); border-style: dashed; }
.topic-card.locked .ticon { filter: grayscale(1); opacity: .55; }
.status.lock { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.side a.is-locked { opacity: .8; }
.side a.is-locked .sb { margin-top: 4px; }
.lock-box { background: var(--surface-2); border-radius: 14px; padding: 14px 16px; margin-top: 10px; }
.lock-box p:last-child { margin: 0; }
.locked-card .kicker .ico { width: 20px; height: 20px; }
.actions a.btn { text-decoration: none; }
@media (min-width: 768px) { .topic-list { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .topic-list { grid-template-columns: repeat(3, 1fr); } }
.topic-card.locked .tfoot { flex-direction: column; align-items: flex-start; gap: 10px; }
.topic-card.locked .go { margin-inline-start: 0; white-space: normal; }
@media (max-width: 419px) {
  .top-in { gap: 8px; }
  .brand { gap: 8px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-text { font-size: 0.9375rem; }
  .lang-pick select { min-width: 0; max-width: 40vw; padding-inline: 32px 24px; font-size: 0.9375rem; background-position: right 8px center; }
  html[dir="rtl"] .lang-pick select { background-position: left 8px center; }
  .lang-pick .globe { inset-inline-start: 8px; width: 18px; height: 18px; }
}
/* Illustrations are drawn left-to-right; Italian labels inside SVG must not inherit RTL */
.card-art svg, .card-art svg text { direction: ltr; unicode-bidi: isolate; }
