/* ==================================================================
   Comparison — kwizzbit/comparison (whole-file segment)
   Faithful slice of /HTML/comparison.html. Globals (reset/body/font-face/:root)
   dropped; tokens canonical (theme.json). Full-bleed via the .kwb-segment wrapper.
   ================================================================== */

.comparison {
  --comparison-table-bg: #F4E6D9;
  --comparison-table-border: rgba(182, 156, 146, 0.45);
}

    .comparison { background: var(--wp--preset--color--cream); padding-block: 5rem 6rem; }
    .comparison__inner { max-width: 1200px; margin-inline: auto; padding-inline: clamp(1rem, 4vw, 3rem); overflow: visible; }

    /* HEADER */
    .comparison__header { text-align: left; margin-bottom: 3rem; }
    .comparison__title {
      font-family: var(--wp--preset--font-family--display);
      font-weight: 400;
      color: var(--wp--preset--color--ink);
      margin: 0 0 1.25rem;
      line-height: 0.92;
    }
    .comparison__title-line1 {
      display: block;
      font-family: 'Pixelar', monospace;
      font-size: 1.1875rem;
      font-weight: 400;
      letter-spacing: 0.06em;
      color: var(--wp--preset--color--coral);
      line-height: 1;
      margin-bottom: 0.5rem;
    }
    .comparison__title-line2 {
      display: block;
      font-size: clamp(1.875rem, 10.13vw, 3.4375rem); /* Scales on mobile, locks at 55px (= features-9 headline) */
      letter-spacing: -0.09em;
      line-height: 0.85;
    }

    /* Tablet and above: lock to desktop size, never scale down */
    @media (min-width: 641px) {
      .comparison__title-line2 { font-size: 3.4375rem; }
    }
    .comparison__title-cursor {
      color: var(--wp--preset--color--coral);
      animation: cursor-blink 1.1s step-end infinite;
    }
    @keyframes cursor-blink {
      0%, 100% { opacity: 1; }
      50%       { opacity: 0; }
    }
    /* Trophy float — global spec: translateY + rotate drift, 4s ease-in-out infinite */
    @keyframes trophy-float {
      0%   { transform: translateY(0)     rotate(-2deg); }
      30%  { transform: translateY(-8px)  rotate(1deg);  }
      60%  { transform: translateY(-4px)  rotate(-1deg); }
      100% { transform: translateY(0)     rotate(-2deg); }
    }
    /* Zero-width anchor — global technique (STYLEGUIDE §8) */
    .comparison__trophy-anchor {
      position: relative;
      display: inline-block;
      width: 0;
      overflow: visible;
    }
    .comparison__trophy-float {
      position: absolute;
      left: -3.5rem;
      top: -3.75rem;
      width: 99px; /* 110 * 0.9 = 99 */
      height: auto;
      pointer-events: none;
      animation: trophy-float 4s cubic-bezier(0.65, 0, 0.35, 1) infinite;
      image-rendering: pixelated;
    }
    @media (max-width: 640px) {
      .comparison__trophy-float {
        width: 54px; /* 60 * 0.9 = 54 */
        top: -2.25rem;
        left: -1.5rem;
      }
    }
    .comparison__lead {
      font-size: 1rem;
      font-weight: 500;
      line-height: 1.6;
      color: var(--wp--custom--color--subcopy);
      margin: 0;
      max-width: 360px;
    }

    /* TABLE WRAPPER — the header above is left-aligned; the table itself
       should be centred in the window. We break it out of the left-aligned
       inner by applying its own centring so it always spans the full inner
       width symmetrically. */
    .comparison__table-wrap {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      /* 40px lets the row-1 shadow bleed freely past the inner container padding */
      padding-inline: 40px;
      margin-inline: -40px;
      position: relative;
      /* Re-centre the table independent of the left-aligned header above */
      align-self: center;
    }
    /* Left-edge fade: appears over the table when scrolled, masking
       the truncated label column. Triggered by .is-scrolled class via JS. */


    /* OUTER GRID */
    .comparison__grid {
      display: grid;
      /* Fixed column widths — never flex, never squeeze.
         Label: 280px, each feature col: 120px. Total: 1000px.
         Horizontal scroll handles any viewport narrower than this. */
      /* Label: 280px + 6 feature cols: 140px each = 1120px total.
         Matches the pricing grid (4 × 268px + 3 × 1rem = 1120px) above it. */
      grid-template-columns: 280px repeat(6, 140px);
      min-width: 1120px;
      width: 1120px;
      margin-inline: auto; /* centre within the wrapper */
    }

    /* COLUMN HEADERS */
    .comparison__col-head-cell {
      background: transparent;
      padding: 0 0.5rem 1rem;
      font-family: var(--wp--preset--font-family--body);
      font-size: 0.8125rem;
      font-weight: 600;
      line-height: 1.3;
      color: var(--wp--preset--color--ink);
      text-align: center;
    }
    .comparison__col-head-cell:first-child { text-align: left; padding-left: 0; }

    /* TABLE BOX */
    .comparison__table {
      grid-column: 1 / -1;
      display: grid;
      grid-template-columns: subgrid;
      background: var(--comparison-table-bg);
      border-radius: 0;
      border: none;
      overflow: visible;
    }

    /* ROW CELLS
       Dividers start at the icon left-edge, not the cell edge.
       padding-left on label is 1.375rem (22px). Icon is 28px wide.
       Gap between icon and copy is 0.875rem (14px).
       We use a background-image gradient instead of border-bottom on
       the label cell so we can offset the line start precisely.
       Feature cells keep a standard border-bottom. */
    .comparison__cell,
    .comparison__row-label {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 1.25rem 0.5rem;
      background: var(--comparison-table-bg);
    }
    /* Kwizzbit row label always white to match its row */
    .comparison__row--kwizzbit.comparison__row-label {
      background: var(--wp--preset--color--white);
    }
    /* Sticky label column handled via JS — see script at bottom */
    /* Feature cells: standard divider, full width */
    .comparison__cell {
      border-bottom: 0.5px solid var(--comparison-table-border);
    }
    /* Last feature cell in each row: mask final 20px via pseudo to create
       right-side indent matching the left-side icon offset */
    .comparison__cell:last-child {
      position: relative;
    }
    .comparison__cell:last-child::after {
      content: "";
      position: absolute;
      bottom: -0.5px;
      right: 0;
      width: 20px;
      height: 1px;
      background: var(--comparison-table-bg);
      pointer-events: none;
    }
    /* Label cell: divider starts at icon left-edge (1.375rem), runs to 100% */
    .comparison__row-label {
      justify-content: flex-start;
      gap: 0.875rem;
      padding-left: 1.375rem;
      padding-right: 1rem;
      background-image: linear-gradient(
        to right,
        transparent 1.375rem,
        var(--comparison-table-border) 1.375rem
      );
      background-repeat: no-repeat;
      background-size: 100% 0.5px;
      background-position: bottom;
    }
    .comparison__row--last.comparison__cell,
    .comparison__row--last.comparison__row-label {
      background-image: none !important;
      /* Explicit border-bottom on every last-row cell.
         Safari skips the table container's bottom border when overflow: visible
         is set. Drawing it on the cells themselves is always reliable. */
      border-bottom: 0.5px solid var(--comparison-table-border) !important;
    }
    /* Last cell pseudo: suppress on last row */
    .comparison__row--last.comparison__cell:last-child::after {
      display: none;
    }
    /* Alt rows: same backdrop as plain rows (no tint) */
    .comparison__row--alt.comparison__cell,
    .comparison__row--alt.comparison__row-label { background-color: transparent; }
    /* Alt rows: same divider as plain rows */
    .comparison__row--alt.comparison__row-label {
      background-image: linear-gradient(
        to right,
        transparent 1.375rem,
        var(--comparison-table-border) 1.375rem
      );
      background-repeat: no-repeat;
      background-size: 100% 0.5px;
      background-position: bottom;
    }

    /* ============================================================
       KWIZZBIT ROW — animated conic gradient border
       Technique: a full-width wrapper div (grid-column: 1/-1) holds
       the conic gradient as its background. A white ::after pseudo
       masks the interior, leaving a 1px animated border all around.
       The 7 cell divs sit inside this wrapper via CSS subgrid.
       This avoids any overflow/clip issues entirely.
       ============================================================ */
    @keyframes border-spin-ccw {
      to { --border-angle: -360deg; }
    }

    /* The wrapper spans all 7 columns */
    .comparison__row--kwizzbit-wrap {
      grid-column: 1 / -1;
      display: grid;
      grid-template-columns: subgrid;
      position: relative;
      z-index: 2;
      /* Conic gradient border via background */
      background: conic-gradient(
        from var(--border-angle),
        #FD4631 0% 60%,
        #FFCB2B 75%,
        #FD4631 90% 100%
      );
      animation: border-spin-ccw 5s linear infinite;
      /* Bleed outside the table's 0.5px border on all sides.
         Padding matches: 2px top/bottom, 2.5px left/right to compensate
         for the 0.5px table border the margin pulls us over. */
      margin: -0.5px;
      padding: 2px 2.5px;
      /* Shadow: #FF3623 10%, Y:18 blur:45 — from Sketch spec */
      box-shadow: 0 18px 45px rgba(255, 54, 35, 0.10);
    }

    /* White interior: a pseudo that fills everything inside the 1px padding */
    .comparison__row--kwizzbit-wrap::after {
      content: "";
      position: absolute;
      inset: 2px 2.5px;
      background: var(--wp--preset--color--white);
      z-index: 0;
      pointer-events: none;
    }

    /* Cells inside the wrapper sit above the white pseudo */
    .comparison__row--kwizzbit.comparison__cell,
    .comparison__row--kwizzbit.comparison__row-label {
      background: var(--wp--preset--color--white);
      border-bottom: none;
      background-image: none; /* no divider on kwizzbit row */
      position: relative;
      z-index: 1;
    }

    /* LABEL INTERNALS */
    .comparison__trophy-wrap { position: relative; }
    .comparison__row-icon { flex-shrink: 0; width: 25px; display: flex; align-items: center; justify-content: center; }

    /* Label copy: auto width, constrained by grid column.
       Subcopy width matches the Kahoot row title width via fit-content
       with a shared max-width derived from the longest title. */
    .comparison__row-label-copy {
      display: flex;
      flex-direction: column;
      gap: 0.25rem;
      /* Let the copy block be as wide as the longest title naturally.
         We use width: fit-content so each instance shrinks to its content.
         All rows share max-width = width of "Edu tools (eg. Kahoot/Wayground)"
         at 0.875rem 700 — measured at ~163px. Set slightly generously. */
      width: fit-content;
      max-width: 168px;
    }
    .comparison__kw-logo { width: 79px; height: auto; display: block; image-rendering: pixelated; }
    .comparison__row-name {
      font-size: 0.875rem;
      font-weight: 700;
      color: var(--wp--preset--color--ink);
      line-height: 1.2;
      white-space: nowrap; /* titles don't wrap — their natural width drives the column */
    }
    .comparison__row-name-suffix { font-size: 0.8125rem; } /* 1px smaller than row-name */
    .comparison__row-desc {
      font-size: 0.75rem;
      font-weight: 500;
      color: var(--wp--custom--color--subcopy);
      line-height: 1.4;
      /* Subcopy wraps within the same max-width as the title above it */
      white-space: normal;
    }

    /* FLAG */
    .comparison__flag { display: flex; align-items: center; justify-content: center; }
    .comparison__flag svg { display: block; flex-shrink: 0; }

    /* TROPHY */
    .comparison__trophy { position: absolute; right: -52px; bottom: -8px; width: 96px; pointer-events: none; }

    /* SCROLL HINT */
    .comparison__scroll-hint { display: none; align-items: center; justify-content: center; gap: 0.375rem; font-size: 0.75rem; font-weight: 600; color: var(--wp--custom--color--subcopy); margin-bottom: 1.5rem; padding: 0.5rem 0.875rem; background: rgba(255, 54, 35, 0.07); border-radius: 0; align-self: center; width: fit-content; margin-inline: auto; }
    @keyframes scroll-nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(5px); } }
    .comparison__scroll-hint svg { animation: scroll-nudge 1.6s ease-in-out infinite; }

    /* SCROLL REVEAL */
    .comparison .js-reveal { opacity: 0; transform: translateY(20px); transition: opacity 0.55s cubic-bezier(0.22,1,0.36,1), transform 0.55s cubic-bezier(0.22,1,0.36,1); }
    .comparison .js-reveal.is-visible { opacity: 1; transform: none; }

    /* TABLET */
    @media (max-width: 1023px) {
      .comparison { padding-block: 4rem 5rem; }
      .comparison__header { margin-bottom: 1.5rem; }
      .comparison__scroll-hint { display: flex; }
      /* Table, columns, typography — all unchanged from desktop.
         Horizontal scroll handles any overflow. Nothing squeezes. */
    }

    /* MOBILE */
    @media (max-width: 640px) {
      .comparison { padding-block: 3rem 3.5rem; }
      .comparison__header { margin-bottom: 1.5rem; }
      .comparison__lead { font-size: 1rem; max-width: 280px; } /* 16px on mobile — matches hero lead */
      /* Table, columns, icons, typography — all unchanged from desktop.
         Horizontal scroll handles any overflow. Nothing squeezes. */
      .comparison__scroll-hint svg { shape-rendering: crispEdges; image-rendering: pixelated; }
      .comparison__title-line1 { font-size: 18px; } /* Pixelar eyebrow → 16px on mobile */
      /* Left-align the scroll indicator — the header is already left-aligned
         so the hint should sit flush with the header copy, not centred. */
      .comparison__scroll-hint { margin-inline: 0; }
    }
