/* ============================================================
   SANARA — nautical-instrument UI
   Surfaces: pre-dawn water inks. Accents: chart blue (tide),
   buoy magenta (bite), celestial amber (sun/moon).
   ============================================================ */

:root {
  --ink-0: #081720;   /* page / deepest */
  --ink-1: #0B1D2A;   /* surface */
  --ink-2: #102939;   /* raised card */
  --ink-3: #163449;   /* strokes, wells */

  --foam:    #E9F2F7;
  --foam-70: rgba(233, 242, 247, .72);
  --foam-50: rgba(233, 242, 247, .52);
  --foam-30: rgba(233, 242, 247, .30);
  --hairline: rgba(233, 242, 247, .10);

  --tide:   #3E8FBE;  /* validated chart mark */
  --tide-2: #2A6E96;
  --bite:   #DE3D90;  /* validated chart mark */
  --celest: #BC8228;  /* validated chart mark */

  --good: #47AE81;
  --warn: #C9873D;
  --slow: #7E93A1;

  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 9px;

  --font-display: "Big Shoulders", "Arial Narrow", sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --sheet-peek: 212px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-body);
  background: var(--ink-0);
  color: var(--foam);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  position: fixed;
  inset: 0;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--tide);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Map ---------- */

#map {
  position: absolute;
  inset: 0;
  background: var(--ink-0);
}

.leaflet-container { font-family: var(--font-body); }
.leaflet-control-attribution {
  background: rgba(8, 23, 32, .72) !important;
  color: var(--foam-50) !important;
  font-size: 10px;
}
.leaflet-control-attribution a { color: var(--foam-70) !important; }
.leaflet-control-zoom { display: none; }

/* Hook pin */
.pin-hook { filter: drop-shadow(0 2px 6px rgba(0,0,0,.55)); }
.pin-hook.is-active .pin-ring { animation: pinPulse 2.2s ease-out infinite; }
@keyframes pinPulse {
  0%   { transform: scale(.6); opacity: .9; }
  100% { transform: scale(1.9); opacity: 0; }
}

/* ---------- Top bar ---------- */

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 14px 26px;
  background: linear-gradient(to bottom, rgba(8,23,32,.88) 0%, rgba(8,23,32,.55) 55%, transparent 100%);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 9px; }
.brand-hook { width: 26px; height: 26px; color: var(--bite); }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 21px;
  letter-spacing: .14em;
}
.brand-tag {
  font-size: 10.5px;
  letter-spacing: .04em;
  color: var(--foam-50);
  margin-top: 3px;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: rgba(16, 41, 57, .82);
  border: 1px solid var(--hairline);
  backdrop-filter: blur(8px);
  transition: background .15s;
}
.icon-btn:hover { background: var(--ink-3); }
.icon-btn svg { width: 20px; height: 20px; }

.chip-btn {
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--bite);
  color: #fff;
  font-weight: 600;
  font-size: 13.5px;
  border: none;
}

/* ---------- Map hint ---------- */

.map-hint {
  position: absolute;
  left: 50%;
  bottom: 46px;
  transform: translateX(-50%);
  z-index: 650;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(8, 23, 32, .85);
  border: 1px solid var(--hairline);
  backdrop-filter: blur(8px);
  font-size: 14px;
  color: var(--foam-70);
  white-space: nowrap;
}
.hint-pulse {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--bite);
  animation: hintPulse 1.6s ease-in-out infinite;
}
@keyframes hintPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(222, 61, 144, .55); }
  50%      { box-shadow: 0 0 0 8px rgba(222, 61, 144, 0); }
}

/* ---------- Bottom sheet ---------- */

.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 800;
  height: 92dvh;
  background: linear-gradient(to bottom, rgba(11,29,42,.97), var(--ink-1) 120px);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  border-top: 1px solid rgba(233,242,247,.14);
  box-shadow: 0 -18px 50px rgba(0, 0, 0, .5);
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.3, .9, .3, 1);
  display: flex;
  flex-direction: column;
  touch-action: none;
}
.sheet[data-state="peek"] { transform: translateY(calc(100% - var(--sheet-peek))); }
.sheet[data-state="half"] { transform: translateY(42%); }
.sheet[data-state="full"] { transform: translateY(0); }
.sheet.dragging { transition: none; }

