/* Astro-Planner Stylesheet */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #1c2128;
    --bg-input: #0d1117;
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --success: #3fb950;
    --warning: #d29922;
    --danger: #f85149;
    --purple: #bc8cff;
}

html {
    scroll-behavior: smooth;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand a {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 600;
}

.navbar-menu { display: flex; gap: 1.5rem; }

.navbar-menu a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.navbar-menu a:hover, .navbar-menu a.active {
    color: var(--text-primary);
    background: var(--bg-card);
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
}

/* Sections */
.section { margin-bottom: 2rem; }

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

h2 { font-size: 1.4rem; margin-bottom: 1rem; }
h3 { font-size: 1.1rem; margin-bottom: 0.75rem; color: var(--text-secondary); }
h4 { font-size: 0.95rem; margin-bottom: 0.5rem; }

/* Grid */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

/* Forms */
.form-group { margin-bottom: 0.75rem; }

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.tooltip-anchor {
    position: relative;
}

.tooltip-anchor[data-tooltip] {
    cursor: help;
}

.tooltip-anchor[data-tooltip]:hover::after,
.tooltip-anchor[data-tooltip]:focus-within::after,
.tooltip-anchor[data-tooltip][data-tooltip-open="true"]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 0;
    bottom: calc(100% + 0.45rem);
    z-index: 250;
    min-width: 15rem;
    max-width: 22rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid rgba(88, 166, 255, 0.28);
    border-radius: 8px;
    background: rgba(13, 17, 23, 0.97);
    color: var(--text-primary);
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.45;
    white-space: normal;
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.34);
    pointer-events: none;
}

.tooltip-anchor[data-tooltip]:hover::before,
.tooltip-anchor[data-tooltip]:focus-within::before,
.tooltip-anchor[data-tooltip][data-tooltip-open="true"]::before {
    content: '';
    position: absolute;
    left: 0.8rem;
    bottom: calc(100% + 0.15rem);
    z-index: 251;
    border-width: 6px;
    border-style: solid;
    border-color: rgba(88, 166, 255, 0.28) transparent transparent transparent;
    pointer-events: none;
}

.tooltip-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
}

.tooltip-hint {
    color: var(--text-muted);
    font-size: 0.82em;
}

@media (max-width: 768px) {
    .tooltip-anchor[data-tooltip]:hover::after,
    .tooltip-anchor[data-tooltip]:focus-within::after,
    .tooltip-anchor[data-tooltip][data-tooltip-open="true"]::after {
        left: auto;
        right: 0;
        min-width: 13rem;
        max-width: min(18rem, 80vw);
    }

    .tooltip-anchor[data-tooltip]:hover::before,
    .tooltip-anchor[data-tooltip]:focus-within::before,
    .tooltip-anchor[data-tooltip][data-tooltip-open="true"]::before {
        left: auto;
        right: 0.8rem;
    }
}

input, select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    background: var(--bg-card);
    color: var(--text-primary);
    text-decoration: none;
}

.btn:hover { border-color: var(--text-secondary); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
    font-weight: 600;
}

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

.btn-dirty {
    animation: pulse-glow 1.5s ease-in-out infinite;
    box-shadow: 0 0 8px var(--accent);
}
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 8px var(--accent); }
    50% { box-shadow: 0 0 18px var(--accent); }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn-secondary {
    background: var(--bg-secondary);
    border-color: var(--border);
}

.btn-small { padding: 0.25rem 0.75rem; font-size: 0.85rem; }

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}

.badge-catalog { color: var(--accent); }
.badge-type { color: var(--purple); }

/* Bortle Badges */
.bortle-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-left: 0.5rem;
}

