:root {
  --brand: #2a78d6;
  --brand-dark: #184f95;
  --aqua: #1baf7a;
  --ocean-900: #0a3d54;
  --ocean-700: #0f5c7a;

  --surface: #fcfcfb;
  --page-bg: #f6f5f0;
  --ink: #0b0b0b;
  --ink-secondary: #52514e;
  --ink-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);

  --area-fill: #cde2fb;
  --radius: 12px;
  --max-width: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #3987e5;
    --brand-dark: #86b6ef;
    --aqua: #199e70;
    --surface: #1a1a19;
    --page-bg: #0d0d0d;
    --ink: #ffffff;
    --ink-secondary: #c3c2b7;
    --ink-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --area-fill: #184f95;
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page-bg);
  color: var(--ink);
  line-height: 1.5;
}

a {
  color: var(--brand-dark);
}

h1, h2, h3 {
  line-height: 1.2;
  margin: 0 0 0.5em;
}

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* Header */

.site-header {
  background: var(--ocean-900);
  color: white;
}

.site-header__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.site-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.site-logo__wave {
  color: #05bfdb;
}

.header-search {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 420px;
}

.header-search input,
.hero-search input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
}

.hero-search input {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 14px 18px;
}

.header-search input:focus,
.hero-search input:focus {
  outline: 2px solid var(--brand);
}

.header-search__results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  max-height: 320px;
  overflow-y: auto;
  z-index: 20;
  padding: 6px;
}

.header-search__results a {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
}

.header-search__results a:hover,
.header-search__results a.is-active {
  background: var(--page-bg);
}

.header-search__results .region {
  color: var(--ink-muted);
  font-size: 0.85rem;
}

/* Hero (homepage) */

.hero {
  text-align: center;
  padding: 48px 0 32px;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  color: var(--ocean-900);
}

@media (prefers-color-scheme: dark) {
  .hero h1 {
    color: white;
  }
}

.hero__tagline {
  color: var(--ink-secondary);
  max-width: 640px;
  margin: 0 auto 24px;
}

.hero-search {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
}

/* Port directory */

.port-directory {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  margin-top: 16px;
}

@media (min-width: 720px) {
  .port-directory {
    grid-template-columns: repeat(2, 1fr);
  }
}

.region-group h2 {
  font-size: 1.1rem;
  color: var(--brand-dark);
  border-bottom: 2px solid var(--gridline);
  padding-bottom: 6px;
}

.port-list {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 1;
}

.port-list li {
  padding: 4px 0;
}

.port-tag {
  font-size: 0.7rem;
  color: var(--ink-muted);
  border: 1px solid var(--gridline);
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 6px;
}

/* Breadcrumb */

.breadcrumb {
  font-size: 0.85rem;
  color: var(--ink-muted);
  padding: 16px 0 8px;
}

.breadcrumb a {
  color: var(--ink-muted);
}

/* Port hero */

.port-hero {
  padding: 8px 0 24px;
}

.port-hero h1 {
  color: var(--ocean-900);
}

@media (prefers-color-scheme: dark) {
  .port-hero h1 {
    color: white;
  }
}

.port-hero__subtitle {
  color: var(--ink-secondary);
  margin: 0;
}

.port-note {
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--ink-secondary);
}

/* Tide curve */

.tide-curve {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 32px;
}

.tide-curve__toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.date-nav-btn {
  border: 1px solid var(--border);
  background: var(--page-bg);
  color: var(--ink);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  cursor: pointer;
}

.date-nav-btn:hover {
  background: var(--gridline);
}

#date-picker {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
}

.tide-curve__svg {
  width: 100%;
  height: auto;
}

.tide-curve__area {
  fill: var(--area-fill);
  opacity: 0.6;
}

.tide-curve__line {
  fill: none;
  stroke: var(--brand);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.tide-curve__dot {
  stroke: var(--surface);
  stroke-width: 2;
}

.tide-curve__dot--high {
  fill: var(--brand);
}

.tide-curve__dot--low {
  fill: var(--aqua);
}

.tide-curve__label {
  font-size: 11px;
  fill: var(--ink-secondary);
}

.tide-curve__now {
  stroke: var(--ink-muted);
  stroke-width: 1;
  stroke-dasharray: 4 3;
}

/* Day cards / tide table */

.day-card {
  margin-bottom: 12px;
}

.day-card__title {
  font-size: 1rem;
  text-transform: capitalize;
}

.tide-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.tide-table th {
  text-align: left;
  color: var(--ink-muted);
  font-weight: 500;
  font-size: 0.8rem;
  padding: 4px 8px;
  border-bottom: 1px solid var(--gridline);
}

.tide-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--gridline);
  font-variant-numeric: tabular-nums;
}

.tide-table__row--high td:first-child {
  color: var(--brand-dark);
  font-weight: 600;
}

.tide-table__row--low td:first-child {
  color: var(--aqua);
  font-weight: 600;
}

/* Forecast grid */

.forecast h2 {
  font-size: 1.2rem;
}

.forecast__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 640px) {
  .forecast__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 980px) {
  .forecast__grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.forecast__grid .day-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}

/* Footer */

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 24px 0;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.site-footer__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

.site-footer__disclaimer {
  max-width: 640px;
}

.site-footer a {
  color: var(--ink-muted);
}
