/*
 * LWC FSBO Calculator (Update): block-local layout only. Shared components
 * (card, fields, stat tiles, table, callout, buttons) own every visual value;
 * no token is declared and no font is loaded. Rules that change a property a
 * component sets are marked DELIBERATE OVERRIDE (Mike approved 1, 2, 4-7).
 */

/* Layout follows the block's own width (container queries). */
.lwc-fsbo-calculator-update-block {
    container-type: inline-size;
    container-name: lwc-fsbo-calculator-update-block-root;
}

/* One card, two sections; parent gaps carry the rhythm. */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__card {
    display: grid;
    gap: var(--clvr-space-8);
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__section {
    display: grid;
    gap: var(--clvr-space-4);
    min-width: 0;
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--clvr-space-3);
}

/* Field grids: one column on phones, two from 34rem. */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--clvr-space-4);
}

@container lwc-fsbo-calculator-update-block-root (min-width: 34rem) {
    .lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }
}

/* Host theme: Bricks sets label { margin-bottom: 5px }; clvr-field__label sets no margin. */
.lwc-fsbo-calculator-update-block .clvr-field__label {
    margin: 0;
}


/* clvr-tooltip doesn't set these, so uppercase table labels would leak in. */
.lwc-fsbo-calculator-update-block .clvr-tooltip__content {
    text-transform: none;
    letter-spacing: normal;
}

