/* Self-hosted Titillium Web (was Google Fonts) - latin + latin-ext subsets,
   woff2 only (every browser this site supports understands woff2). */
@font-face {
  font-family: "Titillium Web";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/titillium-web-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Titillium Web";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/titillium-web-400-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Titillium Web";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/titillium-web-600-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Titillium Web";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/titillium-web-600-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --navy: #12252d;
  --navy-deep: #0c1a20;
  --orange: #ff6614;
  --green: #08d100;
  --red: #ff1744;
  --muted: #989b9f;
  --bg-light: #f5f6f8;
}

body,
html {
  font-family: "Titillium Web", Arial, sans-serif;
  background: #fff;
  color: #25282b;
  margin: 0;
  padding: 0;
  height: 100%;
  /* iOS Safari auto-inflates the font size of short text nodes sitting in
     narrow flex/grid columns (e.g. the live-indicator label) unless this is
     set - without it "live"/"Using MVB" would randomly balloon in size and
     wrap, throwing off the header layout. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ============ Shell layout ============ */

.app-shell {
  display: flex;
  flex-direction: row;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
}

/* ============ Sidebar ============ */

.sidebar {
  width: 560px;
  min-width: 340px;
  flex: 0 0 auto;
  height: 100vh;
  position: relative;
  background-color: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0 32px;
  overflow: hidden;
}

.sidebar-bg {
  position: absolute;
  inset: 0;
  /* Vertical anchor 49.7% must match #wind-rose-svg's "top" pin, so the
     ring stays aligned to its calibrated map point at any aspect ratio.
     "bottom" only worked when .sidebar's height was the binding dimension. */
  background: url("../img/coastline.svg") center 49.7%/cover no-repeat;
  opacity: 0.35;
  z-index: 0;
}

.sidebar-header {
  position: relative;
  z-index: 2;
  width: 100%;
  /* Grid (not flex space-between) so .site-title sits in a true centre
     column - space-between only centres it visually when the two side
     items happen to be equal width, which temp-badge and live-indicator
     aren't. */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 20px;
}

.sidebar-header .temp-badge {
  justify-self: start;
}

.sidebar-header .site-title {
  justify-self: center;
}

.sidebar-header .live-indicator {
  justify-self: end;
}

.temp-badge {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--orange);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.weather-icon {
  display: flex;
  align-items: center;
}

.weather-icon svg {
  width: 25px;
  height: 25px;
  display: block;
}

.temp-badge .unit {
  font-size: 0.85rem;
  font-weight: 400;
  margin-left: 2px;
  opacity: 0.8;
}

.site-title {
  display: flex;
  align-items: center;
  gap: 8px;
  /* Also an h1 now (for SEO/document outline) - reset the heading defaults
     so it keeps rendering exactly as the div it used to be. */
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #fff;
}

.site-logo {
  width: 22px;
  height: 22px;
  fill: #fff;
  flex-shrink: 0;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(8, 209, 0, 0.6);
  animation: live-pulse 2s infinite;
}

.live-indicator.stale .live-dot {
  background: var(--red);
  animation: none;
  box-shadow: none;
}

.live-indicator.stale .live-label {
  color: var(--red);
}

.live-indicator.backup .live-dot {
  background: var(--orange);
  animation: none;
  box-shadow: none;
}

.live-indicator.backup .live-label {
  color: var(--orange);
}

@keyframes live-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(8, 209, 0, 0.55);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(8, 209, 0, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(8, 209, 0, 0);
  }
}

.wind-rose-wrap {
  /* NOT position:relative - #wind-rose-svg's "top" must resolve against
     .sidebar (which sizes the background image) so the two scale together,
     not against this flex slot's variable height. */
  z-index: 1;
  flex: 1 1 auto;
  width: 100%;
}

#wind-rose-svg {
  position: absolute;
  /* Pin the ring's CENTRE to 49.7% of .sidebar's height (the same fraction
     the background art is anchored at), independent of window size. Since
     "top" places the top edge, not the centre, calc() subtracts the ring's
     half-height: top = 49.7% - half. "half" mirrors this element's own size
     (min(95%,440px) square, /2), which min(47.5vw,220px) tracks across both
     the desktop (fixed 560px sidebar) and narrow (~100vw) layouts. Without
     this the compass sat slightly high on phones. */
  top: calc(49.7% - min(47.5vw, 220px));
  left: 50%;
  transform: translateX(-50%);
  /* 95% (not 100%) leaves margin for the arrow needle, which overshoots the
     ring radius slightly and would otherwise clip against the sidebar edge. */
  width: 95%;
  max-width: 440px;
  height: auto;
  display: block;
}

.wind-rose-accent {
  stroke: #d6dbdf;
  fill: #d6dbdf;
}

#wind-arrow .wind-rose-accent {
  stroke: #3c9a4a;
  fill: #3c9a4a;
}

#wind-direction {
  fill: #c3c8cc;
  stroke: none;
}

/* Wind speed / Beaufort gauge */

#wind-speed-bar-fill {
  transition: width 0.6s ease, fill 0.6s ease;
}

#wind-gust-marker {
  transition: width 0.6s ease;
}

#wind-speed-bar {
  position: relative;
  z-index: 1;
  width: min(100%, 460px);
  /* Explicit aspect-ratio matching the viewBox (520x90) - Chrome didn't
     derive the SVG's height from the viewBox like Safari/Firefox, which
     shifted the bar up into the compass. */
  aspect-ratio: 520 / 90;
  padding: 0 20px;
}

.beaufort-boxes rect {
  fill: rgba(255, 255, 255, 0.07);
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 1;
}

