@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Monda:wght@400;500;600;700&display=swap');

/* ==================== DESIGN TOKENS ==================== */
:root {
    /* Colors — severity */
    --burnt-orange: #f3b139;
    --red: #e3584f;
    --baby-blue: #afc3d5;

    /* Colors — UI */
    --grey: #9297a0;
    --white: #ffffff;
    --bg: #081428;
    --card-bg: rgba(9, 19, 39, 0.15);
    --card-border: rgba(255, 255, 255, 0.06);

    /* Colors — pill accents */
    --tide-green: #c0dcd4;
    --temp-blue: #4C5E70;

    /* Radii */
    --card-radius: 16px;
    --pill-radius: 16px;
    --bar-radius: 4px;

    /* Typography — families */
    --font-heading: 'Monda', -apple-system, sans-serif;
    --font-body: 'Inter', -apple-system, sans-serif;

    /* Typography — sizes */
    --text-h1: 36px;
    --text-h4: 20px;
    --text-sm-label: 12px;
    --text-pill-value: 50px;
    --text-pill-unit: 10px;
    --text-condition: 24px;

    /* Typography — label tracking */
    --tracking-label: 1.2px;

    /* Spacing */
    --card-padding: 16px;
    --card-gap: 16px;
    --section-padding: 24px 16px 60px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    background: var(--bg);
    font-family: var(--font-body);
    color: var(--white);
    -webkit-font-smoothing: antialiased;
}

/* Fixed ocean canvas */
canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    display: block;
    touch-action: none;
    z-index: 0;
}

/* Sky gradient overlay */
#sky {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 35%;
    background: linear-gradient(
        to bottom,
        rgba(8, 20, 40, 1.0) 0%,
        rgba(12, 35, 60, 0.95) 25%,
        rgba(20, 55, 85, 0.6) 55%,
        rgba(30, 75, 110, 0.2) 80%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 1;
}

/* Scrollable wrapper */
#scroll-wrap {
    position: relative;
    z-index: 2;
    overflow-x: hidden;
}

/* ==================== HERO SECTION ==================== */
#hero-top {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    align-items: center;
    padding: 16px 20px;
    padding-bottom: 60px;
    background: linear-gradient(
        to bottom,
        rgba(8, 20, 40, 1) 0%,
        rgba(8, 20, 40, 0.95) 50%,
        rgba(8, 20, 40, 0.6) 70%,
        rgba(8, 20, 40, 0.25) 85%,
        transparent 100%
    );
    pointer-events: none;
    transition: padding-bottom 0.4s ease, gap 0.4s ease;
    gap: 0;
}

#hero-top * {
    pointer-events: auto;
}

#logo {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    align-items: center;
}

#logo svg {
    transition: width 0.4s ease, height 0.4s ease;
}

#location-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    width: 100%;
}

#location-map {
    background: none;
    border: none;
    color: white;
    opacity: 0.4;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: opacity 0.2s;
    text-decoration: none;
}

#location-map:hover {
    opacity: 0.8;
}

#hero-location {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 12px;
    min-width: 0;
    transition: all 0.4s ease;
}

#hero-location h1 {
    font-family: var(--font-heading);
    font-size: clamp(28px, 9vw, var(--text-h1));
    font-weight: 700;
    letter-spacing: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
    transition: font-size 0.4s ease;
}

#location-coords {
    font-family: var(--font-body);
    font-size: var(--text-sm-label);
    font-weight: 600;
    color: var(--grey);
    text-transform: uppercase;
    letter-spacing: var(--tracking-label);
    transition: opacity 0.3s ease, max-height 0.3s ease;
    max-height: 24px;
    overflow: hidden;
}

/* Collapsed header state — single row: [logo] [location] */
#hero-top.collapsed {
    grid-template-rows: auto;
    gap: 12px;
    padding-bottom: 16px;
}

#hero-top.collapsed #logo svg {
    width: 54px;
    height: 24px;
}

#hero-top.collapsed #hero-location {
    grid-column: 2;
    grid-row: 1;
    margin-top: 0;
    min-width: 0;
}

#hero-top.collapsed #hero-location h1 {
    font-size: clamp(18px, 4.5vw, 26px);
    font-weight: 700;
}

#hero-top.collapsed #location-coords {
    opacity: 0;
    max-height: 0;
}

#hero {
    height: 72vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 16px 20px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* Hero bottom HUD */
#hero-bottom {
    pointer-events: none;
    margin-bottom: 0;
}

#weather-condition {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-body);
    font-size: var(--text-condition);
    font-weight: 500;
    color: var(--grey);
    margin-bottom: 4px;
}

#condition-icon {
    line-height: 0;
    flex-shrink: 0;
}

#condition-icon svg {
    width: 20px;
    height: 20px;
}

.hero-sea-state {
    font-family: var(--font-heading);
    font-size: var(--text-h1);
    font-weight: 700;
    margin-bottom: 20px;
    letter-spacing: 0;
}

