/* Shared base for all pages: font, reset, building blocks and messages (ui-entscheidung.md §2 to §4). */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("../fonts/inter/inter-latin-wght-normal.260c81a4759b.woff2") format("woff2");
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; color-scheme: only light; }
body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: "Inter", system-ui, sans-serif; font-feature-settings: "cv11", "ss01";
  font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p, figure, dl, dd { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; touch-action: manipulation; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
form { margin: 0; }
.icon { width: 1.5rem; height: 1.5rem; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num, .tnum { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Page change: content fades in and rises 8 px ---------- */
.enter .anim { animation: page-in 0.26s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 16px); } }

/* ---------- Common pieces ---------- */
.mark { display: grid; grid-template-columns: repeat(2, 9px); gap: 2px; }
.mark i { width: 9px; height: 9px; border-radius: 3px; background: var(--E); }
.mark i:nth-child(2) { background: var(--Q); }
.mark i:nth-child(3) { background: var(--S); }
.mark i:nth-child(4) { background: var(--K); }
.title { font-size: clamp(25px, 8vw, 30px); overflow-wrap: break-word; hyphens: auto; line-height: 1.15; font-weight: 750; letter-spacing: -0.025em; }
.lead { font-size: 17px; color: var(--muted); margin-top: 6px; }
.h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 56px; padding: 0 24px; border-radius: var(--r); font-weight: 650; font-size: 17px; letter-spacing: -0.01em; width: 100%; }
.btn-primary { background: var(--c); color: #fff; }
.btn-ink { background: var(--ink); color: #fff; }
.btn-soft { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn .icon { width: 20px; height: 20px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
/* Pressed: answers the touch at once, because Chrome's own tap highlight is off (ui-entscheidung.md §2). */
.btn, .iconbtn, .avatar, .to-admin, .tab, .more-link, .solution-link, .resume, a.row { transition: transform 0.12s ease; }
:is(.btn, .iconbtn, .avatar, .to-admin, .tab, .more-link, .solution-link, .resume, a.row):active:not(:disabled, [aria-disabled="true"]) { transform: scale(0.98); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 15px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.chip-none { background: var(--surface-2); color: var(--muted); }
/* Goal chips (M4): states of TargetTimeService.describe */
.chip .icon { width: 16px; height: 16px; stroke-width: 2.5; }
.chip-reached { background: var(--ok-c); color: var(--ok); }
.chip-open { background: var(--open-c); color: var(--ink-2); }
.chip-no_target { background: var(--surface-2); color: var(--muted); }
/* Round state of a test in a list: tick on green or a grey target */
.state-icon { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.state-icon .icon { width: 14px; height: 14px; stroke-width: 3; }
.state-ok { background: var(--ok-c); color: var(--ok); }
.state-open { background: var(--surface-2); color: var(--muted); }
/* Category glyph in a list row (history, admin cards) */
.row-glyph { width: 46px; height: 46px; border-radius: 14px; background: var(--c-c); color: var(--c-on); display: grid; place-items: center; flex: none; }
.row-glyph .glyph { font-size: 13px; }
.glyph { font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.glyph .sup { font-size: 0.55em; vertical-align: 0.75em; margin-left: 0.02em; }
.card { background: var(--surface); border-radius: var(--r-lg); padding: 20px; }
.hint { font-size: 14px; color: var(--muted); }
.btn-text { color: var(--ink-2); min-height: 48px; }
[hidden] { display: none !important; }

/* ---------- Category chip and equation (test page and result, ui-entscheidung.md §6) ---------- */
.cat-chip { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px 0 6px; border-radius: 17px; background: var(--c-c); color: var(--c-on); font-weight: 650; font-size: 14px; justify-self: start; }
.cat-chip .glyph { font-size: 12px; background: var(--surface); border-radius: 12px; padding: 5px 7px; }
.eq { display: inline-flex; align-items: center; gap: 0.24em; white-space: nowrap; font-variant-numeric: tabular-nums; line-height: 1; }
.eq .sup { font-size: 0.5em; align-self: flex-start; margin-left: -0.16em; margin-top: -0.1em; }
.eq .gap { display: inline-flex; align-items: center; justify-content: center; min-width: 1.7em; height: 1.28em; padding: 0 0.2em; border-radius: 0.2em; background: var(--c-c); color: var(--c-on); box-shadow: inset 0 0 0 0.05em var(--c); position: relative; }
.eq .gap:empty::after { content: ""; width: 0.05em; height: 0.7em; background: var(--c); border-radius: 1px; animation: caret 1.1s steps(1) infinite; }
.eq .gap.is-solution { background: var(--ok-c); color: var(--ok); box-shadow: none; }
@keyframes caret { 50% { opacity: 0; } }

/* ---------- Messages: error, note, toast (Django messages map onto these) ---------- */
.messages { display: grid; gap: 10px; }
.messages:empty { display: none; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: var(--error-c); color: var(--error); font-weight: 600; font-size: 15px; }
.alert .icon { width: 20px; height: 20px; margin-top: 1px; }
.note { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: var(--surface); color: var(--ink-2); font-size: 15px; }
.note .icon { width: 20px; height: 20px; margin-top: 1px; color: var(--muted); }
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40;
  max-width: min(92vw, 420px); padding: 12px 18px; border-radius: 14px; background: var(--ink); color: #fff;
  font-weight: 600; font-size: 15px; box-shadow: 0 10px 30px rgba(18, 20, 26, 0.25);
  animation: toast-in 0.25s ease both; transition: opacity 0.25s ease;
}
.toast.is-hidden { opacity: 0; pointer-events: none; }

/* ---------- Empty state and error pages ---------- */
.empty { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 36px 24px; border-radius: var(--r-lg); background: var(--surface); }
.empty > .icon { width: 44px; height: 44px; padding: 10px; box-sizing: content-box; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); }
.empty b { font-size: 19px; letter-spacing: -0.01em; }
.empty p { color: var(--muted); max-width: 32ch; }
.empty .btn { width: auto; margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  .enter .anim { animation: none; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
