/* ====== Modern dark "night sky over the city" theme — one unified dark surface, no light/dark split ====== */

:root {
    --sky-deep: #0a1420;
    --sky-mid: #16233a;
    --surface: #16233a;
    --surface-alt: #1d2d47;
    --surface-raised: #223754;
    --ink: #eef2f6;
    --ink-soft: #b8c2cf;
    --border: #2c3e58;
    --teal: #2dd4bf;
    --teal-soft: rgba(45, 212, 191, 0.14);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.14);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background-color: var(--sky-deep);
    font-family: 'Inter', sans-serif;
    color: var(--ink);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 16px 96px;
    position: relative;
}

#bg-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

h1, h2, h3 {
    font-family: 'Space Grotesk', sans-serif;
}

/* ---------- Page card: masthead (skyline) + content panel ---------- */

.page-card {
    width: 100%;
    max-width: 1120px;
    margin-top: 32px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
    border: 1px solid var(--border);
}

.masthead {
    position: relative;
    background: linear-gradient(180deg, var(--sky-deep) 0%, var(--sky-mid) 100%);
    padding: 34px 40px 0;
    overflow: hidden;
}

.masthead-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
    position: relative;
    z-index: 2;
    color: var(--ink);
}

/* A soft teal glow that slowly drifts behind the title. */
.masthead::before {
    content: "";
    position: absolute;
    left: 50%;
    top: -50px;
    width: 680px;
    max-width: 120%;
    height: 280px;
    transform: translateX(-50%);
    background: radial-gradient(closest-side, rgba(45, 212, 191, 0.30), rgba(45, 212, 191, 0));
    filter: blur(26px);
    animation: glowDrift 10s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes glowDrift {
    from { transform: translateX(-58%) scale(1); }
    to   { transform: translateX(-42%) scale(1.12); }
}

/* The page title: white to teal lettering with a highlight that follows
   the cursor (see the title effect in shared/nav.js) and a gentle entrance. */
.masthead h1 {
    /* Starting position of the cursor highlight (off to the left, so it is
       hidden). nav.js updates these two values as the mouse moves. */
    --mx: -40%;
    --my: 50%;
    font-size: clamp(2.1rem, 4.6vw, 3.1rem);
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.03em;
    line-height: 1.1;
    background-image:
            radial-gradient(circle 170px at var(--mx) var(--my), rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 100%),
            linear-gradient(90deg, #eef2f6 0%, #d9fbf5 40%, #2dd4bf 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    filter: drop-shadow(0 6px 26px rgba(45, 212, 191, 0.35));
    animation: titleIn 1s cubic-bezier(0.2, 0.7, 0.2, 1) backwards;
}

@keyframes titleIn {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.98);
        filter: blur(10px) drop-shadow(0 6px 26px rgba(45, 212, 191, 0));
    }
    to {
        opacity: 1;
        transform: none;
        filter: blur(0) drop-shadow(0 6px 26px rgba(45, 212, 191, 0.35));
    }
}

.masthead .tagline {
    font-size: 0.98rem;
    color: var(--ink-soft);
    margin: 0 auto; /* keeps the capped tagline centered under the title */
    max-width: 480px;
    line-height: 1.5;
    animation: fadeUp 0.9s 0.25s ease backwards;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .masthead::before, .masthead h1, .masthead .tagline { animation: none; }
}

.skyline {
    display: block;
    width: 100%;
    height: auto;
    margin-top: 18px;
    position: relative;
    z-index: 1;
}

.skyline .twinkle {
    animation: twinkle 3.6s ease-in-out infinite;
}
.skyline .d1 { animation-delay: 0s; }
.skyline .d2 { animation-delay: 0.5s; }
.skyline .d3 { animation-delay: 1s; }
.skyline .d4 { animation-delay: 1.5s; }
.skyline .d5 { animation-delay: 2s; }
.skyline .d6 { animation-delay: 2.5s; }
.skyline .d7 { animation-delay: 1.2s; }
.skyline .d8 { animation-delay: 0.3s; }

