/* ==========================================================================
   KnowTheSpore pages/compare.css: comparison pages (/identify/{a}-vs-{b}/,
   /compare/{a}-vs-{b}/) and their index pages (/identify/, /compare/).
   Loaded through $pageCss = ['compare'] after tokens.css, base.css and
   blocks.css. Every value comes from a tokens.css custom property; breakpoint
   numbers appear only in the marked section at the end, mirroring base.css.
   Templates: templates/comparison.php, templates/comparison-index.php.
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. Title band
   -------------------------------------------------------------------------- */
.cmp-title .t-label { display: block; }
.cmp-title h1 { margin-bottom: var(--space-4); }
.cmp-title .byline { margin-bottom: var(--space-2); }
.cmp-title__date { margin: 0; font-size: var(--fs-caption); }
.cmp-title .t-lead { margin: 0; }


/* --------------------------------------------------------------------------
   2. Versus band: two equal halves, the vs badge on the center line
   -------------------------------------------------------------------------- */
.vs {
    --_gap: var(--space-6);
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--_gap);
    container-type: inline-size;
}
.vs::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    border-left: var(--border-hairline) solid var(--c-line-strong);
}
/* Sits on the center line, level with the middle of the 4:3 pictures. */
.vs__badge {
    position: absolute;
    z-index: var(--z-base);
    left: 50%;
    top: calc((100cqw - var(--_gap)) / 2 * 0.375);
    transform: translate(-50%, -50%);
}
.vs__side .ed-tag { margin-top: var(--space-1); }
.vs__side h2 {
    font-family: var(--role-heading-family);
    font-weight: var(--role-heading-weight);
    font-size: var(--fs-h3);
    line-height: var(--lh-heading);
    letter-spacing: var(--tr-heading);
}
.vs__side h2 a { color: var(--_heading); text-decoration: none; }
.vs__side h2 a:hover { text-decoration: underline; }
.vs__side .t-taxon { margin-block: 0; font-size: var(--fs-small); line-height: var(--lh-tight); }


/* --------------------------------------------------------------------------
   3. Field-mark table
   -------------------------------------------------------------------------- */
.cmp-checks h2 { margin-bottom: var(--space-4); }
.checks-wrap {
    background: var(--c-surface);
    border: var(--border-hairline) solid var(--c-line);
    border-radius: var(--radius-md);
    overflow: hidden;
    /* A white surface on the ink band: light-surface ink and light edibility marks. */
    --_ink: var(--c-ink);
    --_heading: var(--c-ink-heading);
    --_label: var(--c-label-on-light);
    --_link: var(--c-link);
    --_muted: var(--c-ink-muted);
    --_focus: var(--c-focus);
}
.band--ink .checks-wrap .ed-mark { --_c: var(--_m); }
.checks-table {
    width: 100%;
    font-size: var(--fs-small);
    line-height: var(--lh-title);
    color: var(--c-ink);
}
.checks-table th,
.checks-table td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    vertical-align: top;
    border-top: var(--border-hairline) solid var(--c-line);
}
.checks-table thead th {
    border-top: 0;
    background: var(--c-band-lilac);
    color: var(--c-ink-heading);
    font-weight: var(--fw-bold);
}
.checks-table tbody th {
    width: 22%;
    color: var(--c-ink-heading);
    font-weight: var(--fw-bold);
}
.checks-table th + :is(th, td) { border-left: var(--border-hairline) solid var(--c-line); }


/* --------------------------------------------------------------------------
   4. Article content, FAQ, warning strip
   -------------------------------------------------------------------------- */
.cmp-hero {
    margin: 0 0 var(--space-6);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--c-surface-sunk);
}
.cmp-hero img { width: 100%; }
.cmp-body .article-body > .prose + .prose { margin-top: var(--space-5); }

.cmp-warning { border-top: calc(var(--border-hairline) * 2) solid var(--c-danger); }
.cmp-warning__text {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: 0;
    font-size: var(--fs-small);
    line-height: var(--lh-title);
    color: var(--c-ink);
}
.cmp-warning__text i {
    flex: none;
    font-size: var(--fs-h3);
    color: var(--c-danger);
}
.cmp-warning__text strong { color: var(--c-danger); }


/* --------------------------------------------------------------------------
   5. Pair cards (related comparisons and the index)
   -------------------------------------------------------------------------- */
.cmp-related h2 { margin-bottom: var(--space-4); }

.vs-card__media {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-1);
    background: var(--c-surface);
}
.vs-card > .card__media { aspect-ratio: 16 / 9; }
.vs-card.card--h > .card__media { aspect-ratio: auto; }
.vs-card__media .vs-badge {
    position: absolute;
    z-index: var(--z-base);
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}
.vs-card__marks {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-3);
    margin: var(--space-2) 0 0;
}
.vs-card__text {
    margin: var(--space-2) 0 0;
    font-size: var(--fs-small);
    line-height: var(--lh-title);
    color: var(--_muted);
}
.vs-card__flag { margin: 0 0 var(--space-1); color: var(--c-danger); }


/* --------------------------------------------------------------------------
   6. Index pages
   -------------------------------------------------------------------------- */
.cmp-index__head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-3) var(--space-5);
    margin-bottom: var(--space-5);
}
.cmp-index__head h2 { margin-bottom: var(--space-2); }
.cmp-index__head p { margin: 0; }
.cmp-index__count { flex: none; font-size: var(--fs-caption); white-space: nowrap; }

.cmp-guide .t-label { margin: 0; }
.cmp-guide__text {
    margin: var(--space-1) 0 0;
    font-size: var(--fs-small);
    line-height: var(--lh-title);
    color: var(--_muted);
}


/* ==========================================================================
   7. BREAKPOINTS
   The only place breakpoint numbers appear in this sheet. They mirror the
   breakpoint tokens documented in tokens.css: phone (max-width: 767px).
   ========================================================================== */

/* phone */
@media (max-width: 767px) {
    .vs { --_gap: var(--space-4); }
    .vs__badge { width: var(--control-h-sm); height: var(--control-h-sm); font-size: var(--fs-caption); }
    .vs__side h2 { font-size: var(--fs-title); }

    /* Each row becomes a block: the feature label, then the two sides with their names. */
    .checks-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
    }
    .checks-table tbody tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        border-top: var(--border-hairline) solid var(--c-line);
    }
    .checks-table tbody tr:first-child { border-top: 0; }
    .checks-table tbody th {
        grid-column: 1 / -1;
        width: auto;
        padding-bottom: 0;
        border-top: 0;
    }
    .checks-table tbody td {
        border-top: 0;
        padding-top: var(--space-2);
    }
    .checks-table th + :is(th, td) { border-left: 0; }
    .checks-table tbody td + td { border-left: var(--border-hairline) solid var(--c-line); }
    .checks-table tbody td::before {
        content: attr(data-side);
        display: block;
        margin-bottom: var(--space-1);
        font-size: var(--fs-caption);
        font-weight: var(--fw-bold);
        color: var(--c-ink-muted);
    }

    .cmp-index__head { flex-wrap: wrap; align-items: flex-start; }
}
