/*
 * Companion page /itil-4-or-itil-5, S2 SIDE BY SIDE (#compare, paper).
 * Spec: docs/ux-discovery/itil-5-foundation/direction.md ("COMPANION PAGE" S2) + fold-companion.json.
 * Every selector starts main.itil-v1 #compare. Tokens, base, skin and page.css are reused, never edited.
 * Nothing under 16px. No fixed width over 360px.
 *
 * One-screen budget at 1366x768 (content block <= 556px), by construction:
 *   head row 52 (H2 one line 40px beside the 52px button) + 16
 *   card = 1 + 8 + table + 8 + 1, table = thead 64 (2 x 21.6 name + 12 + 8 + 1)
 *        + 4 two-line rows x 61.8 (2 x 22.4 + 16 + 1) + 2 one-line rows x 39.4 - 1   = about 389  =>  card about 407
 *   + 12 + note 24 (one line)                                                        = about 511px, 135px free
 *   With the VAT sentence the note is two lines: about 535px, 111px free.
 *   Exam row on (.v1-q45-compare--exam): Prerequisites and Length share one row, cells 6px and line-height 1.35,
 *   card padding 4px: about 515px, or 539px with the VAT sentence.
 * Text widths were measured with the page font (Plus Jakarta Sans): the longest first line is
 * "Service value system, four dimensions," = 291px; each course column gives 302px of text, so every
 * "two-line" cell stays on two lines. Formats and the date / price lines never break inside a pair.
 * Below 768px the same table becomes one card per course (grid + order; ARIA roles are in the markup).
 */

/* ---------- Layout ---------- */
main.itil-v1 #compare .v1-fold__inner { gap: 16px; }
main.itil-v1 #compare .v1-q45-compare__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px 24px;
}
main.itil-v1 #compare .v1-q45-compare__h2 { margin: 0; min-width: 0; }
main.itil-v1 #compare .v1-q45-compare__head .v1-btn { flex: 0 0 auto; }

/* ---------- Stage and orbs (decoration behind the card; no height) ----------
   Only from 1366px, where the container has an 83px gutter: the orbs peek out 64px at the sides and never pass
   the viewport. They stay clear of the heading row above and of the note below (both would be painted under them). */
main.itil-v1 #compare .v1-q45-compare__stage { position: relative; }
main.itil-v1 #compare .v1-q45-compare__orb { display: none; }
@media (min-width: 1366px) {
    main.itil-v1 #compare .v1-q45-compare__orb { display: block; position: absolute; z-index: 0; pointer-events: none; }
    main.itil-v1 #compare .v1-q45-compare__orb--a { left: -64px; top: 18%; width: 200px; opacity: .5; }
    main.itil-v1 #compare .v1-q45-compare__orb--b { right: -64px; bottom: 24px; width: 240px; opacity: .45; }
}
@media print { main.itil-v1 #compare .v1-q45-compare__orb { display: none; } }

/* ---------- The card ---------- */
main.itil-v1 #compare .v1-q45-compare__card {
    position: relative;
    z-index: 1;
    padding: 8px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow-card), 0 34px 60px -44px rgba(124, 92, 255, .55);
}

/* ---------- The table (desktop and tablet) ---------- */
main.itil-v1 #compare .v1-q45-table {
    table-layout: fixed;
    font-size: 16px;
    line-height: 1.4;
    color: var(--ink);
}
main.itil-v1 #compare .v1-q45-table__corner,
main.itil-v1 #compare .v1-q45-table__label { width: 136px; }

/* Column headers: the course link under a 3px gradient bar. */
main.itil-v1 #compare .v1-q45-table thead :is(th, td) {
    position: relative;
    height: auto;
    padding: 12px 10px 8px;
    background: transparent;
    border-bottom: 1px solid var(--line);
    border-radius: 12px 12px 0 0;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.015em;
    white-space: normal;
    vertical-align: top;
    transition: background-color 160ms ease;
}
main.itil-v1 #compare .v1-q45-table__col::before {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    top: 0;
    height: 3px;
    border-radius: 3px;
    background: var(--grad);
    transform-origin: 0 50%;
    transition: transform 520ms var(--ease-out);
}
main.itil-v1 #compare .v1-q45-col--2::before { transition-delay: 90ms; }
main.itil-v1 #compare .v1-q45-col--3::before { transition-delay: 180ms; }
/* Armed by fold-compare.js until the card scrolls into view; without the script the bars are simply there. */
main.itil-v1 #compare .v1-q45-compare__card.is-bars-armed .v1-q45-table__col::before { transform: scaleX(0); }