@keyframes twinkle {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .skyline .twinkle { animation: none; opacity: 0.6; }
}

/* ---------- Nav (sits inside the masthead) ---------- */

.site-nav {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.site-nav a {
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--ink-soft);
    padding: 8px 15px;
    border-radius: 999px;
    transition: background 0.15s ease, color 0.15s ease;
}

.site-nav a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--ink);
}

.site-nav a.active {
    background: var(--teal);
    color: #0a1420;
    font-weight: 700;
}

/* ---------- Content panel (same dark surface family — no white split) ---------- */

.sheet {
    position: relative;
    width: 100%;
    background: var(--surface);
    padding: 40px 48px 52px;
    border-top: 1px solid var(--border);
}

/* ---------- Form fields ---------- */

.field-block {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 24px;
    margin-bottom: 30px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.82rem; color: var(--ink-soft); font-weight: 500; }

.field-hint {
    font-size: 0.74rem;
    color: var(--ink-soft);
    opacity: 0.8;
    margin-top: -2px;
}

.required-mark {
    color: var(--teal);
    margin-left: 2px;
}

.field select, .field input {
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    padding: 11px 13px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--surface-alt);
    color: var(--ink);
}

.field select:focus, .field input:focus {
    outline: none;
    border-color: var(--teal);
    background: var(--surface-raised);
}

.primary-btn {
    display: block;
    width: 100%;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 14px;
    background: var(--teal);
    color: #0a1420;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    letter-spacing: 0.01em;
    margin-bottom: 4px;
    transition: background 0.15s ease, transform 0.1s ease;
}
.primary-btn:hover { background: #3fe3cd; }
.primary-btn:active { transform: translateY(1px); }

.status-line {
    font-size: 0.85rem;
    color: var(--danger);
    min-height: 1.2em;
    margin: 10px 0 0;
}

/* ---------- Data rows (results) ---------- */

.ledger { margin-top: 34px; }
.ledger.hidden { display: none; }

.ledger-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 13px 14px;
    font-size: 0.95rem;
    border-radius: 10px;
}
.ledger-row:nth-child(odd) { background: var(--surface-alt); }
.ledger-row:nth-child(even) { background: transparent; }

.ledger-row .amount {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
}

.ledger-row.total {
    margin-top: 6px;
    font-weight: 700;
    background: var(--teal-soft);
}

.ledger-row.surplus .amount { color: var(--teal); }
.ledger-row.surplus.negative .amount { color: var(--danger); }

.notes {
    font-size: 0.84rem;
    color: var(--ink-soft);
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--surface-alt);
    border-left: 3px solid var(--teal);
}

/* ---------- Verdict badge ---------- */

.verdict-area {
    margin-top: 32px;
    display: flex;
    justify-content: center;
    min-height: 70px;
}

.verdict-card {
    margin-top: 26px;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 20px 24px;
    border-radius: 16px;
    transform: scale(0.85);
    opacity: 0;
}

.verdict-card.affordable {
    background: linear-gradient(135deg, rgba(45, 212, 191, 0.16), rgba(45, 212, 191, 0.06));
    border: 1px solid rgba(45, 212, 191, 0.35);
}
.verdict-card.over {
    background: linear-gradient(135deg, rgba(248, 113, 113, 0.16), rgba(248, 113, 113, 0.06));
    border: 1px solid rgba(248, 113, 113, 0.35);
}

.verdict-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}
.verdict-card.affordable .verdict-icon { background: var(--teal); color: #0a1420; }
.verdict-card.over .verdict-icon { background: var(--danger); color: #0a1420; }

.verdict-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
}
.verdict-card.affordable .verdict-title { color: var(--teal); }
.verdict-card.over .verdict-title { color: var(--danger); }

.verdict-detail {
    font-size: 0.88rem;
    color: var(--ink-soft);
    margin-top: 2px;
}

.math-explainer {
    margin-top: 18px;
    padding: 16px 18px;
    border-radius: 12px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--ink-soft);
    line-height: 1.7;
}
.math-explainer strong { color: var(--ink); font-weight: 600; }

