/*
 * German Convo Anki — „Karteikasten" design system.
 *
 * The aesthetic is the Leitner file-card box: warm card stock, ruled lines,
 * the classic red margin rule, ink-black type, and Grades as rubber stamps.
 * Display: Archivo (DIN-flavored grotesque). Body: Newsreader (printed
 * matter). Meta/numbers: IBM Plex Mono.
 */

:root {
  --paper: #f2ead7;
  --paper-deep: #e7dbbf;
  --card: #faf5e8;
  --card-edge: #d9cba9;
  --rule: #dccfae;
  --rule-blue: #b9c6d8;
  --ink: #241d12;
  --ink-soft: #7a6f5c;
  --ink-faint: #a99d86;
  --red: #c23a1c;
  --red-deep: #a02c12;
  --pass: #2e6b3f;
  --shaky: #a86f1c;
  --fail: #b0301e;
  --shadow: 32 24 12;
  --font-display: "Archivo", "Helvetica Neue", sans-serif;
  --font-body: "Newsreader", Georgia, serif;
  --font-mono: "IBM Plex Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -10%, rgba(255 252 240 / 0.9), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
}

/* ---------- Chrome ---------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.4rem 0.9rem;
  max-width: 46rem;
  width: 100%;
  margin: 0 auto;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: var(--ink);
}

.wordmark__stamp {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  color: var(--red);
  border: 2.5px solid var(--red);
  border-radius: 3px;
  padding: 0.28rem 0.4rem 0.22rem;
  transform: rotate(-4deg);
  line-height: 1;
}

.wordmark__text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.wordmark__text em {
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 0.62rem;
  font-weight: 400;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

.nav-link {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 2px solid var(--red);
  padding-bottom: 0.1rem;
}

.nav-link:hover { color: var(--red); }

.app-header__nav { display: flex; align-items: center; gap: 1rem; }

.nav-link--button {
  background: none;
  font-family: inherit;
  cursor: pointer;
}

.shell {
  flex: 1;
  width: 100%;
  max-width: 46rem;
  margin: 0 auto;
  padding: 0.4rem 1.4rem 3rem;
}

.app-footer {
  max-width: 46rem;
  width: 100%;
  margin: 0 auto;
  padding: 0 1.4rem 1.6rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}

/* ---------- Index cards ---------- */

.kcard {
  position: relative;
  background-color: var(--card);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 27px,
    color-mix(in srgb, var(--rule) 55%, transparent) 27px,
    color-mix(in srgb, var(--rule) 55%, transparent) 28px
  );
  border: 1px solid var(--card-edge);
  border-radius: 4px;
  box-shadow:
    0 1px 0 rgba(var(--shadow) / 0.08),
    0 6px 18px -8px rgba(var(--shadow) / 0.35);
  padding: 1.5rem 1.6rem 1.6rem 2.4rem;
  margin: 1.3rem 0;
}

/* the classic red margin rule of a Karteikarte */
.kcard::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 1.55rem;
  width: 1.5px;
  background: color-mix(in srgb, var(--red) 55%, transparent);
  pointer-events: none;
}

/* a second card peeking out beneath — it's a box of cards, not a page */
.kcard--stacked::after {
  content: "";
  position: absolute;
  inset: auto 6px -7px 6px;
  height: 12px;
  background: var(--paper-deep);
  border: 1px solid var(--card-edge);
  border-radius: 0 0 4px 4px;
  z-index: -1;
}

.kcard--plain {
  background-image: none;
  padding-left: 1.6rem;
}

.kcard--plain::before { display: none; }

/* ---------- Type ---------- */

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--red);
  margin: 0 0 0.5rem;
}

h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(1.9rem, 6vw, 2.7rem);
  line-height: 1.02;
  letter-spacing: -0.015em;
  text-transform: uppercase;
  margin: 0 0 0.6rem;
}

h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin: 0 0 0.8rem;
}

.lede {
  font-size: 1.15rem;
  font-style: italic;
  color: var(--ink-soft);
  margin: 0;
}

a { color: var(--ink); text-decoration-color: var(--red); text-decoration-thickness: 2px; }
a:hover { color: var(--red); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 3px;
  padding: 0.85rem 1.5rem;
  cursor: pointer;
  text-decoration: none;
  border: 2px solid var(--ink);
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}

.btn--primary {
  background: var(--red);
  border-color: var(--red-deep);
  color: var(--card);
  box-shadow: 3px 3px 0 var(--ink);
}

.btn--primary:hover { background: var(--red-deep); }

.btn--primary:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--ink);
}

.btn--quiet {
  background: transparent;
  border-color: var(--ink-faint);
  color: var(--ink-soft);
  font-size: 0.78rem;
  padding: 0.55rem 0.9rem;
  box-shadow: none;
}

