/* =========================================================
   PREDY HOMES - TOOLS & CALCULATORS STYLESHEET
   Dark Luxury Theme, Clean Modern Inputs, Responsive Grids,
   Mobile Touch Ergonomics & Real-Time Live Visualizations
========================================================= */

/* Prevent Mobile Viewport Zoom & Horizontal Overflow */
html,
body.tools-page {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
}

body.tools-page *,
body.tools-page *::before,
body.tools-page *::after {
    box-sizing: border-box;
}

/* Hero */
.tools-hero {
    padding: 140px 0 30px;
    background: radial-gradient(circle at 50% 20%, rgba(255, 199, 44, 0.04) 0%, transparent 60%);
    text-align: center;
}

.tools-hero-inner {
    max-width: 860px;
    margin: 0 auto;
}

.tools-title {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-weight: 500;
    font-size: clamp(2.4rem, 5vw, 4.4rem);
    line-height: .98;
    letter-spacing: -.05em;
    color: var(--white);
    margin: 0 auto 16px;
}

.tools-title em {
    color: var(--gold);
    font-style: normal;
}

.tools-subtitle {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--muted);
    font-size: clamp(0.95rem, 1.5vw, 1.15rem);
    line-height: 1.6;
    max-width: 680px;
    margin: 0 auto;
}

/* Tool Tab Navigation Wrapper - Sticky across the entire calculator workspace */
.tools-nav-wrapper {
    position: sticky;
    top: var(--header-height, 84px);
    z-index: 850;
    width: 100%;
    max-width: 100vw;
    background: rgba(10, 10, 10, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid var(--line);
    margin-bottom: 36px;
    overflow: hidden;
    box-sizing: border-box;
}

.tools-nav-scroll-container {
    width: 100%;
    max-width: var(--max-width, 1400px);
    margin: 0 auto;
    display: flex;
    justify-content: center;
    padding: 10px 16px;
    box-sizing: border-box;
}

.tools-nav-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin: 0 auto;
    padding: 0;
    width: 100%;
    max-width: 480px;
}

.tool-tab-btn {
    padding: 8px 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
    border-radius: 40px;
    cursor: pointer;
    transition: all .2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    min-height: 38px;
}

.tool-tab-btn svg {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.tool-tab-btn:hover {
    color: var(--white);
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.06);
}

.tool-tab-btn.active {
    color: #000;
    background: var(--gold);
    border-color: var(--gold);
    font-weight: 600;
}

.tool-tab-btn.active svg {
    stroke: #000;
}

/* Tool Panel Section */
.tools-section {
    padding: 0 0 100px;
}

.tool-panel {
    display: none;
}

.tool-panel.active {
    display: block;
    animation: toolFadeIn 0.35s ease;
}

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

/* Unified Calculator Layout (Homepage / Single-Card Style) */
.tools-page .calculator-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(40px, 6vw, 90px);
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.tools-page .calculator-copy {
    max-width: 580px;
}

.tools-page .calculator-copy .section-title {
    font-size: clamp(2.4rem, 4.4vw, 4.2rem);
    line-height: .96;
    letter-spacing: -.05em;
    margin-top: 0;
}

.tools-page .calculator-copy .section-subtitle {
    margin-top: 24px;
    font-size: clamp(1.05rem, 1.35vw, 1.25rem);
    line-height: 1.65;
    color: var(--white-soft);
    max-width: 520px;
}

.tools-page .calculator-card {
    background: linear-gradient(145deg, rgba(255,255,255,.07), rgba(255,255,255,.025));
    border: 1px solid var(--line);
    padding: clamp(28px, 4vw, 48px);
    border-radius: 6px;
    width: 100%;
    box-sizing: border-box;
}

.tools-page .price-slider {
    touch-action: pan-y;
}

/* Tool Grid Layout (Fallback for legacy multi-card tools) */
.tool-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 40px;
    align-items: start;
    max-width: 1140px;
    margin: 0 auto;
}

