/* ==========================================================================
 * modules/offers/css/comparison_table.css
 * --------------------------------------------------------------------------
 * Owner: main-domain offers UI/UX redesign — Batch 3
 *   (plan: ~/.claude/plans/main_domain_offers_uiux_redesign.md §5/Batch 3)
 *
 * Scope: side-by-side feature comparison table consumed by
 *   offers_render_comparison_table(). Read on offers.php right after the
 *   plan-strip, and on landing.php inside a collapsible <details> labelled
 *   "Vergleichen".
 *
 * Boundaries
 *   - Reads from theme_a/tokens.css ONLY (--compare-*, --space-*, --primary,
 *     --primary-rgb, --surface, --surface-2, --border, --text, --text-rgb,
 *     --text-strong, --muted, --shadow, --radius, --plan-card-radius,
 *     --focus-ring). No raw hex.
 *   - All inset / padding / margin / border properties use logical axes
 *     (inset-inline-*, padding-block, padding-inline, margin-inline,
 *     border-inline-*) so RTL works without overrides.
 *   - prefers-reduced-motion disables open/close summary animations.
 *   - @media print neutralizes the sticky column + scroll-snap so the
 *     printed sheet shows the full table grid.
 * ========================================================================== */

/* --------------------------------------------------------------------------
 * Section shell — wraps the heading, intro, and the table itself.
 * Used both as a plain <section> on offers.php and inside <details> on
 * landing.php; the <details> shell adds its own toggle chrome below.
 * ------------------------------------------------------------------------ */

.compare-section {
  margin-block-start: var(--space-8, 40px);
  margin-block-end: var(--space-8, 40px);
}

.compare-section__head {
  margin-block-end: var(--space-5, 20px);
  text-align: center;
}

.compare-section__eyebrow {
  display: inline-block;
  margin-block-end: var(--space-2, 8px);
  padding-block: 4px;
  padding-inline: 12px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.compare-section__title {
  margin: 0 0 var(--space-2, 8px);
  font-size: clamp(1.4rem, 2.4vw + 0.4rem, 1.9rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-strong);
}

.compare-section__intro {
  margin: 0 auto;
  max-inline-size: 60ch;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

/* --------------------------------------------------------------------------
 * Collapsible (<details>) variant on landing.php.
 * The summary acts as the toggle button; we hide the native marker and
 * paint our own chevron so the design matches the other CTAs on the page.
 * ------------------------------------------------------------------------ */

.compare-collapsible {
  margin-block-start: var(--space-6, 24px);
  margin-block-end: var(--space-8, 40px);
  border-radius: var(--plan-card-radius, 16px);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.compare-collapsible__summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3, 12px);
  padding-block: var(--space-4, 16px);
  padding-inline: var(--space-5, 20px);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-strong);
  background: var(--surface);
  border: 0;
  user-select: none;
}

.compare-collapsible__summary::-webkit-details-marker { display: none; }
.compare-collapsible__summary::marker { content: ''; }

.compare-collapsible__summary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.compare-collapsible__chevron {
  inline-size: 18px;
  block-size: 18px;
  flex: 0 0 auto;
  color: var(--primary);
  transition: transform var(--dur-base, 200ms) var(--ease-decelerate, cubic-bezier(0, 0, 0.2, 1));
}

.compare-collapsible[open] .compare-collapsible__chevron {
  transform: rotate(180deg);
}

[dir="rtl"] .compare-collapsible__chevron {
  transform: scaleX(-1);
}

[dir="rtl"] .compare-collapsible[open] .compare-collapsible__chevron {
  transform: scaleX(-1) rotate(180deg);
}

.compare-collapsible__body {
  padding-block: var(--space-5, 20px);
  padding-inline: var(--space-5, 20px);
  border-block-start: 1px solid var(--border);
  background: var(--surface-2);
}

.compare-collapsible__body .compare-section {
  margin-block: 0;
}

.compare-collapsible__body .compare-section__head {
  margin-block-end: var(--space-4, 16px);
}

@media (prefers-reduced-motion: reduce) {
  .compare-collapsible__chevron {
    transition: none;
  }
}

