@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Display:wght@300;400;500;700&family=Orbitron:wght@500;700&display=swap');

/* ── CSS Custom Properties (Theme Tokens) ── */
:root {
    /* Default: Site theme (Solarized Dark) */
    --bg-primary: #002b36;
    --bg-secondary: #073642;
    --text-primary: #9ab2bb;
    --text-muted: #839496;
    --accent: rgb(82, 215, 170);
    --accent-hover: #268bd2;
    --border: #586e75;
    --clock-bg: #073642;
    --clock-border: #586e75;
    --clock-hand-hour: rgb(82, 215, 170);
    --clock-hand-minute: #268bd2;
    --clock-hand-second: #dc322f;
    --clock-number: #9ab2bb;
    --digital-text: rgb(82, 215, 170);
    --btn-bg: rgb(82, 215, 170);
    --btn-text: #002b36;
    --btn-hover-bg: #268bd2;
    --switcher-bg: #073642;
    --switcher-active: rgb(82, 215, 170);
    --space-bg: #000000;
    --sun-color: #FDB813;
    --earth-land: #52d7aa;
    --earth-ocean: #268bd2;
    --moon-color: #9ab2bb;
}

[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #111111;
    --text-primary: #c9d1d9;
    --text-muted: #8b949e;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --border: #30363d;
    --clock-bg: #111111;
    --clock-border: #30363d;
    --clock-hand-hour: #58a6ff;
    --clock-hand-minute: #79c0ff;
    --clock-hand-second: #f85149;
    --clock-number: #c9d1d9;
    --digital-text: #58a6ff;
    --btn-bg: #238636;
    --btn-text: #fff;
    --btn-hover-bg: #2ea043;
    --switcher-bg: #111111;
    --switcher-active: #58a6ff;
    --space-bg: #000000;
    --sun-color: #FDB813;
    --earth-land: #2ea043;
    --earth-ocean: #58a6ff;
    --moon-color: #c9d1d9;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --text-primary: #333333;
    --text-muted: #666666;
    --accent: #268bd2;
    --accent-hover: #2aa198;
    --border: #ccc;
    --clock-bg: #f5f5f5;
    --clock-border: #93a1a1;
    --clock-hand-hour: #268bd2;
    --clock-hand-minute: #2aa198;
    --clock-hand-second: #dc322f;
    --clock-number: #333333;
    --digital-text: #d33682;
    --btn-bg: #268bd2;
    --btn-text: #ffffff;
    --btn-hover-bg: #2aa198;
    --switcher-bg: #f5f5f5;
    --switcher-active: #268bd2;
    --space-bg: #000814;
    --sun-color: #FDB813;
    --earth-land: #2aa198;
    --earth-ocean: #268bd2;
    --moon-color: #93a1a1;
}

/* ── Base Styles ── */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    font-family: 'Noto Sans Display', sans-serif;
}

body {
    font-family: "Noto Sans Display", sans-serif;
    font-optical-sizing: auto;
    font-weight: 300;
    font-style: normal;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ── Theme Switcher ── */
.theme-switcher {
    position: fixed;
    top: 14px;
    left: 14px;
    display: flex;
    gap: 0;
    background: var(--switcher-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
    z-index: 1000;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.theme-switcher button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 16px;
    line-height: 1;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-switcher button:hover {
    color: var(--accent);
}

.theme-switcher button.active {
    background: var(--bg-primary);
    color: var(--switcher-active);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ── Main Container ── */
.container {
    display: flex;
    gap: 40px;
    padding: 80px 40px 40px;
    max-width: 1600px;
    margin: 0 auto;
    align-items: flex-start;
}

/* ── Clock Panel ── */
.clock-panel {
    flex: 1;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* Clock-only mode: center the clock when space panel is hidden */
.container.clock-only {
    justify-content: center;
}

.container.clock-only .clock-panel {
    max-width: 700px;
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent);
    margin: 0;
    text-align: center;
}

/* ── Digital Display ── */
.digital-display {
    background: var(--clock-bg);
    border: 2px solid var(--clock-border);
    border-radius: 12px;
    padding: 20px 30px;
    text-align: center;
    min-width: 300px;
}

.time-display {
    font-family: 'Orbitron', monospace;
    font-size: 3rem;
    font-weight: 700;
    color: var(--digital-text);
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.time-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.play-pause-btn {
    background: var(--clock-border);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--digital-text);
    font-size: 1.4rem;
    transition: background 0.2s, transform 0.15s;
    flex-shrink: 0;
}

.play-pause-btn:hover {
    background: var(--accent);
    transform: scale(1.1);
}

.play-pause-btn.paused {
    animation: pulse-play 1.5s ease-in-out infinite;
}

@keyframes pulse-play {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.date-display {
    font-size: 1.1rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* ── Clock Canvas ── */
#clockCanvas {
    display: block;
    max-width: 100%;
    height: auto;
    cursor: pointer;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--clock-bg);
}

/* ── Clock Controls ── */
.clock-controls {
    display: flex;
    gap: 20px;
    margin: 10px 0;
}

.control-group {
    display: flex;
    gap: 20px;
}

.control-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-primary);
    user-select: none;
}

.control-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
}

/* ── Date Controls ── */
.date-controls {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    width: 100%;
    max-width: 500px;
}

.date-controls h3 {
    margin: 0 0 15px 0;
    font-size: 1.2rem;
    color: var(--accent);
    text-align: center;
}

.date-adjusters {
    display: flex;
    justify-content: space-around;
    gap: 15px;
    margin-bottom: 15px;
}

.adjuster {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.adjuster button {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--accent);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s ease;
}

.adjuster button:hover {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

.adjuster span {
    font-family: 'Orbitron', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 45px;
    text-align: center;
}

.adjuster label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.reset-btn {
    background: var(--btn-bg);
    color: var(--btn-text);
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.reset-btn:hover {
    background: var(--btn-hover-bg);
    transform: translateY(-2px);
}

/* ── Space Panel ── */
.space-panel {
    flex: 1;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.space-panel h2 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    margin: 0;
    text-align: center;
}

#globeContainer {
    width: 100%;
    aspect-ratio: 1;
    max-width: 600px;
    background: var(--space-bg);
    border-radius: 12px;
    border: 2px solid var(--border);
    overflow: hidden;
    cursor: grab;
}

#globeContainer:active {
    cursor: grabbing;
}

#globeContainer canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

.subsolar-label {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.65);
    color: #FFD700;
    font-family: 'Orbitron', monospace;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    pointer-events: none;
    z-index: 2;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.moon-phase-label {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.65);
    color: #ddd;
    font-family: 'Orbitron', monospace;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    pointer-events: none;
    z-index: 2;
    border: 1px solid rgba(200, 200, 200, 0.3);
}

