/* -------------------------------------------------- */
/*  One Ocean Swim — page styles                      */
/*  Palette harmonised with breatheconservation.org   */
/* -------------------------------------------------- */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

:root {
  /* Breathe brand palette */
  --breathe-teal: #2d8da6;
  --breathe-coral: #ef7d54;
  --breathe-navy: #1a4859;
  --breathe-mist: #BDC8D5;

  --bg: #0f2a36;
  --bg-panel: #133c4d;
  --fg: #ffffff;
  --fg-dim: #9fb3be;
  --accent: var(--breathe-teal);
  --accent-bright: #49b5d0;
  --coral: var(--breathe-coral);
  --coral-soft: #ffa484;
  --swim-line: var(--breathe-coral);
  --panel-bg: rgba(19, 60, 77, 0.92);
  --panel-border: rgba(45, 141, 166, 0.22);
  --stat-rule: rgba(255, 255, 255, 0.1);
  --sans: "Montserrat", -apple-system, BlinkMacSystemFont, "SF Pro Text",
          "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* -------- Header -------- */

#site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  border-bottom: 1px solid var(--panel-border);
  gap: 32px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  transition: opacity 160ms;
}
.logo-link:hover { opacity: 0.85; }

.logo {
  height: 38px;
  width: auto;
  display: block;
}

.title h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg);
  line-height: 1.1;
}

.title .subtitle {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--fg-dim);
  letter-spacing: 0.02em;
}

.title .subtitle .progress {
  opacity: 0.6;
  font-style: italic;
  font-size: 11px;
  white-space: nowrap;
}

.title .subtitle .arrow {
  color: var(--coral);
  margin: 0 4px;
  font-weight: 600;
}

.stats {
  display: flex;
  gap: 28px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-variant-numeric: tabular-nums;
}

.stat .v {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--coral);
  line-height: 1;
}

.stat .l {
  font-size: 10px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 3px;
}

/* -------- Control bar -------- */

#controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--panel-border);
  font-size: 13px;
}

.ctrl-btn {
  background: rgba(45, 141, 166, 0.12);
  color: var(--fg);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  padding: 6px 12px;
  font: inherit;
  cursor: pointer;
  transition: background 140ms, border-color 140ms;
  min-width: 40px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
}
.ctrl-btn:hover:not([disabled]) {
  background: rgba(45, 141, 166, 0.28);
  border-color: var(--accent);
}
.ctrl-btn:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 1px;
}
.ctrl-btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}
.ctrl-btn-glyph {
  font-size: 12px;
}
.ctrl-btn-kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--fg-dim);
  line-height: 1;
}

/* -------- Order toggle (chrono / coast) -------- */
.order-toggle {
  display: inline-flex;
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.18);
  overflow: hidden;
}
.order-opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font: inherit;
  font-size: 12px;
  color: var(--fg-dim);
  background: transparent;
  border: 0;
  border-left: 1px solid var(--panel-border);
  cursor: pointer;
  transition: background 140ms, color 140ms;
}
.order-opt:first-child { border-left: 0; }
.order-opt:hover { background: rgba(45, 141, 166, 0.16); color: var(--fg); }
.order-opt:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: -2px;
}
.order-opt.is-active {
  background: rgba(45, 141, 166, 0.32);
  color: var(--fg);
  box-shadow: inset 0 -2px 0 var(--coral);
}
.order-opt .order-icon { font-size: 13px; }
.order-opt .order-label { letter-spacing: 0.02em; }

#ctrl-label {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 14px;
  min-width: 340px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  color: var(--fg);
}
#ctrl-label .primary {
  font-weight: 600;
  color: var(--coral);
}
#ctrl-label .sep {
  color: var(--fg-dim);
  opacity: 0.55;
}
#ctrl-label .secondary {
  color: var(--fg);
}
#ctrl-label .tertiary {
  color: var(--fg-dim);
  font-size: 12px;
}
#ctrl-label.is-overview .primary { color: var(--fg); }
#ctrl-label.is-rest .primary { color: var(--fg-dim); font-style: italic; font-weight: 500; }