#hud-stats {
    display: flex;
    gap: 0;
    margin-bottom: 14px;
}

.hud-stat {
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin-right: 16px;
}

.hud-stat:last-child {
    margin-right: 0;
}

.hud-accent {
    width: 3px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.7);
    flex-shrink: 0;
}

.hud-stat-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hud-label {
    font-family: var(--font-body);
    font-size: var(--text-sm-label);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--tracking-label);
    color: var(--grey);
}

.hud-value {
    font-family: var(--font-heading);
    font-size: var(--text-h4);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
    white-space: nowrap;
}


/* ==================== CARDS SECTION ==================== */
#cards-bg {
    background: linear-gradient(
        to bottom,
        rgba(10, 25, 45, 0) 0%,
        rgba(10, 25, 45, 0.35) 80px,
        rgba(8, 20, 40, 0.45) 200px
    );
    padding-top: 0;
    margin-top: -20px;
}

#cards-section {
    position: relative;
    padding: 24px 16px 60px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 600px;
    margin: 0 auto;
}

/* Data card */
.data-card {
    display: flex;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    padding: var(--card-padding);
    overflow: hidden;

    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.data-card.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Wind dial */
.wind-dial {
    flex-shrink: 0;
    width: 124px;
    height: 124px;
}

.wind-dial-svg {
    width: 100%;
    height: 100%;
}

#wind-dial-arrow {
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: 62px 62px;
}

/* Colored pill with large number */
.card-pill {
    flex-shrink: 0;
    width: 140px;
    height: 105px;
    border-radius: var(--pill-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 16px;
}

.pill-value {
    font-family: var(--font-heading);
    font-size: var(--text-pill-value);
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0;
    color: var(--white);
}

.pill-unit {
    font-family: var(--font-heading);
    font-size: var(--text-pill-unit);
    font-weight: 500;
    color: var(--white);
    opacity: 0.85;
}

/* Pill colors set dynamically via JS severity system */
.pill-wind,
.pill-swell,
.pill-period {
    background: var(--baby-blue);
}

.pill-temp {
    background: var(--temp-blue);
}

/* Card layout: carousel fills card, tide card keeps row-reverse */
.data-card {
    flex-direction: column;
}

#card-tide {
    flex-direction: column;
    gap: 0;
}

.card-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.card-info-label {
    font-family: var(--font-body);
    font-size: var(--text-sm-label);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--tracking-label);
    color: var(--grey);
}

.card-info-detail {
    font-family: var(--font-heading);
    font-size: var(--text-h4);
    font-weight: 700;
    color: var(--white);
    letter-spacing: 0;
}

/* Bar chart */
.card-bars {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 8px;
}

.bar-labels {
    display: flex;
    justify-content: space-between;
}

.bar-label {
    font-size: 8px;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.bar-row {
    display: flex;
    align-items: flex-end;
    gap: 5px;
    height: 40px;
}

.card-bar {
    width: 14px;
    border-radius: 4px;
    min-height: 6px;
    transition: height 0.4s ease;
}

/* Chart row — bars + trend side by side */
.card-chart-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    margin-top: 8px;
}

.card-chart-row .card-bars {
    margin-top: 0;
    flex: 1;
}

/* Card trend indicator */
.card-trend {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex-shrink: 0;
    justify-content: flex-end;
    padding-bottom: 1px;
}

.card-trend svg {
    width: 18px;
    height: 18px;
    opacity: 0.5;
    flex-shrink: 0;
    margin-bottom: 1px;
}

.trend-delta {
    font-family: var(--font-heading);
    font-size: var(--text-pill-unit);
    font-weight: 500;
    color: var(--white);
    line-height: 1;
}

/* ==================== CARD CAROUSEL ==================== */
.card-carousel {
    display: flex;
    width: 200%;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-carousel.showing-forecast {
    transform: translateX(-50%);
}

.card-slide {
    width: 50%;
    flex-shrink: 0;
    min-width: 0;
}

.card-current {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-direction: row-reverse;
}

/* ==================== FORECAST VIEW ==================== */
.card-forecast {
    display: flex;
    flex-direction: column;
    padding: 2px 0 0 16px;
}

.forecast-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.forecast-header-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.forecast-label {
    font-family: var(--font-body);
    font-size: var(--text-sm-label);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--tracking-label);
    color: var(--grey);
}

.forecast-direction {
    font-family: var(--font-heading);
    font-size: var(--text-h4);
    font-weight: 700;
    color: var(--white);
}

.forecast-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.forecast-time {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    color: var(--grey);
    font-variant-numeric: tabular-nums;
}

.forecast-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    border-radius: 8px;
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 600;
    color: var(--white);
    white-space: nowrap;
}

.forecast-bars-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
}

.forecast-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 60px;
    overflow: visible;
    cursor: default;
    touch-action: none;
}

.forecast-bar {
    flex: 1;
    min-width: 0;
    border-radius: 2px;
    min-height: 4px;
    transition: height 0.3s ease;
    position: relative;
}