/* --------------------------------------------------------------------------
 * Scroll wrap — controls the horizontal overflow on small screens and
 * provides the rounded surface that contains the table on desktop.
 * ------------------------------------------------------------------------ */

.compare-table-wrap {
  position: relative;
  border-radius: var(--plan-card-radius, 16px);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden; /* desktop: clip the rounded corners */
}

/* --------------------------------------------------------------------------
 * Table proper. Border-collapse:separate keeps each cell's border
 * controllable individually; we manage row dividers with border-block-end
 * on cells so the featured column can paint its own inline borders.
 * ------------------------------------------------------------------------ */

.compare-table {
  inline-size: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.95rem;
  color: var(--text);
  text-align: start;
  table-layout: fixed;
}

.compare-table caption {
  /* Visually hidden but read by screen readers as the table caption. */
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.compare-table th,
.compare-table td {
  padding-block: var(--space-3, 12px);
  padding-inline: var(--compare-cell-pad-x, 14px);
  vertical-align: middle;
  border-block-end: 1px solid var(--border);
  background: var(--surface);
}

.compare-table tr:last-child th,
.compare-table tr:last-child td {
  border-block-end: 0;
}

/* Row stripe (every second body row) for easier horizontal tracking. */
.compare-table tbody tr:nth-child(even) th,
.compare-table tbody tr:nth-child(even) td {
  background: var(--compare-row-stripe, rgba(11, 18, 32, 0.025));
}

/* Row label column. */
.compare-table th[scope="row"] {
  font-weight: 600;
  color: var(--text-strong);
  text-align: start;
  inline-size: 38%;
  background: var(--compare-header-bg, var(--surface-2));
}

.compare-table tbody tr:nth-child(even) th[scope="row"] {
  /* Even rows: blend the row label cell with the rest of the stripe so the
   * sticky column reads as one continuous band. */
  background: color-mix(in srgb, var(--compare-header-bg) 88%, var(--compare-row-stripe) 12%);
}

/* Column header (tier name). */
.compare-table thead th[scope="col"] {
  font-weight: 700;
  color: var(--text-strong);
  text-align: center;
  background: var(--compare-header-bg, var(--surface-2));
  vertical-align: top;
}

.compare-table thead th[scope="col"].compare-col--label {
  /* Top-left empty header cell. The "Feature" / "الميزة" label sits in the
   * row-label column, so it must align like the row labels below it
   * (start = right in RTL, left in LTR), not centred like the tier columns. */
  background: var(--compare-header-bg, var(--surface-2));
  inline-size: 38%;
  text-align: start;
}

.compare-col__tier {
  display: block;
  font-size: 1.05rem;
  line-height: 1.25;
}

.compare-col__featured {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-block-start: 6px;
  padding-block: 2px;
  padding-inline: 10px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), 0.12);
  /* Orange-on-peach text needs WCAG AA contrast — use the darker derivative. */
  color: var(--primary-on-light);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.compare-col__featured-icon {
  inline-size: 12px;
  block-size: 12px;
  flex: 0 0 auto;
}

/* Data cells. Text follows the document direction:
 *   RTL (Arabic) → right-aligned, LTR (de/en/fr/…) → left-aligned. */
.compare-table tbody td {
  text-align: start;
}

.compare-cell__bool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 28px;
  block-size: 28px;
  border-radius: 999px;
}

.compare-cell__bool--yes {
  background: rgba(var(--primary-rgb), 0.08);
  color: var(--compare-cell-icon-yes, var(--success, var(--primary)));
}

.compare-cell__bool--no {
  background: rgba(var(--text-rgb), 0.05);
  color: var(--compare-cell-icon-no, rgba(var(--text-rgb), 0.35));
}

.compare-cell__bool-icon {
  inline-size: 16px;
  block-size: 16px;
  flex: 0 0 auto;
}

.compare-cell__sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.compare-cell__text {
  display: block;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
}

.compare-cell__measure {
  white-space: nowrap;
  unicode-bidi: isolate;
}

