/* =============================================
   Thomas Monitor — Glassmorphism Dark Theme
   Version 5 — 2026-06-26
   ============================================= */

:root {
    --bg-primary: #0c0a04;
    --bg-secondary: #14120a;
    --glass-bg: rgba(28, 25, 16, 0.65);
    --glass-border: rgba(255, 255, 255, 0.06);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --glass-blur: 20px;
    
    --text-primary: #f0ece4;
    --text-secondary: rgba(240, 236, 228, 0.6);
    --text-tertiary: rgba(240, 236, 228, 0.35);
    
    --accent: #4ade80;
    --accent-hover: #6ee7a0;
    --accent-glow: rgba(74, 222, 128, 0.25);
    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #f87171;
    
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    --star-opacity: 0.6;
}

/* === Light Mode === */
body.light-mode {
    --bg-primary: #e8f0e8;
    --bg-secondary: #dce6dc;
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(0, 0, 0, 0.06);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    
    --text-primary: #1a2e1a;
    --text-secondary: rgba(26, 46, 26, 0.6);
    --text-tertiary: rgba(26, 46, 26, 0.35);
    
    --accent: #16a34a;
    --accent-hover: #15803d;
    --accent-glow: rgba(22, 163, 74, 0.2);
    --success: #16a34a;
    
    --star-opacity: 0;
}

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

html, body {
    height: 100%;
    margin: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100%;
    overflow-x: hidden;
    position: relative;
}

/* === Animated Star Background (CSS Fallback + Three.js Overlay) === */
#stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    transition: background 0.8s ease;
    background: 
        radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 40% 70%, rgba(255,255,255,0.2), transparent),
        radial-gradient(1.5px 1.5px at 60% 20%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 80% 50%, rgba(255,255,255,0.15), transparent),
        radial-gradient(1.5px 1.5px at 10% 80%, rgba(255,255,255,0.25), transparent),
        radial-gradient(1px 1px at 50% 90%, rgba(255,255,255,0.2), transparent),
        radial-gradient(1px 1px at 70% 60%, rgba(255,255,255,0.15), transparent),
        radial-gradient(1px 1px at 90% 10%, rgba(255,255,255,0.2), transparent),
        radial-gradient(1px 1px at 30% 50%, rgba(255,255,255,0.15), transparent),
        radial-gradient(1px 1px at 15% 15%, rgba(255,255,255,0.2), transparent),
        radial-gradient(1px 1px at 85% 85%, rgba(255,255,255,0.15), transparent),
        radial-gradient(1px 1px at 45% 45%, rgba(255,255,255,0.2), transparent);
    background-color: var(--bg-primary);
    animation: twinkle 8s ease-in-out infinite alternate;
    opacity: var(--star-opacity);
    z-index: 0;
}

@keyframes twinkle {
    0% { opacity: 0.4; }
    100% { opacity: 0.8; }
}

#three-bg {
    z-index: 1;
    opacity: 0;
    transition: opacity 1.5s ease;
}

#three-bg.ready {
    opacity: 1;
}

/* Container über allem */
.container {
    position: relative;
    z-index: 2;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* === Glass Card === */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--glass-shadow);
    transition: var(--transition);
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

/* === Header === */
.header {
    padding: 16px 24px;
    margin-bottom: 24px;
}

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

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    font-size: 2rem;
    line-height: 1;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.header-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

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

/* === Theme Toggle Button === */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition);
    color: var(--text-secondary);
    line-height: 1;
}

.theme-toggle:hover {
    background: rgba(74, 222, 128, 0.12);
    border-color: rgba(74, 222, 128, 0.3);
    color: var(--accent);
}

.light-mode .theme-toggle:hover {
    background: rgba(22, 163, 74, 0.1);
    border-color: rgba(22, 163, 74, 0.3);
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid rgba(74, 222, 128, 0.2);
    border-radius: 20px;
}

.live-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.live-text {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--success);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.clock {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.05em;
}

/* === Section Header === */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.section-header h2 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.section-icon {
    font-size: 1.1rem;
}

.section-badge {
    font-size: 0.72rem;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid rgba(74, 222, 128, 0.15);
    color: var(--text-secondary);
}

