/* ================= PLANS ================= */
/* Same top gap as the other app pages, which set it inline on their .wrap. The id is
   what outranks the shell's `:root[data-view="app"] .wrap { padding: 0 28px }`. */
#page-plans .plans-wrap {
    padding-top: 40px;
    padding-bottom: 56px;
}

/* Signed out, this is a public page under the landing header, so it breathes like one. */
:root[data-view="marketing"] #page-plans .plans-wrap {
    padding-top: 64px;
    padding-bottom: 80px;
}

.plans-hero h1 {
    font-size: 2.4rem;
    margin: .1em 0 .3em;
}

.plans-hero p {
    color: var(--text-muted);
    max-width: 72ch;
    font-size: 1.02rem;
    margin: 0;
}

/* There is no free plan, so the trial is the way in and gets its own line above the cards. */
.plans-trial {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin: 24px 0 32px;
    padding: 14px 18px;
    background: var(--success-soft);
    border: 1px solid var(--success);
    border-radius: 6px;
    font-size: .88rem;
    line-height: 1.5;
}

.plans-trial[hidden] {
    display: none;
}

.plans-trial>svg {
    flex: none;
    color: var(--success);
    margin-top: 1px;
}

.plans-trial strong {
    display: block;
    font-size: .95rem;
}

.billing-toggle {
    display: inline-flex;
    border: 1.5px solid var(--text);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
}

.billing-toggle button {
    border: none;
    background: none;
    font-family: 'IBM Plex Mono', monospace;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 7px 14px;
    border-radius: 999px;
    cursor: pointer;
    color: var(--text-muted);
}

.billing-toggle button.active {
    background: var(--text);
    color: var(--bg);
}

.billing-toggle .save-tag {
    color: var(--success);
    font-weight: 600;
    margin-left: 6px;
}

.billing-toggle button.active .save-tag {
    color: inherit;
    opacity: .75;
}

/* Two study plans and the one-time library side by side, each group labelled so the
   library reads as something bought beside a plan rather than a third plan. */
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px 22px;
    align-items: stretch;
}

.pricing-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    min-height: 38px;
}

.pricing-group.is-plans {
    grid-column: span 2;
}

.pg-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
}

.plan-ticket {
    display: flex;
    flex-direction: column;
}

/* No tear line or punched notches here: on these cards they cut through the price copy. */
.plan-ticket::before,
.plan-ticket::after {
    display: none;
}

.plan-ticket .ticket-head {
    position: relative;
    padding: 20px 22px 18px;
    border-bottom: 1px solid var(--border);
}

.plan-ticket .ticket-head h3 {
    font-size: 1.5rem;
}

.plan-ticket .ticket-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 20px 22px 22px;
}

.plan-ticket.popular {
    border-color: var(--accent);
    border-width: 2px;
}

.plan-ticket.is-current {
    border-color: var(--gold);
    border-width: 2px;
}

.plan-flag {
    position: absolute;
    top: 18px;
    right: 20px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: .62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--accent-ink);
    background: var(--accent);
    border-radius: 2px;
    padding: 4px 8px;
}

.plan-flag.is-gold {
    background: var(--gold);
    color: var(--bg);
}

.plan-price {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-top: 12px;
}

.plan-price .amount {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 2.3rem;
    font-weight: 600;
    line-height: 1;
}

.plan-price .period {
    color: var(--text-muted);
    font-size: .84rem;
}

.plan-price-note {
    font-size: .76rem;
    color: var(--text-muted);
    margin-top: 6px;
    min-height: 1.2em;
}

.plan-feature-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0 0 22px;
    flex: 1;
}

.plan-feature {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: .88rem;
    line-height: 1.45;
}

.plan-feature svg {
    flex: none;
    margin-top: 3px;
    color: var(--success);
}

.plan-feature-sub {
    display: block;
    font-size: .76rem;
    color: var(--text-muted);
}

.plan-feature-sub:empty {
    display: none;
}

.plan-cta {
    width: 100%;
    justify-content: center;
}

.plan-action-note {
    margin: 8px 0 0;
    font-size: .76rem;
    color: var(--text-muted);
    text-align: center;
}

.plan-current-flag {
    font-family: 'IBM Plex Mono', monospace;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--gold);
    text-align: center;
    padding: 10px;
    background: var(--gold-soft);
    border-radius: 2px;
}

.plan-cancel-link {
    display: block;
    width: 100%;
    text-align: center;
    margin-top: 10px;
    background: none;
    border: none;
    color: var(--text-muted);
    text-decoration: underline;
    font-size: .78rem;
    cursor: pointer;
    padding: 0;
}

/* À la carte is bought for one subject, so its card carries the picker. */
.plan-subject-pick {
    margin: 0 0 18px;
}

.psp-label {
    display: block;
    margin-bottom: 8px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
}