/* Controls Card */
.tool-controls-card {
    background: linear-gradient(145deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
    border: 1px solid var(--line);
    padding: clamp(24px, 3.5vw, 40px);
    border-radius: 8px;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.tool-card-title {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-weight: 500;
    font-size: clamp(1.8rem, 3.2vw, 2.5rem);
    line-height: 1.1;
    letter-spacing: -.03em;
    color: var(--white);
    margin: 0 0 12px;
}

.tool-card-title em {
    color: var(--gold);
    font-style: normal;
}

.tool-card-desc {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
    margin: 0 0 24px;
}

.tool-field-group {
    margin-bottom: 24px;
}

.tool-controls-card .tool-field-group:last-child {
    margin-bottom: 0;
}

.tool-field-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 10px;
}

.tool-field-value-badge {
    color: var(--gold);
    font-weight: 600;
}

.tool-input-row {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 16px;
    min-height: 52px;
    transition: border-color 0.2s ease;
}

.tool-input-row:focus-within {
    border-color: var(--gold);
}

.tool-input-prefix,
.tool-input-suffix {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 18px;
    color: var(--muted);
    font-weight: 500;
}

.tool-num-input {
    flex: 1;
    background: transparent;
    border: 0;
    padding: 12px 10px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: clamp(1.35rem, 2.2vw, 1.85rem);
    font-weight: 500;
    color: var(--white);
    outline: none;
    font-variant-numeric: tabular-nums;
}

/* Slider Controls with Enhanced Touch Thumb */
.tool-slider {
    width: 100%;
    margin-top: 14px;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: rgba(255,255,255,.18);
    outline: none;
    cursor: pointer;
    touch-action: pan-y;
}

.tool-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--gold);
    cursor: pointer;
    box-shadow: 0 0 12px rgba(255,199,44,.5);
    border: 2px solid #000;
    transition: transform .15s ease;
}

.tool-slider::-webkit-slider-thumb:hover,
.tool-slider::-webkit-slider-thumb:active {
    transform: scale(1.18);
}

.tool-slider::-moz-range-thumb {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--gold);
    cursor: pointer;
    box-shadow: 0 0 12px rgba(255,199,44,.5);
    border: 2px solid #000;
}

/* Toggle Switch Buttons */
.tool-toggle-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.tool-toggle-btn {
    min-height: 48px;
    padding: 10px 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13.5px;
    font-weight: 500;
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--line);
    color: var(--muted);
    border-radius: 6px;
    cursor: pointer;
    transition: all .2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-toggle-btn:hover {
    color: var(--white);
    border-color: rgba(255, 255, 255, 0.2);
}

.tool-toggle-btn.active {
    background: rgba(255, 199, 44, 0.12);
    border-color: var(--gold);
    color: var(--gold);
    font-weight: 600;
}


/* Touch-Optimized Rate Stepper Control */
.tool-rate-touch-control {
    display: flex;
    align-items: stretch;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    min-height: 54px;
    transition: border-color 0.2s ease;
}

.tool-rate-touch-control:focus-within {
    border-color: var(--gold);
}

.tool-stepper-touch-btn {
    width: 52px;
    background: rgba(255, 255, 255, 0.04);
    border: none;
    color: var(--white);
    font-size: 24px;
    font-weight: 300;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.tool-stepper-touch-btn:active {
    background: rgba(255, 199, 44, 0.2);
    color: var(--gold);
}

.tool-stepper-touch-btn:first-child {
    border-right: 1px solid var(--line);
}

.tool-stepper-touch-btn:last-child {
    border-left: 1px solid var(--line);
}

.tool-rate-input-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-right: 8px;
}

.tool-stepper-column {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-left: 8px;
    flex-shrink: 0;
}

.tool-stepper-btn {
    width: 38px;
    height: 22px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.tool-stepper-btn:hover,
.tool-stepper-btn:active {
    background: var(--gold);
    color: #000;
    border-color: var(--gold);
}

.tool-rate-combined {
    display: inline-flex;
    align-items: baseline;
    justify-content: center;
    gap: 2px;
    padding: 10px 0;
    flex: 1;
    cursor: text;
}

.tool-rate-input {
    width: 3.8ch;
    min-width: 1.5ch;
    padding: 0;
    margin: 0;
    font-size: 1.7rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--white);
    background: transparent;
    border: none;
    outline: none;
    text-align: right;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -moz-appearance: textfield;
    appearance: textfield;
}

