/*! Build Box PC builder: all styles in one file.
 *   1. visualizer   the drawing of the build
 *   2. flow         clickable rows, power tiers, selection page, buttons
 *   3. popup        component popup on the builder page
 *   4. games        game performance card (cover art, avg / max FPS)
 * Uses the theme's CSS variables (--primary-color, --surface-color ...). Defaults for them are registered below with
 * @property; any value the theme sets wins over them, so they only matter on a theme without those variables.
 */

/* Defaults for the theme variables this file reads. A registered property only supplies its initial value when nothing
   sets it, so any value the theme declares (anywhere) wins. syntax '*' accepts whatever form the theme uses. */
@property --primary-color {
    syntax: '*';
    inherits: true;
    initial-value: #00bfff;
}

@property --secondary-color {
    syntax: '*';
    inherits: true;
    initial-value: #2563eb;
}

@property --bg-base-color {
    syntax: '*';
    inherits: true;
    initial-value: #080c14;
}

@property --bg-layer-2-color {
    syntax: '*';
    inherits: true;
    initial-value: #0e1626;
}

@property --surface-color {
    syntax: '*';
    inherits: true;
    initial-value: #121c2e;
}

@property --surface-2-color {
    syntax: '*';
    inherits: true;
    initial-value: #1e2d42;
}

@property --muted-color {
    syntax: '*';
    inherits: true;
    initial-value: #8fa6c4;
}

@property --success-color {
    syntax: '*';
    inherits: true;
    initial-value: #3ee08f;
}

@property --warning-color {
    syntax: '*';
    inherits: true;
    initial-value: #ffc857;
}

@property --error-color {
    syntax: '*';
    inherits: true;
    initial-value: #ff5d73;
}

/* ===================================================================== 1. visualizer */
/* BuildBox PC visualizer v2 */

/* Theme tokens. Accent, CPU, GPU and success follow your theme variables (the fallback after the comma is used
   if a variable is missing), so the drawing matches the power bar. */
:root {
    --primary-color: #00BFFF;
    --secondary-color: #2563EB;
    --primary-dk-color: #0099CC;
    --secondary-dk-color: #1D4ED8;
    --gradient-color: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    --gradient-dk-color: linear-gradient(90deg, var(--primary-dk-color), var(--secondary-dk-color));
    --bg-base-color: #080C14;
    --bg-layer-2-color: #0D1420;
    --bg-layer-3-color: #111827;
    --surface-color: #162032;
    --surface-2-color: #1E2D42;
    --text-color: #F0F6FF;
    --muted-color: #7A94B0;
    --faint-color: #3D5470;
    --success-color: #22C55E;
    --success-dk-color: #16A34A;
    --danger-color: #EF4444;
    --danger-dk-color: #DC2626;
    --warning-color: #F59E0B;
    --warning-dk-color: #D97706;
    --info-color: #00BFFF;
    --info-dk-color: #0099CC;
    --font-barlow: 'Barlow', sans-serif;
    --font-barlow-condensed: 'Barlow Condensed', sans-serif;
    --font-mono: 'DM Mono', monospace;
    --scrollbar-color: #3D5470;
    --header-height: 80px;
    --mobile-header-height: 54px;
}

