/* Shared theme system: CSS custom properties for colors + a matching layered background-image per theme, switched by setting data-theme="<id>" on <html> (see public/js/theme.js). "natt" is the default and matches the app's original navy/gold palette. */

:root {
  --bg: #1b1f3b;
  --surface: #262b52;
  --border: #3a3f6b;
  --text: #f4f4f4;
  --text-muted: #cfcfcf;
  --accent: #f4b942;
  --accent-text: #1b1f3b;
  --error: #ff8080;
  --success: #6bd48f;
  --bg-image:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.8) 0, rgba(255, 255, 255, 0.8) 1px, transparent 1.5px),
    radial-gradient(circle at 70% 60%, rgba(255, 255, 255, 0.65) 0, rgba(255, 255, 255, 0.65) 1px, transparent 1.5px),
    radial-gradient(circle at 40% 85%, rgba(255, 255, 255, 0.55) 0, rgba(255, 255, 255, 0.55) 1px, transparent 1.5px),
    radial-gradient(ellipse at top, #2c3468 0%, #1b1f3b 60%);
  --bg-size: 140px 140px, 190px 190px, 100px 100px, 100% 100%;
  --bg-repeat: repeat, repeat, repeat, no-repeat;
  --bg-position: 0 0, 0 0, 0 0, 0 0;
}

html[data-theme="skog"] {
  --bg: #16281c;
  --surface: #21402b;
  --border: #3a5c42;
  --text: #f1f7f0;
  --text-muted: #bfd9c4;
  --accent: #8fd14f;
  --accent-text: #16281c;
  --error: #ff9a80;
  --success: #6bd4c8;
  --bg-image:
    radial-gradient(circle at 15% 20%, rgba(200, 255, 160, 0.14), transparent 40%),
    radial-gradient(circle at 82% 75%, rgba(140, 220, 140, 0.12), transparent 45%),
    linear-gradient(160deg, #102016 0%, #16281c 45%, #1e3524 100%);
  --bg-size: 100% 100%, 100% 100%, 100% 100%;
  --bg-repeat: no-repeat, no-repeat, no-repeat;
  --bg-position: 0 0, 0 0, 0 0;
}

html[data-theme="solnedgang"] {
  --bg: #33193a;
  --surface: #4a2350;
  --border: #6e3566;
  --text: #fff2e6;
  --text-muted: #e3bfd6;
  --accent: #ff8a5b;
  --accent-text: #2a1220;
  --error: #ff5c7a;
  --success: #9fd171;
  --bg-image:
    radial-gradient(circle at 50% 12%, rgba(255, 210, 150, 0.55), transparent 32%),
    linear-gradient(180deg, #24122a 0%, #4a2350 40%, #7a3f5e 75%, #33193a 100%);
  --bg-size: 100% 100%, 100% 100%;
  --bg-repeat: no-repeat, no-repeat;
  --bg-position: 0 0, 0 0;
}

html[data-theme="hav"] {
  --bg: #0b2430;
  --surface: #113244;
  --border: #1f5266;
  --text: #eaf6fb;
  --text-muted: #a9d3e0;
  --accent: #4fd1c5;
  --accent-text: #06222b;
  --error: #ff8a80;
  --success: #7be08a;
  --bg-image:
    repeating-linear-gradient(200deg, rgba(255, 255, 255, 0.05) 0px, rgba(255, 255, 255, 0.05) 2px, transparent 2px, transparent 42px),
    radial-gradient(circle at 78% 18%, rgba(140, 230, 220, 0.16), transparent 40%),
    linear-gradient(160deg, #071b24 0%, #0b2430 50%, #113244 100%);
  --bg-size: auto, 100% 100%, 100% 100%;
  --bg-repeat: repeat, no-repeat, no-repeat;
  --bg-position: 0 0, 0 0, 0 0;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bg-image);
  background-repeat: var(--bg-repeat);
  background-size: var(--bg-size);
  background-position: var(--bg-position);
}

.themePicker {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1000;
}

.themePickerToggle {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 0.15rem 0.5rem rgba(0, 0, 0, 0.35);
}

.themePickerMenu {
  position: absolute;
  right: 0;
  bottom: 3.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 0.15rem 0.5rem rgba(0, 0, 0, 0.35);
}

/* The display:flex above would otherwise beat the hidden attribute on
   pages without their own global [hidden] rule (e.g. flags.html). */
.themePickerMenu[hidden] {
  display: none;
}

.themeOption {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid transparent;
  border-radius: 0.25rem;
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
}

.themeOption:hover,
.themeOption:focus-visible {
  border-color: var(--border);
}

.themeOption[aria-pressed="true"] {
  border-color: var(--accent);
}

.themeSwatch {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  flex: none;
}

.themeOption[data-theme-id="natt"] .themeSwatch { background: #f4b942; }
.themeOption[data-theme-id="skog"] .themeSwatch { background: #8fd14f; }
.themeOption[data-theme-id="solnedgang"] .themeSwatch { background: #ff8a5b; }
.themeOption[data-theme-id="hav"] .themeSwatch { background: #4fd1c5; }

.fraction {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 0.15em;
  font-size: 0.85em;
  line-height: 1.15;
}

.fractionNumerator,
.fractionDenominator {
  padding: 0 0.15em;
}

.fractionNumerator {
  border-bottom: 0.08em solid currentColor;
}

/* Curriculum excerpt shown after answering (public/js/curriculumExcerpt.js). */
.curriculumExcerpt {
  margin: 0 0 1rem 0;
  padding: 0.6rem 0.8rem;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 6px 6px 0;
  text-align: left;
}
.curriculumExcerptLabel {
  margin: 0 0 0.3rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.curriculumExcerpt blockquote {
  margin: 0 0 0.5rem 0;
  font-size: 0.95rem;
  line-height: 1.4;
  font-style: italic;
}
.curriculumExcerptSource {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Free-text comment next to the difficulty rating (quiz.html, review.html). */
.statementComment { display: block; margin-top: 1rem; }
.statementComment span { display: block; margin: 0 0 0.3rem 0; font-size: 0.9rem; color: var(--text-muted); }
.statementComment textarea {
  display: block;
  width: 100%;
  min-height: 3rem;
  padding: 0.4rem;
  border-radius: 0.25rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  box-sizing: border-box;
  resize: vertical;
}
