/* Padletid — coastal, mobile-first theme (spec §6).
 * Colour is paired with label + icon everywhere; tier colours here are accents,
 * not the sole signal. */

:root {
  /* Coastal palette */
  --sea-900: #0b2942;
  --sea-800: #0f3a5c;
  --sea-700: #145278;
  --teal-600: #0f766e;
  --cyan-600: #0e7490;
  --blue-600: #1d4ed8;
  --blue-500: #2563eb;

  --bg: #f2f8fb;
  --surface: #ffffff;
  --surface-2: #eaf3f8;
  --ink: #0b2130;
  --ink-soft: #40586a;
  --muted: #6b8296;
  --line: #d7e6ef;

  /* Tier accents */
  --tier-perfekte: #0d7d6f;
  --tier-perfekte-bg: #d7f2ec;
  --tier-gode: #1d6fd6;
  --tier-gode-bg: #dbe9fb;
  --tier-heilt: #3fa3d6;
  --tier-heilt-bg: #dcf0fa;
  --tier-daarlege: #c07813;
  --tier-daarlege-bg: #fbeecf;
  --tier-ikkje: #5b6b78;
  --tier-ikkje-bg: #e4e9ed;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 6px 24px rgba(11, 41, 66, 0.12);
  --shadow-sm: 0 2px 8px rgba(11, 41, 66, 0.08);
  --tap: 44px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #071827;
    --surface: #0f2c42;
    --surface-2: #123449;
    --ink: #eaf3f8;
    --ink-soft: #b6cbd9;
    --muted: #89a4b6;
    --line: #1c4159;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
    --tier-perfekte-bg: #103e37;
    --tier-gode-bg: #13315a;
    --tier-heilt-bg: #123c50;
    --tier-daarlege-bg: #40340f;
    --tier-ikkje-bg: #26333d;
    --tier-heilt: #6fc0eb;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

h1,
h2 {
  margin: 0;
}

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

/* ---------- Wave header background ---------- */
.wave-bg {
  position: fixed;
  inset: 0 0 auto 0;
  height: 240px;
  z-index: -1;
  background: linear-gradient(160deg, var(--teal-600), var(--cyan-600) 45%, var(--blue-600));
}
.wave-svg {
  position: absolute;
  bottom: -1px;
  width: 100%;
  height: 90px;
}
.wave {
  fill: var(--bg);
}
.wave--back {
  opacity: 0.55;
}
.wave--front {
  fill: var(--bg);
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 8px;
  color: #fff;
}
.topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-logo {
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}
.brand-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tap);
  min-height: var(--tap);
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}
.icon-btn:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}
.icon-btn--ghost {
  background: transparent;
  color: var(--muted);
}
.icon-btn--ghost:hover {
  background: var(--surface-2);
}
.icon-btn--ghost.is-active {
  color: var(--tier-daarlege);
}

/* ---------- Location bar ---------- */
.locationbar {
  padding: 4px 16px 8px;
  position: relative;
}
.search {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 4px 6px 4px 14px;
}
.search__input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 1.05rem;
  min-height: var(--tap);
  outline: none;
}
.search__input::placeholder {
  color: var(--muted);
}