/*
 * DELIBERATE OVERRIDE (2): tooltip icon sized to the labels beside it (18px
 * looked oversized). Approved by Mike, 2026-09-24. Bundle 0.3.6 draws the icon
 * inside a fixed 24px box (WCAG 2.5.8), so 5px padding gives the 14px icon and
 * a 2px pull-in keeps the shared 3px gap.
 */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__labelrow .clvr-tooltip__trigger .clvr-icon {
    padding: calc(1.25 * var(--clvr-space-1));
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__labelrow clvr-tooltip {
    margin-inline-start: calc(-0.5 * var(--clvr-space-1));
}

/* Commission field: $ and % side by side, wrapping at large text sizes (WCAG 1.4.4/1.4.10). */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__ratebox {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--clvr-space-2);
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__ratebox > .clvr-control {
    flex: 1 1 7rem;
    min-width: 0;
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__ratepct {
    display: flex;
    flex: 0 1 8rem;
    min-width: 0;
    align-items: center;
    gap: var(--clvr-space-2);
}

/* More details: a text toggle under the main fields; its panel is a quiet card. */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__advanced {
    display: grid;
    justify-items: start;
    gap: var(--clvr-space-3);
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__advpanel {
    box-sizing: border-box;
    width: 100%;
    background: var(--clvr-color-surface-muted);
}

/* The library has no quiet text button, so the toggle is this block's own link on public tokens. */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__advlink {
    display: inline-flex;
    min-height: var(--clvr-field-height);
    align-items: center;
    gap: var(--clvr-space-1);
    margin-inline-start: calc(-1 * var(--clvr-space-2));
    padding: 0 var(--clvr-space-2);
    border: 0;
    border-radius: var(--clvr-radius-md);
    background: none;
    color: var(--clvr-color-link);
    cursor: pointer;
    font: inherit;
    font-family: var(--clvr-font-heading);
    font-weight: var(--clvr-font-heading-weight);
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__advlink:hover > span {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__advlink:focus-visible {
    outline: 2px solid var(--clvr-color-primary);
    outline-offset: 2px;
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__advlink-icon {
    width: 1rem;
    height: 1rem;
    flex: none;
    transition: transform var(--clvr-duration-fast) ease;
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__advlink[aria-expanded="true"] .lwc-fsbo-calculator-update__advlink-icon {
    transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
    .lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__advlink-icon {
        transition: none;
    }
}

/* Heading with its calculator icon, as the other v2 calculators. */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__heading {
    display: flex;
    align-items: center;
    gap: var(--clvr-space-3);
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__head-icon {
    flex: none;
    color: var(--clvr-color-primary);
}

/* Net proceeds cards: stacked on phones, one row from 34rem. */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__totals {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--clvr-space-4);
}

@container lwc-fsbo-calculator-update-block-root (min-width: 34rem) {
    .lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__totals {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Name above amount; the card's padding and this gap are the only spacing. */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__total {
    display: grid;
    grid-template-rows: 1fr auto;
    gap: var(--clvr-space-2);
    margin: 0;
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__total > * {
    align-self: end;
    margin: 0;
}

/* The Clever card names itself with the wordmark (the column name is visually hidden). */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__total-logo {
    display: flex;
    color: var(--clvr-color-primary);
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__total-logo svg {
    width: auto;
    height: 1.5rem;
}

/* The Clever card carries the recommendation: brand tint plus the selected border. */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__total--clever {
    background: var(--clvr-color-secondary);
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__total--clever .lwc-fsbo-calculator-update__amount {
    color: var(--clvr-color-primary);
}

/*
 * Breakdown frame: the border and radius of .clvr-table-wrap without its
 * overflow, which would clip the row tooltips.
 */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__breakdown {
    box-sizing: border-box;
    width: 100%;
    padding: var(--clvr-space-2);
    border: 1px solid var(--clvr-color-border-subtle);
    border-radius: var(--clvr-radius-lg);
    background: var(--clvr-color-surface);
}

/*
 * Breakdown table: fixed columns on wide cards. DELIBERATE OVERRIDE (8):
 * separate borders (spacing 0) so the Clever band and the net row can take
 * rounded corners; Mus's table restyle, 2026-09-29.
 */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table {
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__col-label {
    width: 31%;
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__col-value {
    width: 23%;
}

/* Header: plain captions over the columns; only the Clever band is tinted. */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table thead > tr > * {
    border-bottom: 0;
    vertical-align: bottom;
}

/* DELIBERATE OVERRIDE (1): only the Clever column's header keeps the th
   tint, so its band stands out. Approved by Mike, 2026-09-24. */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table thead th:not(.lwc-fsbo-calculator-update__clever) {
    background: transparent;
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table thead th.lwc-fsbo-calculator-update__clever {
    border-radius: var(--clvr-radius-md) var(--clvr-radius-md) 0 0;
}

/* Clever wordmark: colour set on the block's own SVG, not the header cell. */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table thead svg {
    display: inline-block;
    width: auto;
    height: 1.25rem;
    color: var(--clvr-color-primary);
    vertical-align: middle;
}

/*
 * Row headers carry line-item names, not column captions, so they drop the
 * shared th caption look (uppercase, 10px, tinted) and share the td padding.
 */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table th[scope="row"] {
    background: transparent;
    color: var(--clvr-color-text);
    font-size: inherit;
    letter-spacing: normal;
    text-transform: none;
}

/* Cost rows sit tighter than the sale price and net rows that frame them. */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table tbody > tr > *,
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table tfoot > tr > * {
    padding-block: var(--clvr-space-2);
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table .lwc-fsbo-calculator-update__row--lead > *,
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table .lwc-fsbo-calculator-update__row--total > * {
    padding-block: var(--clvr-space-3);
}

/* Costs read quieter than the sale price they come out of. */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__row--sub > th[scope="row"] {
    color: var(--clvr-color-text-muted);
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table tbody tr:last-child > * {
    border-bottom: 0;
}

/* Sale price leads; a full rule separates it from the costs below. */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table tr.lwc-fsbo-calculator-update__row--lead > * {
    border-bottom-color: var(--clvr-color-border);
    color: var(--clvr-color-text);
    font-weight: var(--clvr-font-heading-weight);
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table td.lwc-fsbo-calculator-update__clever {
    background: var(--clvr-color-secondary);
    color: var(--clvr-color-text);
}

/* Net proceeds: a tinted closing row; the band ends in rounded corners.
   The .__table tr step outranks the th[scope="row"] reset above. */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table tr.lwc-fsbo-calculator-update__row--total > * {
    border-bottom: 0;
    background: var(--clvr-color-surface-panel);
    color: var(--clvr-color-text);
    font-size: inherit;
    font-weight: var(--clvr-font-heading-weight);
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table tr.lwc-fsbo-calculator-update__row--total > :first-child {
    border-radius: var(--clvr-radius-md) 0 0 var(--clvr-radius-md);
}

/* The tinted net row ends before the Clever band, so both round their corners
   where they meet (on phones the hidden "With a realtor" cell sits between). */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table tr.lwc-fsbo-calculator-update__row--total > td:has(+ td.lwc-fsbo-calculator-update__clever) {
    border-radius: 0 var(--clvr-radius-md) var(--clvr-radius-md) 0;
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table .lwc-fsbo-calculator-update__row--total > td.lwc-fsbo-calculator-update__clever {
    border-radius: 0 0 var(--clvr-radius-md) var(--clvr-radius-md);
    background: var(--clvr-color-secondary);
    color: var(--clvr-color-primary);
}

/* The Clever net figure alone is set in the heading face (Rubik on LWC) to stand
   out. On its span: the bundle's host-table reset forces font-family: inherit on th/td. */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__net {
    font-family: var(--clvr-font-heading);
}

/* A row label's last word and its tooltip wrap together. */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__tipword {
    white-space: nowrap;
}

/* Conversion band: savings claim beside the CTA on wide cards, stacked on narrow ones. */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__outcome {
    display: grid;
    gap: var(--clvr-space-4);
    align-items: center;
    padding: var(--clvr-space-6);
    border-radius: var(--clvr-radius-lg);
    background: var(--clvr-color-secondary);
}

@container lwc-fsbo-calculator-update-block-root (min-width: 44rem) {
    .lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__outcome {
        grid-template-columns: minmax(0, 1fr) auto;
    }
}

/* The sentence and its amount stay one line of text, set in the heading face. */
.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__closer {
    margin: 0;
    text-wrap: balance;
    color: var(--clvr-color-text);
    font-family: var(--clvr-font-heading);
    font-weight: var(--clvr-font-heading-weight);
}

.lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__closer strong {
    color: var(--clvr-color-primary);
    font-weight: var(--clvr-font-heading-weight);
}

/*
 * Phones (below 38rem): the table drops "With a realtor", as the legacy
 * calculator did (Mike, 2026-09-25); its net figure stays in the tiles.
 */
@container lwc-fsbo-calculator-update-block-root (max-width: 37.999rem) {
    .lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__wide-only {
        display: none;
    }

    .lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table tr.lwc-fsbo-calculator-update__row--total > td:has(+ .lwc-fsbo-calculator-update__wide-only + td.lwc-fsbo-calculator-update__clever) {
        border-radius: 0 var(--clvr-radius-md) var(--clvr-radius-md) 0;
    }

    /* Phones: no frame inside the card; the table takes the card's full width. */
    .lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__breakdown {
        padding: 0;
        border: 0;
        border-radius: 0;
    }

    /* Phones: a tighter band and a full-width CTA whose label fits one line. */
    .lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__outcome {
        padding: var(--clvr-space-4);
    }

    .lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__outcome .clvr-button {
        box-sizing: border-box;
        width: 100%;
        justify-content: center;
    }

    /* .clvr-table raises specificity above the table-layout: fixed above. */
    .lwc-fsbo-calculator-update-block .clvr-table.lwc-fsbo-calculator-update__table {
        table-layout: auto;
    }

    .lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table colgroup {
        display: none;
    }

    .lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table th[scope="row"] {
        width: 100%;
    }

    .lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table th[scope="row"] .lwc-fsbo-calculator-update__labelrow {
        display: block;
    }

    /* DELIBERATE OVERRIDE (4): no 34rem table minimum on phones, as the
       design system does for .clvr-chart-data tables. Approved by Mike, 2026-09-25. */
    .lwc-fsbo-calculator-update-block .clvr-table.lwc-fsbo-calculator-update__table {
        min-width: 0;
    }

    /* DELIBERATE OVERRIDE (5): column headings may wrap (clvr-table__number
       is nowrap). Approved by Mike, 2026-09-25. */
    .lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table thead th.clvr-table__number {
        white-space: normal;
        vertical-align: bottom;
    }

    /* DELIBERATE OVERRIDE (6): cell side padding 12px to 8px, so prices
       up to $20M fit (12px overflows above ~$994k). Approved by Mike, 2026-09-25. */
    .lwc-fsbo-calculator-update-block .clvr-table.lwc-fsbo-calculator-update__table th,
    .lwc-fsbo-calculator-update-block .clvr-table.lwc-fsbo-calculator-update__table td {
        padding-inline: var(--clvr-space-2);
    }

    /*
     * DELIBERATE OVERRIDE (7): row-label tooltips start 4rem left of the
     * icon, not centred, so they stay on a phone screen; the arrow moves to
     * match. Stopgap until clvr-tooltip keeps itself on screen. Approved by
     * Mike, 2026-09-25. Depends on the component's internals: recheck on
     * every bundle update.
     */
    .lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table th[scope="row"] .clvr-tooltip__content {
        transform: translate(-4rem, 0.25rem);
    }

    .lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table th[scope="row"] clvr-tooltip[data-open="true"] .clvr-tooltip__content {
        transform: translate(-4rem, 0);
    }

    .lwc-fsbo-calculator-update-block .lwc-fsbo-calculator-update__table th[scope="row"] .clvr-tooltip__content::after {
        left: 4rem;
    }
}
