/* Explorer compare: pick buttons, the tray and the comparison dialog.
   Built from the Explorer's own tokens and components (toggle buttons, .btn,
   the About page copy button, the stage-tinted ID chip); no new colors. */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.main-content:focus { outline: none; }

/* Pick button: the Grid/List toggle, smaller; pressed reads like the active toggle */
.compare-pick {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-secondary);
    background: #FFFFFF;
    border: 1px solid var(--hairline);
    border-radius: 6px;
    padding: 0.1875rem 0.5625rem;
    cursor: pointer;
}
.compare-pick:hover { background: var(--bg-active); color: var(--text-primary); }
.compare-pick[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #FFFFFF; }
.compare-pick:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.compare-pick svg { flex-shrink: 0; }

/* Grid card: tags on the left, Compare on the right of the same row */
.technique-foot { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; }
.technique-foot .technique-tags { margin-bottom: 0; min-width: 0; }
.technique-foot .compare-pick { margin-left: auto; }

/* List row: the same, on the tags line */
.technique-list-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.technique-list-foot .technique-list-tags { min-width: 0; }
.technique-list-foot .compare-pick { margin-left: auto; }

/* Subtechnique: ID and Compare on one row like the card header, the name on its own line */
.subtechnique-head .subtechnique-idrow { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.subtechnique-head .subtechnique-idrow .technique-id { margin-right: 0; }
.subtechnique-head.has-compare .subtechnique-name { display: block; margin-top: 0.375rem; }

/* Stage tint for ID chips that are not links (the link chips get theirs from explorer-theme.css) */
.compare-id { display: inline-block; }
.compare-id.st-A { color: var(--stage-a); background: var(--tint-a); }
.compare-id.st-B { color: var(--stage-b); background: var(--tint-b); }
.compare-id.st-C { color: var(--stage-c); background: var(--tint-c); }
.compare-id.st-D { color: var(--stage-d); background: var(--tint-d); }
.compare-id.st-E { color: var(--stage-e); background: var(--tint-e); }
.compare-id.st-F { color: var(--stage-f); background: var(--tint-f); }

/* Tray: a bar across the bottom of the content column, ruled like the header */
.compare-tray {
    position: fixed;
    left: var(--sidebar-width);
    right: 0;
    bottom: 0;
    z-index: 90;
    background: var(--bg-main);
    border-top: 1px solid var(--hairline);
    padding: 0.875rem 2.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
}
.compare-tray[hidden] { display: none; }
.compare-tray-head { display: flex; align-items: baseline; gap: 0.75rem; }
.compare-tray-title { font-family: var(--site-serif); font-optical-sizing: auto; font-size: 1.125rem; font-weight: 450; color: var(--text-primary); }
.compare-tray-count { font-size: var(--site-small); color: var(--site-gray); }
.compare-tray-picks { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; flex: 1; min-width: 0; }
.compare-tray-pick {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    max-width: 100%;
    background: #FFFFFF;
    border: 1px solid var(--hairline);
    border-radius: 6px;
    padding: 0.25rem 0.25rem 0.25rem 0.375rem;
    font-size: var(--site-small);
}
.compare-tray-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 11rem; }
.compare-remove {
    font: inherit;
    font-size: 1rem;
    line-height: 1;
    width: 1.75rem;
    height: 1.75rem;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}
.compare-remove:hover { border-color: var(--hairline); color: var(--text-primary); }
.compare-remove:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.compare-tray-actions { display: flex; gap: 0.5rem; margin-left: auto; }
.compare-tray .btn { font-size: 0.875rem; font-weight: 500; border-radius: 6px; padding: 0.5rem 0.875rem; }
.compare-tray .btn-secondary, .compare-dialog .btn-secondary { background: #FFFFFF; border-color: var(--hairline); color: var(--text-secondary); font-weight: 500; border-radius: 6px; }
.compare-tray .btn-secondary:hover, .compare-dialog .btn-secondary:hover { background: var(--bg-active); color: var(--text-primary); }
.compare-tray .btn-primary:disabled { opacity: 0.45; cursor: default; }
.compare-tray .btn-primary:disabled:hover { background: var(--btn); }
.compare-tray .btn:focus-visible, .compare-dialog .btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.compare-notice { flex-basis: 100%; font-size: var(--site-small); color: var(--text-primary); }
.compare-notice[hidden] { display: none; }

/* Dialog */
.compare-dialog {
    margin: auto;
    padding: 0;
    width: min(1160px, calc(100% - 3rem));
    max-width: none;
    max-height: calc(100dvh - 3rem);
    border: 1px solid var(--hairline);
    border-radius: 10px;
    background: var(--bg-main);
    color: var(--text-primary);
    overflow: hidden;
}
.compare-dialog[open] { display: flex; flex-direction: column; }
.compare-dialog::backdrop { background: rgba(26, 22, 20, 0.35); }
.compare-dialog-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.5rem 2rem 1.25rem;
    border-bottom: 1px solid var(--hairline);
}
.compare-title {
    font-family: var(--site-serif);
    font-optical-sizing: auto;
    font-size: var(--site-heading);
    font-weight: var(--site-heading-weight);
    letter-spacing: -0.01em;
    line-height: 1.25;
    color: var(--site-ink);
}
.compare-version { margin-top: 0.25rem; font-size: var(--site-small); color: var(--site-gray); }
.compare-close { flex: none; white-space: nowrap; }
.compare-body { overflow-y: auto; padding: 1.25rem 2rem 1.75rem; }
.compare-line { font-size: var(--site-body); line-height: 1.55; color: var(--site-gray); max-width: var(--site-measure); margin-bottom: 1.25rem; }

.compare-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.compare-table th, .compare-table td { text-align: left; vertical-align: top; padding: 1rem 1rem 1rem 0; border-top: 1px solid var(--hairline); }
.compare-table thead th { border-top: 0; padding-top: 0.25rem; }
.compare-table tbody tr:last-child > * { border-bottom: 1px solid var(--hairline); }
.compare-table .compare-field {
    width: 9rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--site-gray);
}
.compare-table thead .compare-field { padding-top: 0.5rem; }
.compare-name {
    display: block;
    margin-top: 0.5rem;
    font-family: var(--site-serif);
    font-optical-sizing: auto;
    font-size: 1.1875rem;
    font-weight: 450;
    line-height: 1.3;
    color: var(--text-primary);
}
.compare-table td p { font-size: 0.9375rem; line-height: 1.55; color: var(--text-primary); overflow-wrap: break-word; }
.compare-table td p + p { margin-top: 0.5rem; }
.compare-parent-name { color: var(--text-primary); }
.compare-table td .compare-parent-definition { color: var(--text-secondary); }
.compare-table .technique-id { display: inline-block; }
.compare-value-label { display: none; }

