:root {
    --bg-glow: #243069;
    --bg-top: #0b1026;
    --bg-deep: #06091a;
    --bg-bottom: #1b2350;
    --accent: #4f9dff;
    --accent-hover: #6fb1ff;
    --accent-press: #3a86f0;
    --visible: #46d39a;
    --card: rgba(255, 255, 255, 0.06);
    --card-border: rgba(255, 255, 255, 0.12);
    --text: #eaf0ff;
    --text-dim: #9aa6cc;
    --star-opacity: 0.5;
    --switch-track: rgba(255, 255, 255, 0.14);
}

/* Light (day) theme */
:root[data-theme="light"] {
    --bg-glow: #cfe2ff;
    --bg-top: #eaf1ff;
    --bg-deep: #f4f8ff;
    --bg-bottom: #dbe7ff;
    --accent: #2f7df0;
    --accent-hover: #1f6fe6;
    --accent-press: #1862d4;
    --visible: #1f9d6b;
    --card: rgba(20, 40, 90, 0.05);
    --card-border: rgba(20, 40, 90, 0.16);
    --text: #182238;
    --text-dim: #5d6b88;
    --star-opacity: 0;
    --switch-track: rgba(20, 40, 90, 0.18);
}

* { box-sizing: border-box; }

/* The HTML [hidden] attribute must always win, even over display:flex elements */
[hidden] { display: none !important; }


html, body {
    margin: 0;
    min-height: 100vh;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text);
    background: radial-gradient(circle at 50% -10%, var(--bg-glow) 0%, var(--bg-top) 45%, var(--bg-deep) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 0 1.25rem;
    position: relative;
    overflow-x: hidden;
    transition: color 0.3s ease, background 0.3s ease;
}