/* === Main Grid === */
.main-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

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

/* ========================
   WEBCAM
   ======================== */
.webcam-section {
    padding: 20px;
}

.webcam-wrapper {
    width: 100%;
}

.webcam-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #000;
    border: 1px solid var(--glass-border);
}

.webcam-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.5s ease;
}

.webcam-skeleton {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: linear-gradient(135deg, #1a1812 0%, #0c0a04 100%);
    z-index: 2;
}

.skeleton-camera-icon {
    font-size: 3rem;
    opacity: 0.4;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.skeleton-pulse {
    width: 120px;
    height: 120px;
    border: 2px solid rgba(74, 222, 128, 0.15);
    border-radius: 50%;
    position: absolute;
    animation: pulse-ring 2s ease-out infinite;
}

@keyframes pulse-ring {
    0% { transform: scale(0.8); opacity: 1; }
    100% { transform: scale(1.4); opacity: 0; }
}

.skeleton-text {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    animation: pulse-text 1.5s ease-in-out infinite;
}

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

.webcam-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 3;
}

.overlay-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.overlay-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255,255,255,0.9);
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.overlay-res {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.6);
}

.overlay-timestamp {
    font-size: 0.7rem;
    font-weight: 500;
    color: rgba(255,255,255,0.7);
    font-variant-numeric: tabular-nums;
}

.webcam-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.ctrl-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.ctrl-btn:hover:not(:disabled) {
    background: rgba(74, 222, 128, 0.12);
    border-color: rgba(74, 222, 128, 0.3);
    color: var(--text-primary);
}

.ctrl-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ctrl-btn.small {
    padding: 4px 10px;
    font-size: 0.72rem;
}

