/**
 * RMD Calculator Styles
 *
 * Design tokens mirror ss-calculator.css so both tools share the same visual
 * language. Shared component classes (.card, .benefits-table, .wizard-*, etc.)
 * are redefined here so each page loads only its own stylesheet.
 *
 * TODO: In a future refactor, extract shared tokens + components to a
 * base.css that both calculators import.
 */

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
    --primary: #1A2332;
    --primary-light: #2d3f57;
    --accent: #C9A961;
    --limestone: #F1EEE6;
    --river: #4A6690;
    --text: #1A2332;
    --text-light: #5a6a7a;
    --bg: #f7f5f0;
    --border: #e0dbd0;
    --warning: #c0392b;
    --success: #27ae60;
    --radius: 10px;
    --shadow: 0 2px 16px rgba(26, 35, 50, 0.08);
}

/* ============================================================
   BASE / RESET
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text);
    background: #fff;
    margin: 0;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.section__inner {
    max-width: 780px;
    margin: 0 auto;
    padding: 0 16px;
}

.rmd-calculator-section {
    margin-top: -48px;
    padding: 0 0 24px;
    position: relative;
    z-index: 1;
    background: transparent;
}

.rmd-calculator-section .section__inner {
    max-width: 900px;
}

.faq-section {
    padding: 40px 0 60px;
    background: var(--limestone);
}

.section__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 6px;
}

.section__subtitle {
    font-size: 0.9rem;
    color: var(--text-light);
    margin: 0 0 28px;
}

/* ============================================================
   WIDGET CARD
   ============================================================ */
.rmd-widget {
    container-type: inline-size;
    container-name: widget;
}

.container {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px 20px;
}

.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px 20px;
}

/* ============================================================
   HERO
   ============================================================ */
.rmd-hero {
    background: linear-gradient(160deg, var(--primary) 0%, var(--river) 100%);
    color: #fff;
    padding: 36px 16px 80px;
    text-align: center;
}

/* ============================================================
   STEPPER BAR
   ============================================================ */
.stepper-bar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 0 0 16px;
    scrollbar-width: none;
}

.stepper-bar::-webkit-scrollbar {
    display: none;
}

.stepper-item {
    flex: 0 0 auto;
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.stepper-item.active {
    background: var(--primary);
    color: #fff;
}

.stepper-item.completed {
    background: var(--accent);
    color: var(--primary);
}

.stepper-item.upcoming {
    background: var(--bg);
    color: var(--text-light);
    opacity: 0.6;
    cursor: default;
}

/* ============================================================
   WIZARD STEPS
   ============================================================ */
.wizard-step {
    display: none;
}

.wizard-step.active {
    display: block;
}

.wizard-step__content {
    padding: 4px 0 20px;
}

.wizard-label {
    display: block;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 10px;
}

.rmd-return-label {
    margin-top: 22px;
}

.wizard-hint {
    font-size: 0.82rem;
    color: var(--text-light);
    margin: 4px 0 10px;
    line-height: 1.5;
}

.wizard-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1.05rem;
    color: var(--text);
    background: #fff;
    transition: border-color 0.15s;
    -moz-appearance: textfield;
    appearance: textfield;
}

.wizard-input::-webkit-outer-spin-button,
.wizard-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

.wizard-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Birth year — placeholder "e.g. 1958" is 9 chars; ch covers content, 2rem covers padding+border */
#rmdBirthYear {
    max-width: calc(11ch + 2rem);
}

/* Money input with $ prefix — up to $10,000,000 (10 chars) + padding */
.money-input-wrap {
    position: relative;
    max-width: calc(13ch + 2.5rem);
}

.money-prefix {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.05rem;
    color: var(--text-light);
    pointer-events: none;
}

.money-input {
    padding-left: 28px;
}

/* Return rate input — "12.5" (4 chars) + extra padding-right for % suffix */
.rmd-return-wrap {
    position: relative;
    max-width: calc(7ch + 2.5rem);
}

.rmd-return-input {
    padding-right: 32px;
}

.rmd-return-suffix {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.05rem;
    color: var(--text-light);
    pointer-events: none;
}

/* Shake animation for invalid step */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-6px);
    }

    60% {
        transform: translateX(6px);
    }
}

.wizard-step.shake {
    animation: shake 0.35s ease;
}

/* ============================================================
   WIZARD NAVIGATION
   ============================================================ */
.wizard-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 20px;
}

.wizard-next {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: auto;
    background: var(--accent);
    color: var(--primary);
    border: none;
    border-radius: 12px;
    padding: 14px 28px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 4px 14px rgba(26, 35, 50, 0.2);
    margin-top: 8px;
}

