@layer components {
  /* ===================================================
     Gnostic Data Tables and Comparative Layout
     Version: 3.0, Responsive Editorial Rewrite (2026)

     Improvements:
     • Preserves desktop table layout
     • Preserves mobile card stacking
     • Preserves horizontal-scroll modifier
     • Removes duplicated dark-mode overrides
     • Uses theme tokens consistently
     • Reduces heavy card and glow styling
     • Improves wrapping, focus states and mobile labels
     • Keeps existing class names and markup contract
     =================================================== */

  /* ===================================================
     Responsive table wrapper
     =================================================== */

  :where(.gnostic-table-responsive) {
    width: 100%;
    min-width: 0;

    margin:
      clamp(
        1.75rem,
        5vw,
        var(--space-lg, 3rem)
      )
      0;

    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behaviour-inline: contain;

    border:
      1px solid
      color-mix(
        in srgb,
        var(--section-border) 78%,
        transparent
      );

    border-radius:
      var(
        --border-radius-base,
        0.75rem
      );

    background:
      color-mix(
        in srgb,
        var(--bg-surface, var(--bg-primary)) 92%,
        transparent
      );

    box-shadow:
      0
      8px
      24px
      color-mix(
        in srgb,
        var(--shadow-glow) 16%,
        transparent
      );

    scrollbar-width: thin;
    scrollbar-color:
      var(--text-accent)
      transparent;
  }

  :where(.gnostic-table-responsive)::-webkit-scrollbar {
    height: 0.55rem;
  }

  :where(.gnostic-table-responsive)::-webkit-scrollbar-track {
    background: transparent;
  }

  :where(.gnostic-table-responsive)::-webkit-scrollbar-thumb {
    background:
      color-mix(
        in srgb,
        var(--text-accent) 45%,
        transparent
      );

    border-radius: 999px;
  }

  /* ===================================================
     Core table
     =================================================== */

  :where(.gnostic-table) {
    width: 100%;
    min-width: 42rem;

    border-collapse: collapse;
    border-spacing: 0;

    color: var(--text-primary);

    font-family:
      var(
        --font-serif,
        "Libre Baskerville",
        serif
      );

    font-size:
      clamp(
        0.88rem,
        1.2vw,
        var(--font-size-sm)
      );

    line-height: 1.6;
  }

  /* ===================================================
     Table header
     =================================================== */

  :where(.gnostic-table thead) {
    background:
      var(
        --table-head-bg,
        color-mix(
          in srgb,
          var(--text-accent) 10%,
          var(--bg-surface, var(--bg-primary))
        )
      );

    color: var(--text-accent);

    border-bottom:
      2px solid
      var(--text-accent);
  }

  :where(.gnostic-table th) {
    color: var(--text-accent);

    font-family: var(--font-display);

    font-size:
      clamp(
        0.82rem,
        1.2vw,
        var(--font-size-base, 1rem)
      );

    font-weight: var(--type-weight-bold, 700);
    line-height: 1.35;
    letter-spacing: 0.035em;
    text-transform: uppercase;
  }

  /* ===================================================
     Cells
     =================================================== */

  :where(.gnostic-table th),
  :where(.gnostic-table td) {
    min-width: 0;

    padding:
      clamp(
        0.75rem,
        1.8vw,
        var(--space-sm, 1rem)
      )
      clamp(
        0.85rem,
        2.2vw,
        var(--space-md, 1.5rem)
      );

    border-right:
      1px solid
      color-mix(
        in srgb,
        var(--section-border) 66%,
        transparent
      );

    border-bottom:
      1px solid
      color-mix(
        in srgb,
        var(--section-border) 66%,
        transparent
      );

    color: var(--text-primary);

    text-align: left;
    vertical-align: top;

    overflow-wrap: anywhere;
    word-break: normal;
  }

  :where(.gnostic-table th:last-child),
  :where(.gnostic-table td:last-child) {
    border-right: 0;
  }

  :where(.gnostic-table tbody tr:last-child td) {
    border-bottom: 0;
  }

  /* ===================================================
     Row alternation and hover
     =================================================== */

  :where(.gnostic-table tbody tr:nth-child(odd)) {
    background:
      var(
        --table-row-odd,
        color-mix(
          in srgb,
          var(--text-primary) 4%,
          transparent
        )
      );
  }

  :where(.gnostic-table tbody tr:nth-child(even)) {
    background:
      var(
        --table-row-even,
        transparent
      );
  }

  :where(.gnostic-table tbody tr:hover) {
    background:
      var(
        --table-row-hover,
        color-mix(
          in srgb,
          var(--highlight) 10%,
          transparent
        )
      );
  }

  /* ===================================================
     Links inside tables
     =================================================== */

  :where(.gnostic-table a) {
    color: var(--text-accent);

    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;

    overflow-wrap: anywhere;

    transition:
      color 0.2s ease,
      text-shadow 0.2s ease,
      text-decoration-color 0.2s ease;
  }

  :where(.gnostic-table a:hover) {
    color: var(--highlight);
    text-decoration-color: transparent;
    text-shadow:
      0
      0
      6px
      var(--shadow-glow);
  }

  :where(.gnostic-table a:focus-visible) {
    color: var(--highlight);

    outline:
      2px solid
      color-mix(
        in srgb,
        var(--text-accent) 70%,
        transparent
      );

    outline-offset: 3px;
    border-radius: 0.15rem;
  }

  /* ===================================================
     Mobile card layout
     =================================================== */

  @media (max-width: 640px) {
    :where(.gnostic-table-responsive:not(.gnostic-table-responsive--scroll)) {
      overflow: visible;

      margin:
        clamp(
          1.5rem,
          7vw,
          2.25rem
        )
        0;

      border: 0;
      border-radius: 0;

      background: transparent;
      box-shadow: none;
    }

    :where(
      .gnostic-table-responsive:not(.gnostic-table-responsive--scroll)
      .gnostic-table
    ) {
      display: block;

      width: 100%;
      min-width: 0;
    }

    :where(
      .gnostic-table-responsive:not(.gnostic-table-responsive--scroll)
      .gnostic-table thead
    ) {
      display: none;
    }

    :where(
      .gnostic-table-responsive:not(.gnostic-table-responsive--scroll)
      .gnostic-table tbody
    ) {
      display: block;
      width: 100%;
    }

    :where(
      .gnostic-table-responsive:not(.gnostic-table-responsive--scroll)
      .gnostic-table tr
    ) {
      display: block;

      width: 100%;
      min-width: 0;

      margin-bottom:
        var(
          --space-md,
          1.5rem
        );

      overflow: hidden;

      border:
        1px solid
        color-mix(
          in srgb,
          var(--section-border) 78%,
          transparent
        );

      border-left:
        3px solid
        var(--text-accent);

      border-radius:
        var(
          --border-radius-base,
          0.75rem
        );

      background:
        color-mix(
          in srgb,
          var(--bg-surface, var(--bg-primary)) 92%,
          transparent
        );

      box-shadow:
        0
        8px
        22px
        color-mix(
          in srgb,
          var(--shadow-glow) 14%,
          transparent
        );
    }

    :where(
      .gnostic-table-responsive:not(.gnostic-table-responsive--scroll)
      .gnostic-table tr:last-child
    ) {
      margin-bottom: 0;
    }

    :where(
      .gnostic-table-responsive:not(.gnostic-table-responsive--scroll)
      .gnostic-table tbody tr:nth-child(odd)
    ),
    :where(
      .gnostic-table-responsive:not(.gnostic-table-responsive--scroll)
      .gnostic-table tbody tr:nth-child(even)
    ),
    :where(
      .gnostic-table-responsive:not(.gnostic-table-responsive--scroll)
      .gnostic-table tbody tr:hover
    ) {
      background:
        color-mix(
          in srgb,
          var(--bg-surface, var(--bg-primary)) 92%,
          transparent
        );
    }

    :where(
      .gnostic-table-responsive:not(.gnostic-table-responsive--scroll)
      .gnostic-table td
    ) {
      display: grid;
      grid-template-columns:
        minmax(6.5rem, 34%)
        minmax(0, 1fr);

      align-items: start;
      gap: 0.75rem;

      width: 100%;

      padding:
        0.75rem
        0.9rem;

      border: 0;

      border-bottom:
        1px solid
        color-mix(
          in srgb,
          var(--section-border) 62%,
          transparent
        );

      background: transparent;

      font-size:
        clamp(
          0.88rem,
          3.7vw,
          0.96rem
        );

      line-height: 1.55;
    }

    :where(
      .gnostic-table-responsive:not(.gnostic-table-responsive--scroll)
      .gnostic-table td[data-label]::before
    ) {
      content: attr(data-label);

      display: block;

      color: var(--text-accent);

      font-family: var(--font-display);

      font-size:
        clamp(
          0.7rem,
          3vw,
          var(--font-size-vs, 0.8rem)
        );

      font-weight: var(--type-weight-bold, 700);
      line-height: 1.35;
      letter-spacing: 0.035em;
      text-transform: uppercase;

      opacity: 0.92;
    }

    :where(
      .gnostic-table-responsive:not(.gnostic-table-responsive--scroll)
      .gnostic-table td:first-child
    ) {
      display: block;

      padding:
        0.9rem
        1rem;

      color: var(--text-accent);

      background:
        var(
          --table-head-bg,
          color-mix(
            in srgb,
            var(--text-accent) 10%,
            transparent
          )
        );

      border-bottom:
        2px solid
        var(--text-accent);

      font-family: var(--font-display);

      font-size:
        clamp(
          0.95rem,
          4vw,
          1.05rem
        );

      font-weight: var(--type-weight-bold, 700);
      line-height: 1.4;
    }

    :where(
      .gnostic-table-responsive:not(.gnostic-table-responsive--scroll)
      .gnostic-table td:first-child::before
    ) {
      content: none;
    }

    :where(
      .gnostic-table-responsive:not(.gnostic-table-responsive--scroll)
      .gnostic-table td:last-child
    ) {
      border-bottom: 0;
    }
  }

  /* ===================================================
     Narrow mobile card layout
     =================================================== */

  @media (max-width: 420px) {
    :where(
      .gnostic-table-responsive:not(.gnostic-table-responsive--scroll)
      .gnostic-table td
    ) {
      grid-template-columns: 1fr;
      gap: 0.3rem;

      padding:
        0.75rem
        0.85rem;
    }

    :where(
      .gnostic-table-responsive:not(.gnostic-table-responsive--scroll)
      .gnostic-table td[data-label]::before
    ) {
      margin-bottom: 0.1rem;
    }

    :where(
      .gnostic-table-responsive:not(.gnostic-table-responsive--scroll)
      .gnostic-table tr
    ) {
      border-radius: 0.65rem;
    }
  }

  /* ===================================================
     Horizontal-scroll table variant
     =================================================== */

  @media (max-width: 640px) {
    :where(.gnostic-table-responsive--scroll) {
      overflow-x: auto;
      overflow-y: hidden;

      border:
        1px solid
        color-mix(
          in srgb,
          var(--section-border) 78%,
          transparent
        );

      border-radius:
        var(
          --border-radius-base,
          0.75rem
        );

      background:
        color-mix(
          in srgb,
          var(--bg-surface, var(--bg-primary)) 92%,
          transparent
        );

      box-shadow:
        0
        6px
        18px
        color-mix(
          in srgb,
          var(--shadow-glow) 14%,
          transparent
        );
    }

    :where(
      .gnostic-table-responsive--scroll
      .gnostic-table
    ) {
      display: table;

      width: max-content;
      min-width: 100%;

      font-size: 0.78rem;
    }

    :where(
      .gnostic-table-responsive--scroll
      .gnostic-table thead
    ) {
      display: table-header-group;
    }

    :where(
      .gnostic-table-responsive--scroll
      .gnostic-table tbody
    ) {
      display: table-row-group;
    }

    :where(
      .gnostic-table-responsive--scroll
      .gnostic-table tr
    ) {
      display: table-row;

      margin: 0;

      border: 0;
      border-radius: 0;

      background: transparent;
      box-shadow: none;
    }

    :where(
      .gnostic-table-responsive--scroll
      .gnostic-table th
    ) {
      min-width: 7rem;

      padding:
        var(--space-xs, 0.5rem)
        var(--space-sm, 1rem);

      font-size: 0.72rem;
      white-space: normal;
    }

    :where(
      .gnostic-table-responsive--scroll
      .gnostic-table td
    ) {
      display: table-cell;

      min-width: 7rem;
      width: auto;

      padding:
        var(--space-xs, 0.5rem)
        var(--space-sm, 1rem);

      border-right:
        1px solid
        color-mix(
          in srgb,
          var(--section-border) 66%,
          transparent
        );

      border-bottom:
        1px solid
        color-mix(
          in srgb,
          var(--section-border) 66%,
          transparent
        );

      background: transparent;
      color: var(--text-primary);

      font-family:
        var(
          --font-serif,
          "Libre Baskerville",
          serif
        );

      font-size: 0.78rem;
      line-height: 1.5;

      white-space: normal;
    }

    :where(
      .gnostic-table-responsive--scroll
      .gnostic-table td:first-child
    ) {
      color: var(--text-primary);
      background: transparent;

      font-family:
        var(
          --font-serif,
          "Libre Baskerville",
          serif
        );

      font-size: 0.78rem;
      font-weight: var(--type-weight-regular, 400);
    }

    :where(
      .gnostic-table-responsive--scroll
      .gnostic-table td::before
    ) {
      content: none;
    }
  }

  /* ===================================================
     Reduced motion
     =================================================== */

  @media (prefers-reduced-motion: reduce) {
    :where(.gnostic-table tbody tr),
    :where(.gnostic-table a) {
      transition: none;
    }
  }
}