#ctrl-spacer { flex: 1; }

#ctrl-meta {
  color: var(--fg-dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* -------- Main layout -------- */

main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 360px;
  min-height: 0;
}

#map {
  height: 100%;
  min-height: 0;
  background: #05101a;
}

/* Leaflet popup restyling */
.leaflet-popup-content-wrapper {
  background: var(--panel-bg);
  color: var(--fg);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  backdrop-filter: blur(8px);
}
.leaflet-popup-tip { background: var(--panel-bg); }
.leaflet-popup-content { margin: 10px 14px; font-size: 13px; }
.leaflet-container { font: inherit; }

/* -------- Detail panel -------- */

#detail-panel {
  overflow-y: auto;
  border-left: 1px solid var(--panel-border);
  position: relative;
  padding: 18px 20px 28px;
  font-size: 13px;
  line-height: 1.5;
  background: var(--bg);
}

#detail-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: transparent;
  color: var(--fg-dim);
  border: 0;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
}
#detail-close:hover { color: var(--fg); }

#detail-content h2 {
  font-size: 16px;
  margin: 0 0 2px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

#detail-content .meta-line {
  font-size: 12px;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
  margin-bottom: 14px;
}

#detail-content h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--coral-soft);
  margin: 18px 0 6px;
  font-weight: 600;
}

#detail-content .grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}

#detail-content .grid .k {
  font-size: 11px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#detail-content .grid .v { font-variant-numeric: tabular-nums; }

#detail-content .sightings {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

#detail-content .sightings .chip {
  padding: 2px 8px;
  border: 1px solid var(--panel-border);
  border-radius: 100px;
  font-size: 11px;
  background: rgba(45, 141, 166, 0.12);
  color: var(--fg);
}
#detail-content .sightings .chip small {
  color: var(--coral);
  margin-left: 4px;
  font-weight: 600;
}

#detail-content .rubbish-line { margin: 4px 0 0; color: var(--fg); }
#detail-content .rubbish-line .count {
  color: var(--coral);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-right: 6px;
}

/* -------- Rest-day & interstitial detail states (the "delight" layer) ---- */

.rest-day-card {
  padding: 48px 10px;
  text-align: center;
  color: var(--fg-dim);
}
.rest-day-card .icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
  filter: grayscale(0.2);
}
.rest-day-card .date {
  font-size: 13px;
  color: var(--fg);
  margin-bottom: 4px;
  font-weight: 500;
}
.rest-day-card .label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  color: var(--coral-soft);
}
.rest-day-card .hint {
  margin-top: 18px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--fg-dim);
  font-style: italic;
  max-width: 240px;
  margin-left: auto;
  margin-right: auto;
}

.gap-card {
  margin: 16px 0;
  padding: 14px 16px;
  border: 1px dashed var(--panel-border);
  border-radius: 4px;
  background: rgba(45, 141, 166, 0.05);
  text-align: center;
}
.gap-card .title {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--coral);
  font-weight: 600;
  margin-bottom: 6px;
}
.gap-card .body {
  font-size: 12px;
  color: var(--fg-dim);
  line-height: 1.5;
}

/* Select option visual treatment for rest days and gap separators */
.rest-label { opacity: 0.65; }

/* -------- Responsive -------- */

@media (max-width: 1100px) {
  main { grid-template-columns: 1fr 320px; }
  #ctrl-label { min-width: 280px; font-size: 12px; }
}

@media (max-width: 900px) {
  #site-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .brand { gap: 12px; }
  .logo { height: 32px; }
  .stats { gap: 20px; }
  .stat { align-items: flex-start; }
  #controls { flex-wrap: wrap; gap: 8px; }
  #ctrl-label { min-width: 200px; flex: 1; font-size: 12px; }
  main { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  #detail-panel { border-left: 0; border-top: 1px solid var(--panel-border); max-height: 45vh; }
}