/* Subtle starfield */
.stars {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(1px 1px at 20% 30%, #fff, transparent),
        radial-gradient(1px 1px at 70% 20%, #cdd9ff, transparent),
        radial-gradient(1px 1px at 40% 70%, #fff, transparent),
        radial-gradient(1px 1px at 85% 60%, #b9c8ff, transparent),
        radial-gradient(1px 1px at 15% 85%, #fff, transparent),
        radial-gradient(1.5px 1.5px at 60% 80%, #fff, transparent);
    opacity: var(--star-opacity);
    transition: opacity 0.4s ease;
}

/* Header */
.site-header {
    text-align: center;
    margin-top: 3.5rem;
    z-index: 1;
}

.logo {
    font-size: clamp(2.2rem, 6vw, 3.4rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
}

.logo .sat {
    display: inline-block;
    animation: float 4s ease-in-out infinite;
}

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

.tagline {
    margin: 0.6rem 0 0;
    color: var(--text-dim);
    font-size: clamp(0.95rem, 2.5vw, 1.15rem);
}

/* Main content */
.content {
    flex: 1;
    width: 100%;
    max-width: 640px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2.5rem 0;
    z-index: 1;
}

.panel {
    width: 100%;
    animation: fadeIn 0.4s ease both;
}

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

.field-label {
    display: block;
    text-align: center;
    font-size: 1.15rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.search-row {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.city-input {
    flex: 1 1 240px;
    padding: 0.95rem 1.1rem;
    font-size: 1.05rem;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.city-input::placeholder { color: var(--text-dim); }

.city-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 157, 255, 0.25);
}

/* Buttons */
.btn {
    position: relative;
    border: none;
    border-radius: 14px;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.95rem 1.5rem;
    transition: transform 0.12s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
}

.btn:active { transform: translateY(1px) scale(0.99); }

.btn-primary {
    color: #fff;
    background: var(--accent);
    box-shadow: 0 6px 18px rgba(79, 157, 255, 0.35);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 8px 24px rgba(79, 157, 255, 0.5);
    transform: translateY(-1px);
}

.btn-primary:active { background: var(--accent-press); }

.btn-secondary {
    display: block;
    margin: 2rem auto 0;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--card-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
}

/* Loading spinner inside the button */
.spinner {
    display: none;
    width: 18px;
    height: 18px;
    margin-left: 0.5rem;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    vertical-align: -3px;
    animation: spin 0.7s linear infinite;
}

.btn.loading .spinner { display: inline-block; }
.btn.loading { pointer-events: none; opacity: 0.85; }

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

/* Errors */
.error {
    margin: 1rem 0 0;
    text-align: center;
    color: #ff9a9a;
    font-weight: 500;
}

/* Results */
.results-head {
    text-align: center;
    margin-bottom: 1.5rem;
}

.results-head h2 {
    margin: 0;
    font-size: 1.4rem;
}

.results-head .place {
    color: var(--text-dim);
    font-size: 0.95rem;
    margin-top: 0.3rem;
}

.best-card {
    background: linear-gradient(135deg, rgba(70, 211, 154, 0.18), rgba(79, 157, 255, 0.14));
    border: 1px solid rgba(70, 211, 154, 0.5);
    border-radius: 18px;
    padding: 1.4rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.best-card .badge {
    display: inline-block;
    background: var(--visible);
    color: #06291c;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    margin-bottom: 0.7rem;
}

.best-card h3 {
    margin: 0 0 0.5rem;
    font-size: 1.3rem;
}

.best-card .detail {
    margin: 0.25rem 0;
    color: var(--text);
}

.best-card .detail .k { color: var(--text-dim); }

/* Yellow variant: the "next chance to spot it" card */
.best-card.next {
    background: linear-gradient(135deg, rgba(245, 197, 66, 0.22), rgba(255, 168, 46, 0.12));
    border-color: rgba(245, 197, 66, 0.6);
}

.best-card.next .badge {
    background: #f5c542;
    color: #4a3600;
}


.section-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    margin: 0 0 0.75rem;
}

.pass-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.pass-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 0.85rem 1.1rem;
}

.pass-item.is-visible {
    border-color: rgba(70, 211, 154, 0.45);
    background: rgba(70, 211, 154, 0.08);
}

.pass-main { display: flex; flex-direction: column; gap: 0.15rem; }
.pass-when { font-weight: 600; }
.pass-meta { color: var(--text-dim); font-size: 0.88rem; }

.pass-tag {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    white-space: nowrap;
}

.pass-tag.visible { background: rgba(70, 211, 154, 0.2); color: var(--visible); }
.pass-tag.hidden { background: rgba(255, 255, 255, 0.08); color: var(--text-dim); }

.empty {
    text-align: center;
    color: var(--text-dim);
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 1.2rem 1.4rem;
    line-height: 1.55;
}

.empty p { margin: 0 0 0.7rem; }
.empty p:last-child { margin-bottom: 0; }
.empty .empty-lead { font-weight: 600; color: var(--text); font-size: 1.05rem; }
.empty strong { color: var(--text); }

/* Notice shown when the next visible pass is beyond the search window */
.notice {
    text-align: center;
    color: var(--text-dim);
    line-height: 1.5;
    margin: 0 0 1.2rem;
}

.notice strong { color: var(--text); }

/* Small, unobtrusive toggle for daytime passes */
.toggle-daytime {
    display: block;
    margin: 1.5rem auto 0;
    padding: 0.45rem 0.9rem;
    font-family: inherit;
    font-size: 0.82rem;
    color: var(--text-dim);
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 999px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}

.toggle-daytime:hover {
    color: var(--text);
    border-color: var(--accent);
    background: rgba(79, 157, 255, 0.08);
}

.daytime-list { margin-top: 0.9rem; }

/* Footer */
.site-footer {
    width: 100%;
    max-width: 760px;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.85rem;
    line-height: 1.5;
    padding: 1.5rem 0 2.5rem;
    z-index: 1;
}

.footer-desc { margin: 0; }

.footer-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1.4rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--card-border);
}

.brand-logo {
    display: inline-flex;
    align-items: center;
    border-radius: 8px;
    transition: background 0.3s ease, padding 0.3s ease;
}

.brand-logo img {
    height: 30px;
    display: block;
}

/* The CIL logo has white lettering; give it a navy chip in light mode */
:root[data-theme="light"] .brand-logo {
    background: #13284c;
    padding: 7px 12px;
}

.copyright {
    margin: 0;
    color: var(--text-dim);
    font-size: 0.78rem;
}

/* Theme switch (top-right) */
.theme-switch {
    position: fixed;
    top: 1rem;
    right: 1.1rem;
    z-index: 10;
}

.theme-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-switch .switch {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    width: 64px;
    height: 32px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--switch-track);
    border: 1px solid var(--card-border);
    cursor: pointer;
    position: relative;
    transition: background 0.3s ease, border-color 0.3s ease;
    backdrop-filter: blur(6px);
}

.theme-switch .switch-icon {
    font-size: 0.82rem;
    line-height: 1;
    z-index: 1;
    opacity: 0.85;
}

.theme-switch .switch-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease;
}

/* Checked = light mode: knob slides right */
.theme-switch input:checked + .switch .switch-knob {
    transform: translateX(32px);
}

.theme-switch .switch:hover { border-color: var(--accent); }

.theme-switch input:focus-visible + .switch {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

