/* "Base Plate Opening" on router base plate product pages
   (functions/woocommerce/base-plate-overlay.php). One plate drawn to scale
   with both center openings concentric (no card around it: a tinted box reads
   as another plate, so the drawing sits flush), a legend with each opening's facts,
   and a status line; the chosen variation lights up and hover / tap / focus
   previews the other. Loaded only on qualifying products
   (functions/core/assets.php), after the product bundle. The active opening
   is the root's data-active ("guide" | "wide"); everything below paints from it.
   --tc-bpo-k (set inline on the root, plate size / 6) scales SVG type and strokes so
   they stay the same size on screen whatever plate is drawn. */

.tc-bpo {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 20px 36px;
    padding: 4px 0 0;
    /* The picker's "More details" link scrolls here and focuses the root. */
    scroll-margin-top: var(--space-6);
}

.tc-bpo:focus {
    outline: none;
}

#wrapper .tc-bpo p {
    margin: 0;
}

.tc-bpo__fig {
    flex: 0 1 400px;
    max-width: 100%;
    margin: 0;
    padding: 0;
}

/* Bigger plates get a little more room so their (smaller-drawn) openings stay readable. */
.tc-bpo[data-tc-bpo-plate^="8-"] .tc-bpo__fig {
    flex-basis: 440px;
}

.tc-bpo[data-tc-bpo-plate^="10-"] .tc-bpo__fig {
    flex-basis: 480px;
}

.tc-bpo__svg {
    display: block;
    width: 100%;
    height: auto;
    font-family: var(--font-mono);
    font-weight: var(--fw-semibold);
}

.tc-bpo__foot {
    margin: 8px 0 0;
    font-size: var(--fs-12);
    line-height: 1.4;
    color: var(--text-soft);
}

.tc-bpo__side {
    display: flex;
    flex: 1 1 280px;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    max-width: 520px;
}

#wrapper .tc-bpo__lede {
    font-size: 15px;
    line-height: 1.45;
    color: var(--text-body);
}

/* Legend: one real button per opening. aria-pressed = pinned in the drawing;
   the active border follows hover / focus / selection. */
.tc-bpo__picks {
    display: grid;
    gap: 10px;
}

.tc-bpo__pick {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    background: #fff;
    color: var(--text-heading);
    font: inherit;
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.tc-bpo__pick:hover {
    border-color: var(--ink-200);
}

.tc-bpo__pick[aria-pressed="true"] {
    background: var(--surface-1);
}

.tc-bpo[data-active="guide"] .tc-bpo__pick--guide {
    border-color: var(--navy-700);
    box-shadow: inset 0 0 0 1px var(--navy-700);
}

.tc-bpo[data-active="wide"] .tc-bpo__pick--wide {
    border-color: var(--orange-500);
    box-shadow: inset 0 0 0 1px var(--orange-500);
}

.tc-bpo__pick:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.tc-bpo__swatch {
    flex: none;
    width: 34px;
    height: 34px;
    box-sizing: border-box;
    border: 4px solid var(--navy-700);
    border-radius: 50%;
    background: #fff;
}

.tc-bpo__pick--wide .tc-bpo__swatch {
    border-style: dashed;
    border-color: var(--orange-500);
    background: var(--orange-050);
}

.tc-bpo__pick-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.tc-bpo__pick-name {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: var(--fs-16);
    font-weight: var(--fw-bold);
    line-height: 1.2;
}

.tc-bpo__pick-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 6px;
}

.tc-bpo__pick-dim {
    font-family: var(--font-mono);
    font-size: var(--fs-14);
    font-weight: var(--fw-medium);
    color: var(--text-muted);
}

.tc-bpo__pick-fit {
    font-size: var(--fs-14);
    color: var(--text-muted);
}

.tc-bpo__pick-best {
    margin-top: 2px;
    font-size: var(--fs-13);
    line-height: 1.35;
    color: var(--text-body);
}

.tc-bpo__tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: var(--navy-700);
    color: #fff;
    font-family: var(--font-ui);
    font-size: var(--fs-11);
    font-weight: var(--fw-semibold);
    letter-spacing: 0.06em;
    line-height: 1.4;
    text-transform: uppercase;
}

.tc-bpo__tag[hidden] {
    display: none;
}

/* Status: the one line that follows the active opening. */
#wrapper .tc-bpo__status {
    padding: 12px 14px;
    border-left: 3px solid var(--navy-700);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    background: var(--surface-1);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-body);
}

.tc-bpo[data-active="wide"] .tc-bpo__status {
    border-left-color: var(--orange-500);
}

.tc-bpo__state {
    display: inline-block;
    margin-right: 6px;
    font-size: var(--fs-11);
    font-weight: var(--fw-semibold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.tc-bpo__status-name {
    color: var(--text-heading);
}

.tc-bpo__status-dim {
    font-family: var(--font-mono);
    font-size: var(--fs-14);
    color: var(--text-heading);
}

.tc-bpo__status.is-empty .tc-bpo__state,
.tc-bpo__status.is-empty .tc-bpo__status-name,
.tc-bpo__status.is-empty .tc-bpo__status-dim,
.tc-bpo__status.is-empty .tc-bpo__choose {
    display: none;
}

.tc-bpo__choose {
    display: inline;
    margin: 0 0 0 6px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--color-link);
    font: inherit;
    font-weight: var(--fw-semibold);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.tc-bpo__choose:hover {
    color: var(--color-link-hover);
}

.tc-bpo__choose:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.tc-bpo__choose[hidden] {
    display: none;
}

/* Facts row. */
.tc-prod-acc-content .tc-bpo__facts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 22px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--fs-13);
    line-height: 1.4;
    color: var(--text-muted);
}