.sheet-handle {
  flex: 0 0 auto;
  width: 100%;
  padding: 10px 0 6px;
  display: grid;
  place-items: center;
}
.handle-bar {
  width: 44px; height: 4.5px;
  border-radius: 3px;
  background: var(--foam-30);
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 16px calc(28px + env(safe-area-inset-bottom));
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}
.sheet[data-state="peek"] .sheet-body { overflow-y: hidden; }

/* ---------- Forecast header ---------- */

.fc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.fc-title { min-width: 0; }
.fc-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: .03em;
  line-height: 1.05;
  border: none;
  background: transparent;
  color: var(--foam);
  width: 100%;
  padding: 0;
}
.fc-name:focus { outline: none; border-bottom: 1px dashed var(--foam-30); }
.fc-coords {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--foam-50);
  margin-top: 4px;
  letter-spacing: .02em;
}

.fc-dial { flex: 0 0 auto; position: relative; width: 78px; height: 78px; }
.fc-dial svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.fc-dial .dial-track { stroke: var(--ink-3); }
.fc-dial .dial-val { transition: stroke-dashoffset .6s ease; }
.fc-dial-num {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 27px;
  line-height: 1;
}
.fc-dial-num small {
  display: block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 8.5px;
  letter-spacing: .12em;
  color: var(--foam-50);
  text-align: center;
  margin-top: 1px;
}

/* Verdict banner */
.verdict {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 10px 0 14px;
  padding: 13px 15px;
  border-radius: var(--r-md);
  background: var(--ink-2);
  border: 1px solid var(--hairline);
}
.verdict.is-go {
  background: linear-gradient(100deg, rgba(222,61,144,.16), rgba(222,61,144,.05));
  border-color: rgba(222, 61, 144, .45);
}
.verdict-icon { width: 34px; height: 34px; flex: 0 0 auto; }
.verdict-main { min-width: 0; }
.verdict-line {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: .04em;
  line-height: 1.1;
}
.verdict.is-go .verdict-line { color: #F183BC; }
.verdict-sub { font-size: 12.5px; color: var(--foam-70); margin-top: 3px; }

/* ---------- Cards & sections ---------- */

.card {
  background: var(--ink-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 14px 15px 15px;
  margin-bottom: 12px;
}

.card-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--foam-50);
  margin-bottom: 10px;
}
.card-label .sub {
  font-weight: 400;
  letter-spacing: .02em;
  text-transform: none;
  font-size: 11.5px;
  color: var(--foam-50);
}

.tide-stats {
  display: flex;
  gap: 18px;
  margin-top: 10px;
}
.tide-stat { line-height: 1.15; }
.tide-stat .v {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: .03em;
}
.tide-stat .k { font-size: 10.5px; color: var(--foam-50); letter-spacing: .05em; text-transform: uppercase; }

/* charts */
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.chart-tip {
  position: fixed;
  z-index: 1200;
  pointer-events: none;
  background: rgba(8, 23, 32, .95);
  border: 1px solid var(--ink-3);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.45;
  max-width: 220px;
  box-shadow: 0 4px 18px rgba(0,0,0,.45);
}
.chart-tip .t { font-family: var(--font-mono); font-size: 10.5px; color: var(--foam-50); }
.chart-tip b { font-weight: 600; }

/* windows chips */
.window-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.window-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(222, 61, 144, .13);
  border: 1px solid rgba(222, 61, 144, .4);
  font-size: 12.5px;
  font-weight: 500;
}
.window-chip .sc {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  color: #F183BC;
}

/* breakdown rows */
.brk-row {
  display: grid;
  grid-template-columns: 92px 1fr 34px;
  align-items: center;
  gap: 10px;
  padding: 4.5px 0;
  font-size: 12.5px;
}
.brk-row .k { color: var(--foam-70); }
.brk-bar {
  height: 7px;
  border-radius: 4px;
  background: var(--ink-3);
  overflow: hidden;
}
.brk-bar i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--tide);
}
.brk-row .v { font-family: var(--font-mono); font-size: 11px; text-align: right; color: var(--foam-70); }