.wizard-next:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(26, 35, 50, 0.3);
    background: var(--accent-hover);
}

.wizard-next:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(26, 35, 50, 0.2);
}

.wizard-next:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.wizard-next svg {
    transition: transform 0.2s;
}

.wizard-next:hover svg {
    transform: translateX(3px);
}

/* ============================================================
   RESULTS PANEL
   ============================================================ */
#rmdCalcForm.hidden {
    display: none;
}

.results {
    display: none;
}

.results.show {
    display: block;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--river);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0 0 16px;
}

.back-btn:hover {
    color: var(--primary);
}

/* ============================================================
   KEY STATS
   ============================================================ */
.key-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 24px;
}

.stat-item {
    background: var(--bg);
    padding: 14px 8px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid var(--border);
}

.stat-label {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
    line-height: 1.3;
}

.stat-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
}

/* ============================================================
   STATUS NOTE (for pre-RMD age users)
   ============================================================ */
.rmd-status-note {
    background: rgba(74, 102, 144, 0.08);
    border-left: 3px solid var(--river);
    border-radius: 0 6px 6px 0;
    padding: 12px 14px;
    margin-bottom: 20px;
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--text);
}

/* ============================================================
   SCHEDULE TABLE
   ============================================================ */
.rmd-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 12px;
    margin-bottom: 20px;
}

.benefits-table {
    width: 100%;
    border-collapse: collapse;
}

.benefits-table th,
.benefits-table td {
    padding: 10px 6px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.benefits-table th {
    background: var(--bg);
    font-weight: 600;
    font-size: 0.65rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.benefits-table td {
    font-size: 0.85rem;
}

.benefits-table .amount {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.9rem;
}

.benefits-table tr.rmd-current-year {
    background: rgba(201, 169, 97, 0.1);
}

.benefits-table tr.rmd-current-year td {
    font-weight: 600;
}

.benefits-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.015);
}

/* ============================================================
   INFO BOX
   ============================================================ */
.info-box {
    background: var(--bg);
    border-radius: 8px;
    padding: 14px;
    margin: 16px 0;
    font-size: 0.85rem;
    line-height: 1.7;
}

.info-box p {
    margin: 0;
}

/* ============================================================
   DISCLAIMER
   ============================================================ */
.disclaimer {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 12px 14px;
    border-radius: 0 6px 6px 0;
    font-size: 0.8rem;
    line-height: 1.6;
    margin-top: 16px;
}

/* ============================================================
   FAQ
   ============================================================ */
.faq-list {
    border-top: 1px solid var(--border);
}

.faq-item {
    border-bottom: 1px solid var(--border);
}

.faq-question {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    list-style: none;
    gap: 16px;
}

.faq-question::-webkit-details-marker {
    display: none;
}

.faq-question::after {
    content: '+';
    font-size: 1.3rem;
    font-weight: 300;
    color: var(--accent);
    flex-shrink: 0;
}

.faq-item[open] .faq-question::after {
    content: '−';
}

.faq-answer {
    padding: 0 0 18px;
}

.faq-answer p {
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.7;
    margin: 0;
}

.faq-answer p+p {
    margin-top: 10px;
}

.faq-answer ul {
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.7;
    margin: 10px 0 0;
    padding-left: 1.4em;
}

.faq-answer ul li {
    margin-bottom: 6px;
}

.faq-answer a {
    color: var(--primary-light);
    text-decoration: underline;
}

/* ============================================================
   RESPONSIVE — 480px+
   ============================================================ */
@media (min-width: 480px) {

    .container,
    .card {
        padding: 28px 28px;
    }

    .stat-value {
        font-size: 1.15rem;
    }
}

/* ============================================================
   RESPONSIVE — 640px+
   ============================================================ */
@media (min-width: 640px) {

    .benefits-table th,
    .benefits-table td {
        padding: 12px 10px;
    }

    .benefits-table th {
        font-size: 0.72rem;
    }

    .benefits-table td {
        font-size: 0.95rem;
    }

    .benefits-table .amount {
        font-size: 1rem;
    }
}

/* ============================================================
   RMD HERO — updated elements
   ============================================================ */
.rmd-hero__inner {
    max-width: 640px;
    margin: 0 auto;
}

.rmd-hero__title {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: 0;
    letter-spacing: -0.02em;
}

.rmd-hero__title::after {
    content: '';
    display: block;
    width: 48px;
    height: 3px;
    background: var(--accent);
    margin: 16px auto;
    border-radius: 2px;
}

