/*
 * Public cost calculator (/cost-calculator).
 *
 * Extends the shared public-pages.css design language -- the #667eea -> #764ba2 gradient,
 * 12-16px radii, soft indigo-tinted shadows -- rather than starting a second one. Everything
 * here is namespaced .cc-* so nothing leaks into the marketing pages that share the layout.
 *
 * Layout intent: inputs on the left and results on the right on a desktop, with the results
 * panel sticky so the headline figure stays in view while the form is edited; a single
 * column below 1000px with the results moved above the form, because on a phone the answer
 * is what the visitor came for and scrolling past a dozen fields to reach it is the whole
 * problem with calculators like this one.
 */

:root {
    --cc-indigo: #667eea;
    --cc-violet: #764ba2;
    --cc-ink: #0f172a;
    --cc-body: #4b5563;
    --cc-muted: #6b7280;
    --cc-line: #e9edf5;
    --cc-tint: #f5f7fe;
    --cc-green: #0f9d58;
    --cc-red: #dc2626;
}

/* ---------- Hero additions ---------- */

.cc-hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 1.5rem;
}

.cc-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.cc-hero-badge strong {
    font-weight: 800;
}

/* ---------- Tabs ---------- */

.cc-tabs {
    display: flex;
    gap: 6px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.28);
    padding: 6px;
    border-radius: 999px;
    margin: 1.75rem auto 0;
    width: fit-content;
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: center;
}

.cc-tab {
    appearance: none;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.92);
    font: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 10px 22px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.cc-tab:hover {
    background: rgba(255, 255, 255, 0.14);
}

.cc-tab[aria-selected="true"] {
    background: #fff;
    color: #4338ca;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.16);
}

.cc-tab:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.7);
    outline-offset: 2px;
}

/* ---------- Shell ---------- */

.cc-shell {
    max-width: 1200px;
    margin: -56px auto 0;
    padding: 0 20px 72px;
    position: relative;
    z-index: 10;
}

.cc-panel[hidden] {
    display: none !important;
}

.cc-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    gap: 1.5rem;
    align-items: start;
}

.cc-card {
    background: #fff;
    border: 1px solid var(--cc-line);
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.07);
    padding: 1.75rem;
}

.cc-card + .cc-card {
    margin-top: 1.5rem;
}

.cc-card-title {
    margin: 0 0 0.35rem;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--cc-ink);
}

.cc-card-hint {
    margin: 0 0 1.5rem;
    color: var(--cc-muted);
    font-size: 0.92rem;
    line-height: 1.55;
}

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

.cc-field {
    margin-bottom: 1.15rem;
}

.cc-field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.cc-label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: #111827;
}

.cc-label-note {
    font-weight: 400;
    color: var(--cc-muted);
}

.cc-input-wrap {
    position: relative;
    display: block;
}

.cc-input-prefix,
.cc-input-suffix {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cc-muted);
    font-weight: 600;
    font-size: 0.95rem;
    pointer-events: none;
}

.cc-input-prefix { left: 13px; }
.cc-input-suffix { right: 13px; }

.cc-input,
.cc-select {
    width: 100%;
    box-sizing: border-box;
    padding: 11px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 11px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--cc-ink);
    background: #fff;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.cc-input-wrap .cc-input { padding-left: 30px; }
.cc-input-wrap--suffix .cc-input { padding-left: 14px; padding-right: 34px; }

.cc-input:focus,
.cc-select:focus {
    border-color: var(--cc-indigo);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.14);
    outline: none;
}

/* Spinners fight with the live recalculation, and the figures here are typed, not nudged. */
.cc-input::-webkit-outer-spin-button,
.cc-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.cc-input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* ---------- Toggles ---------- */

.cc-toggles {
    display: grid;
    gap: 0.6rem;
}

.cc-toggle {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 11px 13px;
    border: 1px solid var(--cc-line);
    border-radius: 11px;
    background: #fcfdff;
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease;
}

.cc-toggle:hover {
    border-color: #c7d2fe;
    background: var(--cc-tint);
}

.cc-toggle input {
    width: 18px;
    height: 18px;
    margin: 1px 0 0;
    accent-color: var(--cc-indigo);
    flex-shrink: 0;
    cursor: pointer;
}

.cc-toggle:focus-within {
    border-color: var(--cc-indigo);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.13);
}