.tool-rate-input::-webkit-inner-spin-button,
.tool-rate-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.tool-rate-suffix {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 1.5rem;
    color: var(--gold);
    font-weight: 600;
    user-select: none;
    line-height: 1;
}

/* Results Card */
.tool-results-card {
    background: linear-gradient(145deg, rgba(255,255,255,.07), rgba(255,255,255,.025));
    border: 1px solid var(--line);
    padding: clamp(24px, 3.5vw, 40px);
    border-radius: 8px;
    position: sticky;
    top: 100px;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.tool-results-card h3 {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 20px;
    font-weight: 500;
    color: var(--white);
    margin: 0 0 20px;
    letter-spacing: -.02em;
}

.tool-result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--muted);
    font-size: 14.5px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.tool-result-row strong {
    font-weight: 500;
    font-size: 18px;
    color: var(--white);
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}

.tool-result-row.negative strong {
    color: #4cd964;
}

.tool-result-highlight {
    padding: 18px 0;
    margin-top: 12px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tool-result-highlight span {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    font-weight: 500;
    color: var(--white);
}

.tool-result-highlight strong {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: clamp(1.8rem, 3.2vw, 2.6rem);
    font-weight: 500;
    color: var(--gold);
    letter-spacing: -.04em;
    font-variant-numeric: tabular-nums;
}

.tool-rebate-relief-badge {
    margin-top: 18px;
    padding: 14px 18px;
    background: rgba(255, 199, 44, 0.08);
    border: 1px solid rgba(255, 199, 44, 0.3);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tool-rebate-relief-badge small {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gold);
    font-weight: 600;
}

.tool-rebate-relief-badge strong {
    font-size: 15px;
    color: var(--white);
    font-weight: 500;
}

.tool-action-btn {
    width: 100%;
    margin-top: 22px;
    text-align: center;
    padding: 16px;
}

.tool-fineprint {
    margin-top: 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.55;
}

/* FAQ or Explainer Box in Tool */
.tool-explainer-box {
    margin-top: 36px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 22px;
}

.tool-explainer-box h4 {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: var(--white);
    margin: 0 0 10px;
}

.tool-explainer-box p {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13.5px;
    color: var(--muted);
    line-height: 1.6;
    margin: 0;
}


/* =========================================================
   RESPONSIVE DESIGN BREAKPOINTS (MOBILE VIEWPORT OPTIMIZATIONS)
========================================================= */

@media (max-width: 900px) {
    /* Full, clean mobile container width */
    body.tools-page .container {
        width: min(calc(100% - 24px), 900px);
        padding: 0;
        margin-inline: auto;
    }

    .tools-hero {
        padding: calc(var(--header-height, 72px) + 16px) 0 12px;
    }

    .tools-title {
        font-size: clamp(1.85rem, 6vw, 2.6rem);
        margin-bottom: 6px;
    }

    .tools-subtitle {
        font-size: 12.5px;
        line-height: 1.45;
        max-width: 520px;
        margin: 0 auto;
    }

    .tools-nav-wrapper {
        top: var(--header-height, 72px);
        margin-bottom: 18px;
    }

    .tools-nav-scroll-container {
        justify-content: center;
        padding: 8px 10px;
        width: 100%;
        max-width: 100%;
    }

    .tools-nav-bar {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        width: 100%;
        max-width: 100%;
    }

    .tool-tab-btn {
        width: 100%;
        min-height: 38px;
        padding: 6px 8px;
        font-size: 12px;
        border-radius: 6px;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        gap: 6px;
        box-sizing: border-box;
    }


    .tools-section {
        padding: 0 0 60px;
    }

    /* Single Unified Calculator Card on Tablet / Mobile */
    .tools-page .calculator-grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 28px;
        width: 100%;
        max-width: 100%;
        margin: 0;
    }

    .tools-page .calculator-copy {
        max-width: 100%;
    }

    .tools-page .calculator-copy .section-title {
        font-size: clamp(2rem, 6.5vw, 2.7rem);
        margin-top: 0;
    }

    .tools-page .calculator-copy .section-subtitle {
        margin-top: 14px;
        font-size: 13.5px;
        line-height: 1.5;
        max-width: 100%;
    }

    .tools-page .calculator-card {
        padding: 24px 18px;
        border-radius: 6px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Grid strictly fits mobile screen width */
    .tool-grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
        max-width: 100%;
        gap: 16px;
        margin: 0;
    }

    /* Card Boxes fit screen properly */
    .tool-controls-card,
    .tool-results-card {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
        padding: 18px 14px;
        border-radius: 8px;
    }

    .tool-results-card {
        position: static;
        top: auto;
    }

    .tool-card-title {
        font-size: clamp(1.4rem, 4.5vw, 1.8rem);
        margin: 0 0 8px;
    }

    .tool-card-desc {
        font-size: 13px;
        line-height: 1.5;
        margin: 0 0 16px;
    }

    /* Inputs & Field Groups */
    .tool-field-group {
        margin-bottom: 16px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .tool-field-label {
        font-size: 13px;
        margin-bottom: 6px;
    }

    .tool-input-row {
        min-height: 48px;
        padding: 0 12px;
        border-radius: 6px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .tool-num-input {
        font-size: clamp(1.2rem, 3.8vw, 1.55rem);
        padding: 8px 6px;
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }


    /* Toggles Side-by-Side in 1 Row (No Stacking) */
    .tool-toggle-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .tool-toggle-btn {
        min-height: 40px;
        padding: 6px 8px;
        font-size: 12px;
        line-height: 1.25;
        text-align: center;
        border-radius: 6px;
        white-space: normal;
        word-break: break-word;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Results Card Content */
    .tool-results-card h3 {
        font-size: 15px;
        margin: 0 0 12px;
        letter-spacing: .04em;
        text-transform: uppercase;
        color: var(--gold);
    }

    .tool-result-row {
        padding: 8px 0;
        font-size: 13px;
        gap: 6px;
    }

    .tool-result-highlight {
        padding: 12px 14px;
        margin: 12px 0;
        border-radius: 6px;
    }

    .tool-result-highlight strong {
        font-size: 1.45rem;
    }

    .tool-rebate-relief-badge {
        padding: 12px 14px;
        margin: 12px 0;
        border-radius: 6px;
    }

    .tool-action-btn {
        margin-top: 14px;
        padding: 12px;
        min-height: 46px;
        font-size: 13px;
    }

    .tool-fineprint {
        margin-top: 10px;
        font-size: 11.5px;
        line-height: 1.5;
    }

    .tool-explainer-box {
        margin-top: 16px;
        padding: 14px 12px;
        border-radius: 6px;
    }

    .tool-explainer-box h4 {
        font-size: 13.5px;
        margin-bottom: 6px;
    }

    .tool-explainer-box p {
        font-size: 12px;
        line-height: 1.5;
    }


}

@media (max-width: 480px) {
    body.tools-page .container {
        width: min(calc(100% - 16px), 480px);
        padding: 0;
        margin-inline: auto;
    }

    .tools-nav-scroll-container {
        padding: 6px 4px;
    }

    .tools-nav-bar {
        gap: 5px;
    }

    .tool-tab-btn {
        padding: 6px 4px;
        font-size: 11px;
        min-height: 35px;
        gap: 4px;
    }

    .tool-tab-btn svg {
        width: 13px;
        height: 13px;
    }

    .tool-controls-card,
    .tool-results-card {
        padding: 15px 12px;
        border-radius: 6px;
    }

    .tools-page .calculator-grid {
        gap: 20px;
    }

    .tools-page .calculator-card {
        padding: 20px 14px;
    }

    .tools-page .price-input {
        font-size: clamp(2.2rem, 8.5vw, 2.9rem);
        padding-bottom: 8px;
    }

    .tools-page .calculator-results {
        margin-top: 26px;
    }

    .tools-page .result-row {
        padding: 13px 0;
        font-size: 13px;
    }

    .tools-page .result-row.savings {
        padding-top: 18px;
        margin-top: 6px;
        font-size: 14.5px;
    }

    .tools-page .result-row.savings strong {
        font-size: 24px;
    }

    .tool-card-title {
        font-size: 1.35rem;
    }

    .tool-card-desc {
        font-size: 12.5px;
        margin: 0 0 14px;
    }

    .tool-num-input {
        font-size: 1.25rem;
    }

    .tool-toggle-btn {
        min-height: 38px;
        font-size: 11.5px;
        padding: 4px 6px;
    }
}
