:root {
    --bg-deep:       #050514;
    --accent-violet: #7c6af7;
    --accent-blue:   #60a5fa;
    --accent-green:  #34d399;
    --text:          #f1f5f9;
    --text-muted:    #94a3b8;
    --text-dim:      #475569;
    --border:        rgba(255, 255, 255, 0.07);
    --card-bg:       rgba(15, 12, 35, 0.85);
    --radius-card:   1rem;
    --radius-btn:    0.75rem;
    --radius-input:  0.75rem;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    background-color: var(--bg-deep);
}

h1, h2, h3, .hero-eyebrow, .card-name-overlay h3 {
    font-family: 'Syne', sans-serif;
}

/* ── Starfield ─────────────────────────────────────────── */

.starfield-container {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

/* ── Hero ───────────────────────────────────────────────── */

.hero {
    position: relative;
    z-index: 1;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem 1rem;
    background: radial-gradient(
        ellipse at 50% 30%,
        rgba(30, 20, 60, 0.85) 0%,
        rgba(5, 5, 20, 0.95) 70%
    );
    overflow: hidden;
}

.hero-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
    width: 100%;
    max-width: 900px;
}

.hero-title {
    text-align: center;
}

.hero-eyebrow {
    display: block;
    font-family: 'Syne', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.45em;
    text-transform: uppercase;
    color: var(--accent-violet);
    margin-bottom: 0.75rem;
}

h1 {
    font-size: clamp(2.5rem, 6vw, 5rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    padding: 0.05em 0 0.2em;
    background: linear-gradient(135deg, #ffffff 0%, #a78bfa 50%, #60a5fa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
}

.hero-sub {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 420px;
    margin: 0 auto;
}

/* ── Search Panel ───────────────────────────────────────── */

.search-panel {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 1.5rem;
    padding: 2rem;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.input-group {
    display: flex;
    gap: 0.75rem;
}

input[type="text"],
input[type="tel"] {
    flex: 1;
    min-width: 0;
    padding: 0.875rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-input);
    background: rgba(0, 0, 0, 0.3);
    color: var(--text);
    font-size: 1.2rem;
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.1em;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="tel"]:focus {
    outline: none;
    border-color: rgba(124, 106, 247, 0.6);
    box-shadow: 0 0 0 3px rgba(124, 106, 247, 0.15);
}

input[type="text"]::placeholder,
input[type="tel"]::placeholder {
    color: var(--text-dim);
    font-weight: 400;
    letter-spacing: 0.05em;
}

/* ── Buttons ────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    border: none;
    border-radius: var(--radius-btn);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, #7c6af7, #4f46e5);
    color: white;
    box-shadow: 0 4px 20px rgba(124, 106, 247, 0.4);
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 28px rgba(124, 106, 247, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text);
}

/* ── Error message ──────────────────────────────────────── */

.error-message {
    padding: 0.75rem 1rem;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 0.5rem;
    color: #fca5a5;
    font-size: 0.875rem;
    text-align: center;
}

/* ── Loading ────────────────────────────────────────────── */

.loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: center;
}

.loading-dots {
    display: flex;
    gap: 0.4rem;
}

.loading-dots div {
    width: 0.6rem;
    height: 0.6rem;
    background-color: var(--accent-violet);
    border-radius: 50%;
    animation: pulse 1.4s infinite ease-in-out;
}

.loading-dots div:nth-child(2) { animation-delay: 0.2s; }
.loading-dots div:nth-child(3) { animation-delay: 0.4s; }

.loading-text {
    font-size: 0.875rem;
    color: var(--text-muted);
}

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

.hidden {
    display: none !important;
}

/* ── Results Section ────────────────────────────────────── */

.results-section {
    position: relative;
    z-index: 1;
    padding: 4rem 1rem 3rem;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.results-section.visible {
    opacity: 1;
    transform: translateY(0);
}

.results-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.results-header h2 {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.results-location {
    font-size: 0.95rem;
    color: var(--accent-violet);
    font-weight: 500;
}

/* ── Time Controls ──────────────────────────────────────── */

.time-controls {
    max-width: 680px;
    margin: 0 auto 2.5rem;
    padding: 1.5rem 2rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.time-display {
    display: block;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-violet);
    margin-bottom: 1rem;
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.slider-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    white-space: nowrap;
    flex-shrink: 0;
}

input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: linear-gradient(
        to right,
        var(--accent-violet) var(--slider-pct, 0%),
        rgba(255, 255, 255, 0.1) var(--slider-pct, 0%)
    );
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-violet);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(124, 106, 247, 0.7);
    cursor: pointer;
    transition: box-shadow 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    box-shadow: 0 0 14px rgba(124, 106, 247, 0.9);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--accent-violet);
    border: none;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(124, 106, 247, 0.7);
    cursor: pointer;
}

/* ── Constellation Grid ─────────────────────────────────── */

.constellation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    max-width: 1280px;
    margin: 0 auto;
}

/* ── Constellation Cards ────────────────────────────────── */

.constellation-card {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-card);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.constellation-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(124, 106, 247, 0.3);
}

.card-image-wrapper {
    position: relative;
    height: 180px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-image-bg, linear-gradient(135deg, #1a0a3a, #0a1a3a));
}

/* glyph removed — replaced by star-pattern-svg */

.constellation-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
    transition: transform 0.4s ease, opacity 0.3s ease;
    opacity: 0;
}

