/* tin9: one stylesheet, light, dark and high contrast. Sizes in rem so the text size setting scales everything. */

:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --text: #1a1e1c;
  --muted: #4d5550;
  --border: #c4cbc6;
  --border-strong: #6b746f;
  --accent: #0a5c54;
  --accent-hover: #084a44;
  --accent-text: #ffffff;
  --accent-soft: #e0eeeb;
  --link: #0a5c54;
  --focus: #1846c4;
  --danger: #a3221a;
  --danger-text: #ffffff;
  --ok-bg: #e4f1e8;
  --ok-text: #1b5530;
  --err-bg: #fbe8e6;
  --err-text: #861b13;
  --info-bg: #e6eefb;
  --info-text: #1d3f7a;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --radius: 0.5rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not(.hc) {
    --bg: #111513;
    --surface: #1a1f1d;
    --text: #e7ebe9;
    --muted: #a9b2ad;
    --border: #3a423e;
    --border-strong: #87918c;
    --accent: #5fc4b5;
    --accent-hover: #7fd3c6;
    --accent-text: #06201c;
    --accent-soft: #1d3330;
    --link: #7fd3c6;
    --focus: #8fb2ff;
    --danger: #ff8a80;
    --danger-text: #2a0503;
    --ok-bg: #173323;
    --ok-text: #a8e2bb;
    --err-bg: #3a1714;
    --err-text: #ffb4ab;
    --info-bg: #182a47;
    --info-text: #b5ccf5;
    color-scheme: dark;
  }
}

/* High contrast: black, white and yellow, no soft tints. */
:root.hc {
  --bg: #000000;
  --surface: #000000;
  --text: #ffffff;
  --muted: #ffffff;
  --border: #ffffff;
  --border-strong: #ffffff;
  --accent: #ffe14d;
  --accent-hover: #ffffff;
  --accent-text: #000000;
  --accent-soft: #000000;
  --link: #ffe14d;
  --focus: #00e5ff;
  --danger: #ff9c9c;
  --danger-text: #000000;
  --ok-bg: #000000;
  --ok-text: #ffffff;
  --err-bg: #000000;
  --err-text: #ffffff;
  --info-bg: #000000;
  --info-text: #ffffff;
  color-scheme: dark;
}
:root.hc .alert, :root.hc .card, :root.hc .note { border-width: 2px; border-color: #fff; }

:root[data-text="125"] { font-size: 125%; }
:root[data-text="150"] { font-size: 150%; }
:root[data-text="200"] { font-size: 200%; }

:root.readable {
  --font: Verdana, "Atkinson Hyperlegible", Tahoma, "Segoe UI", sans-serif;
}
:root.readable body { letter-spacing: 0.03em; word-spacing: 0.1em; line-height: 1.75; }

:root.links a:not(.btn) {
  background: #ffe14d;
  color: #000 !important;
  text-decoration: underline 0.15em;
  outline: 2px solid #000;
}

:root.bigcursor, :root.bigcursor * { cursor: url("/static/cursor.svg") 4 2, auto !important; }
:root.bigcursor a, :root.bigcursor button, :root.bigcursor label, :root.bigcursor select, :root.bigcursor summary,
:root.bigcursor input[type="checkbox"], :root.bigcursor input[type="radio"] { cursor: url("/static/cursor-hand.svg") 14 2, pointer !important; }

:root.nomotion *, :root.nomotion *::before, :root.nomotion *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-wrap: anywhere;
}
main { flex: 1; padding-block: 2rem 3rem; }
main:focus { outline: none; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.75rem; }
h1 { font-size: 2rem; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; margin-top: 2rem; }
h3, .h3 { font-size: 1.1rem; }
p { margin: 0 0 1rem; }
ul, ol { padding-left: 1.4rem; }
a { color: var(--link); text-decoration-thickness: 0.08em; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 0.15em; }
code { font-family: var(--mono); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.wrap { width: 100%; max-width: 62rem; margin-inline: auto; padding-inline: 1rem; }
.narrow { max-width: 34rem; }
.lead { font-size: 1.15rem; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.strong { font-weight: 600; }
.pre { white-space: pre-wrap; }
.break { word-break: break-all; }
.row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.stack > * + * { margin-top: 1rem; }
.stack > * { margin-bottom: 0; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 1rem; top: -10rem; z-index: 10;
  background: var(--accent); color: var(--accent-text); padding: 0.75rem 1rem; border-radius: var(--radius);
  font-weight: 600;
}
.skip:focus { top: 1rem; }

/* ---------- header and footer ---------- */

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; padding-block: 0.75rem; }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 700; font-size: 1.25rem; color: var(--text); text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 0.45rem;
  background: var(--accent); color: var(--accent-text); font-size: 0.95rem; letter-spacing: -0.02em;
}
.brand-sub { font-weight: 500; color: var(--muted); font-size: 1rem; }
.header-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.lang-link { padding: 0.5rem 0.75rem; font-weight: 600; }
.a11y-open svg { flex: none; }