main.itil-v1 #compare .v1-q45-table__course {
    --v1-td: none;
    color: var(--ink);
    transition: color var(--t-fast) ease;
}
main.itil-v1 #compare .v1-q45-table__name {
    padding-bottom: 2px;
    background-image: linear-gradient(var(--link), var(--link));
    background-repeat: no-repeat;
    background-position: 0 100%;
    background-size: 0% 2px;
    transition: background-size 320ms var(--ease-out);
}
main.itil-v1 #compare .v1-q45-table__go {
    display: inline-block;
    width: 18px;
    height: 18px;
    margin-left: 6px;
    vertical-align: -3px;
    color: var(--link);
    opacity: .6;
    transition: transform 320ms var(--ease-out), opacity var(--t-fast) ease;
}
main.itil-v1 #compare .v1-q45-table__course:hover,
main.itil-v1 #compare .v1-q45-table__course:focus-visible { color: var(--link); }
main.itil-v1 #compare .v1-q45-table__course:hover .v1-q45-table__name,
main.itil-v1 #compare .v1-q45-table__course:focus-visible .v1-q45-table__name { background-size: 100% 2px; }
main.itil-v1 #compare .v1-q45-table__course:hover .v1-q45-table__go,
main.itil-v1 #compare .v1-q45-table__course:focus-visible .v1-q45-table__go { opacity: 1; transform: translateX(4px); }

/* Body rows. */
main.itil-v1 #compare .v1-q45-table tbody :is(th, td) {
    padding: 8px 10px;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
    transition: background-color 160ms ease;
}
main.itil-v1 #compare .v1-q45-table tbody tr:last-child :is(th, td) { border-bottom: 0; }
main.itil-v1 #compare .v1-q45-table tbody tr:last-child td { border-radius: 0 0 12px 12px; }
main.itil-v1 #compare .v1-q45-table__label {
    padding-left: 0;
    font-weight: 700;
    color: var(--mute);
}
main.itil-v1 #compare .v1-q45-table__cell { text-wrap: pretty; }
main.itil-v1 #compare .v1-q45-table__line { display: block; white-space: nowrap; }
main.itil-v1 #compare .v1-q45-table__line--from { color: var(--mute); }
main.itil-v1 #compare .v1-q45-table__line--from .v1-price { color: var(--ink); }
main.itil-v1 #compare .v1-q45-table__source { --v1-td: underline; color: var(--link); font-weight: 600; white-space: nowrap; }

/* Hover or focus on a course header tints its whole column. No layout shift: background only. */
@media (min-width: 768px) {
    /* The row people came for (next date and price) sits on a faint lilac band. */
    main.itil-v1 #compare .v1-q45-table tbody tr:last-child td { background-color: rgba(124, 92, 255, .05); }
    main.itil-v1 #compare .v1-q45-table:has(.v1-q45-col--1 .v1-q45-table__course:is(:hover, :focus-visible)) .v1-q45-col--1,
    main.itil-v1 #compare .v1-q45-table:has(.v1-q45-col--2 .v1-q45-table__course:is(:hover, :focus-visible)) .v1-q45-col--2,
    main.itil-v1 #compare .v1-q45-table:has(.v1-q45-col--3 .v1-q45-table__course:is(:hover, :focus-visible)) .v1-q45-col--3 {
        background-color: rgba(124, 92, 255, .08);
    }
    /* Same tint for browsers without :has (set by fold-compare.js). */
    main.itil-v1 #compare .v1-q45-table[data-col-on="1"] .v1-q45-col--1,
    main.itil-v1 #compare .v1-q45-table[data-col-on="2"] .v1-q45-col--2,
    main.itil-v1 #compare .v1-q45-table[data-col-on="3"] .v1-q45-col--3 {
        background-color: rgba(124, 92, 255, .08);
    }
}

/* ---------- The note ---------- */
main.itil-v1 #compare .v1-q45-compare__note {
    margin: -4px 0 0;          /* 16px gap - 4px = 12px under the card */
    font-size: 16px;
    line-height: 1.5;
    color: var(--mute);
    text-wrap: pretty;
}

/* ---------- Exam row on: a tighter card, so the extra row still fits one screen ---------- */
main.itil-v1 #compare.v1-q45-compare--exam .v1-q45-compare__card { padding-block: 4px; }
main.itil-v1 #compare.v1-q45-compare--exam .v1-q45-table { line-height: 1.35; }
main.itil-v1 #compare.v1-q45-compare--exam .v1-q45-table tbody :is(th, td) { padding-block: 6px; }
main.itil-v1 #compare.v1-q45-compare--exam .v1-q45-table thead :is(th, td) { padding: 10px 10px 6px; }