.cc-toggle-text {
    font-size: 0.9rem;
    line-height: 1.45;
}

.cc-toggle-text strong {
    display: block;
    color: #111827;
    font-weight: 650;
}

.cc-toggle-text span {
    color: var(--cc-muted);
    font-size: 0.85rem;
}

/* ---------- Segmented control ---------- */

.cc-segment {
    display: flex;
    gap: 4px;
    background: #f1f3f9;
    padding: 4px;
    border-radius: 11px;
}

.cc-segment label {
    flex: 1;
    position: relative;
    text-align: center;
}

.cc-segment input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.cc-segment span {
    display: block;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 650;
    color: #5b6472;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
    line-height: 1.3;
}

.cc-segment input:checked + span {
    background: #fff;
    color: #4338ca;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.1);
}

.cc-segment input:focus-visible + span {
    outline: 2px solid var(--cc-indigo);
    outline-offset: 1px;
}

/* ---------- Collapsible extras ---------- */

.cc-more {
    border: 1px solid var(--cc-line);
    border-radius: 11px;
    background: #fcfdff;
    margin-top: 1.15rem;
}

.cc-more > summary {
    cursor: pointer;
    list-style: none;
    padding: 12px 14px;
    font-weight: 650;
    font-size: 0.92rem;
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.cc-more > summary::-webkit-details-marker { display: none; }

.cc-more > summary::after {
    content: "＋";
    color: var(--cc-indigo);
    font-weight: 700;
}

.cc-more[open] > summary::after { content: "－"; }

.cc-more[open] > summary {
    border-bottom: 1px solid var(--cc-line);
}

.cc-more-body {
    padding: 1.15rem 14px 0.35rem;
}

/* ---------- Result ---------- */

.cc-result {
    position: sticky;
    top: 20px;
}

.cc-headline {
    background: linear-gradient(135deg, var(--cc-indigo) 0%, var(--cc-violet) 100%);
    border-radius: 16px;
    padding: 1.75rem;
    color: #fff;
    box-shadow: 0 16px 36px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

.cc-headline::after {
    content: "";
    position: absolute;
    width: 220px;
    height: 220px;
    right: -70px;
    top: -90px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    filter: blur(30px);
}

.cc-headline-inner {
    position: relative;
    z-index: 1;
}

.cc-headline-label {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    opacity: 0.88;
    margin: 0 0 0.35rem;
}

.cc-headline-value {
    font-size: 2.6rem;
    font-weight: 800;
    line-height: 1.1;
    margin: 0;
    letter-spacing: -0.5px;
    /* Digits change on every keystroke; tabular figures stop the number jittering. */
    font-variant-numeric: tabular-nums;
}

.cc-headline-sub {
    margin: 0.5rem 0 0;
    font-size: 0.95rem;
    opacity: 0.92;
}

.cc-headline-split {
    display: flex;
    gap: 1.25rem;
    margin-top: 1.35rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.24);
    flex-wrap: wrap;
}

.cc-headline-split div {
    flex: 1;
    min-width: 110px;
}

.cc-headline-split dt {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.82;
    font-weight: 700;
    margin-bottom: 3px;
}

.cc-headline-split dd {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
}

/* Proportion bar: take-home against everything withheld. */
.cc-bar {
    display: flex;
    height: 9px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.24);
    margin-top: 1.35rem;
}

.cc-bar span {
    display: block;
    transition: width 0.3s ease;
}

.cc-bar-take { background: #fff; }
.cc-bar-cut { background: rgba(255, 255, 255, 0.38); }

.cc-bar-legend {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin-top: 0.7rem;
    font-size: 0.82rem;
    opacity: 0.92;
}

.cc-bar-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cc-bar-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ---------- Breakdown tables ---------- */

.cc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.93rem;
}

.cc-table caption {
    text-align: left;
    font-weight: 800;
    color: var(--cc-ink);
    font-size: 1rem;
    padding-bottom: 0.7rem;
}

.cc-table th,
.cc-table td {
    padding: 9px 0;
    border-bottom: 1px solid #f1f3f8;
    text-align: left;
    font-weight: 400;
    color: var(--cc-body);
}

.cc-table td:last-child,
.cc-table th:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    font-weight: 600;
    color: #1f2937;
}