.admin-nav ul { list-style: none; margin: 0; padding: 0 0 0.5rem; display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; align-items: center; }
.admin-nav a { display: inline-block; padding: 0.35rem 0; font-weight: 600; text-decoration: none; }
.admin-nav a[aria-current="page"] { text-decoration: underline 0.15em; text-underline-offset: 0.35em; }
.admin-nav .logout { margin-left: auto; }

.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding-block: 1.25rem; }
.footer-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; }
.footer-links a { display: inline-block; padding-block: 0.25rem; }

/* ---------- components ---------- */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; margin-bottom: 1.5rem;
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.hero { margin-bottom: 2rem; max-width: 44rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 2.75rem; padding: 0.5rem 1rem;
  font: inherit; font-weight: 600; line-height: 1.2; text-decoration: none;
  color: var(--text); background: var(--surface);
  border: 2px solid var(--border-strong); border-radius: var(--radius);
  cursor: pointer;
}
.btn:hover { background: var(--accent-soft); }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: var(--danger-text); }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-quiet:hover { border-color: var(--border); }
.btn-big { min-height: 3.25rem; padding-inline: 1.5rem; font-size: 1.05rem; }
.btn-small { min-height: 2.25rem; padding: 0.25rem 0.75rem; font-size: 0.9rem; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.linklike { font: inherit; font-weight: 600; color: var(--link); background: none; border: 0; padding: 0.35rem 0; cursor: pointer; text-decoration: underline; }

.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1.25rem; max-width: 36rem; }
.field label, label.strong { font-weight: 600; }
.hint { margin: 0; color: var(--muted); font-size: 0.92rem; }
input[type="text"], input[type="password"], input[type="number"], input[type="email"], textarea, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 2px solid var(--border-strong); border-radius: var(--radius);
  padding: 0.6rem 0.75rem; width: 100%; min-height: 2.75rem;
}
textarea { resize: vertical; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
.check { display: flex; gap: 0.6rem; align-items: flex-start; margin-bottom: 0.75rem; }
.check input { width: 1.25rem; height: 1.25rem; margin-top: 0.2rem; flex: none; accent-color: var(--accent); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem 1rem; margin: 0 0 1rem; }
legend { font-weight: 700; padding-inline: 0.35rem; }

.alert { border-radius: var(--radius); padding: 0.85rem 1rem; margin-bottom: 1.25rem; border: 1px solid transparent; }
.alert > :last-child { margin-bottom: 0; }
.alert-success { background: var(--ok-bg); color: var(--ok-text); border-color: currentColor; }
.alert-error { background: var(--err-bg); color: var(--err-text); border-color: currentColor; }
.alert-info { background: var(--info-bg); color: var(--info-text); border-color: currentColor; }
.success { border-color: var(--ok-text); }

.note { border-left: 4px solid var(--accent); background: var(--surface); padding: 0.85rem 1rem; margin-bottom: 1.5rem; border-radius: 0 var(--radius) var(--radius) 0; }
.note-title { font-size: 1rem; margin: 0 0 0.35rem; }
.note p { margin: 0; }

.copy-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.35rem 0 0.75rem; }
.copy-row input { flex: 1 1 16rem; font-family: var(--mono); font-size: 0.95rem; }