.planet-label {
    position: absolute;
    color: rgba(255, 255, 255, 0.85);
    font-family: 'Noto Sans Display', sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    pointer-events: none;
    z-index: 2;
    transform: translate(-50%, -100%);
    text-shadow: 0 0 4px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.7);
    white-space: nowrap;
    display: none;
}

.tilt-label {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.65);
    color: #ffaa44;
    font-family: 'Orbitron', monospace;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    pointer-events: none;
    z-index: 2;
    border: 1px solid rgba(255, 170, 68, 0.3);
}

.globe-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    width: 100%;
    max-width: 600px;
}

.globe-controls label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary);
    user-select: none;
}

.globe-controls input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent);
}

.body-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    width: 100%;
    max-width: 600px;
    margin-top: 4px;
}

.body-nav button {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}

.body-nav button:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.body-nav #currentBodyName {
    font-family: 'Orbitron', monospace;
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
    min-width: 100px;
    text-align: center;
}

.season-info {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    width: 100%;
    text-align: center;
}

#seasonName {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 10px;
}

#locationInfo {
    font-size: 1rem;
    color: var(--text-muted);
}

/* ── Tide Gauge ── */
.tide-gauge-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
    width: 100%;
}

.tide-gauge-panel h3 {
    margin: 0 0 12px 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    text-align: center;
}

.tide-gauge-row {
    display: flex;
    gap: 16px;
    align-items: stretch;
    min-height: 120px;
}

.tide-bar-container {
    position: relative;
    width: 38px;
    min-height: 110px;
    background: linear-gradient(to top, #1a3a5c 0%, #0a1a2e 100%);
    border-radius: 6px;
    border: 1px solid var(--border);
    overflow: hidden;
    flex-shrink: 0;
}

.tide-bar-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0%;
    background: linear-gradient(to top, #2288cc, #55bbee);
    transition: height 0.8s ease;
    border-radius: 0 0 5px 5px;
}

.tide-water-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: #55ddff;
    box-shadow: 0 0 6px #55ddff;
    transition: bottom 0.8s ease;
    bottom: 0;
}

.tide-bar-marks {
    position: absolute;
    top: 4px;
    bottom: 4px;
    right: 3px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
}

.tide-bar-marks span {
    font-size: 0.55rem;
    color: rgba(255,255,255,0.5);
    text-align: right;
    line-height: 1;
}

.tide-gauge-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tide-level-label {
    font-family: 'Orbitron', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: #55bbee;
}

.tide-breakdown {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 0.78rem;
}

.tide-body-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tide-body-name {
    width: 58px;
    font-weight: 600;
    flex-shrink: 0;
    font-size: 0.72rem;
}

.tide-body-bar {
    flex: 1;
    height: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    overflow: hidden;
}

.tide-body-bar span {
    display: block;
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.tide-body-pct {
    width: 52px;
    text-align: right;
    color: var(--text-muted);
    font-size: 0.7rem;
    flex-shrink: 0;
}

.tide-body-height {
    width: 36px;
    text-align: right;
    color: var(--text-primary);
    font-size: 0.7rem;
    font-weight: 600;
    flex-shrink: 0;
}

.tide-explain {
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    font-style: italic;
}

.tide-local-info {
    background: rgba(85, 187, 238, 0.08);
    border: 1px solid rgba(85, 187, 238, 0.2);
    border-radius: 8px;
    padding: 8px 10px;
    margin: 4px 0;
}

.tide-local-state {
    font-family: 'Orbitron', monospace;
    font-size: 0.95rem;
    font-weight: 700;
    color: #55bbee;
    margin-bottom: 2px;
}

.tide-local-height {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 600;
}

.tide-local-detail {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Responsive ── */
@media screen and (max-width: 1200px) {
    .container {
        flex-direction: column;
        align-items: center;
        padding: 80px 20px 40px;
    }

    .clock-panel,
    .space-panel {
        max-width: 100%;
        width: 100%;
    }
}

@media screen and (max-width: 768px) {
    .title {
        font-size: 2rem;
    }

    .time-display {
        font-size: 2.2rem;
    }

    .play-pause-btn {
        width: 34px;
        height: 34px;
        font-size: 1.2rem;
    }

    .date-adjusters {
        flex-direction: column;
        gap: 10px;
    }

    .space-panel h2 {
        font-size: 1.5rem;
    }

    #seasonName {
        font-size: 1.5rem;
    }

    .theme-switcher {
        top: 8px;
        left: 8px;
        padding: 2px;
    }

    .theme-switcher button {
        padding: 5px 8px;
        font-size: 14px;
    }
}