/* Dashed vertical line through the selected bar */
.forecast-bar.is-selected::before {
    content: '';
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: calc(100% + 28px);
    background: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.5) 0px,
        rgba(255, 255, 255, 0.5) 3px,
        transparent 3px,
        transparent 6px
    );
    pointer-events: none;
}

/* Dots above and below the selected bar */
.forecast-bar.is-selected::after {
    content: '';
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--white);
    pointer-events: none;
    box-shadow: 0 calc(100% + 30px) 0 0 var(--white);
}

.forecast-time-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
}

.forecast-time-label {
    font-family: var(--font-body);
    font-size: 10px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.3px;
}

.forecast-time-label:first-child {
    color: rgba(255, 255, 255, 0.6);
}

/* Swipe hint dot indicators */
.card-dots {
    display: flex;
    justify-content: center;
    gap: 5px;
    padding-top: 8px;
}

.card-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: background 0.2s;
}

.card-dot.active {
    background: rgba(255, 255, 255, 0.6);
}

/* Bar colors set dynamically via JS severity system */

/* ==================== TIDE CURVE CARD ==================== */
.tide-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 0 0 4px 0;
}

.tide-header-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tide-state {
    font-family: var(--font-heading);
    font-size: var(--text-h4);
    font-weight: 700;
    color: var(--white);
}

.tide-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tide-pill {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 8px;
    background: #505d6f;
}

.tide-pill-val {
    font-family: var(--font-heading);
    font-size: var(--text-h4);
    font-weight: 700;
    color: var(--white);
    line-height: 1;
}

.tide-pill-unit {
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 500;
    color: var(--white);
    opacity: 0.85;
}

.tide-curve {
    position: relative;
    width: 100%;
    height: 90px;
    cursor: default;
    touch-action: none;
    overflow: visible;
}

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

/* ==================== LOADING ==================== */
#loading {
    position: fixed;
    inset: 0;
    background: #000a14;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.8s ease;
}

#loading.hidden {
    opacity: 0;
    pointer-events: none;
}

#loading-text {
    color: rgba(255, 255, 255, 0.5);
    font-size: 16px;
    letter-spacing: 1px;
}

/* ==================== ADMIN PANEL ==================== */
#admin-panel {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    height: 100%;
    z-index: 30;
    background: rgba(0, 10, 20, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    overflow-y: auto;
    transition: right 0.3s ease;
    -webkit-overflow-scrolling: touch;
}

#admin-panel.open {
    right: 0;
}

#admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 600;
    font-size: 15px;
}

#admin-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.6;
}

#admin-close:hover {
    opacity: 1;
}

#admin-body {
    padding: 12px 16px;
}

.admin-section {
    margin-bottom: 20px;
}

.admin-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
    margin-bottom: 10px;
}

.admin-section label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 4px;
    opacity: 0.8;
}

.admin-section label span {
    font-variant-numeric: tabular-nums;
    opacity: 0.6;
}

.admin-section input[type="range"] {
    width: 100%;
    margin-bottom: 12px;
    accent-color: #4a9eff;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    outline: none;
}

.admin-section input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4a9eff;
    cursor: pointer;
}

#admin-presets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.preset-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    padding: 8px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}

.preset-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.admin-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-actions button {
    flex: 1;
    background: rgba(74, 158, 255, 0.2);
    border: 1px solid rgba(74, 158, 255, 0.3);
    color: #4a9eff;
    padding: 10px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}

.admin-actions button:hover {
    background: rgba(74, 158, 255, 0.3);
}

/* ==================== FOOTER ==================== */
#site-footer {
    display: flex;
    justify-content: center;
    padding: 20px 16px 40px;
    background: rgba(8, 20, 40, 0.45);
}

#admin-toggle {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    opacity: 0.4;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    font-size: 18px;
    transition: opacity 0.2s;
}

#admin-toggle:hover {
    opacity: 0.7;
}

/* ==================== RESPONSIVE ==================== */
@media (min-width: 768px) {
    :root {
        --card-radius: 20px;
        --pill-radius: 20px;
        --card-padding: 22px;
        --card-gap: 24px;
        --text-pill-value: 64px;
        --text-pill-unit: 14px;
        --text-sm-label: 14px;
        --text-h4: 28px;
    }

    #cards-section {
        max-width: 600px;
        padding: 32px 24px 80px;
        gap: 18px;
    }

    .card-pill {
        width: 226px;
        height: 165px;
        gap: 18px;
    }

    .wind-dial {
        width: 160px;
        height: 160px;
    }

    .card-current {
        gap: var(--card-gap);
    }

    .card-bar {
        width: 17px;
    }

    .bar-row {
        height: 60px;
        gap: 7px;
    }

    .forecast-bars {
        height: 80px;
    }

    .card-bars {
        gap: 4px;
    }

    .tide-curve {
        height: 100px;
    }

    .tide-dot {
        width: 18px;
        height: 18px;
    }
}
