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

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

html, body {
    width: 100%;
    background: #081428;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: 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,
#location-next {
    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,
#location-next: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-size: clamp(28px, 9vw, 42px);
    font-weight: 600;
    letter-spacing: -0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
    transition: font-size 0.4s ease;
}

#location-coords {
    font-size: 14px;
    opacity: 0.4;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 400;
    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: 600;
}

#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 {
    font-size: 20px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 4px;
}

.hero-sea-state {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 20px;
    letter-spacing: -1px;
}

#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-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    opacity: 0.5;
    font-weight: 500;
}

.hud-value {
    font-size: 20px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.3px;
    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;
    align-items: center;
    gap: 16px;
    background: rgba(9, 19, 39, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 28px;
    padding: 16px;
    overflow: hidden;

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

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

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

.pill-value {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 48px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: -1px;
    color: white;
}

.pill-unit {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: white;
    opacity: 0.85;
}

/* Pill colors set dynamically via JS severity system */
.pill-wind,
.pill-swell,
.pill-period {
    background: #AFC3D5;
}

/* Card layout: info left, pill right */
.data-card {
    flex-direction: row-reverse;
}

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

.card-info-label {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1.6px;
    color: #9297a0;
    font-weight: 600;
}

.card-info-detail {
    font-family: 'Space Grotesk', -apple-system, sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.3px;
}

/* 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;
}

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

/* ==================== 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) {
    #cards-section {
        max-width: 600px;
        padding: 32px 24px 80px;
        gap: 18px;
    }

    .data-card {
        border-radius: 40px;
        padding: 22px;
        gap: 24px;
    }

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

    .pill-value {
        font-size: 80px;
    }

    .pill-unit {
        font-size: 16px;
    }

    .card-info-label {
        font-size: 16px;
    }

    .card-info-detail {
        font-size: 35px;
    }

    .card-bar {
        width: 17px;
    }

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

    .card-bars {
        gap: 4px;
    }
}
