/* ===== THEMES =====
   Two of the three. The picker offers earth, white and dark; earth has no
   block here on purpose — it is the palette in base.css (and, on the history
   atlas, in history-profile.css), showing through when neither selector
   below matches. Adding a colour to one theme means adding it to both of
   these blocks and to the earth palette, or one theme quietly keeps the
   old value. */
[data-theme="white"] {
  --bg:     #ffffff;
  --surf:   #f5f5f4;
  --surf-2: #ececea;
  --border: #dddcd9;
  --sep:    #e5e4e1;
  --text:   #1f1d3a;
  --muted:  #5d5b75;
  --faint:  #9b99ac;
  --accent: #f43f5e;
}

/* "Expedition night" — deep indigo, not grey */
[data-theme="dark"] {
  --bg:     #15142b;
  --surf:   #201e3d;
  --surf-2: #2a2850;
  --border: #34325a;
  --sep:    #2e2c4e;
  --text:   #edebff;
  --muted:  #a5a3bd;
  --faint:  #6a6887;
  --accent: #ff6b81;
  --accent-deep: #f43f5e;
  --gold-soft: #ffe0a3;
  --cert-speculative: #e05252;
  --danger: #e05252;
  --sh-sm: 0 1px 3px rgba(0,0,0,0.3), 0 2px 6px rgba(0,0,0,0.2);
  --sh:    0 2px 12px rgba(0,0,0,0.4), 0 4px 20px rgba(0,0,0,0.2);
  --sh-lg: 0 6px 28px rgba(0,0,0,0.5), 0 12px 44px rgba(0,0,0,0.3);
}

/* ===== THEME SWITCHER ===== */
.theme-switcher {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  pointer-events: auto;
}

.theme-icon-btn {
  width: 1.85rem;
  height: 1.85rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
}

.theme-icon-btn svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-icon-btn:hover,
.theme-icon-btn:focus-visible {
  color: var(--text);
  border-color: var(--border);
  background: color-mix(in srgb, var(--surf) 74%, transparent);
  outline: none;
}

.theme-icon-btn.is-active {
  color: var(--text);
  border-color: var(--text);
}

.theme-menu {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  z-index: 700;
  min-width: 12rem;
  display: grid;
  gap: 0.1rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  box-shadow: var(--sh);
}

.language-menu {
  right: auto;
  left: 0;
}

.theme-option {
  min-height: 2rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0 0.6rem;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  /* Sentence case at the same size and weight as .settings-row-label, because
     these sit in the same menu as those rows and are the same kind of thing: a
     setting you pick. They used to be uppercase, letter-spaced and semibold,
     which is the treatment .settings-section-label uses for its headings — so
     the options shouted louder than the headings above them. Anchors get the
     underline removed for the same reason: in this menu a link is an option,
     not prose. */
  font-size: 0.72rem;
  font-weight: 400;
  text-align: left;
  text-decoration: none;
}

.theme-option:hover,
.theme-option:focus-visible,
.theme-option.is-active {
  color: var(--text);
  border-color: var(--border);
  outline: none;
}

.theme-swatch {
  width: 0.72rem;
  height: 0.72rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
}

.theme-swatch-earth { background: #fffefb; }
.theme-swatch-white { background: #ffffff; }
.theme-swatch-dark  { background: #15142b; }

/* ===== SETTINGS PANEL EXTRAS ===== */
.settings-sep {
  height: 1px;
  background: var(--sep);
  margin: 0.3rem 0;
}

.settings-section-label {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 0.35rem 0.6rem 0.15rem;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0.6rem;
  min-height: 2rem;
}

.settings-row-label {
  font-size: 0.72rem;
  color: var(--text);
}

.settings-row-val {
  font-size: 0.68rem;
  color: var(--muted);
}

/* Language switcher. Each language is named in itself, so the labels are never
   translated — a reader looking for Swedish is looking for "Svenska". */
.settings-locale-choice {
  display: inline-flex;
  gap: 0.15rem;
  padding: 0.1rem;
  border-radius: 0.5rem;
  background: var(--surf-2);
}

.settings-locale-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.68rem;
  line-height: 1;
  padding: 0.3rem 0.5rem;
  border-radius: 0.4rem;
  cursor: pointer;
}

.settings-locale-btn:hover,
.settings-locale-btn:focus-visible {
  color: var(--text);
}

.settings-locale-btn.is-active {
  background: var(--surf);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--sh-sm, 0 1px 2px rgba(0, 0, 0, 0.12));
}

/* Toggle switch */
.settings-toggle {
  position: relative;
  width: 2.4rem;
  min-width: 2.4rem;
  height: 1.25rem;
  border-radius: 2rem;
  border: 1.5px solid var(--muted);
  background: var(--surf-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
}

.settings-toggle[aria-pressed="true"] {
  background: var(--text);
  border-color: var(--text);
}

.settings-toggle-thumb {
  position: absolute;
  top: 50%;
  left: 0.18rem;
  transform: translateY(-50%);
  width: 0.78rem;
  height: 0.78rem;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s, background 0.2s;
  pointer-events: none;
}

.settings-toggle[aria-pressed="true"] .settings-toggle-thumb {
  transform: translate(0.95rem, -50%);
  background: var(--bg);
}

.theme-btn {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  pointer-events: auto;
}
.theme-btn[data-theme-btn="earth"] { background: #fffefb; }
.theme-btn[data-theme-btn="white"] { background: #ffffff; }
.theme-btn[data-theme-btn="dark"]  { background: #15142b; }
.theme-btn:hover { border-color: var(--muted); }
.theme-btn.is-active { border-color: var(--text); border-width: 2px; }