.btn--quiet:hover { border-color: var(--ink); color: var(--ink); }

button.btn { -webkit-appearance: none; appearance: none; }

/* ---------- Rubber stamps ---------- */

.stamp {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.22rem 0.5rem 0.16rem;
  border: 2.5px solid currentColor;
  border-radius: 3px;
  transform: rotate(-3deg);
  mix-blend-mode: multiply;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='40'%3E%3Cfilter id='r'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='3' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.9 0.28'/%3E%3CfeComposite operator='over' in2='SourceGraphic'/%3E%3C/filter%3E%3Crect width='120' height='40' fill='white' filter='url(%23r)'/%3E%3C/svg%3E");
  mask-size: cover;
}

.stamp--pass { color: var(--pass); }
.stamp--shaky { color: var(--shaky); }
.stamp--fail { color: var(--fail); }
.stamp--ink { color: var(--ink-soft); }

@keyframes stamp-in {
  0% { transform: rotate(-9deg) scale(1.6); opacity: 0; }
  60% { transform: rotate(-3deg) scale(0.96); opacity: 1; }
  100% { transform: rotate(-3deg) scale(1); opacity: 1; }
}

.session-report__item .stamp { animation: stamp-in 0.35s ease-out both; }

/* ---------- Staggered reveal ---------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.rise > * { animation: rise 0.45s ease-out both; }
.rise > *:nth-child(1) { animation-delay: 0.03s; }
.rise > *:nth-child(2) { animation-delay: 0.1s; }
.rise > *:nth-child(3) { animation-delay: 0.17s; }
.rise > *:nth-child(4) { animation-delay: 0.24s; }
.rise > *:nth-child(5) { animation-delay: 0.31s; }

@media (prefers-reduced-motion: reduce) {
  .rise > *, .session-report__item .stamp { animation: none; }
}

/* ---------- Home: stat drawer ---------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
  margin: 1.3rem 0;
}

.stat-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 3px;
  padding: 1.5rem 0.9rem 0.8rem;
  box-shadow: 0 4px 12px -8px rgba(var(--shadow) / 0.3);
}

/* tab divider sticking up, like the labeled dividers in a card box */
.stat-card__label {
  position: absolute;
  top: -0.72rem;
  left: 0.6rem;
  background: var(--paper-deep);
  border: 1px solid var(--card-edge);
  border-radius: 3px 3px 0 0;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 0.14rem 0.5rem 0.06rem;
}

.stat-card__value {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.9rem;
  line-height: 1;
  letter-spacing: -0.01em;
}

.stat-card__of {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink-faint);
}

.stat-card__meter {
  display: flex;
  gap: 3px;
  margin-top: 0.5rem;
}

.stat-card__meter i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-faint);
}

.stat-card__meter i.is-filled {
  background: var(--red);
  border-color: var(--red);
}

.stat-card__hint {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--ink-faint);
  margin-top: 0.45rem;
}

/* ---------- Home: flow card ---------- */

.flow-card__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.1rem;
}

.flow-card__meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-soft);
  letter-spacing: 0.03em;
}

.peek-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ---------- Session list ---------- */

.session-list__items,
.session-report__items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.session-list__items li {
  position: relative;
  font-size: 1.22rem;
  line-height: 28px;
  padding: 0.62rem 0 0.6rem 0.2rem;
  border-bottom: 1px dashed color-mix(in srgb, var(--ink-faint) 45%, transparent);
}

.session-list__items li::before {
  content: "Nr. " attr(value);
  display: block;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  color: var(--red);
  margin-bottom: 0.05rem;
}

.session-list__items li:last-child { border-bottom: none; }

/* ---------- Record dock ---------- */

.record-dock {
  position: sticky;
  bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: 6px;
  padding: 0.8rem 1.1rem;
  margin-top: 1.4rem;
  box-shadow: 0 10px 24px -8px rgba(var(--shadow) / 0.6);
}

.record-btn {
  flex: none;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 3px solid var(--paper);
  background: var(--red);
  cursor: pointer;
  position: relative;
  transition: transform 0.08s ease;
}

.record-btn:hover { transform: scale(1.05); }

.record-btn::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: var(--paper);
  opacity: 0.9;
}

.record-btn--stop::after { border-radius: 2px; }

@keyframes rec-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(194 58 28 / 0.7); }
  70% { box-shadow: 0 0 0 14px rgba(194 58 28 / 0); }
}

.record-dock[data-state="recording"] .record-btn { animation: rec-pulse 1.4s infinite; }

