/* ==========================================================================
   Sacramento Storm Season Loss Calculator — page-missed-call-audit.php
   Adapted from the standalone missed-call-loss-calculator.html.

   Design intent: match the rest of the site (Manrope, brand-blue accents,
   white/elevated card surfaces) instead of the standalone's dark earthy
   palette. The standalone was a self-contained tool with its own design
   language; embedded inline on a WP page, it needs to feel like part of the
   site, not a foreign artifact.

   Scoping: every rule is scoped to .calculator-container so generic element
   selectors (label, input[type="number"], input[type="range"]) don't bleed
   into the rest of the page. The container also re-establishes a few local
   tokens (--calc-*) for the result/punch palette so we don't sprinkle
   alpha-channel rgba() literals through the file.
   ========================================================================== */

.calculator-container {
    /* Calculator-local tokens — derived from the global --ig-* palette so the
       tool inherits brand colors automatically if the theme palette shifts.
       --calc-loss-* is the red-tinted result palette (the loss number is the
       emotional anchor; it deserves a slightly warmer treatment than a plain
       brand-blue card). */
    --calc-loss: var(--ig-red);
    --calc-loss-soft: rgba(220, 38, 38, 0.06);
    --calc-loss-border: rgba(220, 38, 38, 0.18);
    --calc-loss-glow: rgba(220, 38, 38, 0.12);
    --calc-accent: var(--ig-blue);
    --calc-accent-deep: var(--ig-blue-deep);
    --calc-accent-soft: var(--ig-blue-soft);
    --calc-accent-border: var(--ig-blue-border);

    max-width: 720px;
    margin: 0 auto;
    font-family: var(--ig-font);
    color: var(--ig-text-secondary);
    line-height: 1.6;
}

.calculator-container * {
    box-sizing: border-box;
}

.calculator-container .container-inner {
    position: relative;
}

/* ---------- HEADER ---------- */
.calculator-container .calc-header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--ig-border);
}

.calculator-container .eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--calc-accent-soft);
    border: 1px solid var(--calc-accent-border);
    border-radius: var(--ig-r-pill);
    padding: 8px 18px;
    font-size: .78rem;
    font-weight: 600;
    color: var(--calc-accent-deep);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 20px;
}

.calculator-container h1,
.calculator-container .calc-header h2 {
    font-family: var(--ig-font);
    font-size: clamp(1.75rem, 4.5vw, 2.6rem);
    font-weight: 800;
    color: var(--ig-text);
    line-height: 1.15;
    margin: 0 0 14px;
    letter-spacing: -0.02em;
}

.calculator-container h1 .accent,
.calculator-container .calc-header h2 .accent {
    background: var(--ig-gradient-accent);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradient-shift 6s ease-in-out infinite;
}

.calculator-container .subhead {
    color: var(--ig-text-muted);
    font-size: 1rem;
    max-width: 540px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ---------- INPUT CARD ---------- */
.calculator-container .card {
    background: var(--ig-bg-card);
    border: 1px solid var(--ig-border);
    border-radius: var(--ig-r-2xl);
    padding: 32px 28px;
    margin-bottom: 20px;
    box-shadow: var(--ig-shadow-card);
    position: relative;
}

.calculator-container .card-label {
    font-size: .72rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--calc-accent-deep);
    margin-bottom: 24px;
    font-weight: 700;
}

.calculator-container .input-group,
.calculator-container .slider-group {
    margin-bottom: 26px;
}

.calculator-container .input-group:last-child,
.calculator-container .slider-group:last-child {
    margin-bottom: 0;
}

.calculator-container label {
    display: block;
    color: var(--ig-text);
    font-size: .95rem;
    margin-bottom: 6px;
    font-weight: 700;
}

.calculator-container .helper {
    color: var(--ig-text-muted);
    font-size: .85rem;
    line-height: 1.55;
    margin-bottom: 14px;
}

.calculator-container input[type="number"],
.calculator-container select {
    width: 100%;
    background: var(--ig-bg-card);
    border: 1.5px solid var(--ig-border-strong);
    color: var(--ig-text);
    padding: 12px 14px;
    font-family: inherit;
    font-size: 1rem;
    border-radius: var(--ig-r-md);
    transition: border-color .2s ease, box-shadow .2s ease;
}

.calculator-container input[type="number"]:focus,
.calculator-container select:focus {
    outline: none;
    border-color: var(--calc-accent);
    box-shadow: 0 0 0 3px var(--calc-accent-soft);
}

/* ---------- SLIDER ---------- */
.calculator-container .slider-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.calculator-container input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    background: var(--ig-bg-elevated);
    border: 1px solid var(--ig-border);
    border-radius: var(--ig-r-pill);
    height: 8px;
    outline: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
}

.calculator-container input[type="range"]:focus-visible {
    outline: 2px solid var(--calc-accent);
    outline-offset: 2px;
}