.subject-chips {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.subject-chip {
    position: relative;
    font-family: 'IBM Plex Mono', monospace;
    font-size: .78rem;
    font-weight: 600;
    padding: 7px 0;
    border: 1.5px solid var(--border-strong);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
}

.subject-chip:hover {
    border-color: var(--text);
}

.subject-chip.is-on {
    background: var(--text);
    border-color: var(--text);
    color: var(--bg);
}

/* On an active à la carte plan the subject is fixed, so the other chips go quiet. */
.subject-chip:disabled {
    cursor: not-allowed;
    opacity: .4;
}

.subject-chip:disabled:hover {
    border-color: var(--border-strong);
}

/* The one-time Handout Library: same height as the plans, set apart by its gold edge. */
.library-ticket {
    border-color: var(--gold);
    border-width: 2px;
}

.library-ticket .ticket-head {
    background: var(--gold-soft);
}

/* ---------- compare table + questions ----------
   Side by side under the cards so the page uses its full width instead of leaving
   an empty right column below the pricing grid. */
.plans-more {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 28px;
    align-items: start;
    margin-top: 48px;
}

/* These are <section>s, so undo the landing page's section padding and divider. */
.plans-more section {
    padding: 0;
    border-top: none;
}

.plan-compare h2,
.plan-faq h2 {
    font-size: 1.5rem;
    margin: 0 0 14px;
}

.plan-faq {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.plan-faq h2 {
    margin-bottom: 6px;
}

.plan-faq .faq-item[open]>summary {
    border-bottom-style: solid;
}

.plan-compare-scroll {
    overflow-x: auto;
    border: 1.5px solid var(--text);
    border-radius: 6px;
    background: var(--bg-raised);
}

.plan-compare table {
    width: 100%;
    border-collapse: collapse;
    font-size: .86rem;
}

.plan-compare th,
.plan-compare td {
    padding: 11px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

.plan-compare thead th {
    font-family: 'IBM Plex Mono', monospace;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    background: var(--bg);
}

.plan-compare tbody th {
    font-weight: 500;
}

.plan-compare td {
    width: 24%;
    color: var(--text-muted);
}

.pc-yes {
    color: var(--success);
}

.pc-no {
    color: var(--border-strong);
}

.plan-compare .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.plans-footnote {
    color: var(--text-muted);
    font-size: .78rem;
    margin: 36px 0 0;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

#planFeedback .feedback-box {
    margin-top: 0;
    margin-bottom: 22px;
}

/* Below this the table and questions are too cramped to share a row, beside the sidebar. */
@media (max-width: 1200px) {
    .plans-more {
        grid-template-columns: 1fr;
        gap: 40px;
    }
}

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

    .pricing-group.is-plans {
        grid-column: auto;
    }


    /* Each card carries its own "One-time" flag, so the column label is not needed stacked. */
    .pricing-group.is-addon {
        display: none;
    }

    .plans-hero h1 {
        font-size: 2rem;
    }
}

/* ================= PLAN ACCESS =================
   What a plan does not open is marked where it is met — roadmap rows, exam presets, deck
   chips, the card stage — before anything is clicked. Clicking is what explains the lock
   (see accessCheck in js/12-plans.js), so a locked control stays a real, focusable button. */
.pg-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.plan-feature-ai.is-off {
    color: var(--text-muted);
}

.plan-feature-ai.is-off svg {
    color: var(--text-muted);
}

.pc-sub {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: .68rem;
    color: var(--text-muted);
}

.plan-lock-badge,
.plan-lock-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: .64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--gold);
}

.plan-lock-badge {
    margin-left: auto;
    flex: none;
}

.lesson-row.is-plan-locked .lname {
    color: var(--text-muted);
}

.lesson-row.is-plan-locked .status-icon {
    opacity: .5;
}

.exam-preset.is-plan-locked {
    border-style: dashed;
    background: var(--bg);
}

.exam-preset.is-plan-locked .ep-title,
.exam-preset.is-plan-locked .ep-desc {
    color: var(--text-muted);
}

.exam-preset .plan-lock-tag {
    margin-left: auto;
}

.deck-chip.is-plan-locked {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

/* The roadmap's one-line explanation of why rows are locked, with its way out. */
.plan-note {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 0 0 18px;
    padding: 12px 16px;
    border: 1px dashed var(--gold);
    border-radius: 4px;
    background: var(--gold-soft);
    font-size: .88rem;
}

.plan-note>svg {
    flex: none;
    color: var(--gold);
}

.plan-note>span {
    flex: 1;
    min-width: 200px;
}

/* A locked deck covers the card stage but keeps its footprint, so the page does not jump. */
.flash-lock {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    text-align: center;
    background: var(--bg);
    border: 1px dashed var(--border-strong);
    border-radius: 4px;
}

.flash-lock[hidden] {
    display: none;
}

.flash-lock p {
    margin: 0;
    max-width: 34ch;
    color: var(--text-muted);
    font-size: .92rem;
}

.flash-lock-icon {
    color: var(--gold);
}

.flash-lock-icon svg {
    width: 26px;
    height: 26px;
}

@media (max-width: 720px) {
    .pg-controls {
        width: 100%;
    }
}
