/*
 * lanyting shared stylesheet.
 *
 * Used by the Django app (templates/base.html, served from /static/ via
 * collectstatic) and by the landing pages in landing/, which are deployed
 * as-is, so both sites serve this file at /static/css/app.css.
 *
 * Rules only for the app are scoped to <body class="app">, rules only for the
 * landing pages to <body class="landing">. Element selectors are scoped with
 * :where() so the scoping adds no specificity.
 */

/* ---------- Design tokens ---------- */

:root {
  color-scheme: light dark;
  --bg: #f6f8fa;
  --surface: #ffffff;
  --border: #d0d7de;
  --text: #1f2328;
  --muted: #59636e;
  --accent: #2563eb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #161b22;
    --border: #30363d;
    --text: #e6edf3;
    --muted: #8b949e;
    --accent: #4f9cf9;
  }
}

/* ---------- Shared base ---------- */

* {
  box-sizing: border-box;
}

body {
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--text);
  accent-color: var(--accent);
  margin: 0;
  line-height: 1.6;
}

a {
  color: var(--accent);
}

h1,
h2 {
  letter-spacing: -0.02em;
  line-height: 1.25;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -999px;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  background: var(--surface);
  padding: 0.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

/* ---------- Landing pages (body.landing) ---------- */

:where(.landing) * {
  margin: 0;
  padding: 0;
}

:where(.landing) h3 {
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

:where(.landing) header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.logo span {
  color: var(--accent);
}

:where(.landing) nav a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 1.5rem;
  font-size: 0.95rem;
}

:where(.landing) nav a:first-child {
  margin-left: 0;
}

:where(.landing) nav a:hover {
  color: var(--text);
}

.hero {
  text-align: center;
  padding: 5rem 0 4rem;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 1.25rem;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
}

.hero p {
  color: var(--muted);
  font-size: 1.15rem;
  max-width: 660px;
  margin: 0 auto;
}

:where(.landing) section {
  padding: 3rem 0;
}

:where(.landing) section > h2 {
  text-align: center;
  margin-bottom: 1rem;
  font-size: clamp(1.5rem, 3vw, 2rem);
}

.section-lead {
  color: var(--muted);
  text-align: center;
  max-width: 680px;
  margin: 0 auto 2rem;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

:where(.landing) .card {
  padding: 1.5rem;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease;
}

:where(.landing) .card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

:where(.landing) .card h3 {
  margin-bottom: 0.5rem;
  font-size: 1.05rem;
}

:where(.landing) .card p {
  color: var(--muted);
  font-size: 0.95rem;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  list-style: none;
}

.step {
  text-align: center;
  padding: 1rem;
}

.step .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.step h3 {
  margin-bottom: 0.5rem;
}

.step p {
  color: var(--muted);
  font-size: 0.95rem;
}

.prose {
  max-width: 700px;
  margin: 0 auto;
}

.prose p,
.prose ul,
.prose ol {
  margin-bottom: 1rem;
}

.prose ul,
.prose ol {
  padding-left: 1.5rem;
}

.prose h2 {
  margin: 2.5rem 0 0.75rem;
}

.prose h3 {
  margin: 1.5rem 0 0.5rem;
}

.prose li {
  margin-bottom: 0.35rem;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  list-style: none;
  max-width: 760px;
  margin: 0 auto;
}

.pill-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.95rem;
}

.note {
  color: var(--muted);
  font-size: 0.875rem;
}

.faq {
  max-width: 760px;
  margin: 0 auto;
}

.faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}

.faq summary {
  cursor: pointer;
  font-weight: 600;
}

.faq details p {
  color: var(--muted);
  margin-top: 0.75rem;
}

.sources li {
  font-size: 0.9rem;
  color: var(--muted);
}

.breadcrumbs {
  font-size: 0.9rem;
  color: var(--muted);
  padding-top: 1.5rem;
}

article.prose {
  padding: 2rem 0 3rem;
}

article.prose h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin-bottom: 1rem;
}

:where(.landing) footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
}

:where(.landing) footer a {
  color: var(--muted);
}

:where(.landing) footer a:hover {
  color: var(--text);
}

/* ---------- App (body.app) ---------- */

.topbar {
  max-width: 42rem;
  margin: 0 auto;
  padding: 1rem;
}

.topbar a {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.topbar a span {
  color: var(--accent);
}

:where(.app) main {
  max-width: 42rem;
  margin: 0 auto 3rem;
  padding: 0 1rem;
}

.muted {
  color: var(--muted);
}

:where(.app) .card {
  padding: 1.25rem 1.5rem;
  margin: 1.25rem 0;
}

:where(.app) .card > :first-child {
  margin-top: 0;
}

:where(.app) .card > :last-child {
  margin-bottom: 0;
}

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

.topics li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.topics li:last-child {
  border-bottom: 0;
}

.anchors {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0;
  margin: 0.4rem 0 0;
}

.anchors li {
  padding: 0;
  border-bottom: 0;
}

:where(.app) button.chip {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  box-shadow: none;
}

:where(.app) button,
:where(.app) input[type="text"] {
  font-size: 1rem;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

:where(.app) button {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

:where(.app) button:hover:not(:disabled) {
  filter: brightness(1.1);
}

:where(.app) button:active:not(:disabled) {
  transform: translateY(1px);
}

:where(.app) button:disabled {
  opacity: 0.6;
  cursor: default;
}

:where(.app) input[type="text"] {
  background: var(--surface);
  color: var(--text);
}

.full-width {
  width: 100%;
}

:where(.app) label {
  display: block;
  margin: 0.5rem 0;
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

:where(.app) label:hover {
  border-color: var(--accent);
}

:where(.app) label:has(input[type="radio"]:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

:where(.app) progress {
  width: 100%;
  height: 0.5rem;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: var(--border);
}

:where(.app) progress::-webkit-progress-bar {
  background: var(--border);
}

:where(.app) progress::-webkit-progress-value {
  background: var(--accent);
}

:where(.app) progress::-moz-progress-bar {
  background: var(--accent);
}

.lecture {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin: 1rem 0;
}

.lecture h3,
.lecture h4 {
  margin: 1.25rem 0 0.5rem;
}

.lecture code {
  font-size: 0.9em;
  padding: 0.1em 0.3em;
  border-radius: 4px;
  background: color-mix(in srgb, var(--border) 45%, transparent);
}

.lecture pre {
  overflow-x: auto;
  padding: 0.75rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--border) 30%, transparent);
}

.lecture pre code {
  padding: 0;
  background: none;
}

.lecture table {
  border-collapse: collapse;
  width: 100%;
}

.lecture th,
.lecture td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.6rem;
  text-align: left;
}

.lecture blockquote {
  margin: 1rem 0;
  padding-left: 1rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

:where(.app) fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

.mode-choice {
  margin-bottom: 1rem;
}

.verdict {
  font-size: 1.25rem;
  font-weight: 700;
}

.verdict.correct {
  color: #1a7f37;
}

.verdict.incorrect {
  color: #cf222e;
}

@media (prefers-color-scheme: dark) {
  .verdict.correct {
    color: #3fb950;
  }

  .verdict.incorrect {
    color: #f85149;
  }
}

a.button {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  padding: 0.55rem 1rem;
  border-radius: 8px;
}

a.button:hover {
  filter: brightness(1.1);
}

.error {
  color: #e5534b;
}

.loading-hint {
  color: var(--muted);
  font-style: italic;
  margin-left: 0.5rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

footer.site {
  max-width: 42rem;
  margin: 0 auto 2rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- Shared: reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    transform: none !important;
  }
}