:root {
    --pcv-surface: var(--surface-2-color, #1a1a1a);
    --pcv-grid: rgba(120, 190, 255, 0.07);
    --pcv-line: var(--muted-color, #7ebaff);
    /* detail lines */
    --pcv-dim: #4f6d99;
    /* empty slots, secondary text */
    --pcv-accent: var(--primary-color, #35c6ff);
    /* parts that have been added */
    --pcv-hover: #e3f6ff;
    --pcv-cpu: var(--secondary-color, #6f95ff);
    /* CPU core glow */
    --pcv-gpu: var(--primary-color, #19c4ff);
    /* GPU under-glow */
    --pcv-ok: var(--success-color, #3ee08f);
    --pcv-warn: #ffc857;
    --pcv-error: #ff5d73;
}

.pc-builder {
    background: linear-gradient(0deg, var(--bg-base-color), var(--bg-layer-2-color));
    padding: 40px 0;
}

.pc-builder__container {
    max-width: 1750px;
    margin: 0 auto;
}


.components-select-list li {
    display: flex;
    align-items: center;
    background-color: var(--surface-2-color);
    border-radius: 8px;
    padding: 15px;
    gap: 25px;
    margin: 20px 0;
}

.components-select-list li:nth-child(1) {
    margin-top: 0;
}

.components-select-list li:last-child {
    margin-bottom: 0;
}

.components-select-list li.component-added .component-type {
    padding-bottom: 5px;
    color: var(--muted-color);
}

.components-select-list li.component-added .component-price {
    padding-top: 5px;
    color: var(--primary-color);
}

.component-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.component-icon img {
    display: block;
    width: 24px;
    height: 24px;
}

.pc-builder__image img {
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 8px;
}

.pc-builder__summary {
    gap: 20px;
}

.pc-builder_card {
    background-color: var(--surface-2-color);
    border-radius: 8px;
    padding: 25px;
    gap: 15px;
    display: flex;
    flex-direction: column;
}

.power-allocation {
    justify-content: space-between;
    align-items: end;
}

.power-allocation .stats {
    color: var(--muted-color);
}

.power-allocation .headroom {
    color: var(--success-color);
}

.power-allocation-bar {
    padding: 15px 0;
}

.power-allocation-bar--filled {
    display: flex;
    height: 22px;
    background: #2d3748;
    border-radius: 999px;
    overflow: hidden;
}

.segment {
    height: 100%;
    transition: width 0.4s ease;
}

.segment-gpu {
    background: var(--primary-color);
}

.segment-cpu {
    background: var(--secondary-color);
}

.segment-other {
    background: var(--surface-color);
}

.power-legend {
    display: flex;
    gap: 20px;
}

.dot {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    margin-right: 8px;
}

.dot-gpu {
    background: var(--primary-color);
}

.dot-cpu {
    background: var(--secondary-color);
}

.dot-safe {
    background: var(--success-color);
}

.selected-parts-spec {
    padding: 20px 0;
}

.pc-builder__visualizer {
    gap: 20px;
}

/* ---------- frame ---------- */
.pcv {
    container-type: inline-size;
    padding: 12px 12px 10px;
    border: 1px solid rgba(185, 210, 242, 0.2);
    border-radius: 12px;
    color: var(--pcv-line);
    font-family: var(--font-mono);
    background:
        linear-gradient(var(--pcv-grid) 1px, transparent 1px) 0 0 / 24px 24px,
        linear-gradient(90deg, var(--pcv-grid) 1px, transparent 1px) 0 0 / 24px 24px,
        var(--pcv-surface);
}

.pcv__svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.pcv text {
    font-family: var(--font-mono);
}

/* ---------- line art ---------- */
.pcv .ln {
    fill: none;
    stroke: var(--pcv-line);
    stroke-width: 1.3;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    transition: stroke 0.2s ease, fill-opacity 0.2s ease;
}

.pcv .ln.dim {
    stroke: var(--pcv-dim);
}

.pcv .ln.k {
    stroke: var(--pcv-accent);
    stroke-width: 1.7;
}

.pcv .ln.f {
    fill: var(--pcv-accent);
    fill-opacity: 0.13;
}

.pcv [data-slot="case"] .ln.f {
    fill-opacity: 0.05;
}

.pcv .glass {
    fill: #fff;
    fill-opacity: 0.04;
    stroke: none;
}

.pcv .cap {
    font-size: 11px;
    fill: var(--pcv-dim);
}

.pcv .limit {
    stroke: var(--pcv-warn);
    stroke-width: 1;
    stroke-dasharray: 3 4;
    vector-effect: non-scaling-stroke;
}

/* ---------- empty slots: dashed outline and a breathing plus ---------- */
.pcv-part {
    cursor: pointer;
    outline: none;
}

.pcv-part[data-state="empty"] .ln {
    stroke: var(--pcv-dim);
    stroke-width: 1.2;
    stroke-dasharray: 5 5;
}

.pcv-part[data-state="empty"] .ln.f {
    fill-opacity: 0.03;
}

.pcv .pl {
    fill: none;
    stroke: var(--pcv-accent);
    stroke-width: 1.5;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

.pcv circle.pl {
    fill: var(--pcv-surface);
}

.pcv .plus {
    animation: pcv-breathe 2.8s ease-in-out infinite;
    animation-delay: var(--d, 0s);
}

.pcv-part[data-state="empty"]:hover .plus,
.pcv-part[data-state="empty"].pcv-hot .plus {
    animation: none;
    opacity: 1;
}

.pcv-part[data-state="empty"]:hover .ln,
.pcv-part[data-state="empty"].pcv-hot .ln {
    stroke: var(--pcv-accent);
}

.pcv-part[data-state="empty"]:hover .ln.f,
.pcv-part[data-state="empty"].pcv-hot .ln.f {
    fill-opacity: 0.1;
}

/* ---------- added parts: solid, lit, glowing ---------- */
.pcv-part:not([data-state="empty"]) .ln.k {
    filter: url(#pcv-glow);
}

.pcv-part[data-slot="case"] .ln.k {
    filter: none;
}

.pcv-part:hover .ln.k,
.pcv-part:focus-visible .ln.k,
.pcv-part.pcv-hot .ln.k {
    stroke: var(--pcv-hover);
}

.pcv-part[data-on] .spin .ln {
    stroke: var(--pcv-line);
}

/* conflicts: placed after hover so they win */
.pcv-part[data-state="error"] .ln.k,
.pcv-part[data-state="error"] .limit {
    stroke: var(--pcv-error);
}

.pcv-part[data-state="error"] .ln.f {
    fill: var(--pcv-error);
    fill-opacity: 0.14;
}

.pcv-part[data-state="error"] .ln.k {
    animation: pcv-pulse 1.6s ease-in-out infinite;
}

.pcv-part[data-state="warn"] .ln.k {
    stroke: var(--pcv-warn);
}

.pcv-part[data-state="warn"] .ln.f {
    fill: var(--pcv-warn);
    fill-opacity: 0.12;
}

/* ---------- things that come alive when a part is added and healthy ---------- */
.pcv .fan,
.pcv .spin {
    transform-box: fill-box;
    transform-origin: center;
}

.pcv .die {
    fill: var(--pcv-cpu);
    opacity: 0.3;
}

.pcv-part[data-on] .die {
    animation: pcv-glow 2.4s ease-in-out infinite;
}

.pcv .act,
.pcv .pled {
    fill: var(--pcv-dim);
}

.pcv-part[data-on] .act {
    fill: var(--pcv-ok);
    animation: pcv-act 2.1s linear infinite;
}

.pcv-part[data-on] .pled {
    fill: var(--pcv-ok);
}

/* motherboard debug lights: POST, CPU, DRAM, VGA, BOOT */
.pcv .led {
    fill: #10233f;
    stroke: var(--pcv-dim);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.pcv .led.is-ok {
    fill: var(--pcv-ok);
    stroke: var(--pcv-ok);
    filter: url(#pcv-glow);
}

.pcv .led.is-warn {
    fill: var(--pcv-warn);
    stroke: var(--pcv-warn);
}

.pcv .led.is-err {
    fill: var(--pcv-error);
    stroke: var(--pcv-error);
    animation: pcv-blink 0.9s steps(1) infinite;
}

.pcv .led.is-wait {
    fill: var(--pcv-warn);
    stroke: var(--pcv-warn);
    animation: pcv-blink 1.6s ease-in-out infinite;
}

.pcv .led-t {
    font-size: 8.5px;
    fill: var(--pcv-dim);
    paint-order: stroke;
    stroke: var(--pcv-surface);
    stroke-width: 3px;
    stroke-linejoin: round;
}

/* power cables */
.pcv-cables {
    pointer-events: none;
}

.pcv .c-base {
    fill: none;
    stroke: var(--pcv-dim);
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.pcv .c-flow {
    fill: none;
    stroke: var(--pcv-accent);
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-dasharray: 5 11;
    vector-effect: non-scaling-stroke;
    opacity: 0;
}

.pcv .cable.is-live .c-flow {
    opacity: 1;
    animation: pcv-flow 0.9s linear infinite;
}

.pcv .cable.is-error .c-base {
    stroke: var(--pcv-error);
}

/* power-on sweep */
.pcv .scan {
    fill: var(--pcv-accent);
    opacity: 0;
    pointer-events: none;
}

/* ---------- checklist column (one row per slot) ---------- */
.pcv-co {
    cursor: pointer;
}

.pcv-co .hit {
    fill: transparent;
}

.pcv-co text {
    pointer-events: none;
}

.pcv .lead {
    fill: none;
    stroke: var(--pcv-dim);
    stroke-width: 1;
    stroke-dasharray: 2 3;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

.pcv .lead:not([data-state="empty"]) {
    stroke: var(--pcv-accent);
    opacity: 0.55;
}

.pcv-co .mk {
    transform-box: fill-box;
    transform-origin: center;
}

.pcv-co .mk circle {
    fill: var(--pcv-surface);
    stroke: var(--pcv-dim);
    stroke-width: 1.3;
    vector-effect: non-scaling-stroke;
}

.pcv-co .mk path {
    fill: none;
    stroke: var(--pcv-dim);
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.pcv-co[data-state="ok"] .mk circle {
    fill: var(--pcv-accent);
    stroke: var(--pcv-accent);
}

.pcv-co[data-state="warn"] .mk circle {
    fill: var(--pcv-warn);
    stroke: var(--pcv-warn);
}

.pcv-co[data-state="error"] .mk circle {
    fill: var(--pcv-error);
    stroke: var(--pcv-error);
}

.pcv-co[data-state="ok"] .mk path,
.pcv-co[data-state="warn"] .mk path,
.pcv-co[data-state="error"] .mk path {
    stroke: var(--pcv-surface);
}

.pcv-co .co-k {
    font-size: 11px;
    fill: var(--pcv-dim);
}

.pcv-co .co-n {
    font-size: 12px;
    fill: var(--pcv-line);
}

.pcv-co .co-s {
    font-size: 11.5px;
    fill: var(--pcv-dim);
}

.pcv-co[data-state="ok"] .co-k {
    fill: var(--pcv-accent);
}

.pcv-co[data-state="empty"] .co-n {
    fill: var(--pcv-dim);
}

.pcv-co[data-state="warn"] .co-k,
.pcv-co[data-state="warn"] .co-n {
    fill: var(--pcv-warn);
}

.pcv-co[data-state="error"] .co-k,
.pcv-co[data-state="error"] .co-n {
    fill: var(--pcv-error);
}

.pcv-co:hover .co-n,
.pcv-co.pcv-hot .co-n {
    fill: var(--pcv-hover);
}

@container (max-width: 480px) {
    .pcv-callouts {
        display: none;
    }
}

/* ---------- status pills: always show what has and hasn't been added ---------- */
.pcv__pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.pcv-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px dashed var(--pcv-dim);
    border-radius: 999px;
    color: var(--pcv-dim);
    font-size: 0.72rem;
    line-height: 1.2;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.pcv-pill::before {
    content: "+";
    font-weight: 700;
}

.pcv-pill[data-state="ok"] {
    border: 1px solid var(--pcv-accent);
    background: color-mix(in srgb, var(--pcv-accent) 14%, transparent);
    color: var(--pcv-hover);
}

.pcv-pill[data-state="ok"]::before {
    content: "\2713";
    color: var(--pcv-accent);
}

.pcv-pill[data-state="warn"] {
    border: 1px solid var(--pcv-warn);
    background: rgba(255, 200, 87, 0.12);
    color: var(--pcv-warn);
}

.pcv-pill[data-state="warn"]::before,
.pcv-pill[data-state="error"]::before {
    content: "!";
}

.pcv-pill[data-state="error"] {
    border: 1px solid var(--pcv-error);
    background: rgba(255, 93, 115, 0.14);
    color: var(--pcv-error);
}

.pcv-pill:hover,
.pcv-pill.pcv-hot,
.pcv-pill:focus-visible {
    border-color: var(--pcv-hover);
    outline: none;
}

/* ---------- compatibility messages ---------- */
.pcv__issues {
    display: grid;
    gap: 6px;
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.8125rem;
    line-height: 1.4;
}

.pcv-issue {
    padding: 7px 10px;
    border-left: 3px solid var(--c, var(--pcv-dim));
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
}

.pcv-issue.is-error {
    --c: var(--pcv-error);
}

.pcv-issue.is-warn {
    --c: var(--pcv-warn);
}

.pcv-issue.is-ok {
    --c: var(--pcv-ok);
}

.pcv-issue.pcv-hot {
    background: rgba(255, 255, 255, 0.1);
}

/* Your list is not restyled. If you add data-link-list to [data-pcv], the list item for a hovered part gets a
   temporary .pcv-hot class; style it yourself, for example:
   .components-select-list li.pcv-hot { outline: 1px solid var(--pcv-accent); outline-offset: -1px; } */

/* ---------- keyframes ---------- */
@keyframes pcv-pulse {
    50% {
        opacity: 0.45;
    }
}

@keyframes pcv-breathe {

    0%,
    100% {
        opacity: 0.45;
    }

    50% {
        opacity: 1;
    }
}

@keyframes pcv-glow {

    0%,
    100% {
        opacity: 0.25;
    }

    50% {
        opacity: 0.8;
    }
}

@keyframes pcv-chase {

    0%,
    100% {
        opacity: 0.25;
    }

    40% {
        opacity: 1;
    }
}

@keyframes pcv-blink {
    50% {
        opacity: 0.15;
    }
}

@keyframes pcv-act {

    0%,
    100% {
        opacity: 0.25;
    }

    8% {
        opacity: 1;
    }

    18% {
        opacity: 0.25;
    }

    52% {
        opacity: 1;
    }

    60% {
        opacity: 0.25;
    }

    78% {
        opacity: 1;
    }

    86% {
        opacity: 0.25;
    }
}

@keyframes pcv-flow {
    to {
        stroke-dashoffset: -16;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pcv * {
        animation: none !important;
        transition: none !important;
    }
}


/* ===================================================================== 2. flow */
/* PC builder flow: clickable list rows, power tiers, and the selection page. Uses your theme variables.
   Your own pc-builder.css is not touched. */

/* ---------- builder: each row is one link (the name), stretched over the whole row ---------- */
.components-select-list li {
    position: relative;
    transition: box-shadow 0.2s ease;
}

.components-select-list a.component-name {
    color: inherit;
    text-decoration: none;
}

.components-select-list a.component-name::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 8px;
}

.components-select-list li:hover,
.components-select-list li:focus-within {
    box-shadow: inset 0 0 0 1px var(--primary-color);
}

.components-select-list a.component-name:focus-visible {
    outline: none;
}

/* ---------- builder: power card tiers ---------- */
.power-legend [data-tier="warn"] .dot {
    background: var(--warning-color, #ffc857);
}

.power-legend [data-tier="over"] .dot {
    background: var(--error-color, #ff5d73);
}

.power-legend [data-tier="none"] .dot {
    background: var(--muted-color);
}

.power-allocation .headroom[data-tier="warn"] {
    color: var(--warning-color, #ffc857);
}

.power-allocation .headroom[data-tier="over"] {
    color: var(--error-color, #ff5d73);
}

.power-allocation .headroom[data-tier="none"] {
    color: var(--muted-color);
}

/* ---------- selection page ---------- */
.pc-picker .pc-builder__container {
    padding: 0 15px;
}

.pc-picker__head {
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 30px;
}

.pc-picker__back {
    display: inline-block;
    margin-bottom: 12px;
    color: var(--muted-color);
    text-decoration: none;
}

.pc-picker__back:hover {
    color: var(--primary-color);
}

.pc-picker__count {
    margin: 6px 0 0;
    color: var(--muted-color);
}

.pc-picker__list {
    display: grid;
    gap: 20px;
}

.pcb-product {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 30px;
    padding: 25px;
    border: 1px solid transparent;
    border-radius: 8px;
    background-color: var(--surface-2-color);
    transition: border-color 0.2s ease;
}

.pcb-product:hover {
    border-color: color-mix(in srgb, var(--primary-color) 45%, transparent);
}

.pcb-product.is-selected {
    border-color: var(--primary-color);
}

.pcb-product__name {
    margin: 0 0 14px;
}

.pcb-product__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pcb-product__chips li {
    padding: 4px 12px;
    border-radius: 999px;
    background-color: var(--surface-color);
    color: var(--muted-color);
}

/* Whether the part works with the rest of the build. The label starts with words, so colour is never the only signal. */
.pcb-product__match {
    margin: 12px 0 0;
    padding: 6px 12px;
    border-left: 3px solid var(--pcb-match, var(--muted-color));
    border-radius: 6px;
    background-color: var(--surface-color);
    color: var(--muted-color);
}

.pcb-product__match[data-level="ok"] {
    --pcb-match: var(--success-color, #3ee08f);
}

.pcb-product__match[data-level="warn"] {
    --pcb-match: var(--warning-color, #ffc857);
}

.pcb-product__match[data-level="error"] {
    --pcb-match: var(--error-color, #ff5d73);
}

.pcb-product__specs {
    margin-top: 16px;
}

.pcb-product__specs summary {
    cursor: pointer;
    color: var(--primary-color);
}

.pcb-specs {
    margin-top: 12px;
    border-collapse: collapse;
}

.pcb-specs th,
.pcb-specs td {
    padding: 6px 24px 6px 0;
    text-align: left;
    vertical-align: top;
}

.pcb-specs th {
    font-weight: 400;
    color: var(--muted-color);
    white-space: nowrap;
}

.pcb-product__buy {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 14px;
    flex-shrink: 0;
}

.pcb-product__price {
    color: var(--primary-color);
}

/* Buttons. If your theme already has a button class, put it on these links instead and delete this block. */
.pcb-btn {
    display: inline-block;
    padding: 12px 22px;
    border: 0;
    border-radius: 8px;
    background-color: var(--primary-color);
    color: #fff;
    font-family: var(--font-barlow);
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: filter 0.2s ease;
}

.pcb-btn:hover {
    filter: brightness(1.1);
}

.pcb-btn[hidden] {
    display: none;
}

.pcb-btn--ghost {
    background: transparent;
    color: var(--primary-color);
    box-shadow: inset 0 0 0 1px var(--primary-color);
}

@media (max-width: 767px) {
    .pcb-product {
        flex-direction: column;
        gap: 20px;
    }

    .pcb-product__buy {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }
}


/* =====================================================================
   Component popup (opens from the builder page, replaces the trip to the selection page)
   Reuses .pcb-product / .pcb-btn / .pcb-specs from the selection page block above.
   ===================================================================== */
html.pcb-modal-open {
    overflow: hidden;
}

/* The dialog is a full-screen transparent shell; the panel inside is the visible box.
   A click that lands on the shell itself is a click outside the panel. */
.pcb-modal {
    --pcb-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    box-sizing: border-box;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 24px 16px;
    border: 0;
    background: transparent;
    color: inherit;
    overflow: hidden;
}

.pcb-modal[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

.pcb-modal::backdrop {
    background: rgba(4, 8, 16, 0.72);
    backdrop-filter: blur(3px);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.pcb-modal.is-open::backdrop {
    opacity: 1;
}

.pcb-modal__panel {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: min(960px, 100%);
    min-height: min(560px, 100%);
    max-height: 100%;
    border: 1px solid color-mix(in srgb, var(--primary-color) 35%, transparent);
    border-radius: 12px;
    background-color: var(--surface-color, #0f1a2b);
    outline: none;
    opacity: 0;
    transform: translateY(14px) scale(0.98);
    transition: opacity 0.2s ease, transform 0.24s var(--pcb-ease);
}

.pcb-modal.is-open .pcb-modal__panel {
    opacity: 1;
    transform: none;
}

.pcb-modal__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 22px 25px 16px;
}

.pcb-modal__title {
    margin: 0;
}

.pcb-modal__count {
    margin: 6px 0 0;
    min-height: 1.4em;
    color: var(--muted-color);
}

.pcb-modal__actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.pcb-modal__close {
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted-color);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.pcb-modal__close:hover {
    color: var(--primary-color);
    background-color: var(--surface-2-color);
}

.pcb-modal__close:focus-visible,
.pcb-modal .pcb-btn:focus-visible,
.pcb-modal summary:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.pcb-modal__tools {
    padding: 0 25px 16px;
}

.pcb-modal__search {
    box-sizing: border-box;
    width: 100%;
    padding: 12px 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    background-color: var(--surface-2-color);
    color: inherit;
    font: inherit;
}

.pcb-modal__search:focus {
    outline: none;
    border-color: var(--primary-color);
}

.pcb-modal__body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0 25px 25px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.pcb-modal .pc-picker__list {
    gap: 14px;
}

.pcb-modal button.pcb-btn {
    font: inherit;
    font-weight: 600;
    line-height: 1.2;
}

/* rows settle in one after another once the data arrives */
.pcb-modal__item {
    animation: pcb-rise 0.28s var(--pcb-ease) both;
    animation-delay: calc(var(--pcb-i, 0) * 45ms);
}

@keyframes pcb-rise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
}

/* placeholder rows shown while the list loads: same box as a real row, so nothing jumps when data lands */
.pcb-skeleton {
    pointer-events: none;
}

.pcb-skeleton__bar {
    display: block;
    border-radius: 6px;
    background: linear-gradient(90deg,
            var(--surface-color, #0f1a2b) 25%,
            color-mix(in srgb, var(--muted-color, #8a97ad) 22%, var(--surface-color, #0f1a2b)) 50%,
            var(--surface-color, #0f1a2b) 75%) 0 0 / 200% 100%;
    animation: pcb-shimmer 1.2s linear infinite;
}

.pcb-skeleton__bar--title {
    width: 70%;
    height: 22px;
    margin-bottom: 16px;
}

.pcb-skeleton__bar--chips {
    width: 45%;
    height: 24px;
}

.pcb-skeleton__bar--price {
    width: 90px;
    height: 22px;
}

.pcb-skeleton__bar--btn {
    width: 140px;
    height: 44px;
    border-radius: 8px;
}

@keyframes pcb-shimmer {
    to {
        background-position: -200% 0;
    }
}

.pcb-modal__state {
    padding: 40px 0;
    text-align: center;
    color: var(--muted-color);
}

.pcb-modal__state[hidden] {
    display: none;
}

.pcb-modal__state p {
    margin: 0 0 14px;
}

.pcb-modal__state .pcb-btn {
    margin: 0 4px;
}

.pcb-modal__more {
    display: block;
    margin: 20px auto 0;
}

.pcb-modal__more[hidden] {
    display: none;
}

@media (max-width: 767px) {

    /* bottom sheet on phones */
    .pcb-modal {
        padding: 0;
    }

    .pcb-modal[open] {
        align-items: flex-end;
    }

    .pcb-modal__panel {
        width: 100%;
        height: 92%;
        min-height: 0;
        border-bottom: 0;
        border-radius: 16px 16px 0 0;
        transform: translateY(40px);
    }

    .pcb-modal__head {
        padding: 18px 16px 12px;
    }

    .pcb-modal__tools {
        padding: 0 16px 12px;
    }

    .pcb-modal__body {
        padding: 0 16px 20px;
    }

    .pcb-modal .pcb-product {
        padding: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {

    .pcb-modal::backdrop,
    .pcb-modal__panel {
        transition: none;
    }

    .pcb-modal__panel {
        transform: none;
    }

    .pcb-modal__item,
    .pcb-skeleton__bar {
        animation: none;
    }
}

/* =====================================================================
   4. Game performance card. Sits inside .pc-builder_card; the card's own box comes from your theme.
   Reuses pcb-rise, pcb-shimmer and .pcb-btn from the blocks above.
   ===================================================================== */
.pcb-games .card-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.pcb-games__preset {
    color: var(--muted-color);
    white-space: nowrap;
}

.pcb-games__gpu {
    margin: 0 0 14px;
    color: var(--muted-color);
}

.pcb-games__gpu strong {
    color: var(--primary-color);
    font-weight: 600;
}

.pcb-games__gpu[data-state="warn"] {
    color: var(--warning-color, #ffc857);
}

.pcb-games__list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
    transition: opacity 0.2s ease;
}

.pcb-games__list.is-loading {
    opacity: 0.5;
    pointer-events: none;
}

.pcb-games__empty {
    padding: 18px 0;
    text-align: center;
    color: var(--muted-color);
}

.pcb-game {
    --pcb-tier: var(--muted-color);
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 12px;
    padding: 10px;
    border-radius: 10px;
    background-color: var(--surface-2-color);
    animation: pcb-rise 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both;
    animation-delay: calc(var(--pcb-i, 0) * 45ms);
    transition: opacity 0.2s ease;
}

.pcb-game[data-tier="great"] {
    --pcb-tier: var(--primary-color);
}

.pcb-game[data-tier="good"] {
    --pcb-tier: var(--success-color, #3ee08f);
}

.pcb-game[data-tier="ok"] {
    --pcb-tier: var(--warning-color, #ffc857);
}

.pcb-game[data-tier="low"] {
    --pcb-tier: var(--error-color, #ff5d73);
}

.pcb-game.is-leaving {
    opacity: 0.3;
}

.pcb-game__cover {
    position: relative;
    display: block;
    align-self: start;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    border-radius: 6px;
    background-color: var(--surface-color);
}

.pcb-game__cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pcb-game__cover.is-missing img {
    display: none;
}

.pcb-game__cover.is-missing::after {
    /* art that fails to load: the game's first letter instead */
    content: attr(data-initial);
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--muted-color);
    font-size: 20px;
    font-weight: 700;
}

.pcb-game__body {
    min-width: 0;
}

.pcb-game__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
}

.pcb-game__title {
    display: -webkit-box;
    overflow: hidden;
    color: inherit;
    font-weight: 600;
    line-height: 1.25;
    text-decoration: none;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.pcb-game__title:hover {
    color: var(--primary-color);
}

.pcb-game__remove {
    flex: none;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted-color);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.pcb-game__remove:hover {
    color: var(--primary-color);
    background-color: var(--surface-color);
}

.pcb-game__remove:focus-visible,
.pcb-game__title:focus-visible,
.pcb-games__result:focus-visible,
.pcb-games__reset:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.pcb-game__nums {
    display: flex;
    align-items: flex-end;
    gap: 18px;
    margin-top: 8px;
}

.pcb-game__stat {
    display: flex;
    flex-direction: column;
}

.pcb-game__num {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    line-height: 1;
}

.pcb-game__stat:first-child .pcb-game__num {
    color: var(--pcb-tier);
}

.pcb-game__lbl {
    margin-top: 4px;
    color: var(--muted-color);
    white-space: nowrap;
}

.pcb-game__tier {
    margin-left: auto;
    color: var(--pcb-tier);
    font-weight: 600;
    white-space: nowrap;
}

.pcb-game__bar {
    height: 4px;
    margin-top: 8px;
    overflow: hidden;
    border-radius: 2px;
    background-color: var(--surface-color);
}

.pcb-game__bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background-color: var(--pcb-tier);
    animation: pcb-grow 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* Phones: the stats row (Avg FPS, Max FPS / Engine cap, tier label) is wider than the text column next to the cover,
 * so "Playable" ran out of the card. Slimmer cover and padding, and the row may wrap, with the tier label on its own line. */
@media (max-width: 480px) {
    .pcb-game {
        grid-template-columns: 60px minmax(0, 1fr);
        gap: 10px;
        padding: 8px;
    }

    .pcb-game__nums {
        flex-wrap: wrap;
        gap: 8px 16px;
    }

    .pcb-game__tier {
        flex: 0 0 100%;
        margin-left: 0;
    }
}

@keyframes pcb-grow {
    from {
        width: 0;
    }
}

.pcb-game__req {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    color: var(--muted-color);
}

.pcb-game__req[hidden] {
    display: none;
}

.pcb-game__req::before {
    content: "";
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--muted-color);
}

.pcb-game__req[data-level="rec"]::before,
.pcb-game__req[data-level="ok"]::before {
    background-color: var(--success-color, #3ee08f);
}

.pcb-game__req[data-level="min"]::before {
    background-color: var(--warning-color, #ffc857);
}

.pcb-game__req[data-level="below"]::before {
    background-color: var(--error-color, #ff5d73);
}

/* placeholder rows while the first answer loads: same height as a real row */
.pcb-game--skeleton {
    height: 92px;
    animation: pcb-shimmer 1.2s linear infinite;
    background: linear-gradient(90deg,
            var(--surface-2-color) 25%,
            color-mix(in srgb, var(--muted-color, #8a97ad) 22%, var(--surface-2-color)) 50%,
            var(--surface-2-color) 75%) 0 0 / 200% 100%;
}

.pcb-games__state {
    margin: 14px 0 0;
    text-align: center;
    color: var(--muted-color);
}

.pcb-games__state[hidden] {
    display: none;
}

.pcb-games__state p {
    margin: 0 0 10px;
}

/* add a game */
.pcb-games__add {
    margin-top: 14px;
}

.pcb-games__search {
    box-sizing: border-box;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    background-color: var(--surface-2-color);
    color: inherit;
    font: inherit;
}

.pcb-games__search:focus {
    outline: none;
    border-color: var(--primary-color);
}

.pcb-games__search:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.pcb-games__results {
    margin: 8px 0 0;
    padding: 4px;
    list-style: none;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--primary-color) 35%, transparent);
    border-radius: 8px;
    background-color: var(--surface-color);
}

.pcb-games__results[hidden] {
    display: none;
}

.pcb-games__result {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 6px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.pcb-games__result:hover,
.pcb-games__result:focus-visible {
    background-color: var(--surface-2-color);
}

.pcb-games__result img {
    width: 36px;
    height: auto;
    aspect-ratio: 2 / 3;
    border-radius: 4px;
    object-fit: cover;
    background-color: var(--surface-2-color);
}

.pcb-games__result .name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pcb-games__result .year {
    color: var(--muted-color);
}

.pcb-games__none {
    padding: 10px;
    color: var(--muted-color);
}

.pcb-games__foot {
    margin-top: 14px;
    color: var(--muted-color);
}

.pcb-games__foot p {
    margin: 0;
}

.pcb-games__foot a {
    color: var(--primary-color);
}

.pcb-games__reset {
    margin-top: 8px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--primary-color);
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
}

.pcb-games__reset[hidden] {
    display: none;
}

@media (prefers-reduced-motion: reduce) {

    .pcb-game,
    .pcb-game__bar span,
    .pcb-game--skeleton {
        animation: none;
    }

    .pcb-games__list,
    .pcb-game {
        transition: none;
    }
}

/* ===================================================================== 3. several drives, cooler, "fits your build" note */

/* Storage row: one block per drive. Each drive's name is its own link, stretched over just that block. */
.components-select-list .component-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    min-width: 0;
}

.components-select-list .component-group .selected-component {
    position: relative;
}

.components-select-list .component-group .selected-component+.selected-component {
    padding-top: 14px;
    border-top: 1px solid var(--surface-color);
}

.components-select-list .component-group .selected-component a.component-name::after {
    inset: -8px 0;
}

.pcb-drive-add {
    position: relative;
    z-index: 1;
    align-self: flex-start;
    padding: 6px 14px;
    border: 1px dashed var(--primary-color);
    border-radius: 999px;
    background: transparent;
    color: var(--primary-color);
    cursor: pointer;
    font: inherit;
}

.components-select-list .pcb-multi-note {
    position: relative;
    z-index: 1;
    margin: 0;
    color: var(--muted-color);
}

/* A popup row whose part has no room left in the build: dimmed, its button turned off. */
.pcb-product.is-full .pcb-product__name,
.pcb-product.is-full .pcb-product__chips {
    opacity: .6;
}

.pcb-drive-add:hover,
.pcb-drive-add:focus-visible {
    background-color: color-mix(in srgb, var(--primary-color) 14%, transparent);
    outline: none;
}

/* The popup's note about the list being narrowed. */
.pcb-modal__note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    margin: 0 0 16px;
    padding: 8px 14px;
    border-radius: 6px;
    background-color: var(--surface-color);
    color: var(--muted-color);
}

.pcb-modal__note[hidden] {
    display: none;
}

.pcb-linkbtn {
    padding: 0;
    border: 0;
    background: none;
    color: var(--primary-color);
    cursor: pointer;
    font: inherit;
    text-decoration: underline;
}

/* ===================================================================== 4. long builds (many drives / parts)
   The parts list grows with every drive, while the drawing and the side cards stay short. Without this the middle and
   right columns end early (empty gap) and the spec cards start far down the page. */

/* Storage: a long drive list scrolls inside its own row instead of stretching the whole column. */
.components-select-list .component-group {
    max-height: 340px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
}

.components-select-list .component-group::-webkit-scrollbar {
    width: 6px;
}

.components-select-list .component-group::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

.components-select-list .component-group::-webkit-scrollbar-track {
    background: transparent;
}

/* Keep long drive names to two lines (full name stays in the spec card). */
.components-select-list .component-group .selected-component a.component-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Desktop: the drawing follows you while the parts list scrolls past. It sticks below the fixed site header;
   --pcb-header-h is measured by pc-builder.js (the 120px fallback only applies if the script cannot find a header).
   No max-height / overflow, so no scrollbar. Only on screens tall enough to show the whole column. */
@media (min-width: 992px) and (min-height: 760px) {
    .pc-builder__visualizer {
        align-self: flex-start;
        /* a stretched column cannot stick */
        position: sticky;
        top: var(--pcb-sticky-top, calc(var(--pcb-header-h, 120px) + 20px)); /* set by pc-builder.js: lower than the header when the column is taller than the screen */
    }
}

/* Anchor jumps (#...) land below the fixed header too. */
.pc-builder {
    scroll-margin-top: calc(var(--pcb-header-h, 120px) + 20px);
}

/* =====================================================================
   Quote request: the two buttons in the Order Summary card and the email popup.
   The popup reuses the .pcb-modal shell from the component popup; --sm makes the panel narrow.
   ===================================================================== */
.pcb-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
}

.pcb-actions .pcb-btn {
    flex: 1 1 200px;
    text-align: center;
}

.pcb-actions button.pcb-btn {
    font-family: var(--font-barlow);
    font-size: 20px;
    font-weight: 600;
    line-height: 1.2;
}


.pcb-btn[aria-disabled="true"]:hover {
    filter: none;
}

.pcb-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.pcb-btn:disabled:hover {
    filter: none;
}

.pcb-modal--sm .pcb-modal__panel {
    width: min(480px, 100%);
    min-height: 0;
}

.pcb-quote__form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pcb-quote__parts {
    margin: 0 0 8px;
    padding: 0;
    list-style: none;
    max-height: 180px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.pcb-quote__parts li {
    display: flex;
    gap: 12px;
    padding: 6px 0;
    border-top: 1px solid color-mix(in srgb, var(--muted-color) 22%, transparent);
}

.pcb-quote__parts li:first-child {
    border-top: 0;
}

.pcb-quote__slot {
    flex: 0 0 96px;
    color: var(--muted-color);
}

.pcb-quote__label {
    color: var(--muted-color);
}

.pcb-quote__hint {
    margin: 0;
    color: var(--muted-color);
}

.pcb-quote__error {
    margin: 0;
    color: var(--error-color, #ff5d73);
}

.pcb-quote__error[hidden] {
    display: none;
}

.pcb-quote__form .pcb-btn {
    margin-top: 8px;
}

.pcb-quote__done {
    padding: 8px 0 4px;
    text-align: center;
}

.pcb-quote__done[hidden],
.pcb-quote__form[hidden] {
    display: none;
}

.pcb-quote__done p {
    margin: 0 0 14px;
}

.pcb-quote__code strong {
    color: var(--primary-color);
    letter-spacing: 0.04em;
}

/* Honeypot: off screen, not display:none, because some bots skip fields that are hidden that way. */
.pcb-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

@media (max-width: 767px) {

    /* the small popup is a bottom sheet that is only as tall as its content */
    .pcb-modal--sm .pcb-modal__panel {
        height: auto;
        max-height: 92%;
    }
}

/* Share popup ("Publish PC") */
.pcb-share__done { display: flex; flex-direction: column; gap: 12px; }
.pcb-share__done[hidden] { display: none; }
.pcb-share__row { display: flex; gap: 8px; align-items: stretch; }
.pcb-share__row .pcb-modal__search { flex: 1 1 auto; min-width: 0; }
.pcb-share__row .pcb-btn { flex: 0 0 auto; }
.pcb-btn:disabled { opacity: .5; cursor: not-allowed; }
.pcb-share__row .pcb-btn { text-align: center; text-decoration: none; }

/* Order summary card: kept compact because it sits at the bottom of the sticky column and must stay on screen. */
.pcb-sum-card { padding: 16px 20px 18px; gap: 8px; }
.pcb-sum-card .card-heading h3 { font-size: 20px; }
.pcb-sum__total { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pcb-sum__label { color: var(--muted-color, #8a8f98); }
.pcb-sum__count { margin-left: 4px; }
.pcb-sum__price { font-weight: 700; line-height: 1.1; }
.pcb-sum__rows { margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 20px; }
.pcb-sum__row { display: flex; gap: 6px; }
.pcb-sum__row[hidden] { display: none; }
.pcb-sum__row dt { margin: 0; color: var(--muted-color, #8a8f98); }
.pcb-sum__row dd { margin: 0; font-weight: 600; }
.pcb-sum__row dd[data-tone="ok"] { color: var(--success-color, #2fb344); }
.pcb-sum__row dd[data-tone="warn"] { color: var(--warning-color, #e0a100); }
.pcb-sum__row dd[data-tone="error"] { color: var(--error-color, #e5484d); }
.pcb-sum-card .pcb-actions { margin-top: 8px; gap: 10px; }
.pcb-sum-card .pcb-actions button.pcb-btn { font-size: 17px; padding-top: 10px; padding-bottom: 10px; }

.pcb-actions__hint { margin: 6px 0 0; color: var(--muted-color, #8a8f98); }
.pcb-actions__hint[hidden] { display: none; }

/* ---------- clear all (bottom right of the drawing) ---------- */
.pcv__foot {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

.pcv__clear {
    padding: 6px 14px;
    border: 1px solid color-mix(in srgb, var(--pcv-error) 55%, transparent);
    border-radius: 999px;
    background: transparent;
    color: var(--pcv-error);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.pcv__clear[hidden] {
    display: none;
}

.pcv__clear:hover,
.pcv__clear[data-confirm] {
    border-color: var(--pcv-error);
    background: var(--pcv-error);
    color: #fff;
}

.pcv__clear:focus-visible {
    outline: 2px solid var(--pcv-accent);
    outline-offset: 2px;
}

.pcv__foot {
    align-items: center;
    justify-content: flex-end;
}

/* ---------- spec tables: first rows only, rest on request ---------- */
.component-spec-card.is-collapsed .pcb-spec-extra {
    display: none;
}

.component-spec-card:not(.is-collapsed) .pcb-spec-extra {
    animation: pcb-rise 0.25s var(--pcb-ease, cubic-bezier(0.2, 0.8, 0.2, 1)) both;
}

.pcb-spec-more {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 6px 0;
    border: 0;
    background: none;
    color: var(--primary-color);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.pcb-spec-more::after {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 0.2s ease;
}

.pcb-spec-more[aria-expanded="true"]::after {
    transform: translateY(2px) rotate(-135deg);
}

.pcb-spec-more[aria-haspopup]::after {
    transform: rotate(-45deg);
}

.pcb-spec-more:hover {
    text-decoration: underline;
}

.pcb-spec-more:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.pcb-modal--md .pcb-modal__panel {
    width: min(640px, 100%);
    min-height: 0;
}

.pcb-modal--md .component-spec-card {
    width: 100%;
    max-width: none;
    padding: 0;
}

@media (prefers-reduced-motion: reduce) {
    .component-spec-card .pcb-spec-extra,
    .pcb-spec-more::after {
        animation: none;
        transition: none;
    }
}

/* ---------- popup: sort and filters, "In your build" tag ---------- */
.pcb-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px 12px;
    margin-top: 12px;
}

.pcb-filters__facets {
    display: contents;
}

.pcb-filter {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.pcb-filter__label {
    color: var(--muted-color);
}

.pcb-filter__select {
    box-sizing: border-box;
    max-width: 200px;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    background-color: var(--surface-2-color);
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.pcb-filter[data-active="1"] .pcb-filter__select {
    border-color: var(--primary-color);
}

.pcb-filter__select:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.pcb-filters__reset {
    padding-bottom: 10px;
}

.pcb-filters__reset[hidden] {
    display: none;
}

.pcb-product__tag {
    display: inline-block;
    margin-left: 10px;
    padding: 2px 9px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary-color) 18%, transparent);
    color: var(--primary-color);
    font-weight: 600;
    vertical-align: middle;
    white-space: nowrap;
}

@media (max-width: 767px) {
    .pcb-filter {
        flex: 1 1 calc(50% - 6px);
    }

    .pcb-filter__select {
        max-width: none;
        width: 100%;
    }
}

/* ---------- "Show everything" switch, unpriced parts, incomplete total ---------- */
.pcb-modal__avail {
    padding: 0 25px 12px;
}

.pcb-switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.pcb-switch__input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.pcb-switch__track {
    position: relative;
    flex: none;
    width: 38px;
    height: 22px;
    border-radius: 999px;
    background: var(--surface-2-color);
    border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.pcb-switch__track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.7;
    transition: transform 0.2s ease, opacity 0.2s ease, background-color 0.2s ease;
}

.pcb-switch__input:checked + .pcb-switch__track {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.pcb-switch__input:checked + .pcb-switch__track::after {
    transform: translateX(16px);
    background: #fff;
    opacity: 1;
}

.pcb-switch__input:focus-visible + .pcb-switch__track {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.pcb-switch__hint {
    color: var(--muted-color);
}

.pcb-modal__avail-note {
    margin: 8px 0 0;
    color: var(--muted-color);
}

.pcb-modal__avail-note[hidden] {
    display: none;
}

.pcb-product.is-unavailable .pcb-product__price {
    color: var(--muted-color);
    font-weight: 500;
}

.component-price[data-unavail] {
    color: var(--muted-color);
    font-size: 0.8em;
}

.pcb-sum__note {
    margin: 8px 0 0;
    padding: 10px 12px;
    border-left: 3px solid var(--pcv-warn, #f5a524);
    border-radius: 6px;
    background: color-mix(in srgb, var(--pcv-warn, #f5a524) 12%, transparent);
    line-height: 1.45;
}

.pcb-sum__note[hidden] {
    display: none;
}

.pcb-sum__total [data-sum-price] {
    transition: opacity 0.2s ease;
}

[data-pcb-summary][data-incomplete] .pcb-sum__price {
    opacity: 0.55;
}

@media (prefers-reduced-motion: reduce) {
    .pcb-switch__track,
    .pcb-switch__track::after {
        transition: none;
    }
}

/* ---------- popup: compact top: title and count on one line, search and filters on one row, so the parts get the room ---------- */
.pcb-modal__head {
    align-items: center;
    gap: 12px;
    padding: 14px 25px 8px;
}

/* Title and "323 options" sit side by side instead of stacked (the component popup only). */
.pcb-modal__heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 12px;
    min-width: 0;
}

.pcb-modal .pcb-modal__title {
    font-size: clamp(1.125rem, 2.2vw, 1.4rem);
    line-height: 1.25;
}

.pcb-modal__heading .pcb-modal__count {
    margin: 0;
    min-height: 0;
}

.pcb-modal__close {
    width: 36px;
    height: 36px;
}

.pcb-modal__avail {
    padding: 0 25px 8px;
}

.pcb-switch {
    gap: 8px;
}

.pcb-switch__text {
    font-size: 0.9rem;
    line-height: 1.3;
}

/* One row: search, then the dropdowns (label above each, small). The filter wrappers are "contents" so the
   search, Sort, Brand, Socket... are all items of the same row and share its width. */
.pcb-modal__tools {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px 10px;
    padding: 0 25px 10px;
}

.pcb-modal__tools[hidden] {
    display: none;
}

.pcb-modal__tools .pcb-modal__search {
    flex: 2 1 220px;
    width: auto;
    min-width: 0;
    min-height: 40px;
    padding: 8px 12px;
}

.pcb-modal__tools .pcb-filters {
    display: contents;
}

.pcb-modal__tools .pcb-filter {
    flex: 1 1 130px;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    margin: 0;
}

.pcb-modal__tools .pcb-filter__label {
    font-size: 0.75rem;
    line-height: 1.2;
    white-space: nowrap;
}

.pcb-modal__tools .pcb-filter__select {
    width: 100%;
    max-width: none;
    min-height: 40px;
    padding: 6px 10px;
}

.pcb-modal__tools .pcb-filters__reset {
    flex: none;
    align-self: center;
    padding-bottom: 0;
    white-space: nowrap;
}

/* Notes live in the scrolling part, so they never take room from the list. */
.pcb-modal__body {
    padding-top: 4px;
}

.pcb-modal__note {
    margin-bottom: 10px;
    padding: 6px 12px;
}

.pcb-modal__avail-note {
    margin: 0 0 10px;
    padding: 6px 12px;
    border-radius: 6px;
    background-color: var(--surface-color);
}

@media (max-width: 767px) {
    .pcb-modal__head {
        padding: 12px 16px 6px;
    }

    .pcb-modal__avail {
        padding: 0 16px 6px;
    }

    /* The note that comes with the switch says the same; one line less on a phone. */
    .pcb-switch__hint {
        display: none;
    }

    .pcb-modal__tools {
        padding: 0 16px 8px;
        gap: 6px 8px;
    }

    .pcb-modal__tools .pcb-modal__search {
        flex: 1 1 100%;
        min-height: 38px;
    }

    .pcb-modal__tools .pcb-filter {
        flex: 1 1 28%;
    }

    /* "Recommended" is the longest option: the Sort dropdown (first in the filters) gets a bit more of the row. */
    .pcb-modal__tools .pcb-filters > .pcb-filter:first-child {
        flex-grow: 1.7;
    }

    .pcb-modal__tools .pcb-filter__select {
        min-height: 38px;
    }
}