.rmd-hero__title-modifier {
    display: block;
    font-size: 0.52em;
    font-weight: 400;
    opacity: 0.8;
    margin-top: 8px;
    line-height: 1.4;
    letter-spacing: 0;
}

.rmd-hero__answer {
    font-size: 0.82rem;
    opacity: 0.7;
    line-height: 1.7;
    max-width: 560px;
    margin: 16px auto 0;
    text-align: center;
}

.rmd-hero__trust {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.rmd-hero__trust-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.75);
    white-space: nowrap;
}

.rmd-hero__trust-item svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--accent);
}

/* Hero responsive rules moved to 768px+ breakpoint below */

/* ============================================================
   HOW IT WORKS SECTION
   ============================================================ */
.rmd-how-it-works {
    padding: 40px 0;
    background: white;
}

.rmd-hiw__grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 28px;
}

.rmd-hiw__step {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    padding: 24px;
    background: var(--bg);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.rmd-hiw__step-number {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--river));
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
}

.rmd-hiw__step-body {
    flex: 1;
    min-width: 0;
}

.rmd-hiw__step-body h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 10px;
}

.rmd-hiw__step-body p {
    font-size: 0.88rem;
    color: var(--text-light);
    line-height: 1.7;
    margin: 0 0 10px;
}

.rmd-hiw__step-body p:last-child {
    margin-bottom: 0;
}

.rmd-hiw__list {
    font-size: 0.88rem;
    color: var(--text-light);
    line-height: 1.7;
    margin: 8px 0 10px 1.4em;
    padding: 0;
}

.rmd-hiw__list li {
    margin-bottom: 4px;
}

.rmd-hiw__formula {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #fff;
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    padding: 12px 16px;
    margin: 12px 0;
}

.rmd-hiw__formula-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
}

.rmd-hiw__formula-eq {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
}

.rmd-hiw__formula a,
.rmd-hiw__step-body a {
    color: var(--river);
    text-decoration: underline;
}

.rmd-hiw__limitations {
    background: rgba(201, 169, 97, 0.08);
    border-left: 4px solid var(--accent);
    border-radius: 0 8px 8px 0;
    padding: 18px 20px;
    font-size: 0.88rem;
    line-height: 1.7;
    color: var(--text);
}

.rmd-hiw__limitations strong {
    display: block;
    font-size: 0.9rem;
    color: var(--primary);
    margin-bottom: 10px;
}

.rmd-hiw__limitations ul {
    margin: 0 0 12px 1.4em;
    padding: 0;
    color: var(--text-light);
}

.rmd-hiw__limitations ul li {
    margin-bottom: 4px;
}

.rmd-hiw__limitations p {
    margin: 0;
    color: var(--text-light);
}

.rmd-hiw__limitations a {
    color: var(--river);
    text-decoration: underline;
}

/* ============================================================
   RESOURCES SECTION
   ============================================================ */
.rmd-resources {
    padding: 40px 0;
    background: white;
}

.rmd-resources__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.rmd-resources__card {
    display: block;
    padding: 20px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid var(--border);
    text-decoration: none;
    transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}

.rmd-resources__card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(26, 35, 50, 0.08);
}

.rmd-resources__card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
    margin: 0 0 4px;
}

.rmd-resources__card-desc {
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.6;
    margin: 0;
}

@media (min-width: 640px) {
    .rmd-resources__grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .rmd-hero {
        padding: 56px 24px 100px;
    }

    .rmd-hero__title {
        font-size: 2.5rem;
    }

    .rmd-hero__title::after {
        width: 56px;
        margin: 20px auto;
    }

    .rmd-hero__trust {
        gap: 32px;
    }

    .rmd-hero__trust-item {
        font-size: 0.85rem;
    }

    .rmd-calculator-section {
        margin-top: -64px;
        padding: 0 0 40px;
    }

    .wizard-nav {
        justify-content: center;
    }

    .rmd-how-it-works {
        padding: 48px 0;
    }

    .faq-section {
        padding: 48px 0 60px;
    }

    .rmd-resources {
        padding: 48px 0;
    }
}

@media (min-width: 1024px) {
    .rmd-resources__grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* On mobile, ensure single-input steps don't produce a lone narrow field.
   The ch-based max-width is intentional for desktop; 50% of the container
   is the floor on small screens. Multi-input steps are unaffected. */
@media (max-width: 767px) {
    #rmdBirthYear {
        min-width: 50%;
    }
}