.compare-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-top: 1.5rem; }
/* The About page's citation Copy button */
.compare-copy {
    flex: none;
    font-family: var(--site-sans);
    font-size: var(--site-small);
    font-weight: 500;
    line-height: 1.4;
    color: var(--link);
    background: transparent;
    border: 1px solid var(--primary);
    border-radius: 6px;
    padding: 0.25rem 0.75rem;
    cursor: pointer;
}
.compare-copy:hover { background: var(--site-tint); }
.compare-copy:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.compare-copy-status { font-size: var(--site-small); color: var(--site-gray); }
.compare-copy-fallback {
    flex-basis: 100%;
    min-height: 8rem;
    font: 0.8125rem/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--text-primary);
    background: #FFFFFF;
    border: 1px solid var(--hairline);
    border-radius: 6px;
    padding: 0.75rem;
}
.compare-copy-fallback[hidden] { display: none; }

@media (max-width: 1024px) {
    .compare-tray { left: 0; padding: 0.75rem 1rem; }
}

/* Phones: the dialog fills the screen, and each field becomes a group holding
   every pick's value for that field, each labeled with its ID */
@media (max-width: 640px) {
    .compare-tray { gap: 0.5rem 0.75rem; }
    .compare-tray-picks { order: 3; flex-basis: 100%; }
    .compare-tray-name { display: none; }
    .compare-tray-pick { padding-left: 0.25rem; }
    .compare-notice { order: 4; }

    .compare-dialog { width: 100%; height: 100%; max-height: 100dvh; border: 0; border-radius: 0; }
    .compare-dialog-head { padding: 1rem 1rem 0.875rem; }
    .compare-body { padding: 1rem 1rem 1.5rem; }
    .compare-line { font-size: 0.9375rem; }

    .compare-table, .compare-table thead, .compare-table tbody, .compare-table tr,
    .compare-table th, .compare-table td { display: block; width: auto; }
    .compare-table tr { border-top: 1px solid var(--hairline); padding: 0.875rem 0 1rem; }
    .compare-table th, .compare-table td,
    .compare-table thead th, .compare-table tbody tr:last-child > * { border: 0; padding: 0; }
    .compare-table tbody tr:last-child { border-bottom: 1px solid var(--hairline); }
    .compare-table .compare-field { width: auto; margin-bottom: 0.625rem; }
    .compare-table thead .compare-field { padding-top: 0; }
    .compare-table thead th + th, .compare-table td + td { margin-top: 0.875rem; }
    .compare-name { display: inline; margin: 0 0 0 0.375rem; font-size: 1.0625rem; }
    .compare-value-label { display: block; margin-bottom: 0.25rem; }
}