.record-dock__copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.record-dock__label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.record-dock__timer {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: color-mix(in srgb, var(--paper) 75%, transparent);
  font-variant-numeric: tabular-nums;
}

.record-dock__status {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  margin: 0;
  color: color-mix(in srgb, var(--paper) 75%, transparent);
}

.record-dock__status[data-state="failed"] { color: #f2b6a5; }
.record-dock__status[data-state="uploaded"] { color: #bcd9b2; }

/* evaluating spinner */
.evaluating {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 1.4rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.evaluating::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px dashed var(--red);
  animation: spin 1.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Session report ---------- */

.report-summary {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin: 0.4rem 0 0.6rem;
}

.session-report__item {
  padding: 1.05rem 0 1rem;
  border-bottom: 1px dashed color-mix(in srgb, var(--ink-faint) 45%, transparent);
}

.session-report__item:last-child { border-bottom: none; }

.session-report__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
}

.session-report__number {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  color: var(--red);
}

.session-report__prompt {
  font-size: 1.18rem;
  font-weight: 500;
  margin: 0.1rem 0 0.5rem;
}

.session-report__transcript {
  font-style: italic;
  font-size: 1.08rem;
  margin: 0 0 0.4rem;
}

.session-report__transcript.is-empty { color: var(--ink-faint); }

.session-report__corrections,
.session-report__model-answer {
  font-size: 0.95rem;
  margin: 0.25rem 0;
  padding-left: 0.9rem;
  border-left: 2.5px solid var(--rule-blue);
}

.session-report__corrections { border-left-color: var(--shaky); }

.model-answer-audio {
  display: block;
  width: 100%;
  max-width: 260px;
  height: 2rem;
  margin-top: 0.35rem;
}

.session-report__corrections b,
.session-report__model-answer b {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: block;
}

.next-up {
  text-align: center;
  margin-top: 1.6rem;
}

.next-up .flow-card__meta { display: block; margin-top: 0.6rem; }

/* ---------- Archive ---------- */

.session-history {
  list-style: none;
  margin: 0;
  padding: 0;
}

.session-history__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.8rem 0.2rem;
  border-bottom: 1px dashed color-mix(in srgb, var(--ink-faint) 45%, transparent);
}

.session-history__row:last-child { border-bottom: none; }

.session-history__date {
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

.session-row__chips {
  display: flex;
  gap: 0.45rem;
}

.chip {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  padding: 0.14rem 0.5rem 0.1rem;
  border-radius: 999px;
  border: 1.5px solid currentColor;
}

.chip--pass { color: var(--pass); }
.chip--shaky { color: var(--shaky); }
.chip--fail { color: var(--fail); }

.chip.is-zero { opacity: 0.35; }

/* ---------- Small screens ---------- */

@media (max-width: 540px) {
  .shell { padding: 0.2rem 0.9rem 2.4rem; }
  .app-header { padding: 0.9rem 0.9rem 0.6rem; }
  .kcard { padding: 1.2rem 1.1rem 1.3rem 2.1rem; }
  .kcard::before { left: 1.35rem; }
  .stat-card__value { font-size: 1.45rem; }
  .stat-row { gap: 0.55rem; margin-top: 1.5rem; }
}

/* ---------- Forms (login, password reset) ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0 0 1.1rem;
}

.field label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field input {
  font-family: var(--font-body);
  font-size: 1.05rem;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--card-edge);
  border-radius: 3px;
  padding: 0.65rem 0.8rem;
}

.field input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--red) 25%, transparent);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.4rem;
}

.form-hint {
  margin-top: 1.2rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.flash {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  padding: 0.6rem 0.8rem;
  border-radius: 3px;
  margin: 0 0 1.2rem;
}

.flash--alert {
  background: color-mix(in srgb, var(--fail) 12%, var(--card));
  border: 1px solid var(--fail);
  color: var(--fail);
}

.flash--notice {
  background: color-mix(in srgb, var(--pass) 12%, var(--card));
  border: 1px solid var(--pass);
  color: var(--pass);
}

/* ---------- Print: the sheet you take to the microphone ---------- */

@media print {
  @page { margin: 1.4cm; }

  body {
    background: #fff;
    color: #000;
    font-size: 12pt;
  }

  .no-print, .app-header, .app-footer, .record-dock, .evaluating { display: none !important; }

  .shell { max-width: none; padding: 0; }

  .kcard {
    border: none;
    box-shadow: none;
    background: #fff;
    padding: 0;
    margin: 0;
  }

  .kcard::before, .kcard--stacked::after { display: none; }

  h1 { font-size: 16pt; }

  .session-list__items li {
    break-inside: avoid;
    border-bottom-color: #ccc;
  }

  .session-list__items li::before { color: #000; }
}