.tc-bpo__facts strong {
    font-family: var(--font-mono);
    font-weight: var(--fw-semibold);
    color: var(--text-heading);
}

/* The drawing. Geometry is inline SVG from PHP; this is only paint. */
.tc-bpo__plate {
    fill: #f2f7fb;
    stroke: var(--ink-200);
    stroke-width: calc(3px * var(--tc-bpo-k, 1));
}

.tc-bpo__bevel {
    fill: none;
    stroke: #fff;
    stroke-width: calc(6px * var(--tc-bpo-k, 1));
}

.tc-bpo__axis {
    stroke: var(--ink-100);
    stroke-width: calc(2px * var(--tc-bpo-k, 1));
}

.tc-bpo__hole {
    fill: #fff;
    stroke: var(--ink-200);
    stroke-width: calc(2.5px * var(--tc-bpo-k, 1));
}

.tc-bpo__tick {
    stroke: var(--ink-400);
    stroke-width: calc(2px * var(--tc-bpo-k, 1));
}

.tc-bpo__tick-label {
    fill: var(--ink-400);
    font-size: calc(22px * var(--tc-bpo-k, 1));
    text-anchor: middle;
    /* The 1″ label sits where the wide ring crosses the centerline; knock the ring out behind it. */
    paint-order: stroke;
    stroke: #f2f7fb;
    stroke-width: calc(8px * var(--tc-bpo-k, 1));
    stroke-linejoin: round;
}

.tc-bpo__tick-label--start {
    text-anchor: start;
}

.tc-bpo__tick-label--end {
    text-anchor: end;
}

.tc-bpo__opening {
    cursor: pointer;
    transition: opacity 150ms ease;
}

.tc-bpo__halo {
    fill: none;
    stroke-width: calc(26px * var(--tc-bpo-k, 1));
    opacity: 0;
    pointer-events: none;
    transition: opacity 150ms ease;
}

.tc-bpo__opening--guide .tc-bpo__halo {
    stroke: var(--navy-700);
}

.tc-bpo__opening--wide .tc-bpo__halo {
    stroke: var(--orange-500);
}

.tc-bpo__ring {
    transition: stroke-width 150ms ease;
}

.tc-bpo__ring--guide {
    fill: #fff;
    stroke: var(--navy-700);
    stroke-width: calc(5px * var(--tc-bpo-k, 1));
}

.tc-bpo__ring--wide {
    fill: var(--orange-050);
    stroke: var(--orange-500);
    stroke-width: calc(5px * var(--tc-bpo-k, 1));
}

.tc-bpo__ring-label {
    font-size: calc(20px * var(--tc-bpo-k, 1));
    text-anchor: middle;
    pointer-events: none;
}

.tc-bpo__ring-label--guide {
    fill: var(--navy-700);
}

.tc-bpo__ring-label--wide {
    fill: var(--orange-700);
}

.tc-bpo[data-active="guide"] .tc-bpo__opening--guide .tc-bpo__halo,
.tc-bpo[data-active="wide"] .tc-bpo__opening--wide .tc-bpo__halo {
    opacity: 0.18;
}

.tc-bpo[data-active="guide"] .tc-bpo__opening--guide .tc-bpo__ring,
.tc-bpo[data-active="wide"] .tc-bpo__opening--wide .tc-bpo__ring {
    stroke-width: calc(7px * var(--tc-bpo-k, 1));
}

.tc-bpo[data-active="guide"] .tc-bpo__opening--wide,
.tc-bpo[data-active="wide"] .tc-bpo__opening--guide {
    opacity: 0.5;
}

.tc-bpo__ext,
.tc-bpo__dim {
    stroke: var(--navy-700);
    stroke-width: calc(2px * var(--tc-bpo-k, 1));
}

.tc-bpo__arrow {
    fill: var(--navy-700);
}

.tc-bpo__dim-label {
    fill: var(--navy-700);
    font-size: calc(26px * var(--tc-bpo-k, 1));
    text-anchor: middle;
}

@media (max-width: 767px) {
    .tc-bpo {
        gap: 16px;
    }

    .tc-bpo__fig {
        flex-basis: 100%;
    }

    .tc-bpo__side {
        max-width: none;
    }

    /* The drawing is narrower, so SVG text (in drawing units) grows to stay
       legible; the caps keep the labels inside the openings on big plates. */
    .tc-bpo__tick-label {
        font-size: min(calc(28px * var(--tc-bpo-k, 1)), 36px);
    }

    .tc-bpo__ring-label {
        font-size: min(calc(26px * var(--tc-bpo-k, 1)), 34px);
    }

    .tc-bpo__dim-label {
        font-size: min(calc(32px * var(--tc-bpo-k, 1)), 44px);
    }

    .tc-bpo__halo {
        stroke-width: min(calc(32px * var(--tc-bpo-k, 1)), 44px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .tc-bpo__pick,
    .tc-bpo__opening,
    .tc-bpo__halo,
    .tc-bpo__ring {
        transition: none;
    }
}