/* ---------- Tablet (768 to 1099px): the table stays, with a narrower label column; the section flows ---------- */
@media (min-width: 768px) and (max-width: 1099.98px) {
    main.itil-v1 #compare .v1-q45-compare__card { padding-inline: 12px; }
    main.itil-v1 #compare .v1-q45-table__corner,
    main.itil-v1 #compare .v1-q45-table__label { width: 112px; }
    main.itil-v1 #compare .v1-q45-table thead :is(th, td),
    main.itil-v1 #compare .v1-q45-table tbody :is(th, td) { padding-inline: 8px; }
    main.itil-v1 #compare .v1-q45-table__label { padding-left: 0; }
    main.itil-v1 #compare .v1-q45-table__col::before { left: 8px; right: 8px; }
    main.itil-v1 #compare .v1-q45-table__line { white-space: normal; }
}

/* ---------- Phones: one white card per course ---------- */
@media (max-width: 767.98px) {
    main.itil-v1 #compare .v1-q45-compare__head { flex-direction: column; align-items: stretch; gap: 16px; }
    main.itil-v1 #compare .v1-q45-compare__head .v1-btn { width: 100%; }

    main.itil-v1 #compare .v1-q45-compare__card {
        padding: 0;
        background: none;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }
    /* The cells become the items of a one-column grid, grouped by course with `order` (DOM order inside a group
       is the row order: name, who it suits, prerequisites, length, formats, what it covers, next date and price). */
    main.itil-v1 #compare .v1-q45-table {
        position: relative;
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
    }
    main.itil-v1 #compare .v1-q45-table :is(thead, tbody, tr) { display: contents; }
    main.itil-v1 #compare .v1-q45-table__corner { display: none; }
    /* Row headers stay for assistive tech (clipped, not removed); data-label shows the label inside each card. */
    main.itil-v1 #compare .v1-q45-table__label {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0 0 0 0);
        clip-path: inset(50%);
        white-space: nowrap;
        border: 0;
    }
    main.itil-v1 #compare .v1-q45-col--1 { order: 1; }
    main.itil-v1 #compare .v1-q45-col--2 { order: 2; }
    main.itil-v1 #compare .v1-q45-col--3 { order: 3; }

    main.itil-v1 #compare .v1-q45-table thead th.v1-q45-table__col {
        display: block;
        width: auto;
        padding: 15px 20px 0;
        overflow: hidden;
        background: var(--surface);
        border: 1px solid var(--line);
        border-bottom: 0;
        border-radius: 20px 20px 0 0;
        font-size: 19px;
        line-height: 1.25;
    }
    main.itil-v1 #compare .v1-q45-table thead th.v1-q45-table__col:not(.v1-q45-col--1) { margin-top: 16px; }
    main.itil-v1 #compare .v1-q45-table__col::before { left: 0; right: 0; border-radius: 0; }
    main.itil-v1 #compare .v1-q45-table__course {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        min-height: 48px;
    }
    main.itil-v1 #compare .v1-q45-table__go { flex: 0 0 auto; width: 20px; height: 20px; margin: 0; opacity: 1; }

    main.itil-v1 #compare .v1-q45-table tbody td.v1-q45-table__cell {
        display: block;
        width: auto;
        padding: 10px 20px;
        background: var(--surface);
        border: 0;
        border-left: 1px solid var(--line);
        border-right: 1px solid var(--line);
        border-radius: 0;
        box-shadow: inset 0 1px 0 var(--line);
        font-size: 16px;
        line-height: 1.45;
    }
    main.itil-v1 #compare .v1-q45-table__cell::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 2px;
        font-weight: 700;
        color: var(--mute);
    }
    main.itil-v1 #compare .v1-q45-table tbody tr:last-child td.v1-q45-table__cell {
        padding-bottom: 20px;
        border-bottom: 1px solid var(--line);
        border-radius: 0 0 20px 20px;
    }
    main.itil-v1 #compare .v1-q45-table__line { white-space: normal; }

    main.itil-v1 #compare .v1-q45-compare__note { margin-top: 0; }
}

/* ---------- Reduced motion: no bar growth, colour-only hover ---------- */
@media (prefers-reduced-motion: reduce) {
    main.itil-v1 #compare .v1-q45-table__col::before { transition: none; transform: none !important; }
    main.itil-v1 #compare .v1-q45-table__name,
    main.itil-v1 #compare .v1-q45-table__go { transition: none; }
    main.itil-v1 #compare .v1-q45-table__course:hover .v1-q45-table__go,
    main.itil-v1 #compare .v1-q45-table__course:focus-visible .v1-q45-table__go { transform: none; }
}