.cc-table tbody tr:last-child th,
.cc-table tbody tr:last-child td {
    border-bottom: none;
}

.cc-table tfoot th,
.cc-table tfoot td {
    border-top: 2px solid var(--cc-line);
    border-bottom: none;
    padding-top: 11px;
    font-weight: 800;
    color: var(--cc-ink);
}

.cc-table-note {
    color: var(--cc-muted);
    font-size: 0.82rem;
    display: block;
    font-weight: 400;
    margin-top: 2px;
}

.cc-table--split {
    margin-top: 1.5rem;
}

.cc-table-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1.75rem;
}

.cc-amount-out td:last-child,
.cc-amount-out th:last-child { color: var(--cc-red); }

.cc-amount-in td:last-child,
.cc-amount-in th:last-child { color: var(--cc-green); }

/* ---------- Callouts ---------- */

.cc-note {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 11px;
    font-size: 0.88rem;
    line-height: 1.55;
    margin-top: 1.25rem;
    border-left: 3px solid;
}

.cc-note-icon { flex-shrink: 0; }

.cc-note--info {
    background: #eff6ff;
    color: #1e40af;
    border-color: #3b82f6;
}

.cc-note--warn {
    background: #fffbeb;
    color: #92400e;
    border-color: #f59e0b;
}

.cc-note--good {
    background: #ecfdf5;
    color: #065f46;
    border-color: #10b981;
}

.cc-note[hidden] { display: none !important; }

/* ---------- Regime comparison ---------- */

.cc-compare {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-top: 0.35rem;
}

.cc-compare-item {
    border: 1px solid var(--cc-line);
    border-radius: 12px;
    padding: 1.1rem 1.15rem;
    background: #fcfdff;
}

.cc-compare-item[data-better="true"] {
    border-color: #a7f3d0;
    background: #f0fdf7;
}

.cc-compare-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--cc-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin: 0 0 0.3rem;
}

.cc-compare-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--cc-ink);
    margin: 0;
    font-variant-numeric: tabular-nums;
}

.cc-compare-foot {
    font-size: 0.82rem;
    color: var(--cc-muted);
    margin: 0.3rem 0 0;
}

/* ---------- Editorial content ---------- */

.cc-prose {
    max-width: 820px;
    margin: 0 auto;
    padding: 4rem 20px 0;
    color: var(--cc-body);
    line-height: 1.75;
}