.compare-cell__text[dir="rtl"] {
  text-align: right;
}

.compare-cell__text[dir="ltr"] {
  text-align: left;
}

/* Dimension/number runs (e.g. "85 × 55", "14,0 × 29,7") are wrapped in
 * <bdi dir="ltr"> by offers_compare_cell_text_html(). Force a hard LTR
 * isolate here so the bidi algorithm cannot pull the digits into the
 * Arabic flow — without this, "طيّ لولبي" gets visually split with the
 * dimensions inserted in the middle of the word. */
.compare-cell__text bdi {
  direction: ltr;
  unicode-bidi: isolate;
}

.compare-cell__empty {
  color: var(--muted);
  font-weight: 400;
}

/* --------------------------------------------------------------------------
 * Featured column highlight. Painted via class on the column header and on
 * every cell that belongs to the same column index (the renderer adds
 * .compare-col--featured to all <th>/<td> in that column).
 * ------------------------------------------------------------------------ */

.compare-table .compare-col--featured {
  background: rgba(var(--primary-rgb), 0.045);
  border-inline-start: 1px solid rgba(var(--primary-rgb), 0.25);
  border-inline-end: 1px solid rgba(var(--primary-rgb), 0.25);
}

.compare-table tbody tr:nth-child(even) td.compare-col--featured {
  background: rgba(var(--primary-rgb), 0.07);
}

.compare-table thead th[scope="col"].compare-col--featured {
  background: rgba(var(--primary-rgb), 0.1);
  border-block-start: 2px solid var(--primary);
  border-block-end: 1px solid rgba(var(--primary-rgb), 0.25);
  color: var(--text-strong);
}

.compare-table tbody tr:last-child td.compare-col--featured {
  border-block-end: 2px solid var(--primary);
}

/* --------------------------------------------------------------------------
 * Mobile <600px — horizontal scroll-snap, sticky row-label column.
 * Wrap uses overflow-x:auto + scroll-snap on each <th[scope="col"]>; the
 * row-label cells stay visible on the inline-start edge while users swipe
 * through the offer columns.
 * ------------------------------------------------------------------------ */

@media (max-width: 599px) {
  .compare-table-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--plan-card-radius, 16px);
  }

  .compare-table {
    inline-size: max-content;
    min-inline-size: 100%;
  }

  .compare-table th,
  .compare-table td {
    padding-inline: var(--space-3, 12px);
  }

  /* Row-label / first column: sticky to the inline-start edge so the
   * swiping user always knows what the visible cell represents. */
  .compare-table th[scope="row"],
  .compare-table thead th[scope="col"].compare-col--label {
    position: sticky;
    inset-inline-start: 0;
    z-index: 2;
    inline-size: 44vw;
    min-inline-size: 160px;
    max-inline-size: 220px;
    /* Drop shadow on the inline-end edge so users get a visual cue that
     * content is scrolling behind it. */
    box-shadow: 1px 0 0 var(--border);
  }

  [dir="rtl"] .compare-table th[scope="row"],
  [dir="rtl"] .compare-table thead th[scope="col"].compare-col--label {
    box-shadow: -1px 0 0 var(--border);
  }

  /* Each offer column gets a snap-aligned width. */
  .compare-table thead th[scope="col"]:not(.compare-col--label),
  .compare-table tbody td:not(.compare-col--row-label) {
    scroll-snap-align: start;
    inline-size: 56vw;
    min-inline-size: 200px;
  }

}

/* --------------------------------------------------------------------------
 * Print — drop the sticky column + scroll wrap so the full grid prints.
 * ------------------------------------------------------------------------ */

@media print {
  .compare-collapsible[open] .compare-collapsible__chevron,
  .compare-collapsible__summary {
    display: none;
  }
  .compare-collapsible__body {
    padding: 0;
    border: 0;
    background: transparent;
  }
  .compare-table-wrap {
    overflow: visible;
    box-shadow: none;
    border: 1px solid var(--border);
  }
  .compare-table th,
  .compare-table td {
    background: transparent !important;
    box-shadow: none !important;
    position: static !important;
  }
}