/* terrain */
.terrain-grid-wrap { display: flex; gap: 14px; align-items: flex-start; }
.terrain-facts { flex: 1; min-width: 0; }
.terrain-fact { display: flex; gap: 8px; align-items: baseline; padding: 3.5px 0; font-size: 13px; }
.terrain-fact .v { font-family: var(--font-mono); font-size: 12.5px; white-space: nowrap; }
.terrain-fact .k { color: var(--foam-50); font-size: 11.5px; }
.terrain-note { margin-top: 9px; font-size: 12.5px; line-height: 1.5; color: var(--foam-70); }

/* day list */
.day-row {
  display: grid;
  grid-template-columns: 74px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 13px;
}
.day-row:last-child { border-bottom: none; }
.day-row .d { color: var(--foam-70); font-weight: 500; }
.day-row .w { font-family: var(--font-mono); font-size: 12px; }
.day-row .none { color: var(--foam-30); }
.day-score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  min-width: 30px;
  text-align: right;
}

/* conditions strip */
.cond-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.cond-cell {
  background: var(--ink-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: 9px 10px;
  line-height: 1.2;
}
.cond-cell .v { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: .02em; }
.cond-cell .u { font-size: 10px; color: var(--foam-50); }
.cond-cell .k { font-size: 10px; color: var(--foam-50); text-transform: uppercase; letter-spacing: .08em; margin-top: 3px; }

/* actions */
.fc-actions { display: flex; gap: 9px; margin: 4px 0 10px; }
.btn {
  flex: 1;
  height: 46px;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 14.5px;
  display: grid;
  place-items: center;
  border: 1px solid var(--hairline);
  background: var(--ink-2);
  transition: filter .15s;
}
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: var(--bite); border-color: transparent; color: #fff; }
.btn.danger { color: #E58989; }

/* skeleton / loading */
.skeleton { animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
.load-note {
  display: flex; align-items: center; gap: 10px;
  color: var(--foam-70); font-size: 13px; padding: 6px 2px 14px;
}
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--ink-3);
  border-top-color: var(--tide);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.err-box {
  background: rgba(194, 84, 84, .1);
  border: 1px solid rgba(194, 84, 84, .35);
  border-radius: var(--r-md);
  padding: 13px 15px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 12px;
}

/* ---------- Spots panel ---------- */

.spots-panel {
  position: absolute;
  top: calc(64px + env(safe-area-inset-top));
  right: 12px;
  z-index: 750;
  width: min(330px, calc(100vw - 24px));
  max-height: 60dvh;
  overflow-y: auto;
  background: rgba(11, 29, 42, .97);
  border: 1px solid var(--ink-3);
  border-radius: var(--r-md);
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  backdrop-filter: blur(10px);
}
.spots-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 8px 8px 16px;
  position: sticky; top: 0;
  background: inherit;
}
.spots-head h2 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.spots-list { list-style: none; }
.spot-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 11px 16px;
  border-top: 1px solid var(--hairline);
  text-align: left;
}
.spot-row:hover { background: var(--ink-2); }
.spot-row .nm { flex: 1; min-width: 0; font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spot-row .co { font-family: var(--font-mono); font-size: 10px; color: var(--foam-50); }
.spot-del { color: var(--foam-50); padding: 6px; border-radius: 8px; }
.spot-del:hover { color: #E58989; background: rgba(194,84,84,.12); }
.spots-empty { padding: 8px 16px 18px; font-size: 13px; color: var(--foam-50); line-height: 1.5; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%; bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 1300;
  background: var(--ink-2);
  border: 1px solid var(--ink-3);
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 13.5px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
  white-space: nowrap;
}

/* ---------- Desktop ---------- */

@media (min-width: 920px) {
  .sheet {
    left: auto;
    top: 0;
    width: 440px;
    height: 100%;
    border-radius: 0;
    border-top: none;
    border-left: 1px solid var(--ink-3);
    transform: translateX(100%);
  }
  .sheet[data-state="peek"],
  .sheet[data-state="half"],
  .sheet[data-state="full"] { transform: translateX(0); }
  .sheet[data-state="peek"] .sheet-body { overflow-y: auto; }
  .sheet-handle { display: none; }
  .sheet-body { padding-top: 14px; }
  .spots-panel { right: 456px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