.ctrl-btn.active {
    background: rgba(74, 222, 128, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

.ctrl-status {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-left: auto;
}

/* ========================
   WEATHER — CURRENT
   ======================== */
.weather-section {
    padding: 20px;
}

.weather-current {
    margin-bottom: 16px;
}

.weather-main {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.weather-temp-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.weather-temp {
    font-size: 3.2rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    color: var(--text-primary);
    line-height: 1;
}

.weather-condition {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding-top: 4px;
}

.weather-icon {
    font-size: 2rem;
}

.weather-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.weather-feels {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.weather-meta {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    display: flex;
    gap: 16px;
}

.weather-meta strong {
    color: var(--text-secondary);
    font-weight: 500;
}

/* === Stats Grid === */
.weather-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

@media (max-width: 600px) {
    .weather-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.stat-card {
    padding: 14px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    text-align: center;
    transition: var(--transition);
}

.stat-card:hover {
    background: rgba(255,255,255,0.04);
    border-color: rgba(255,255,255,0.1);
}

.stat-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-icon {
    font-size: 1.3rem;
}

.stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 0.68rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ========================
   HISTORY CHART
   ======================== */
.history-section {
    padding: 20px;
    margin-bottom: 24px;
}

.history-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.history-metric-select select {
    padding: 4px 8px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.72rem;
    cursor: pointer;
    outline: none;
}

.history-metric-select select:focus {
    border-color: var(--accent);
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 280px;
}

.chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

.chart-skeleton {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    padding: 0 20px 20px;
}

.skeleton-chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    width: 100%;
    height: 80%;
}

.sk-bar {
    flex: 1;
    background: linear-gradient(to top, rgba(74,222,128,0.08), rgba(74,222,128,0.02));
    border-radius: 4px 4px 0 0;
    animation: sk-bar-pulse 1.5s ease-in-out infinite;
    min-height: 10%;
}

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

/* ========================
   SKELETON SHARED
   ======================== */
.skeleton-block {
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skeleton-line {
    height: 12px;
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 100%);
    border-radius: 6px;
    animation: shimmer 2s ease-in-out infinite;
    background-size: 200% 100%;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.w-60 { width: 60%; }
.w-50 { width: 50%; }
.w-40 { width: 40%; }
.w-30 { width: 30%; }

.hidden {
    display: none !important;
}

/* ========================
   FOOTER
   ======================== */
.footer {
    text-align: center;
    padding: 20px;
    font-size: 0.72rem;
    color: var(--text-tertiary);
}

.footer p {
    margin-bottom: 4px;
}

.footer-dummy-hint {
    color: var(--warning);
    font-weight: 500;
}

.footer-legal {
    font-size: 0.65rem;
    opacity: 0.6;
}

.api-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s;
}

.api-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* ========================
   RESPONSIVE — Mobile First
   ======================== */

/* Small phones */
@media (max-width: 480px) {
    .container {
        padding: 8px;
    }

    .header {
        padding: 10px 12px;
    }

    .header-inner {
        flex-direction: row;
        align-items: center;
    }

    .header-left {
        gap: 10px;
    }

    .header-title {
        font-size: 0.9rem;
    }

    .header-subtitle {
        display: none;
    }

    .header-right {
        gap: 8px;
    }

    .live-indicator {
        padding: 3px 8px;
    }

    .live-text {
        font-size: 0.6rem;
    }

    .clock {
        font-size: 0.85rem;
    }

    .logo-icon {
        font-size: 1.4rem;
    }

    .webcam-section,
    .weather-section,
    .history-section {
        padding: 12px;
    }

    .weather-temp {
        font-size: 2.2rem;
    }

    .weather-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .stat-card {
        padding: 10px 8px;
    }

    .stat-value {
        font-size: 1rem;
    }

    .stat-icon {
        font-size: 1.1rem;
    }

    .webcam-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .ctrl-status {
        margin-left: 0;
        text-align: center;
    }

    .ctrl-btn {
        justify-content: center;
        padding: 8px 12px;
    }

    .history-controls {
        flex-wrap: wrap;
        gap: 4px;
    }

    .chart-wrapper {
        height: 200px;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .section-header h2 {
        font-size: 0.9rem;
    }

    .weather-meta {
        flex-direction: column;
        gap: 4px;
    }
}

/* Tablets */
@media (min-width: 481px) and (max-width: 900px) {
    .container {
        padding: 12px;
    }

    .header {
        padding: 12px 16px;
    }

    .header-title {
        font-size: 1rem;
    }

    .webcam-section,
    .weather-section,
    .history-section {
        padding: 14px;
    }

    .weather-temp {
        font-size: 2.5rem;
    }

    .weather-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

/* Avoid double-scrollbar on mobile */
@media (hover: none) and (pointer: coarse) {
    ::-webkit-scrollbar {
        width: 0;
    }
}
/* ========================
   MODAL
   ======================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal {
    width: 100%;
    max-width: 480px;
    padding: 28px 24px 24px;
    position: relative;
    animation: slideUp 0.25s ease;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.modal-close:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.modal-icon {
    font-size: 2rem;
    color: var(--accent);
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(74, 222, 128, 0.1);
    border-radius: 14px;
}

.modal-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Comparison bar */
.modal-comparison {
    padding: 0 0 4px;
}

.comparison-bar-wrapper {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.comparison-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease, background 0.3s;
    position: relative;
}
.comparison-bar::after {
    content: '';
    position: absolute;
    right: -4px;
    top: -3px;
    width: 14px;
    height: 14px;
    background: var(--text-primary);
    border-radius: 50%;
    border: 2px solid var(--accent);
}

.comparison-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

.modal-description {
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-primary);
}
.modal-description i {
    font-size: 1.1rem;
    color: var(--accent);
    margin-top: 2px;
    flex-shrink: 0;
}

.modal-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.modal-detail-item {
    padding: 10px 12px;
    background: rgba(255,255,255,0.04);
    border-radius: 8px;
    font-size: 0.8rem;
}
.modal-detail-item .dt-label {
    color: var(--text-secondary);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.modal-detail-item .dt-value {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.85rem;
    margin-top: 2px;
}

.light-mode .modal-overlay {
    background: rgba(0,0,0,0.5);
}
.light-mode .modal-icon {
    background: rgba(22, 163, 74, 0.1);
}
.light-mode .modal-detail-item {
    background: rgba(0,0,0,0.03);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
    .modal {
        padding: 20px 16px 16px;
    }
    .modal-details {
        grid-template-columns: 1fr;
    }
    .modal-value {
        font-size: 1.5rem;
    }
}

/* ========================
   SCROLLBAR
   ======================== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}
