/* Te Szakmad exam app. Palette taken from the logo: teal, warm grey, near-black.
   No web fonts and no external requests, so an exam still renders if the room's
   internet is flaky. */

:root {
  --teal: #4189ab;
  --teal-dark: #2f6a86;
  --teal-darker: #235268;
  --teal-tint: #eaf3f7;
  --teal-tint-strong: #d3e6ef;

  --ink: #1e2124;
  --ink-soft: #4a5056;
  --ink-faint: #767d85;

  --grey: #c4c4c4;
  --line: #e2e5e8;
  --surface: #ffffff;
  --canvas: #f6f7f8;

  --good: #1f7a54;
  --good-tint: #e7f4ee;
  --bad: #a83232;
  --bad-tint: #fbecec;
  --warn: #9a6b12;
  --warn-tint: #fdf3e2;
  --violet: #6b4ea8;
  --violet-tint: #f0ecf9;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(30, 33, 36, 0.06), 0 4px 16px rgba(30, 33, 36, 0.06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue",
    Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eef1f3;
    --ink-soft: #b4bcc4;
    --ink-faint: #8b949d;
    --line: #333a40;
    --surface: #21262a;
    --canvas: #171b1e;
    --teal-tint: #1d2f38;
    --teal-tint-strong: #24404e;
    --good-tint: #16301f;
    --bad-tint: #331b1b;
    --warn-tint: #332a15;
    --violet-tint: #29223a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; margin: 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75em; }
a { color: var(--teal-dark); }

.wrap { max-width: 780px; margin: 0 auto; padding: 0 20px; }
.wrap-wide { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* --- header ------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  max-width: 1180px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand img { width: 38px; height: 38px; display: block; }
.brand-name { font-family: var(--serif); font-size: 1.05rem; font-weight: 600; }
.brand-sub { font-size: 0.72rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-faint); }
.topbar-spacer { flex: 1; }

/* --- countdown ---------------------------------------------------------- */

.clock {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--teal-tint);
  border: 1px solid var(--teal-tint-strong);
  font-variant-numeric: tabular-nums;
}
.clock-time { font-size: 1.25rem; font-weight: 650; letter-spacing: 0.01em; }
.clock-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); }
.clock.is-warning { background: var(--warn-tint); border-color: #e6cd9a; }
.clock.is-warning .clock-time { color: var(--warn); }
.clock.is-critical { background: var(--bad-tint); border-color: #eab5b5; }
.clock.is-critical .clock-time { color: var(--bad); }

/* --- cards and layout --------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-tight { padding: 16px 18px; }
.stack > * + * { margin-top: 14px; }

.eyebrow {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--teal-dark);
  font-weight: 700;
  margin-bottom: 6px;
}
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); font-size: 0.9rem; }
.hu { color: var(--ink-faint); font-style: italic; }
.hu-block { display: block; margin-top: 4px; }

/* --- buttons ------------------------------------------------------------ */

.btn {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--teal);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover:not(:disabled) { background: var(--teal-dark); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--teal-dark); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--teal-tint); border-color: var(--teal-tint-strong); }
.btn-quiet { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn-quiet:hover:not(:disabled) { background: var(--canvas); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* A smaller button for a table row's own action — the default .btn padding
   (11px 20px) is taller than table.data's row padding (9px 10px), so inside
   a short row it visually overflows and crowds the row's border lines. */
.btn-sm { padding: 4px 12px; font-size: 0.85rem; }

.icon-btn {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--canvas); }
.intro-close {
  float: right;
  margin: -4px -4px 0 10px;
}

/* --- section navigation ------------------------------------------------- */

.sections {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 20px;
  max-width: 1180px;
  margin: 0 auto;
  scrollbar-width: thin;
}
.section-tab {
  font: inherit;
  white-space: nowrap;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-tab:hover:not(:disabled) { border-color: var(--teal-tint-strong); }
.section-tab[aria-current="true"] {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
  font-weight: 600;
}
/* Sequential reveal: a section not yet reached is shown, greyed and unclickable,
   so the student can see the shape of the exam without seeing its content. */
.section-tab:disabled { opacity: 0.45; cursor: not-allowed; }
.tab-count {
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--canvas);
  color: var(--ink-faint);
}
.section-tab[aria-current="true"] .tab-count { background: rgba(255, 255, 255, 0.22); color: #fff; }
.tab-count.is-done { background: var(--good-tint); color: var(--good); }

/* --- questions ---------------------------------------------------------- */

.question { padding: 18px 0; border-top: 1px solid var(--line); }
.question:first-of-type { border-top: 0; padding-top: 4px; }
.q-head { display: flex; gap: 12px; align-items: baseline; }
.q-num {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--teal-tint);
  color: var(--teal-darker);
  font-size: 0.8rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.q-num.is-answered { background: var(--teal); color: #fff; }
.q-body { flex: 1; min-width: 0; }
.q-topic {
  font-size: 0.72rem;
  color: var(--teal-dark);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.q-prompt { font-weight: 500; }
.q-given {
  font-family: var(--mono);
  font-size: 0.92rem;
  background: var(--canvas);
  border-left: 3px solid var(--teal);
  padding: 9px 12px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 10px 0;
  white-space: pre-wrap;
}

.options { display: grid; gap: 8px; margin-top: 12px; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--surface);
}
.option:hover { border-color: var(--teal); background: var(--teal-tint); }
.option input { margin: 3px 0 0; accent-color: var(--teal); flex: 0 0 auto; }
.option.is-selected { border-color: var(--teal); background: var(--teal-tint); font-weight: 500; }

.text-input, .textarea, .field {
  font: inherit;
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  margin-top: 10px;
}
.text-input:focus, .textarea:focus, .field:focus {
  outline: 2px solid var(--teal);
  outline-offset: -1px;
  border-color: var(--teal);
}
.textarea { min-height: 220px; resize: vertical; line-height: 1.6; font-family: var(--sans); }
.field { margin-top: 4px; }
label.stacked { display: block; margin-bottom: 12px; font-weight: 500; }
label.stacked .faint { font-weight: 400; }

/* --- audio player ------------------------------------------------------- */

.audio {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--teal-tint);
  border: 1px solid var(--teal-tint-strong);
  border-radius: var(--radius);
  margin: 12px 0 4px;
  flex-wrap: wrap;
}
.audio-btn {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 999px;
  background: var(--teal);
  color: #fff;
  padding: 10px 22px;
  cursor: pointer;
  min-width: 130px;
}
.audio-btn:disabled { background: var(--grey); cursor: not-allowed; }
.audio-meta { font-size: 0.9rem; color: var(--ink-soft); }
.audio-bar { flex: 1 1 140px; height: 6px; border-radius: 999px; background: var(--teal-tint-strong); overflow: hidden; min-width: 120px; }
.audio-bar span { display: block; height: 100%; width: 0; background: var(--teal); transition: width 0.2s linear; }

.passage {
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 12px 0 18px;
  white-space: pre-wrap;
  line-height: 1.7;
}
.passage h3 { margin-bottom: 8px; }

/* --- notices ------------------------------------------------------------ */

.notice {
  padding: 13px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--teal-tint-strong);
  background: var(--teal-tint);
  font-size: 0.95rem;
}
.notice-warn { background: var(--warn-tint); border-color: #e6cd9a; }
.notice-bad { background: var(--bad-tint); border-color: #eab5b5; color: var(--bad); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(140%);
  background: var(--ink);
  color: #fff;
  padding: 13px 22px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 60;
  transition: transform 0.28s ease;
  max-width: min(90vw, 520px);
  text-align: center;
}
.toast.is-visible { transform: translateX(-50%) translateY(0); }

.saving {
  font-size: 0.8rem;
  color: var(--ink-faint);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.saving.is-visible { opacity: 1; }

/* --- footer bar --------------------------------------------------------- */

.actionbar {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.actionbar-inner { display: flex; align-items: center; gap: 14px; max-width: 1180px; margin: 0 auto; width: 100%; flex-wrap: wrap; }
.progress-text { font-size: 0.9rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* --- result ------------------------------------------------------------- */

.verdict {
  display: flex;
  align-items: center;
  gap: 26px;
  flex-wrap: wrap;
  padding: 26px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
}
.verdict.is-pass { background: var(--good-tint); border-color: #b9dcc9; }
.verdict.is-fail { background: var(--bad-tint); border-color: #eab5b5; }
.score-big {
  font-family: var(--serif);
  font-size: 3.4rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.verdict-word { font-size: 1.5rem; font-weight: 700; font-family: var(--serif); }
.verdict.is-pass .verdict-word, .verdict.is-pass .score-big { color: var(--good); }
.verdict.is-fail .verdict-word, .verdict.is-fail .score-big { color: var(--bad); }

.bars { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 92px; gap: 12px; align-items: center; }
.bar-track { height: 10px; border-radius: 999px; background: var(--canvas); border: 1px solid var(--line); overflow: hidden; }
.bar-fill { height: 100%; background: var(--teal); }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; font-size: 0.92rem; color: var(--ink-soft); }
.bar-label { font-size: 0.92rem; }
.bar-label small { display: block; color: var(--ink-faint); font-size: 0.78rem; }

table.data { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
table.data th, table.data td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-faint); font-weight: 700; }
table.data tr:hover td { background: var(--canvas); }
.table-scroll { overflow-x: auto; }

.pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--canvas);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.pill-pass { background: var(--good-tint); color: var(--good); border-color: #b9dcc9; }
.pill-fail { background: var(--bad-tint); color: var(--bad); border-color: #eab5b5; }
.pill-warn { background: var(--warn-tint); color: var(--warn); border-color: #e6cd9a; }
.pill-teal { background: var(--teal-tint); color: var(--teal-darker); border-color: var(--teal-tint-strong); }
.pill-violet { background: var(--violet-tint); color: var(--violet); border-color: var(--violet-tint); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.level-card {
  display: block;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
}
.level-card:hover { border-color: var(--teal); background: var(--teal-tint); }
.level-card.is-locked { opacity: 0.55; pointer-events: none; }
.level-card strong { font-family: var(--serif); font-size: 1.1rem; display: block; }

.hidden { display: none !important; }

/* --- anti-copy: deter lifting exam content into another app ------------- */
/* Selection stays enabled on the result screen and inside form fields. */

#screen-exam {
  user-select: none;
  -webkit-user-select: none;
}

#screen-exam input,
#screen-exam textarea,
#screen-exam [contenteditable='true'] {
  user-select: text;
  -webkit-user-select: text;
}

@media (max-width: 620px) {
  .bar-row { grid-template-columns: 110px 1fr 70px; }
  .score-big { font-size: 2.6rem; }
  .topbar-inner { gap: 10px; }
  .brand-sub { display: none; }
}

/* --- print: the result sheet is the deliverable ------------------------- */

@media print {
  body { background: #fff; font-size: 11pt; }
  .topbar { position: static; border-bottom: 2px solid var(--teal); }
  .no-print, .actionbar, .sections, .toast { display: none !important; }
  .card, .verdict { box-shadow: none; break-inside: avoid; border-color: #ccc; }
  .verdict.is-pass, .verdict.is-fail { background: #fff !important; }
  a { text-decoration: none; color: inherit; }
}

/* --- build version badge, top-right on every page ----------------------- */

#version-badge {
  text-align: right;
  font-size: 10px;
  line-height: 1.4;
  color: #9aa5ab;
  background: var(--surface);
  padding: 2px 20px;
  user-select: none;
}

@media print {
  #version-badge { display: none !important; }
}
