/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent-blue: #38bdf8;
  --accent-green: #4ade80;
  --accent-orange: #fb923c;
  --accent-purple: #818cf8;
  --radius: 12px;

  /* Harmonize Pico with the existing palette */
  --pico-background-color: var(--bg);
  --pico-color: var(--text);
  --pico-muted-color: var(--text-muted);
  --pico-h1-color: var(--text);
  --pico-h2-color: var(--text);
  --pico-h3-color: var(--text);
  --pico-primary: var(--accent-blue);
  --pico-primary-hover: var(--accent-blue);
  --pico-primary-focus: rgba(56, 189, 248, 0.25);
  --pico-card-background-color: var(--surface);
  --pico-card-border-color: var(--border);
  --pico-border-color: var(--border);
  --pico-border-radius: var(--radius);
  --pico-form-element-background-color: var(--surface);
  --pico-form-element-border-color: var(--border);
  --pico-form-element-color: var(--text);
  --pico-form-element-focus-color: var(--accent-blue);
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
header {
  text-align: center;
  padding: 2rem 1rem 1rem;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-size: 0.9rem;
}

/* ===== Main ===== */
main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

/* ===== Cards ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
}

.card--tide::before  { background: var(--accent-blue); }
.card--temp::before  { background: var(--accent-orange); }
.card--weather::before { background: var(--accent-green); }
.card--wind::before  { background: var(--text-muted); }
.card--uv::before    { background: linear-gradient(180deg, #facc15, #fb923c, #f87171); }

.card__icon { font-size: 2rem; flex-shrink: 0; }

.card__body { display: flex; flex-direction: column; }

.card__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.card__value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
}

.card--tide .card__value    { color: var(--accent-blue); }
.card--temp .card__value    { color: var(--accent-orange); }
.card--weather .card__value { color: var(--accent-green); }
.card--wind .card__value    { color: var(--text); }

.card__unit {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.card__updated {
  position: absolute;
  bottom: 0.5rem; right: 0.75rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ===== Wind Compass ===== */
.wind-compass { margin-left: auto; flex-shrink: 0; }

.wind-compass__ring {
  width: 56px; height: 56px;
  border: 2px solid var(--border);
  border-radius: 50%;
  position: relative;
}

.wind-compass__label {
  position: absolute;
  font-size: 0.55rem;
  color: var(--text-muted);
  font-weight: 600;
}

.wind-compass__arrow {
  position: absolute;
  top: 50%; left: 50%;
  width: 2px; height: 20px;
  background: var(--accent-blue);
  transform-origin: top center;
  transform: translate(-50%, 0) rotate(0deg);
  border-radius: 1px;
}

.wind-compass__arrow::after {
  content: "";
  position: absolute;
  top: -4px; left: -3px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 6px solid var(--accent-blue);
}

/* ===== Tide Schedule ===== */
.tide-schedule {
  margin-bottom: 2rem;
}

.tide-schedule h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.tide-schedule__list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
}

.tide-event {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
}

.tide-event--past { opacity: 0.5; }

.tide-event__icon {
  font-weight: 700;
  font-size: 0.9rem;
}

.tide-event--high .tide-event__icon { color: var(--accent-orange); }
.tide-event--low  .tide-event__icon { color: var(--accent-purple); }

.tide-event__type {
  font-weight: 600;
  min-width: 32px;
}

.tide-event__time {
  color: var(--text-muted);
  flex: 1;
}

.tide-event__height {
  font-weight: 600;
  color: var(--accent-blue);
}

/* ===== Charts ===== */
.charts {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.chart-container h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
}

canvas {
  width: 100% !important;
  height: 260px !important;
}

/* ===== Forecast ===== */
.forecast {
  margin-bottom: 2rem;
}

.forecast h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.forecast__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.5rem;
}

.forecast__day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.5rem;
  text-align: center;
}

.forecast__day-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.forecast__day-icon  { font-size: 1.5rem; margin-bottom: 0.25rem; }
.forecast__day-temps { font-size: 0.85rem; }
.forecast__day-hi    { font-weight: 700; color: var(--accent-orange); }
.forecast__day-lo    { color: var(--text-muted); }
.forecast__day-wind  { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.25rem; }
.forecast__day-desc  { font-size: 0.65rem; color: var(--text-muted); margin-top: 0.15rem; }

/* ===== Marine Forecast ===== */
.marine-forecast {
  margin-bottom: 2rem;
}

.marine-forecast h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.marine-forecast__text {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 500px;
  overflow-y: auto;
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

footer a {
  color: var(--accent-blue);
  text-decoration: none;
}

footer a:hover { text-decoration: underline; }

/* ===== Responsive ===== */
@media (max-width: 480px) {
  header h1 { font-size: 1.35rem; }
  .card__value { font-size: 1.75rem; }
  canvas { height: 200px !important; }
}