.calculator-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    background: var(--calc-accent);
    border: 3px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(45, 123, 201, 0.32);
    transition: transform .15s ease, box-shadow .15s ease;
}

.calculator-container input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(45, 123, 201, 0.42);
}

.calculator-container input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    background: var(--calc-accent);
    border: 3px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(45, 123, 201, 0.32);
    transition: transform .15s ease, box-shadow .15s ease;
}

.calculator-container input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(45, 123, 201, 0.42);
}

.calculator-container .slider-value {
    /* Fixed width (was min-width) so all five input pills are exactly the
       same size regardless of whether the row has a $ prefix, % suffix, x
       suffix, or no decoration at all. Right edges of all pills align
       cleanly down the input column. 124px fits the widest case ($1,200
       with $ prefix) with breathing room. */
    width: 124px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--calc-accent-deep);
    font-family: var(--ig-font);
    background: var(--calc-accent-soft);
    border: 1.5px solid var(--calc-accent-border);
    border-radius: var(--ig-r-md);
    padding: 8px 12px;
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
    margin-bottom: 0;
}

.calculator-container .slider-value:focus-within {
    border-color: var(--calc-accent);
    background: #fff;
    box-shadow: 0 0 0 3px var(--calc-accent-soft);
}

.calculator-container .slider-value-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--calc-accent-deep);
    font: inherit;
    font-weight: 700;
    text-align: right;
    padding: 0;
    margin: 0;
    -moz-appearance: textfield;
}

.calculator-container .slider-value-input::-webkit-outer-spin-button,
.calculator-container .slider-value-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.calculator-container .slider-value-input:focus {
    outline: none;
}

.calculator-container .slider-value-prefix,
.calculator-container .slider-value-suffix {
    color: var(--calc-accent-deep);
    flex-shrink: 0;
    font-weight: 700;
}

