/* Wildwood Live Cams - Styles */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg-primary: #fafafa;
    --bg-secondary: #ffffff;
    --card-bg: #ffffff;
    --card-border: #e5e5e5;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.12);
    --text-primary: #171717;
    --text-secondary: #525252;
    --text-muted: #a3a3a3;
    --accent: #0ea5e9;
    --accent-hover: #0284c7;
    --video-bg: #e5e5e5;
    --divider: #e5e5e5;
}

[data-theme="dark"] {
    --bg-primary: #0a0a0a;
    --bg-secondary: #171717;
    --card-bg: #171717;
    --card-border: #262626;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.4);
    --text-primary: #fafafa;
    --text-secondary: #a3a3a3;
    --text-muted: #525252;
    --accent: #38bdf8;
    --accent-hover: #7dd3fc;
    --video-bg: #262626;
    --divider: #262626;
    --logo-glow: rgba(56, 189, 248, 0.3);
    --logo-glow-hover: rgba(56, 189, 248, 0.45);
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--accent-hover);
}

/* Header */
header {
    padding: 2rem 1rem 1.5rem;
    text-align: center;
    position: relative;
    border-bottom: 1px solid var(--divider);
    background: var(--bg-secondary);
}

.header-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 2.5rem;
}

.header-logo {
    max-width: 420px;
    width: 90%;
    height: auto;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 0 8px var(--logo-glow, rgba(14, 165, 233, 0.25)));
    transition: filter 0.4s ease;
}

.header-logo:hover {
    filter: drop-shadow(0 0 12px var(--logo-glow-hover, rgba(14, 165, 233, 0.4)));
}

@media (min-width: 640px) {
    .header-logo {
        max-width: 540px;
        width: auto;
    }
}

.theme-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

.theme-toggle .sun-icon { display: none; }
.theme-toggle .moon-icon { display: block; }
[data-theme="dark"] .theme-toggle .sun-icon { display: block; }
[data-theme="dark"] .theme-toggle .moon-icon { display: none; }

.subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
}

.hosted-by-text {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Theme-aware visibility */
.show-light { display: block; }
.show-dark { display: none; }
[data-theme="dark"] .show-light { display: none; }
[data-theme="dark"] .show-dark { display: block; }

.tagline {
    display: inline-block;
    margin-top: 0.75rem;
    padding: 0.35rem 0.75rem;
    background: #fef3c7;
    color: #b45309;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 6px;
}

[data-theme="dark"] .tagline {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

/* Camera Grid */
.camera-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1rem;
    max-width: 1400px;
    margin: 0 auto;
}

@media (min-width: 640px) {
    .camera-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
        padding: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .camera-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.camera-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: all 0.2s ease;
}

@media (hover: hover) {
    .camera-card:hover {
        box-shadow: var(--card-shadow-hover);
    }
}

.video-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--video-bg);
    cursor: pointer;
}

.video-container video,
.video-container iframe {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: none;
    display: block;
}

.video-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--card-border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.video-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.video-watermark {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 32px;
    height: 32px;
    opacity: 0.5;
    pointer-events: none;
    z-index: 5;
}

.expand-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.video-container:hover .expand-btn,
.video-container:active .expand-btn {
    opacity: 1;
}

.expand-btn svg {
    width: 18px;
    height: 18px;
    color: white;
}

/* Camera info */
.camera-info {
    padding: 1rem;
}

.camera-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.camera-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    background: #22c55e;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.live-badge::before {
    content: '';
    width: 5px;
    height: 5px;
    background: white;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

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

.camera-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.camera-provider {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.camera-provider a {
    color: var(--text-muted);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.camera-provider a:hover {
    color: var(--accent);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    flex-shrink: 0;
}

.modal-title {
    color: white;
    font-weight: 600;
    font-size: 1rem;
}

.modal-close {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close svg {
    width: 24px;
    height: 24px;
    color: white;
}

.modal-video-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    position: relative;
}

.modal-video-container video,
.modal-video-container iframe {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border: none;
}

.modal-watermark {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 32px;
    height: 32px;
    opacity: 0.5;
    pointer-events: none;
    z-index: 10;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 1rem;
    border-top: 1px solid var(--divider);
    background: var(--bg-secondary);
}

.footer-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.footer-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.15));
    transition: filter 0.3s ease;
}

.footer-brand:hover .footer-logo {
    filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.2));
}

[data-theme="dark"] .footer-logo {
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.15));
}

[data-theme="dark"] .footer-brand:hover .footer-logo {
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.25));
}

.footer-brand span {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.footer-links {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.footer-links a {
    color: var(--text-secondary);
}

.footer-copy {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Safe areas */
@supports (padding: max(0px)) {
    header { padding-top: max(2rem, env(safe-area-inset-top)); }
    .theme-toggle { top: max(1rem, env(safe-area-inset-top)); }
    footer { padding-bottom: max(2rem, env(safe-area-inset-bottom)); }
    .modal-header { padding-top: max(1rem, env(safe-area-inset-top)); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