.constellation-image.loaded {
    opacity: 1;
}

.constellation-card:hover .constellation-image {
    transform: scale(1.04);
}

.card-name-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem 1.25rem 1rem;
    background: linear-gradient(to top, rgba(5, 5, 20, 0.97) 0%, transparent 100%);
}

.card-name-overlay h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.15rem;
}

.latin-name {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ── Card Body ──────────────────────────────────────────── */

.card-body {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.constellation-details {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.stat-chips {
    display: flex;
    gap: 0.75rem;
}

.stat-chip {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.75rem 0.5rem;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-violet);
    line-height: 1.1;
}

.stat-label {
    display: block;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin-top: 0.2rem;
}

.rise-set-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0.75rem 0;
    border-top: 1px solid var(--border);
    gap: 0.5rem;
}

.rise-set-row span {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.rise-set-row .rs-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
}

.rise-set-row .rs-time {
    font-weight: 600;
    color: var(--text);
}

.rise-set-divider {
    flex: 1;
    height: 1px;
    background: var(--border);
    margin: 0 0.5rem;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

.visibility-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.7rem;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.badge-bright {
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.25);
}

.badge-moderate {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.25);
}

.badge-faint {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
    border: 1px solid rgba(148, 163, 184, 0.15);
}

.info-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: var(--accent-violet);
    text-decoration: none;
    padding: 0.35rem 0.75rem;
    border: 1px solid rgba(124, 106, 247, 0.3);
    border-radius: 99px;
    transition: background 0.2s, color 0.2s;
}

.info-link:hover {
    background: rgba(124, 106, 247, 0.15);
    color: white;
}

.observing-tip {
    font-size: 0.8rem;
    color: var(--text-dim);
    line-height: 1.5;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-left: 2px solid rgba(124, 106, 247, 0.4);
    border-radius: 0 0.5rem 0.5rem 0;
}

/* ── Error retry button ─────────────────────────────────── */

.error-retry-btn {
    display: inline-block;
    margin-top: 0.5rem;
    margin-left: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 99px;
    color: #fca5a5;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.error-retry-btn:hover {
    background: rgba(239, 68, 68, 0.35);
}

/* ── Search Again button ─────────────────────────────────── */

.btn-search-again {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 1rem;
    padding: 0.5rem 1.1rem;
    background: rgba(124, 106, 247, 0.1);
    border: 1px solid rgba(124, 106, 247, 0.3);
    border-radius: 99px;
    color: var(--accent-violet);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.btn-search-again:hover {
    background: rgba(124, 106, 247, 0.2);
    color: white;
}

/* ── Slider graduation marks ─────────────────────────────── */

.slider-marks {
    display: flex;
    justify-content: space-between;
    margin-top: 0.4rem;
    padding: 0 2px;
}

.slider-marks span {
    font-size: 0.65rem;
    color: var(--text-dim);
    letter-spacing: 0.03em;
}

/* ── Star pattern SVG overlay on cards ───────────────────── */

.star-pattern-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.constellation-image.loaded ~ .star-pattern-svg,
.constellation-card:has(.constellation-image.loaded) .star-pattern-svg {
    opacity: 0;
}

/* ── Staggered card entrance animation ───────────────────── */

.constellation-card {
    opacity: 0;
    transform: translateY(20px);
    transition:
        opacity 0.45s ease var(--card-delay, 0ms),
        transform 0.45s ease var(--card-delay, 0ms),
        box-shadow 0.25s ease,
        border-color 0.25s ease;
}

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

/* ── Empty / No results ─────────────────────────────────── */

.no-results {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.no-results p {
    font-size: 1.1rem;
}

/* ── Footer ─────────────────────────────────────────────── */

.site-footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-dim);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
}

.hero .site-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    border-top: none;
    padding: 1rem;
}

.site-footer a {
    color: var(--text-muted);
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--text);
}

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 640px) {
    .hero-inner {
        gap: 2rem;
    }

    .search-panel {
        padding: 1.5rem;
    }

    .input-group {
        flex-direction: column;
    }

    .btn-secondary {
        width: 100%;
    }

    .constellation-grid {
        grid-template-columns: 1fr;
    }

    .card-image-wrapper {
        height: 180px;
    }

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

    .time-controls {
        padding: 1.25rem;
    }
}

@media (max-width: 380px) {
    h1 {
        font-size: 2rem;
    }

    .card-image-wrapper {
        height: 150px;
    }
}

/* ── Mobile landscape ───────────────────────────────────── */

@media (max-height: 600px) and (orientation: landscape) {
    .hero {
        height: auto;
        min-height: 100vh;
        padding: 1.5rem 1rem 3.5rem;
        justify-content: flex-start;
    }

    .hero-inner {
        flex-direction: row;
        align-items: center;
        gap: 2rem;
        padding-top: 1rem;
    }

    .hero-title {
        flex: 1;
        text-align: left;
    }

    h1 {
        font-size: clamp(1.6rem, 4vw, 2.5rem);
    }

    .hero-sub {
        font-size: 0.9rem;
        margin: 0;
    }

    .search-panel {
        flex: 1;
        max-width: 400px;
    }

    .hero .site-footer {
        position: fixed;
    }
}