.cc-prose h2 {
    font-size: 1.75rem;
    color: var(--cc-ink);
    margin: 3rem 0 0.85rem;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.cc-prose h2:first-child { margin-top: 0; }

.cc-prose h3 {
    font-size: 1.12rem;
    color: #1f2937;
    margin: 1.85rem 0 0.5rem;
    font-weight: 700;
}

.cc-prose p { margin: 0 0 1.1rem; }

.cc-prose ul { margin: 0 0 1.1rem; padding-left: 1.3rem; }
.cc-prose li { margin-bottom: 0.5rem; }

.cc-prose a {
    color: #4f46e5;
    font-weight: 600;
}

.cc-prose strong { color: #1f2937; }

.cc-scroll {
    overflow-x: auto;
    margin: 0 0 1.5rem;
    border: 1px solid var(--cc-line);
    border-radius: 12px;
    background: #fff;
}

.cc-reference {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 480px;
}

.cc-reference caption {
    caption-side: top;
    text-align: left;
    padding: 1rem 1.1rem 0.5rem;
    font-weight: 700;
    color: var(--cc-ink);
}

.cc-reference th,
.cc-reference td {
    padding: 10px 1.1rem;
    border-bottom: 1px solid #f1f3f8;
    text-align: left;
}

.cc-reference thead th {
    background: var(--cc-tint);
    font-weight: 700;
    color: #374151;
    font-size: 0.85rem;
    white-space: nowrap;
}

.cc-reference tbody td { color: var(--cc-body); }
.cc-reference tbody tr:last-child td { border-bottom: none; }
.cc-reference td:not(:first-child) { font-variant-numeric: tabular-nums; }

/* ---------- FAQ ---------- */

.cc-faq {
    background: #fff;
    border: 1px solid var(--cc-line);
    border-radius: 12px;
    margin-bottom: 0.7rem;
}

.cc-faq[open] {
    border-color: #c7d2fe;
    box-shadow: 0 8px 22px rgba(102, 126, 234, 0.1);
}

.cc-faq > summary {
    cursor: pointer;
    list-style: none;
    padding: 1rem 2.9rem 1rem 1.15rem;
    font-weight: 650;
    color: #1f2937;
    position: relative;
    line-height: 1.5;
}

.cc-faq > summary::-webkit-details-marker { display: none; }

.cc-faq > summary::after {
    content: "+";
    position: absolute;
    right: 1.15rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.35rem;
    color: var(--cc-indigo);
}

.cc-faq[open] > summary::after { content: "\2212"; }

.cc-faq > summary:focus-visible {
    outline: 2px solid var(--cc-indigo);
    outline-offset: 2px;
    border-radius: 12px;
}

.cc-faq-body {
    padding: 0 1.15rem 1.15rem;
    font-size: 0.95rem;
}

.cc-faq-body > :first-child { margin-top: 0; }
.cc-faq-body > :last-child { margin-bottom: 0; }

/* ---------- Disclaimer + CTA ---------- */

.cc-disclaimer {
    max-width: 820px;
    margin: 3rem auto 0;
    padding: 1.35rem 1.5rem;
    background: #f9fafb;
    border: 1px solid var(--cc-line);
    border-radius: 12px;
    color: var(--cc-muted);
    font-size: 0.87rem;
    line-height: 1.65;
}

.cc-disclaimer h2 {
    font-size: 0.95rem;
    color: #374151;
    margin: 0 0 0.5rem;
    font-weight: 700;
}

.cc-disclaimer p { margin: 0 0 0.6rem; }
.cc-disclaimer p:last-child { margin-bottom: 0; }

.cc-cta {
    max-width: 1200px;
    margin: 4rem auto 0;
    padding: 3rem 1.5rem;
    text-align: center;
    background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 100%);
    border-radius: 16px;
}

.cc-cta h2 {
    font-size: 1.9rem;
    color: var(--cc-ink);
    margin: 0 0 0.6rem;
    font-weight: 800;
}

.cc-cta p {
    color: var(--cc-muted);
    margin: 0 auto;
    max-width: 560px;
    line-height: 1.65;
}

.cc-cta-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.6rem;
}

.cc-outro {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 80px;
}

/* ---------- Utilities ---------- */

.cc-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;
}

/* Fades the results a touch while a recalculation is in flight, so a slow connection looks
   busy rather than broken. Values stay readable throughout -- never blanked. */
.cc-result[data-busy="true"] .cc-card,
.cc-result[data-busy="true"] .cc-headline {
    opacity: 0.72;
    transition: opacity 0.15s ease;
}

/* ---------- Responsive ---------- */

@media (max-width: 1000px) {
    .cc-grid {
        grid-template-columns: 1fr;
    }

    /* The answer comes first on a narrow screen; the form is what you scroll to. */
    .cc-result {
        position: static;
        order: -1;
    }

    .cc-shell {
        margin-top: -40px;
    }
}

@media (max-width: 640px) {
    .cc-shell {
        padding: 0 14px 56px;
        margin-top: -28px;
    }

    .cc-card {
        padding: 1.25rem;
        border-radius: 14px;
    }

    .cc-headline {
        padding: 1.35rem;
    }

    .cc-headline-value {
        font-size: 2.1rem;
    }

    .cc-tabs {
        width: 100%;
    }

    .cc-tab {
        flex: 1;
        padding: 10px 12px;
        font-size: 0.88rem;
    }

    .cc-table-grid {
        gap: 1.35rem;
    }

    .cc-prose {
        padding-top: 2.75rem;
    }

    .cc-prose h2 {
        font-size: 1.45rem;
    }

    .cc-cta {
        padding: 2.25rem 1.15rem;
        border-radius: 14px;
    }

    .cc-cta h2 {
        font-size: 1.45rem;
    }
}

/* A 16px font stops iOS Safari zooming the viewport when a field takes focus. */
@media (max-width: 480px) {
    .cc-input,
    .cc-select {
        font-size: 16px;
    }
}

@media print {
    .navbar,
    .footer,
    .cc-tabs,
    .cc-cta,
    form.cc-form {
        display: none !important;
    }

    .cc-headline {
        box-shadow: none;
        color: #000;
        background: none;
        border: 1px solid #999;
    }
}
