/* customise.css (BUY-024).
 *
 * Customise panel, filter presets, and the themes (Midnight Slate default, True OLED Black, Daylight Paper).
 * Use the theme variables from style.css :root for any colour that should
 * follow the theme.
 *
 * Midnight Slate is style.css's own :root. The two other themes only
 * redefine those variables, set by ui_prefs.applyTheme as data-theme on
 * <html>; map tiles, pins, clusters and the data ramps are left alone.
 */

/* ==========================================================================
   Themes
   ========================================================================== */

/* True OLED Black: pure black wherever the page is background, so an OLED
   screen (the Pixel 8 Pro) switches those pixels off; controls stay a
   near-black grey so their edges still read. */
:root[data-theme="oled"] {
  color-scheme: dark;
  --bg-primary: #000000;
  --bg-surface: rgba(0, 0, 0, 0.92);
  --bg-surface-hover: #16191e;
  --border-color: rgba(255, 255, 255, 0.16);
  --panel-raised: #14171c;
  --panel-pressed: #262b33;
  --panel-pressed-strong: #343a44;
  --segment-active: #1f242c;
  --bg-inset: #000000;
  --input-bg: #000000;
  --bg-card: #0a0c0f;
  --popup-bg: #000000;
  --slider-track: #2b3038;
  --slider-thumb-ring: #000000;
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.75), 0 8px 10px -6px rgba(0, 0, 0, 0.6);
}

/* Daylight Paper: dark ink on warm white, every text colour at least 4.5:1
   against the paper and the white cards (most well above), for reading
   outdoors in sunlight. */
:root[data-theme="daylight"] {
  color-scheme: light;
  --bg-primary: #f5f3ee;
  --bg-surface: rgba(255, 255, 255, 0.96);
  --bg-surface-hover: #eef1f5;
  --border-color: rgba(15, 23, 42, 0.2);
  --text-main: #0f172a;
  --text-muted: #334155;
  --text-dim: #475569;
  --text-strong: #020617;
  --text-soft: #1e293b;
  --accent: #047857;
  --accent-hover: #065f46;
  --accent-light: rgba(4, 120, 87, 0.12);
  --on-accent: #ffffff;
  --panel-raised: #f1f5f9;
  --panel-pressed: #e2e8f0;
  --panel-pressed-strong: #cbd5e1;
  --segment-active: #ffffff;
  --bg-inset: #e2e8f0;
  --input-bg: #ffffff;
  --bg-card: #ffffff;
  --popup-bg: #ffffff;
  --slider-track: #cbd5e1;
  --slider-thumb-ring: #ffffff;
  --overlay-rgb: 15, 23, 42;
  --info: #0369a1;
  --info-rgb: 3, 105, 161;
  --info-soft: #1d4ed8;
  --positive: #047857;
  --positive-soft: #065f46;
  --negative-text: #b91c1c;
  --warning-text: #92400e;
  --warning-strong: #b45309;
  --transport: #15803d;
  --match-strong-text: #075985;
  --match-good-text: #0369a1;
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.2), 0 8px 10px -6px rgba(15, 23, 42, 0.12);
}

/* The few rules whose dark-only literals are not theme roles. */
:root[data-theme="daylight"] .mode-btn.active {
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
}

/* White on the midnight sky blue is 4.1:1; one shade darker passes in sun. */
:root[data-theme="daylight"] .pill-btn.active,
:root[data-theme="daylight"] .chip-btn.active,
:root[data-theme="daylight"] .active-filter-dot {
  background: #0369a1;
  border-color: #0369a1;
}

:root[data-theme="daylight"] .legend-swatch {
  border-color: rgba(15, 23, 42, 0.35);
}

:root[data-theme="daylight"] .count-badge {
  border-color: rgba(4, 120, 87, 0.35);
}

:root[data-theme="daylight"] .match-badge--weak,
:root[data-theme="daylight"] .match-badge--excluded,
:root[data-theme="daylight"] .value-badge--none {
  border-color: rgba(71, 85, 105, 0.45);
}