.bortle-1, .bortle-2 { background: #003300; color: #00ff00; }
.bortle-3 { background: #1a3300; color: #66ff00; }
.bortle-4 { background: #333300; color: #ccff00; }
.bortle-5 { background: #4d3300; color: #ffcc00; }
.bortle-6 { background: #663300; color: #ff9900; }
.bortle-7 { background: #660000; color: #ff6600; }
.bortle-8 { background: #660000; color: #ff3300; }
.bortle-9 { background: #4d0000; color: #ff0000; }

.bortle-display {
    display: flex;
    align-items: center;
}

.bortle-display select { flex: 1; }

/* Banners */
.info-banner, .warning-banner {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.info-banner {
    background: rgba(88, 166, 255, 0.1);
    border: 1px solid rgba(88, 166, 255, 0.3);
    color: var(--accent);
}

.warning-banner {
    background: rgba(210, 153, 34, 0.1);
    border: 1px solid rgba(210, 153, 34, 0.3);
    color: var(--warning);
}

/* Hero */
.hero-card {
    position: relative;
    overflow: hidden;
    padding: 1.75rem;
    border: 1px solid rgba(88, 166, 255, 0.22);
    border-radius: 16px;
    background:
        radial-gradient(circle at top right, rgba(88, 166, 255, 0.18), transparent 28%),
        linear-gradient(135deg, rgba(28, 33, 40, 0.98), rgba(13, 17, 23, 0.98));
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.hero-eyebrow {
    margin-bottom: 0.75rem;
    color: var(--accent-hover);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.hero-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(220px, 0.8fr);
    align-items: end;
    gap: 1.5rem;
}

.hero h1 {
    max-width: 18ch;
    margin-bottom: 0.75rem;
    font-size: clamp(2rem, 4.2vw, 3.15rem);
    line-height: 1.02;
    text-wrap: balance;
}

.hero-copy {
    max-width: 62ch;
    color: var(--text-secondary);
    font-size: 1rem;
}

.hero-actions {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-self: end;
    align-self: center;
}

.hero-actions .btn {
    min-width: 220px;
}

.hero-trust {
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

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

    .hero-card {
        padding: 1.35rem;
    }

    .hero h1 {
        max-width: 13ch;
        font-size: clamp(2rem, 8vw, 2.7rem);
        text-wrap: pretty;
    }

    .hero-copy {
        max-width: none;
    }

    .hero-actions {
        justify-self: start;
        align-self: start;
        width: 100%;
    }

    .hero-actions .btn {
        width: 100%;
        min-width: 0;
    }
}

/* Night Info */
.night-info { margin-top: 0.75rem; }

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.2rem 0;
    font-size: 0.85rem;
}

.info-row span:first-child { color: var(--text-secondary); }

.equipment-meta {
    margin: 0.55rem 0 0.8rem;
    padding: 0.35rem 0 0.1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.equipment-meta .info-row {
    font-size: 0.78rem;
    gap: 0.75rem;
    padding: 0.16rem 0;
}

.equipment-meta .info-row span:last-child {
    text-align: right;
    color: var(--text-primary);
    max-width: 68%;
    line-height: 1.35;
}

.spectral-chart-wrap {
    margin-top: 0.5rem;
    padding: 0.4rem 0.2rem 0;
    height: 200px;
    position: relative;
}

/* Target Cards */
.target-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.target-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s;
}

.target-card:hover { border-color: var(--accent); }

.target-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.target-rank {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent);
    min-width: 1.5rem;
}

.target-header h3 {
    font-size: 1rem;
    margin: 0;
    color: var(--text-primary);
}

.target-common-name {
    min-height: 1.35rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-style: italic;
    line-height: 1.35rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.target-common-name-empty {
    visibility: hidden;
}

.target-details, .target-exposure, .target-snr { margin-top: 0.5rem; }

.target-exposure {
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
}

.target-snr {
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
}

.target-snr h4 {
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    color: var(--accent);
}

.text-green { color: #4caf50; font-weight: 600; }
.text-muted { color: var(--text-muted); }
.text-yellow { color: #facc15; font-weight: 600; }
.text-red { color: #f87171; font-weight: 600; }
.text-orange { color: #ff9800; font-weight: 600; }

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.2rem 0;
    font-size: 0.85rem;
}

.detail-row > span:first-child {
    color: var(--text-secondary);
    flex: 0 0 42%;
    max-width: 42%;
    line-height: 1.45;
}

.detail-row > span:nth-child(2) {
    margin-left: auto;
    min-width: 0;
    text-align: right;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.detail-row > span:nth-child(3) {
    flex: 0 0 auto;
    margin-left: 0.25rem;
}

.detail-value {
    display: block;
}

.detail-value-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.05rem;
}

.detail-subvalue {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.detail-row-stack > span:first-child,
.detail-row-stack > .detail-value {
    padding-top: 0.05rem;
}

.score-badge {
    background: var(--accent);
    color: #000;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.8rem;
}

/* Table */
.table-wrapper { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.data-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover { background: var(--bg-secondary); }

.designation { font-weight: 600; color: var(--accent); }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.result-info {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 2rem;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 100%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 { margin: 0; }

.modal-body { padding: 1.5rem; }

.common-name {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 1rem;
}

/* Object Image */
.object-image-container {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.object-image {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

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

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* Utility */
[x-cloak] { display: none !important; }

/* Credits Page */
.credit-list { display: flex; flex-direction: column; gap: 1rem; }
.credit-item { padding: 0.75rem 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.credit-item:last-child { border-bottom: none; }
.credit-item strong { color: var(--accent-blue, #60a5fa); }
.credit-item p { margin: 0.25rem 0 0; font-size: 0.85em; color: var(--text-secondary, #aaa); line-height: 1.5; }
.credit-item a { color: var(--accent-blue, #60a5fa); text-decoration: none; }
.credit-item a:hover { text-decoration: underline; }
.credit-license { display: inline-block; margin-left: 0.5rem; font-size: 0.72em; padding: 0.1rem 0.4rem; border-radius: 3px; background: rgba(255,255,255,0.08); color: var(--text-secondary, #aaa); vertical-align: middle; }
.credit-ack { font-size: 0.78em !important; color: var(--text-secondary, #888) !important; margin-top: 0.4rem !important; }