.search-results {
  list-style: none;
  margin: 6px 0 0;
  padding: 6px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow);
  position: absolute;
  left: 16px;
  right: 16px;
  z-index: 20;
  max-height: 55vh;
  overflow-y: auto;
}
.search-results__item {
  padding: 12px 12px;
  border-radius: 10px;
  cursor: pointer;
  min-height: var(--tap);
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.search-results__item:hover,
.search-results__item:focus-visible {
  background: var(--surface-2);
  outline: none;
}
.search-results__name {
  font-weight: 600;
}

/* Favourite chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.chip {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.chip--active {
  border-color: var(--cyan-600);
  box-shadow: 0 0 0 2px rgba(14, 116, 144, 0.25);
}
.chip__label {
  border: none;
  background: transparent;
  color: var(--ink);
  padding: 8px 6px 8px 14px;
  font-size: 0.95rem;
  cursor: pointer;
  min-height: 40px;
}
.chip__remove {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  padding: 8px 12px 8px 6px;
  cursor: pointer;
  min-height: 40px;
}
.chip__remove:hover {
  color: var(--tier-ikkje);
}

/* ---------- Content ---------- */
.content {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 16px 40px;
}
.section-heading {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin: 22px 4px 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* States */
.state {
  text-align: center;
  padding: 40px 16px;
  color: var(--ink-soft);
}
.state--welcome {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-top: 12px;
}
.state--error {
  background: var(--tier-daarlege-bg);
  color: var(--tier-daarlege);
  border-radius: var(--radius);
  border: 1px solid rgba(192, 120, 19, 0.4);
  font-weight: 600;
}
.spinner {
  width: 34px;
  height: 34px;
  border: 4px solid var(--surface-2);
  border-top-color: var(--cyan-600);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Notices / banners / caveats */
.notices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.notice,
.caveat,
.banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.notice {
  background: var(--surface-2);
  color: var(--ink-soft);
}
.caveat {
  background: var(--tier-heilt-bg);
  color: var(--sea-700);
  margin-top: 10px;
}
.banner--fallback {
  background: var(--tier-daarlege-bg);
  color: var(--tier-daarlege);
  font-weight: 600;
  margin-bottom: 12px;
}
.notice svg,
.caveat svg,
.banner svg {
  flex: none;
  margin-top: 1px;
}

/* ---------- Hero ---------- */
.hero-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px;
  border-top: 6px solid var(--tier-color, var(--cyan-600));
}
.hero-card__tier {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--tier-color, var(--cyan-600));
}
.hero-card__tier-label {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.1;
}
.hero-card__range {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 10px 0 16px;
  color: var(--ink);
}
.hero-card__summary {
  margin: 14px 0 0;
  font-size: 1rem;
  color: var(--ink-soft);
  font-style: italic;
}
.hero-empty {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 20px;
  text-align: center;
  color: var(--tier-ikkje);
}
.hero-empty__text {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 12px 0 0;
}

/* Stats grid */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
  margin: 0;
}
.stat {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.stat__label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 0;
}
.stat__value {
  margin: 4px 0 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

/* ---------- Window list ---------- */
.window-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.window-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  border-left: 6px solid var(--tier-color, var(--cyan-600));
}
.window-card--caution {
  background: var(--tier-daarlege-bg);
}
.window-card__header {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: none;
  background: transparent;
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  min-height: var(--tap);
  color: var(--ink);
}
.window-card__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--tier-color, var(--cyan-600));
  font-weight: 700;
  font-size: 0.85rem;
  flex: none;
  min-width: 92px;
}
.window-card__main {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.window-card__range {
  font-weight: 600;
}
.window-card__quick {
  font-size: 0.85rem;
}
.window-card__chev {
  transition: transform 0.2s ease;
  color: var(--muted);
}
.window-card.is-open .window-card__chev {
  transform: rotate(180deg);
}
.window-card__body {
  padding: 0 16px 16px;
}
.caution-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--tier-daarlege);
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

/* Hour table */
.hour-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-top: 8px;
}
.hour-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.hour-table td {
  padding: 6px 6px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.hour-row__time {
  font-weight: 600;
}
.hour-table .tier-icon {
  vertical-align: middle;
}

/* ---------- Tier colour hooks ---------- */
.tier-perfekte {
  --tier-color: var(--tier-perfekte);
}
.tier-gode {
  --tier-color: var(--tier-gode);
}
.tier-heilt_greie {
  --tier-color: var(--tier-heilt);
}
.tier-daarlege {
  --tier-color: var(--tier-daarlege);
}
.tier-ikkje {
  --tier-color: var(--tier-ikkje);
}
.hour-row.tier-daarlege td {
  color: var(--tier-daarlege);
}
.hour-row .tier-icon {
  color: var(--tier-color);
}

/* ---------- Settings dialog ---------- */
.settings {
  border: none;
  border-radius: 18px 18px 0 0;
  padding: 0;
  width: 100%;
  max-width: 560px;
  margin: auto auto 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  max-height: 90dvh;
}
.settings::backdrop {
  background: rgba(7, 24, 39, 0.55);
  backdrop-filter: blur(2px);
}
.settings__form {
  display: flex;
  flex-direction: column;
  max-height: 90dvh;
}
.settings__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--surface);
}
.settings__header h2 {
  font-size: 1.2rem;
}
.settings__header .icon-btn {
  background: var(--surface-2);
  color: var(--ink-soft);
}
.settings__fields {
  overflow-y: auto;
  padding: 12px 18px;
}
.settings__group {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin: 0 0 14px;
  padding: 8px 14px 12px;
}
.settings__group legend {
  font-weight: 700;
  color: var(--ink-soft);
  padding: 0 6px;
  font-size: 0.9rem;
}
.settings__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  min-height: var(--tap);
}
.settings__row label {
  font-size: 0.95rem;
}
.settings__inputwrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.settings__row input[type="number"] {
  width: 84px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font-size: 1rem;
  text-align: right;
  min-height: 40px;
}
.settings__unit {
  color: var(--muted);
  font-size: 0.85rem;
  min-width: 42px;
}
.settings__row--switch input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--cyan-600);
}
.settings__footer {
  display: flex;
  gap: 10px;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
  background: var(--surface);
}
.btn {
  flex: 1;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  min-height: var(--tap);
}
.btn--primary {
  background: var(--cyan-600);
  color: #fff;
}
.btn--primary:hover {
  background: var(--sea-700);
}
.btn--ghost {
  background: var(--surface-2);
  color: var(--ink-soft);
}
.btn:focus-visible {
  outline: 3px solid var(--blue-500);
  outline-offset: 2px;
}

@media (min-width: 560px) {
  .settings {
    border-radius: 18px;
    margin: auto;
  }
}