/* ==========================================================================
   Customise panel (inside #customise-host; the panel container is the shell's)
   ========================================================================== */

.customise-host {
  max-width: 640px;
}

.customise-form {
  display: grid;
  gap: 14px;
}

.customise-lead {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.customise-group {
  min-width: 0;
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 10px 12px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.customise-group legend {
  padding: 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.customise-intro {
  margin: 0 0 2px;
  font-size: 12px;
  color: var(--text-dim);
}

/* The whole row is the label, so the tap target is the row (44px), not the
   20px box. */
.customise-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--panel-raised);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.customise-option:has(input:checked) {
  background: rgba(var(--info-rgb), 0.1);
  border-color: var(--info);
}

.customise-option:has(input:focus-visible) {
  box-shadow: 0 0 0 2px rgba(var(--info-rgb), 0.45);
}

.customise-option input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  accent-color: var(--info);
  cursor: pointer;
}

.customise-option-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.customise-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.customise-hint {
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-dim);
}

.customise-inline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.customise-option--inline {
  align-items: center;
}

.customise-seen-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 2px 0;
  font-size: 12px;
  color: var(--text-muted);
}

.customise-clear-seen,
.customise-reset {
  min-height: 44px;
  padding: 8px 14px;
}

.customise-reset:disabled {
  opacity: 0.5;
  cursor: default;
}

/* A theme option shows a chip of its own page and surface colours. */
.customise-swatch {
  flex: none;
  width: 34px;
  height: 34px;
  margin-top: -3px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.customise-theme--midnight .customise-swatch {
  background: linear-gradient(135deg, #0f172a 0 55%, #1e293b 55% 100%);
}

.customise-theme--oled .customise-swatch {
  background: linear-gradient(135deg, #000000 0 55%, #14171c 55% 100%);
}

.customise-theme--daylight .customise-swatch {
  background: linear-gradient(135deg, #f5f3ee 0 55%, #ffffff 55% 100%);
}

.customise-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

@media (max-width: 600px) {
  .customise-inline {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Filter presets (#preset-chips, #custom-presets-host)
   ========================================================================== */

.btn-link-inline {
  min-height: 40px;
  padding: 0 4px;
  background: none;
  border: none;
  color: var(--info);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.btn-link-inline[aria-expanded="true"] {
  text-decoration: underline;
}

.preset-chip {
  min-height: 40px;
}

/* What the preset in force sets, readable on a touch screen. */
.preset-desc {
  flex-basis: 100%;
  margin: 2px 0 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-dim);
}

#custom-presets-host[hidden] {
  display: none;
}

.preset-custom-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-custom {
  display: inline-flex;
  align-items: stretch;
}

.preset-custom .preset-chip {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.preset-delete {
  min-width: 40px;
  min-height: 40px;
  padding: 0 10px;
  background: var(--panel-raised);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-left: none;
  border-radius: 0 20px 20px 0;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.preset-custom.is-confirming .preset-delete {
  background: rgba(239, 68, 68, 0.16);
  color: var(--negative-text);
  border-color: rgba(239, 68, 68, 0.45);
  font-weight: 700;
}

.preset-form {
  flex-basis: 100%;
  display: grid;
  gap: 6px;
}

.preset-form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.preset-form-row {
  display: flex;
  gap: 6px;
}

.preset-name-input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 8px 10px;
  background: var(--input-bg);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font: inherit;
  font-size: 14px;
  outline: none;
}

.preset-name-input::placeholder {
  color: var(--text-dim);
}

.preset-name-input:focus {
  border-color: var(--info);
  box-shadow: 0 0 0 2px rgba(var(--info-rgb), 0.2);
}

.preset-name-input[aria-invalid="true"] {
  border-color: var(--negative-text);
}

.preset-form-save,
.preset-form-cancel {
  min-height: 40px;
}

.preset-form-error {
  font-size: 12px;
  color: var(--negative-text);
}