/* ---------- RESULT ---------- */
.calculator-container .result-card {
    background: linear-gradient(180deg, #fff 0%, var(--calc-loss-soft) 100%);
    border: 1.5px solid var(--calc-loss-border);
    border-radius: var(--ig-r-2xl);
    padding: 36px 32px;
    text-align: center;
    margin-top: 28px;
    margin-bottom: 20px;
    box-shadow: 0 8px 28px var(--calc-loss-glow);
    position: relative;
    overflow: hidden;
}

.calculator-container .result-label {
    color: var(--ig-text-muted);
    font-size: .9rem;
    margin-bottom: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.calculator-container .result-amount {
    font-family: var(--ig-font);
    font-size: clamp(2.75rem, 9vw, 4.6rem);
    font-weight: 800;
    color: var(--calc-loss);
    line-height: 1;
    margin-bottom: 6px;
    letter-spacing: -0.03em;
}

.calculator-container .result-period {
    color: var(--ig-text-muted);
    font-size: .95rem;
    margin-bottom: 28px;
}

.calculator-container .result-breakdown {
    /* Constrain width and auto-margin so the 2x2 stat grid is centered
       inside the result card instead of stretching edge-to-edge with
       lopsided whitespace. text-align: center inside each cell makes the
       label + value visually centered above each other. */
    border-top: 1px solid var(--ig-border);
    padding-top: 24px;
    margin: 12px auto 0;
    max-width: 420px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 32px;
    text-align: center;
}

.calculator-container .breakdown-item {
    display: flex;
    flex-direction: column;
}

.calculator-container .breakdown-label {
    color: var(--ig-text-muted);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    margin-bottom: 4px;
    font-weight: 600;
}

.calculator-container .breakdown-value {
    color: var(--ig-text);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* ---------- PUNCH ---------- */
.calculator-container .punch {
    background: var(--calc-accent-soft);
    border: 1px solid var(--calc-accent-border);
    color: var(--ig-text);
    padding: 18px 20px;
    margin-top: 24px;
    border-radius: var(--ig-r-lg);
}

.calculator-container .punch-headline {
    font-size: 1rem;
    line-height: 1.55;
    color: var(--ig-text);
    font-weight: 500;
}

.calculator-container .punch-headline strong {
    color: var(--calc-accent-deep);
    font-weight: 800;
}

/* ---------- CTA ---------- */
.calculator-container .cta-section {
    text-align: center;
    margin-top: 28px;
}

/* The .cta-stack wrapper is inline-block so it shrink-wraps to the widest
   child — which is the secondary text line below the button. The button
   then fills that wrapper width. Net effect: the button width tracks the
   secondary text width naturally on every viewport without hard-coded
   sizes. max-width: 100% prevents the button from exceeding its parent on
   very narrow viewports. */
.calculator-container .cta-stack {
    display: inline-block;
    max-width: 100%;
    text-align: center;
}

.calculator-container .cta-button {
    display: flex;                  /* was inline-flex; we want full wrapper width */
    width: 100%;
    align-items: center;
    justify-content: center;        /* center label + arrow inside the pill */
    gap: 8px;
    background: var(--ig-gradient);
    color: #fff;
    padding: 16px 32px;
    border: none;
    border-radius: var(--ig-r-md);
    font-family: inherit;
    font-size: 1.02rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: opacity .2s ease, transform .2s ease, box-shadow .2s ease;
    box-shadow: 0 6px 18px rgba(45, 123, 201, 0.25);
    box-sizing: border-box;
}

.calculator-container .cta-button:hover {
    opacity: .92;
    transform: translateY(-2px);
    color: #fff;
    box-shadow: var(--ig-shadow-glow);
}

.calculator-container .cta-button:active {
    transform: translateY(0);
}

.calculator-container .cta-secondary {
    display: block;
    margin-top: 14px;
    color: var(--ig-text-muted);
    font-size: .92rem;
}

.calculator-container .cta-secondary a {
    color: var(--calc-accent-deep);
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 600;
}

.calculator-container .cta-secondary a:hover {
    color: var(--calc-accent);
}

/* ---------- EMAIL CAPTURE ---------- */
.calculator-container .email-section {
    background: var(--ig-bg-elevated);
    border: 1px dashed var(--ig-border-strong);
    padding: 28px 24px;
    margin-top: 24px;
    border-radius: var(--ig-r-2xl);
    text-align: center;
}

.calculator-container .email-section h3 {
    font-family: var(--ig-font);
    font-size: 1.15rem;
    color: var(--ig-text);
    margin: 0 0 8px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.calculator-container .email-section p {
    color: var(--ig-text-muted);
    font-size: .92rem;
    margin: 0 0 16px;
    line-height: 1.6;
}

.calculator-container .email-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: stretch;
}

.calculator-container .email-row input {
    flex: 1;
    min-width: 200px;
}

.calculator-container .email-submit {
    background: var(--calc-accent-deep);
    color: #fff;
    border: none;
    padding: 0 24px;
    font-family: inherit;
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: var(--ig-r-md);
    transition: background .2s ease, transform .15s ease;
    white-space: nowrap;
}

.calculator-container .email-submit:hover {
    background: var(--calc-accent);
    transform: translateY(-1px);
}

.calculator-container .email-submit:disabled,
.calculator-container .email-submit.is-sending {
    /* Disabled-during-submit state: shows a "working on it" cursor and a
       slight opacity dip — never the browser's default greyed-out look,
       which felt broken with the brand-blue. The .is-sending class
       guarantees the same look even on browsers that don't honor :disabled
       styling cleanly. */
    opacity: .8;
    cursor: progress;
    transform: none;
    background: var(--calc-accent-deep);
}

/* ---------- POST-SEND SUCCESS CARD ---------- */
/* Replaces the email row (input + button + fineprint + heading + lead) after
   a successful submission. Renders as a green-tinted notice with an inline
   checkmark — clear "we got it" feedback without leaving a disabled button
   cluttering the page. */
.calculator-container .email-success {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 20px;
    background: rgba(5, 150, 105, 0.08);
    border: 1px solid rgba(5, 150, 105, 0.25);
    border-radius: var(--ig-r-md);
    text-align: left;
    margin-top: 4px;
}
.calculator-container .email-success-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--ig-green);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1;
}
.calculator-container .email-success-body {
    color: var(--ig-text-secondary);
    font-size: .95rem;
    line-height: 1.55;
}
.calculator-container .email-success-body strong {
    display: inline;
    color: var(--ig-text);
    font-weight: 700;
    margin-right: 4px;
}

.calculator-container .email-fineprint {
    margin-top: 14px;
    font-size: .75rem;
    color: var(--ig-text-dim);
}

/* ---------- FOOTER ---------- */
.calculator-container .calc-footer {
    text-align: center;
    margin-top: 36px;
    padding-top: 24px;
    border-top: 1px solid var(--ig-border);
    color: var(--ig-text-muted);
    font-size: .8rem;
    line-height: 1.7;
}

.calculator-container .calc-footer .brand {
    color: var(--calc-accent-deep);
    font-weight: 700;
}

/* ---------- ANIMATIONS ---------- */
@keyframes calc-pulse-counter {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.04); }
}

.calculator-container .result-amount.pulse {
    animation: calc-pulse-counter 0.4s ease-out;
}

.calculator-container .hidden {
    display: none;
}

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
    .calculator-container .card {
        padding: 24px 20px;
    }
    .calculator-container .result-card {
        padding: 28px 20px;
    }
    .calculator-container .result-breakdown {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    .calculator-container .email-row {
        flex-direction: column;
    }
    .calculator-container .email-row input {
        min-width: 0;
    }
    .calculator-container .email-submit {
        padding: 14px 24px;
    }
    .calculator-container .slider-row {
        gap: 10px;
    }
    .calculator-container .slider-value {
        width: 104px;
        padding: 6px 10px;
        font-size: 1rem;
    }
}