.beaufort-labels {
  fill: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  font-family: "Titillium Web", Arial, sans-serif;
  font-weight: 600;
}

.beaufort-unit {
  fill: rgba(255, 255, 255, 0.4);
  font-size: 10px;
}

.ws-ticks {
  stroke: #b9c6d6;
  opacity: 0.72;
}

.ws-labels {
  fill: #e7ecf5;
  font-size: 14px;
  font-family: "Titillium Web", Arial, sans-serif;
  font-weight: 600;
  opacity: 0.9;
}

.ws-unit {
  opacity: 0.7;
}

/* ============ Main content ============ */

.main-content {
  flex: 1 1 0;
  height: 100vh;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg-light);
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.main-content > .block {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
}

.block {
  background: #fff;
  border: 1px solid rgba(37, 40, 43, 0.08);
  box-shadow: 0 10px 30px rgba(18, 38, 63, 0.08);
  border-radius: 4px;
  padding: 16px 18px;
  color: #1f252f;
}

.block h2 {
  margin: 0 0 12px 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #0f172a;
}

/* Webcam */

.webcam-frame {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 4px;
}

.webcam-frame iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Graphs */

.graphs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.graphs-header h2 {
  margin: 0;
}

.range-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-light);
  border-radius: 4px;
  padding: 4px;
}

.range-tab {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 3px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}

.range-tab:hover {
  background: rgba(37, 40, 43, 0.06);
}

.range-tab.active {
  background: var(--navy);
  color: #fff;
}

#graphs {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.graph-card {
  border: 1px solid rgba(37, 40, 43, 0.08);
  border-radius: 4px;
  padding: 8px 8px 2px;
  background: #fbfcfe;
}

.graph-title {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.01em;
  color: #334155;
  margin-bottom: 4px;
}

.chart {
  width: 100%;
  min-height: 260px;
}

/* Data grid */

.data-grid {
  display: grid;
  width: 100%;
  max-width: 1080px;
  /* 240px (not 280px) so 3 boxes fit per row - at 280px the 3rd box
     overflowed and auto-fit stranded it on its own row. */
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin: 0 auto;
}

.data-block p {
  margin: 6px 0;
  font-size: 0.95rem;
  color: #334155;
}

.sun-block {
  display: flex;
  flex-direction: column;
}

.sun-rows {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 48px;
}

.sun-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 1.3rem;
  margin: 0;
}

.sun-icon {
  display: flex;
  align-items: center;
  color: var(--orange);
}

.sun-icon svg {
  width: 52px;
  height: 52px;
  display: block;
}

.tide-graphic {
  width: 100%;
  margin: 4px 0 2px;
}

.tide-graphic svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Forecast links */

.forecast-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.forecast-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(37, 40, 43, 0.08);
  border-radius: 4px;
  background: #fbfcfe;
  color: #1f252f;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.forecast-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(18, 38, 63, 0.12);
  border-color: var(--orange);
}

.forecast-card:hover .forecast-arrow {
  color: var(--orange);
  transform: translate(1px, -1px);
}

.forecast-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid rgba(37, 40, 43, 0.08);
}

.forecast-icon img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.forecast-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.forecast-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: #0f172a;
}

.forecast-desc {
  font-size: 0.78rem;
  color: var(--muted);
}

.forecast-arrow {
  margin-left: auto;
  flex-shrink: 0;
  color: rgba(37, 40, 43, 0.35);
  transition: color 0.15s ease, transform 0.15s ease;
}

/* Sponsors */

.sponsors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.sponsor-banner {
  display: block;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(37, 40, 43, 0.08);
  line-height: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.sponsor-banner:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(18, 38, 63, 0.12);
}

.sponsor-banner img {
  width: 100%;
  height: auto;
  display: block;
}

/* Footer */

.site-footer {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 4px 18px 16px;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--muted);
  text-align: center;
}

.site-footer p {
  margin: 0 0 10px;
}

.site-footer p:last-child {
  margin-bottom: 0;
}

/* Responsive */

@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    width: 100%;
    /* Explicit height (not auto) so #wind-rose-svg's percentage "top" has
       something to resolve against. 50vh keeps it proportional near the
       900px breakpoint; the 660px floor covers short (landscape) viewports. */
    height: 50vh;
    min-height: 660px;
    padding-bottom: 24px;
  }

  .main-content {
    height: auto;
    overflow-y: visible;
    padding: 8px;
    gap: 10px;
  }

  /* Trim block/card padding on mobile so the chart plot gets more width. */
  .block {
    padding: 12px 10px;
  }

  #graphs {
    grid-template-columns: 1fr;
  }

  .graph-card {
    padding: 6px 4px 2px;
  }

  /* Sea (first box) spans the full row; Weather and Sun share the row below. */
  .data-grid {
    grid-template-columns: 1fr 1fr;
  }

  .data-grid > .data-block:first-child {
    grid-column: 1 / -1;
  }

  /* Cap the tide graphic - the full-row Sea box would otherwise stretch it
     much wider than on desktop. */
  .tide-graphic {
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
  }

  /* Stack Sunrise/Sunset so they fill the box height instead of floating. */
  .sun-rows {
    flex-direction: column;
    gap: 15px;
  }

  /* On narrow screens shrink the icon/padding and drop the description so
     each forecast card reads as one compact line. */
  .forecast-links {
    gap: 8px;
  }

  .forecast-card {
    gap: 10px;
    padding: 8px 10px;
  }

  .forecast-icon {
    width: 28px;
    height: 28px;
  }

  .forecast-icon img {
    width: 18px;
    height: 18px;
  }

  .forecast-desc {
    display: none;
  }
}
