/* ============ Cottage Dashboard - mobile-app redesign ============ */

:root {
  --stage: linear-gradient(140deg, #cfe7f8 0%, #eaf3fb 60%, #f3f8fc 100%);
  --sheet: #f4f8fc;
  --card: #ffffff;
  --track: #e7eef6;
  --ink: #17324a;
  --ink-soft: #6a829a;
  --line: #e7eef6;
  --accent: #2e8ed6;
  --accent-2: #66b8ea;
  --sun: #f7b23c;
  --good: #27a567; --warn: #e3a31a; --bad: #df5640;
  --shadow: 0 8px 22px rgba(26, 70, 110, .08);
  --shadow-sm: 0 3px 10px rgba(26, 70, 110, .06);
  --hero-foot: rgba(8, 20, 38, .30);
  --font: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
:root[data-theme="dark"] {
  --stage: #080d18; --sheet: #111a29; --card: #1a2536; --track: #26344a;
  --ink: #e9f1fa; --ink-soft: #92a6bd; --line: #26344a;
  --accent: #5cb4ec; --accent-2: #347fc0; --sun: #f5cf6a;
  --good: #38c07d; --warn: #ecba46; --bad: #ef6a55;
  --shadow: 0 8px 22px rgba(0,0,0,.4); --shadow-sm: 0 3px 10px rgba(0,0,0,.35); --hero-foot: var(--sheet);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --stage: #080d18; --sheet: #111a29; --card: #1a2536; --track: #26344a;
    --ink: #e9f1fa; --ink-soft: #92a6bd; --line: #26344a;
    --accent: #5cb4ec; --accent-2: #347fc0; --sun: #f5cf6a;
    --good: #38c07d; --warn: #ecba46; --bad: #ef6a55;
    --shadow: 0 8px 22px rgba(0,0,0,.4); --shadow-sm: 0 3px 10px rgba(0,0,0,.35); --hero-foot: var(--sheet);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0; font-family: var(--font); color: var(--ink);
  background: var(--stage); background-attachment: fixed;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- App shell (phone frame on desktop, full-bleed on mobile) ---------- */
.app {
  position: relative; width: 100%; max-width: 460px; height: 100dvh;
  display: flex; flex-direction: column; overflow: hidden; background: var(--sheet);
}
@media (min-width: 500px) {
  body { padding: 20px; }
  .app { height: min(900px, calc(100dvh - 40px)); border-radius: 34px; box-shadow: 0 36px 90px rgba(10,30,60,.30); }
}

/* ---------- Hero ---------- */
.hero {
  position: relative; flex: 0 0 auto; height: 43dvh; min-height: 286px;
  color: #fff; overflow: hidden; padding: calc(env(safe-area-inset-top) + 16px) 20px 40px;
  display: flex; flex-direction: column;
}
@media (min-width: 500px) { .hero { height: 300px; } }

.hero[data-daylight="day"]   { --hero-grad: linear-gradient(180deg,#4aa6e4 0%,#7cc4ef 52%,#aedcf5 100%);
  --sun:#ffd166; --water-top:#3f93cf; --water-bot:#2a74af; }
.hero[data-daylight="night"] { --hero-grad: linear-gradient(180deg,#141d44 0%,#22325f 55%,#2c426f 100%);
  --sun:#eee6b4; --water-top:#1a2e54; --water-bot:#11203d; }

.hero__scene { position: absolute; inset: 0; z-index: 0; overflow: hidden;
  background: var(--hero-grad);            /* fallback if the illustration fails to load */
  background-size: cover; background-position: center; background-repeat: no-repeat; }
.hero[data-daylight="day"]   .hero__scene { background-image: url('/assets/cottage_day.png'), var(--hero-grad); }
.hero[data-daylight="night"] .hero__scene { background-image: url('/assets/cottage_night.png'), var(--hero-grad); }
/* the sun + water are part of the illustration now */
.hero__scene::before, .hero__scene::after { content: none; }
.hero__veil { position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,.12), transparent 26%, transparent 68%, var(--hero-foot)); }

.hero__top, .hero__now { position: relative; z-index: 2; }
.hero__top { display: flex; align-items: flex-start; justify-content: space-between; }
.hero__loc { display: flex; gap: 8px; align-items: center; }
.pin { width: 22px; height: 22px; fill: #fff; opacity: .92; flex: none; }
.hero__place { font-weight: 700; font-size: 1.06rem; letter-spacing: .2px; }
.hero__sub { font-size: .78rem; opacity: .85; margin-top: 1px; }
.hero__ctrls { display: flex; gap: 8px; }
.ctrl {
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255,255,255,.18); color: #fff; font: 600 .82rem/1 var(--font);
  display: grid; place-items: center; backdrop-filter: blur(6px); transition: transform .15s, background .2s;
}
.ctrl:hover { background: rgba(255,255,255,.28); }
.ctrl:active { transform: scale(.92); }
.ctrl__ico { width: 18px; height: 18px; }

.hero__now { margin-top: auto; display: flex; flex-direction: column; align-items: flex-end;
  text-align: right; text-shadow: 0 2px 12px rgba(8,20,38,.45);
  animation: rise .55s cubic-bezier(.2,.7,.3,1) both; }
.hero__icon { width: 40px; height: 40px; filter: drop-shadow(0 3px 8px rgba(0,0,0,.28)); }
.hero__temp { font-size: 5rem; font-weight: 700; line-height: .9; letter-spacing: -2px; }
.hero__unit { font-size: 1.5rem; font-weight: 600; opacity: .8; vertical-align: top; margin-left: 2px; }
.hero__cond { display: flex; align-items: center; gap: 6px; font-size: 1.05rem; font-weight: 600;
  opacity: .96; margin-top: 4px; }
.hero__meta { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 16px;
  margin-top: 10px; font-size: .82rem; opacity: .92; }
.hero__nh { margin-top: 12px; display: inline-flex; align-items: center; gap: 6px; font-size: .8rem;
  background: rgba(255,255,255,.2); padding: 6px 11px; border-radius: 999px; backdrop-filter: blur(6px); }

/* ---------- Bottom sheet ---------- */
.sheet {
  position: relative; z-index: 3; margin-top: -24px; flex: 1 1 auto; min-height: 0;
  background: var(--sheet); border-radius: 26px 26px 0 0; overflow-y: auto; overscroll-behavior: contain;
  box-shadow: 0 -14px 34px rgba(16,46,80,.16);
  padding: 18px 16px calc(86px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;            /* Firefox */
  -ms-overflow-style: none;         /* old Edge */
}
.sheet::-webkit-scrollbar { width: 0; height: 0; display: none; }  /* WebKit */

/* ---------- Panels & section cards ---------- */
.panel:not([hidden]) { display: block; animation: panelIn .34s ease both; }

.block { background: transparent; margin-top: 18px; }
.block__h { font-size: .76rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-soft); font-weight: 700; margin: 0 4px 10px; }

.card {
  background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 16px;
}
.card + .card { margin-top: 12px; }
.unavail { color: var(--ink-soft); font-size: .9rem; padding: 8px 4px; }

/* ---------- Tiles (NOW) ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { background: var(--card); border-radius: 18px; box-shadow: var(--shadow-sm);
  padding: 14px; display: flex; flex-direction: column; gap: 8px; min-height: 96px; }
.tile--wide { grid-column: 1 / -1; }
.tile__l { font-size: .68rem; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-soft); font-weight: 700; }
.tile__v { font-size: 1.55rem; font-weight: 700; line-height: 1; }
.tile__v small { font-size: .8rem; font-weight: 600; color: var(--ink-soft); }
.bar { height: 6px; border-radius: 4px; background: var(--track); overflow: hidden; margin-top: auto; }
.bar > i { display: block; height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.bar--uv > i { background: linear-gradient(90deg,#5fc46a,#e3a31a 60%,#df5640); }

/* wind tile */
.wind { display: flex; align-items: center; gap: 14px; }
.gauge { width: 60px; height: 60px; flex: none; }
.wind__main { display: flex; flex-direction: column; gap: 3px; }
.wind__spd { font-size: 1.45rem; font-weight: 700; line-height: 1; }
.wind__sub { font-size: .78rem; color: var(--ink-soft); }
.badge { align-self: flex-start; font-size: .74rem; font-weight: 600; padding: 3px 9px;
  border-radius: 999px; background: var(--track); }
.badge--offwater { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.badge--offland  { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }
.badge--alongshore { background: color-mix(in srgb, var(--ink-soft) 16%, transparent); }

/* On the Water */
.water { background: linear-gradient(150deg, color-mix(in srgb, var(--accent) 16%, var(--card)), var(--card)); }
.water__row { display: flex; align-items: center; gap: 18px; }
.water__temp { display: flex; flex-direction: column; }
.water__deg { font-size: 2.7rem; font-weight: 800; line-height: .9; color: var(--accent); }
.water__note { font-size: .8rem; color: var(--ink-soft); margin-top: 4px; }
.water__stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; flex: 1;
  font-size: .88rem; }
.water__stats b { display: block; font-weight: 700; }
.water__stats span { color: var(--ink-soft); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Hourly (FORECAST) ---------- */
.spark { width: 100%; height: 96px; display: block; overflow: visible; }
.hours { display: flex; gap: 2px; overflow-x: auto; margin-top: 6px; padding-bottom: 2px;
  scrollbar-width: none; }
.hours::-webkit-scrollbar { display: none; }
.hour { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 50px; }
.hour__t { font-size: .74rem; color: var(--ink-soft); }
.hour__d { font-size: .92rem; font-weight: 700; }
.hour__p { font-size: .68rem; color: var(--accent); min-height: .8em; }

/* ---------- 7-day (FORECAST) ---------- */
.day { display: grid; grid-template-columns: 2.6rem 30px 2.4rem 1fr; align-items: center;
  gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.day:first-child { border-top: 0; }
.day__n { color: var(--ink-soft); font-weight: 600; font-size: .9rem; }
.day__i { width: 28px; height: 28px; }
.day__p { font-size: .74rem; color: var(--accent); }
.day__range { display: flex; align-items: center; gap: 8px; }
.day__lo { font-size: .85rem; color: var(--ink-soft); width: 2.1rem; text-align: right; }
.day__hi { font-size: .9rem; font-weight: 700; width: 2.1rem; }
.range { position: relative; flex: 1; height: 6px; border-radius: 4px; background: var(--track); }
.range > i { position: absolute; height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, #7cc4ef, var(--sun)); }

/* ---------- Border table (TRIP) ---------- */
.bx { width: 100%; border-collapse: collapse; }
.bx th { color: var(--ink-soft); font-weight: 700; font-size: .72rem; padding: 4px 4px 10px; }
.bx thead th { text-align: center; }
.bx thead th small { display: block; font-weight: 500; opacity: .75; }
.bx tbody th { text-align: left; font-size: .9rem; color: var(--ink); }
.bx td { text-align: center; padding: 10px 4px; border-top: 1px solid var(--line); }
.pill { display: inline-block; min-width: 3.4rem; padding: 4px 8px; border-radius: 10px;
  font-weight: 700; font-size: .85rem; }
.pill small { display: block; font-weight: 500; font-size: .64rem; opacity: .8; }
.pill--good { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.pill--warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pill--bad  { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.pill--na   { color: var(--ink-soft); }
.bx__as { margin-top: 12px; color: var(--ink-soft); font-size: .7rem; text-align: center; }
.addr { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px;
  background: none; border: 0; padding: 2px 0; font: inherit; font-size: .82rem;
  color: var(--ink-soft); cursor: pointer; text-align: left; transition: color .2s; }
.addr svg { width: 14px; height: 14px; opacity: .65; flex: none; }
.addr:active { transform: scale(.99); }
.addr--copied { color: var(--good); }

/* FX */
.fx { display: flex; align-items: baseline; gap: 8px; }
.fx__rate { font-size: 1.7rem; font-weight: 800; }
.fx__sub { color: var(--ink-soft); font-size: .76rem; }

/* Map */
.mapwrap { border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-sm); }
.map { width: 100%; height: 230px; border: 0; display: block; }
.dir { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px;
  background: var(--accent); color: #fff; text-decoration: none; padding: 13px;
  border-radius: 14px; font-weight: 700; box-shadow: var(--shadow); transition: transform .15s; }
.dir:active { transform: scale(.98); }

/* ---------- Credit ---------- */
.credit { text-align: center; color: var(--ink-soft); font-size: .68rem; line-height: 1.5;
  margin: 22px 6px 6px; }
.credit a { color: var(--accent); text-decoration: none; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  height: calc(66px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: color-mix(in srgb, var(--sheet) 84%, transparent);
  backdrop-filter: blur(16px) saturate(1.3); border-top: 1px solid var(--line);
}
.tab { border: 0; background: none; cursor: pointer; color: var(--ink-soft);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font: 600 .68rem/1 var(--font); transition: color .2s; }
.tab svg { width: 23px; height: 23px; transition: transform .2s; }
.tab.is-active { color: var(--accent); }
.tab.is-active svg { transform: translateY(-1px) scale(1.06); }
.tab:active svg { transform: scale(.9); }

/* ---------- Motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes panelIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Desktop: fill the window, two-pane (hero left, content right) ---------- */
@media (min-width: 768px) {
  body { display: block; padding: 0; }

  .app {
    max-width: none; width: 100vw; height: 100dvh;
    display: grid;
    grid-template-columns: minmax(340px, 38%) 1fr;
    grid-template-rows: auto 1fr;
  }

  /* Hero = full-height left panel */
  .hero { grid-column: 1; grid-row: 1 / span 2; height: auto; min-height: 0;
    padding: 28px 32px 36px; }
  .hero__scene { background-position: center 45%; }

  /* Tabs = top nav of the right pane */
  .tabbar {
    grid-column: 2; grid-row: 1; position: static;
    height: 62px; padding: 0 20px; border-top: 0; border-bottom: 1px solid var(--line);
    grid-template-columns: repeat(3, max-content); justify-content: start; gap: 6px;
    align-items: center;
  }
  .tab { flex-direction: row; gap: 8px; height: 40px; padding: 0 16px; border-radius: 11px;
    font-size: .82rem; }
  .tab svg { width: 20px; height: 20px; }
  .tab.is-active { background: color-mix(in srgb, var(--accent) 13%, transparent); }
  .tab.is-active svg { transform: none; }

  /* Content = scrolling right pane */
  .sheet {
    grid-column: 2; grid-row: 2; margin-top: 0; min-height: 0;
    border-radius: 0; box-shadow: none; padding: 8px 28px 36px;
  }

  /* Fill the wider pane: more columns where it helps */
  .tiles { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .water__stats { grid-template-columns: repeat(4, 1fr); }

  .panel[data-panel="forecast"]:not([hidden]),
  .panel[data-panel="trip"]:not([hidden]) {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start;
  }
  /* let grid children shrink so wide content (hourly strip) doesn't blow out the column */
  .panel[data-panel="forecast"]:not([hidden]) > *,
  .panel[data-panel="trip"]:not([hidden]) > * { min-width: 0; }
  .panel[data-panel="trip"]:not([hidden]) > .card:last-child { grid-column: 1 / -1; }
  .credit { grid-column: 1 / -1; }
  .map { height: 320px; }
}

/* Wider desktops: cap the hero so it doesn't get too broad */
@media (min-width: 1280px) {
  .app { grid-template-columns: minmax(380px, 460px) 1fr; }
}
