/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg:           #09131f;
  --bg2:          #0d1c2e;
  --card-bg:      rgba(255,255,255,0.055);
  --card-border:  rgba(255,255,255,0.10);
  --text:         #e4eaf4;
  --text-muted:   #6a8aad;
  --accent-warm:  #ffa420;
  --accent-cyan:  #3ee5ff;
  --accent-red:   #ff5060;
  --accent-green: #35d97a;
  --radius:       16px;
  --font:         -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

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

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(30,80,160,0.18) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(10,40,90,0.25) 0%, transparent 60%);
}

/* ── App shell ──────────────────────────────────────────────────────────── */
.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 0 60px;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.header {
  padding: 18px 20px 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(to bottom, var(--bg) 70%, transparent);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.location {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
}

.location .icon {
  width: 16px;
  height: 16px;
  color: var(--accent-warm);
  flex-shrink: 0;
}

.updated {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* ── Card base ──────────────────────────────────────────────────────────── */
.card {
  margin: 0 16px 16px;
  background: var(--card-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ── Conditions card ────────────────────────────────────────────────────── */
.conditions-card { padding: 20px; }

/* Row 1: current temp + today high/low */
.cond-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.cond-main {
  display: flex;
  align-items: flex-end;
  gap: 14px;
}

.current-temp {
  font-size: 4.5rem;
  font-weight: 200;
  line-height: 1;
  letter-spacing: -0.04em;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.current-detail {
  padding-bottom: 6px;
}

.current-condition {
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 500;
}

.current-feels {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.high-low {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.hl-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.hl-arrow {
  width: 14px;
  height: 14px;
  fill: currentColor;
  flex-shrink: 0;
}

.hl-arrow.up  { color: var(--accent-warm); }
.hl-arrow.down { color: var(--accent-cyan); }

.hl-temp {
  font-size: 1.25rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  min-width: 44px;
  text-align: right;
}

.hl-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  min-width: 48px;
}

/* Row 2: stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--card-border);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}

.stat {
  background: rgba(255,255,255,0.03);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.stat-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* Row 3: astronomy */
.astro-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 4px;
  border-top: 1px solid var(--card-border);
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 16px;
}

.astro-sep {
  width: 1px;
  height: 32px;
  background: var(--card-border);
  flex-shrink: 0;
}

.astro-item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.astro-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.astro-icon.sunrise { color: var(--accent-warm); }
.astro-icon.sunset  { color: #ff8c50; }

.moon-emoji { font-size: 1.35rem; line-height: 1; }

.astro-label {
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.astro-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 1px;
}

/* Row 4: tides */
.tides-section { padding-top: 4px; }

.tides-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.tide-icon {
  width: 16px;
  height: 16px;
  color: var(--accent-cyan);
}

.tides-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.tide-event {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  padding: 8px 10px;
}

.tide-event-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.tide-info { flex: 1; min-width: 0; }

.tide-type {
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.tide-time {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.tide-height {
  font-size: 0.78rem;
  color: var(--accent-cyan);
  font-variant-numeric: tabular-nums;
}

.tide-loading {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

#tide-mini-chart {
  width: 100%;
  height: 56px;
  display: block;
  border-radius: 8px;
}

/* ── Chart section ──────────────────────────────────────────────────────── */
.chart-section {
  margin: 0 0 0;
  position: relative;
}

.chart-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  cursor: grab;
  -webkit-overflow-scrolling: touch;
  /* hide scrollbar on most browsers */
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.chart-scroll:active { cursor: grabbing; }

.chart-scroll::-webkit-scrollbar {
  height: 3px;
}

.chart-scroll::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.18);
  border-radius: 3px;
}

.chart-scroll::-webkit-scrollbar-track {
  background: transparent;
}

#weather-chart {
  display: block;
}

.chart-legend {
  display: flex;
  gap: 16px;
  padding: 8px 20px;
  justify-content: center;
}

.legend-item {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-item::before {
  content: '';
  display: inline-block;
  width: 24px;
  height: 3px;
  border-radius: 2px;
}

.legend-item.temp::before    { background: var(--accent-warm); }
.legend-item.feels::before   { background: var(--accent-cyan); border-top: 2px dashed var(--accent-cyan); height: 0; }
.legend-item.precip::before  { background: var(--accent-green); }
.legend-item.pressure::before{ background: rgba(255,255,255,0.4); }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .current-temp { font-size: 3.5rem; }
  .stats-grid   { grid-template-columns: repeat(2, 1fr); }

  .astro-row {
    flex-wrap: wrap;
    gap: 12px;
  }
  .astro-sep { display: none; }
  .astro-item { flex: 0 0 calc(50% - 6px); }

  .tides-list { grid-template-columns: 1fr; }
  .card       { margin: 0 10px 12px; }
}

@media (max-width: 380px) {
  .cond-top { flex-direction: column; }
  .high-low { flex-direction: row; align-self: stretch; justify-content: space-around; }
}
