/* Theme tokens ported from wavelog-web-app (daisyUI "wavelog" / "wavelog-light"). */
:root {
  --base-100: oklch(20% 0.006 286);
  --base-200: oklch(14% 0.005 286);
  --base-300: oklch(0.2393 0 0);
  --base-content: oklch(96% 0.002 286);
  --primary: oklch(96% 0.002 286);
  --primary-content: oklch(14% 0.005 286);
  --neutral: oklch(24% 0.006 286);
  --error: oklch(63% 0.237 25.331);
  --error-content: oklch(97% 0.013 17.38);
  --accent: oklch(62% 0.214 259.815);
  --muted-50: color-mix(in oklch, var(--base-content) 50%, transparent);
  --muted-60: color-mix(in oklch, var(--base-content) 60%, transparent);
  --muted-70: color-mix(in oklch, var(--base-content) 70%, transparent);
  --radius-field: 0.375rem;
  --radius-box: 0.5rem;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --base-100: oklch(100% 0 0);
    --base-200: oklch(97% 0.002 286);
    --base-300: oklch(93% 0.004 286);
    --base-content: oklch(20% 0.006 286);
    --primary: oklch(30% 0.006 286);
    --primary-content: oklch(98% 0.002 286);
    --neutral: oklch(88% 0.004 286);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--base-300);
  color: var(--base-content);
  font: 16px/1.5 ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--base-300);
  border-bottom: 1px solid var(--neutral);
}

.brand-title {
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.brand-sub {
  font-size: 0.75rem;
  line-height: 1.25;
  color: var(--muted-50);
}

.back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: var(--radius-field);
  background: var(--base-100);
  color: var(--base-content);
  text-decoration: none;
  font-size: 1.25rem;
  line-height: 1;
}

main {
  max-width: 48rem;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.section-title {
  margin: 0 0 8px;
  font-size: 0.875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  color: var(--muted-70);
}

.card {
  background: var(--base-100);
  border-radius: var(--radius-box);
  padding: 16px;
}

/* Tool list */
.tool-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.tool-list a {
  display: block;
  background: var(--base-100);
  border-radius: var(--radius-box);
  padding: 12px 16px;
  color: var(--base-content);
  text-decoration: none;
}

.tool-list a strong { display: block; font-size: 0.875rem; font-weight: 600; }
.tool-list a span {
  font-size: 0.75rem;
  color: var(--muted-50);
}

/* Inputs */
.field {
  display: grid;
  grid-template-columns: 1fr 7rem;
  align-items: center;
  column-gap: 12px;
}

.field + .field { margin-top: 8px; }

.field label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-70);
}

.field :is(input[type="number"], input[type="text"], select) {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  font: inherit;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  background: var(--base-200);
  color: var(--base-content);
  border: 1px solid var(--base-300);
  border-radius: var(--radius-field);
  transition: border-color 0.15s;
}

.field :is(input[type="text"], select) { text-align: left; }

.field :is(input[type="number"], input[type="text"], select):focus {
  outline: none;
  border-color: color-mix(in oklch, var(--base-content) 30%, transparent);
}

.field input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  height: 40px;
  margin: 0;
  accent-color: var(--primary);
  touch-action: pan-y;
}

.field input[type="range"]::-webkit-slider-thumb { width: 32px; height: 32px; }
.field input[type="range"]::-moz-range-thumb { width: 32px; height: 32px; }

/* Results (StatCard style) */
.results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

.result {
  min-width: 0;
  background: var(--base-100);
  border-radius: var(--radius-box);
  padding: 12px;
}

.result .label {
  font-size: 0.75rem;
  color: var(--muted-50);
}

.result .value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.result .secondary {
  margin-top: 2px;
  white-space: pre-line;
  font-size: 0.75rem;
  color: var(--muted-60);
}

.note {
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--muted-50);
}

/* Map pages */
body.map-page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
}

#map {
  flex: 1;
  min-height: 0;
  background: var(--base-200);
}

@media (prefers-color-scheme: dark) {
  .base-tiles { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9); }
}

.leaflet-container { font: inherit; font-size: 0.75rem; }

.leaflet-control-attribution {
  background: color-mix(in oklch, var(--base-100) 80%, transparent) !important;
  color: var(--muted-60);
}

.leaflet-control-attribution a { color: inherit; }

.here { stroke: #fff; fill: var(--accent); }

.waypoint {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-content);
  border: 2px solid var(--base-100);
  font-size: 0.75rem;
  font-weight: 700;
}

.map-panel {
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--base-300);
  border-top: 1px solid var(--neutral);
}

.map-panel .results { margin-top: 0; }

.actions {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 8px;
  margin-top: 8px;
}

.actions button,
.button {
  height: 44px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--base-content);
  background: var(--base-200);
  border: 1px solid var(--base-300);
  border-radius: var(--radius-field);
}

.actions button:active,
.button:active { background: var(--base-100); }

.actions button:disabled { opacity: 0.4; }

.button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  text-decoration: none;
}

#route .results { margin-top: 0; }

.field.wide { grid-template-columns: 1fr 62%; }

.section { margin-top: 24px; }
.card + .results { margin-top: 12px; }

/* Two-way switch (e.g. Mayday / Pan-Pan) */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 12px;
  background: var(--base-200);
  border-radius: var(--radius-box);
}

.segmented button {
  height: 40px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted-60);
  background: transparent;
  border: 0;
  border-radius: var(--radius-field);
}

.segmented button[aria-pressed="true"] {
  background: var(--base-100);
  color: var(--base-content);
}

/* Collapsible settings */
details.card summary {
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 24px;
}

details.card summary::after { content: "›"; transform: rotate(90deg); opacity: 0.6; }
details.card[open] summary::after { transform: rotate(-90deg); }
details.card[open] summary { margin-bottom: 12px; }
details.card summary::-webkit-details-marker { display: none; }

/* Mayday script */
.callout {
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: var(--radius-box);
  background: var(--error);
  color: var(--error-content);
  font-size: 0.875rem;
  font-weight: 600;
}

.script {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.45;
  text-transform: uppercase;
}

.script p { margin: 0 0 10px; }
.script p:last-child { margin-bottom: 0; }
.script .blank { color: var(--error); }

.position {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  white-space: pre-line;
}

.position-meta {
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--muted-50);
}

/* Collapsible groups (convert) */
details.card + details.card { margin-top: 8px; }

/* Channel reference (Solent quick reference) */
.channels { list-style: none; margin: 0; padding: 4px 16px; }

.channels li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  font-size: 0.875rem;
}

.channels li + li { border-top: 1px solid var(--neutral); }

.channels b {
  flex: none;
  font-size: 1.125rem;
  font-variant-numeric: tabular-nums;
}