@keyframes verdictIn {
    0%   { transform: scale(0.85); opacity: 0; }
    70%  { transform: scale(1.03); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
.verdict-card.animate { animation: verdictIn 0.4s ease-out forwards; }

@media (prefers-reduced-motion: reduce) {
    .verdict-card.animate { animation: none; transform: scale(1); opacity: 1; }
}

/* ---------- Live tape ---------- */

.live-tape {
    margin-top: 26px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.tape-head {
    font-family: 'Inter', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--ink-soft);
    background: var(--surface-raised);
    padding: 7px 14px;
}

.tape-lines {
    max-height: 130px;
    overflow-y: auto;
    padding: 6px 14px;
}

.tape-lines div {
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    padding: 4px 0;
    color: var(--ink);
}

.tape-lines .tape-total {
    font-weight: 700;
    color: var(--teal);
    border-top: 1px solid var(--border);
    margin-top: 4px;
    padding-top: 6px;
}

/* ---------- Ticker tape (homepage) ---------- */

.ticker {
    width: 100%;
    overflow: hidden;
    background: var(--sky-deep);
    border-radius: 10px;
    margin-top: 18px;
    padding: 10px 0;
    border: 1px solid var(--border);
}

.ticker-track {
    display: flex;
    width: max-content;
    animation: tickerScroll 22s linear infinite;
}

.ticker-track span {
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    color: var(--teal);
    white-space: nowrap;
    padding: 0 22px;
    border-right: 1px solid var(--border);
}

@keyframes tickerScroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
    .ticker-track { animation: none; }
}

.secondary-btn {
    display: block;
    width: 100%;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 13px;
    background: transparent;
    color: var(--ink-soft);
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    margin-top: 10px;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.secondary-btn:hover { border-color: var(--teal); color: var(--teal); }

.preview-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 10px;
    margin-bottom: 24px;
}

.preview-chip {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
}

.preview-chip .chip-label {
    font-size: 0.72rem;
    color: var(--ink-soft);
}

.preview-chip .chip-value {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 1.05rem;
    margin-top: 2px;
}

.preview-hint {
    font-size: 0.8rem;
    color: var(--ink-soft);
    margin: 6px 0 20px;
}

.estimate-tag {
    font-size: 0.72rem;
    color: var(--ink-soft);
    font-weight: 400;
    margin-left: 6px;
}

@media (max-width: 560px) {
    .preview-strip { grid-template-columns: 1fr; }
}

.match-row {
    border-radius: 10px;
    margin-bottom: 6px;
    overflow: hidden;
    background: var(--surface-alt);
}

.match-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
}
.match-summary:hover { background: var(--surface-raised); }

.match-summary .match-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.match-chevron {
    color: var(--ink-soft);
    font-size: 0.8rem;
    transition: transform 0.2s ease;
    display: inline-block;
}
.match-row.open .match-chevron {
    transform: rotate(180deg);
    color: var(--teal);
}

.results-hint {
    font-size: 0.82rem;
    color: var(--ink-soft);
    margin: 4px 0 12px;
}

.match-detail {
    padding: 4px 16px 18px;
    border-top: 1px solid var(--border);
}

.match-explain {
    font-size: 0.84rem;
    color: var(--ink-soft);
    line-height: 1.6;
    margin: 10px 0;
}
.match-explain strong { color: var(--ink); }

.hidden { display: none !important; }

footer.report-foot {
    margin-top: 40px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--ink-soft);
    text-align: center;
}

.coming-soon {
    padding: 60px 20px;
    text-align: center;
    color: var(--ink-soft);
    font-family: 'Space Grotesk', sans-serif;
}

@media (max-width: 560px) {
    .sheet { padding: 30px 24px 40px; }
    .masthead { padding: 22px 24px 0; }
    .field-block { grid-template-columns: 1fr; }
}