/* ─── Variables ─── */
:root {
    --bg:         #080d1a;
    --card:       #0e1628;
    --border:     rgba(255,255,255,0.07);
    --accent:     #00d4aa;
    --accent-dim: rgba(0, 212, 170, 0.2);
    --text:       #e8eaf0;
    --muted:      rgba(232, 234, 240, 0.45);
    --high:       #ff6b6b;
    --low:        #74b9ff;
    --water-top:  #00b896;
    --water-bot:  #003f60;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.5;
    min-height: 100vh;
}

/* ─── Header ─── */
header {
    background: linear-gradient(160deg, #06101f 0%, #0a1830 100%);
    padding: 48px 24px 0;
    position: relative;
}

.header-content {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding-bottom: 40px;
}

.subtitle {
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

h1 {
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #fff;
}

.header-meta {
    font-size: 0.78rem;
    color: var(--muted);
    padding-bottom: 6px;
}

.wave-divider {
    position: relative;
    height: 70px;
    margin: 0 -24px;
    overflow: hidden;
}

.wave-divider svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* ─── Main ─── */
main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px 48px;
}

/* ─── API message ─── */
.api-message {
    padding: 14px 20px;
    border-radius: 10px;
    margin-bottom: 24px;
    font-size: 0.9rem;
}

.api-message.hidden { display: none; }

.api-message.error {
    background: rgba(255, 107, 107, 0.12);
    border: 1px solid rgba(255, 107, 107, 0.3);
    color: #ff8f8f;
}

.api-message.info {
    background: rgba(0, 212, 170, 0.08);
    border: 1px solid var(--accent-dim);
    color: var(--accent);
}

/* ─── Grid ─── */
.grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 820px) {
    .grid { grid-template-columns: 1fr; }
}

/* ─── Cards ─── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px;
}

.card h2 {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 24px;
}

/* ─── Gauge ─── */
.gauge-wrap {
    display: flex;
    gap: 14px;
    align-items: stretch;
    margin-bottom: 28px;
}

.gauge {
    flex: 1;
    position: relative;
    height: 260px;
    border-radius: 14px;
    border: 1px solid var(--accent-dim);
    overflow: hidden;
    background: rgba(0, 20, 40, 0.6);
}

.water-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%; /* set dynamically by JS */
    background: linear-gradient(to bottom, var(--water-top), var(--water-bot));
    transition: height 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.wave-surface {
    position: absolute;
    top: -22px;
    left: 0;
    width: 200%;
    height: 42px;
    animation: wave-slide 3.5s linear infinite;
}

.wave-svg {
    width: 100%;
    height: 100%;
}

@keyframes wave-slide {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

.gauge-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.gauge-value {
    display: flex;
    align-items: baseline;
    gap: 3px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

.gauge-value span:first-child {
    font-size: 2.6rem;
    font-weight: 700;
    color: #fff;
}

.gauge-unit {
    font-size: 1.1rem;
    color: var(--accent);
    font-weight: 600;
}

.tide-direction {
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 4px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.tide-direction.rising  { color: #00d4aa; }
.tide-direction.falling { color: #74b9ff; }

/* ─── Scale ─── */
.scale {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0 0 2px;
    font-size: 0.72rem;
    color: var(--muted);
    height: 260px;
}

/* ─── Next Tide Cards ─── */
.next-tides {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.next-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
}

.high-dot { background: var(--high); }
.low-dot  { background: var(--low); }

.next-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 4px;
}

.next-time {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.next-height {
    font-size: 0.82rem;
    color: var(--muted);
}

/* ─── Chart ─── */
.chart-card {
    display: flex;
    flex-direction: column;
}

.chart-container {
    position: relative;
    height: 320px;
    flex: 1;
}

.legend {
    display: flex;
    gap: 20px;
    margin-top: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--muted);
}

.legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
}

/* ─── Footer ─── */
footer {
    text-align: center;
    padding: 24px;
    font-size: 0.78rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 24px;
    justify-content: center;
}

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

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