.secret code { font-size: 1.1rem; letter-spacing: 0.05em; background: var(--accent-soft); padding: 0.3rem 0.5rem; border-radius: 0.3rem; }
.qr { margin: 1rem 0; }
.qr svg { width: 13rem; height: 13rem; background: #fff; border-radius: var(--radius); display: block; }
.qr figcaption { font-size: 0.9rem; color: var(--muted); margin-top: 0.35rem; }

.steps { padding-left: 1.6rem; }
.steps li { margin-bottom: 0.5rem; padding-left: 0.25rem; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0.75rem 1.5rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); font-size: 0.9rem; }
.facts dd { margin: 0; font-weight: 600; }

.pill { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 1rem; font-size: 0.85rem; font-weight: 600; border: 1px solid currentColor; }
.pill-active { color: var(--ok-text); background: var(--ok-bg); }
.pill-used, .pill-expired { color: var(--muted); }
.pill-revoked { color: var(--err-text); background: var(--err-bg); }

meter.bar { width: 100%; height: 1rem; margin-bottom: 1rem; }

/* tables scroll sideways on narrow screens instead of breaking the page */
/* position: relative keeps absolutely positioned screen reader text inside the scroll box */
.table-scroll { position: relative; overflow-x: auto; margin-bottom: 1.5rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; min-width: 34rem; }
th, td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th { font-size: 0.9rem; color: var(--muted); font-weight: 600; }
tbody tr:last-child > * { border-bottom: 0; }
tbody th { font-weight: 600; }
.num { text-align: right; white-space: nowrap; }

.reports { list-style: none; padding: 0; }
.reports .is-done { opacity: 0.75; }

/* ---------- upload ---------- */

.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface);
  padding: 2rem 1rem; text-align: center; margin-bottom: 1.5rem;
}
.dropzone p { margin: 0.75rem 0 0; }
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.files-section h2 { margin-top: 0; }
table.files { min-width: 0; }
.files th, .files td { padding-inline: 0.5rem; }
.files td.status { white-space: nowrap; }
.files .file-name { display: block; font-weight: 600; }
.files .file-remove { margin-top: 0.4rem; }
.files progress { width: 6rem; height: 0.6rem; margin-left: 0.5rem; vertical-align: middle; }
.total { font-weight: 600; }
.total.is-over { color: var(--err-text); }

.progress-box { margin-top: 1.5rem; padding: 1.25rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.progress-box progress { width: 100%; height: 1.25rem; }
.progress-text { font-weight: 700; font-size: 1.1rem; margin: 0.5rem 0 0.25rem; }

progress { accent-color: var(--accent); }

/* ---------- downloads ---------- */

.dl-list { list-style: none; padding: 0; margin: 1.5rem 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.dl-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.dl-list li:last-child { border-bottom: 0; }
.dl-name { flex: 1 1 14rem; font-weight: 600; word-break: break-all; }
.dl-size { color: var(--muted); white-space: nowrap; }

/* ---------- prose pages ---------- */

.prose { max-width: 44rem; }
.prose h2 { margin-top: 2.25rem; }
.easy { font-size: 1.15rem; line-height: 1.8; }
.easy p { margin-bottom: 0.6rem; }

/* ---------- accessibility dialog ---------- */

.a11y-dialog {
  width: min(32rem, calc(100vw - 1rem)); max-height: calc(100vh - 1rem); overflow: auto;
  padding: 0; border: 2px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
.a11y-dialog::backdrop { background: rgb(0 0 0 / 0.55); }
.a11y-form { padding: 1.25rem; }
.a11y-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.5rem; }
.a11y-head h2 { margin: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.seg label { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.75rem; border: 2px solid var(--border-strong); border-radius: var(--radius); cursor: pointer; }
.seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.seg input { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; }
.voice-row { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.75rem; }
.reading { outline: 3px solid var(--focus); outline-offset: 4px; }

@media (max-width: 40rem) {
  h1 { font-size: 1.6rem; }
  main { padding-block: 1.25rem 2rem; }
  .admin-nav .logout { margin-left: 0; }
}

@media print {
  .site-header, .site-footer, .a11y-dialog, .skip { display: none; }
}
