/* ══════════════════════════════════════════════════════════════════════
   states-modal.css — full-screen glass takeover for the "Montana vs Other
   States" comparison (and the FW-13 crosswalk / case-law / legislation
   modals). Loaded non-blocking from index.html.

   Two scopes only — nothing here leaks to other UI:
     • .guide-dlg--full ........... generic near-full glass shell + morph
       (also reusable by any future full-screen GUIDEDialog).
     • .guide-states-modal-body ... the hub State Library content polish.
     • .guide-xwalk-body .......... the FW-13 crosswalk / case-law / legislation
       content (de-inlined from src/multi-state-crosswalk.js).

   Token-only (no raw hex, no z-index literal ≥ 100) per styles/CONVENTIONS.md.
   ══════════════════════════════════════════════════════════════════════ */

/* ── 1. Full-screen dialog shell ────────────────────────────────────────
   :has() lets us reach the shared backdrop from the full-size dialog. A
   dialog is a raised sheet over a scrim — the one treatment every GUIDE
   dialog uses — so no frost and no specular edge. */
.guide-dlg-backdrop:has(.guide-dlg--full) {
  background: var(--guide-scrim, rgba(17, 27, 36, 0.55));
  padding: clamp(12px, 3vh, 32px);
}

.guide-dlg-backdrop:has(.guide-dlg--full) .guide-dlg--full {
  background: var(--guide-color-raised);
  border: 1px solid var(--guide-color-line);
  border-radius: var(--guide-radius-lg, 12px);
  box-shadow: var(--guide-shadow-overlay);
}

/* Morph entrance — a more pronounced spring than the default dialog. */
.guide-dlg-backdrop:has(.guide-dlg--full) .guide-dlg--full {
  transform: translateY(20px) scale(0.96);
  transition:
    transform var(--guide-dur-slow, 320ms) var(--guide-ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1)),
    opacity var(--guide-dur-base, 180ms) var(--guide-ease-out, cubic-bezier(0.22, 1, 0.36, 1));
}
.guide-dlg-backdrop[data-open="true"]:has(.guide-dlg--full) .guide-dlg--full {
  transform: translateY(0) scale(1);
}

/* Larger header + close affordance for the bigger canvas. */
.guide-dlg--full .guide-dlg-head {
  padding: var(--guide-sp-4, 16px) var(--guide-sp-6, 24px);
  background: var(--guide-color-raised);
}
.guide-dlg--full .guide-dlg-head::before { width: 5px; }
.guide-dlg--full .guide-dlg-title {
  font-size: clamp(18px, 2.4vw, 24px);
  font-weight: 800;
  letter-spacing: -0.015em;
}
.guide-dlg--full .guide-dlg-close {
  width: 38px;
  height: 38px;
  border-radius: var(--guide-radius-lg, 12px);
}
.guide-dlg--full .guide-dlg-close:hover {
  background: color-mix(in srgb, var(--guide-color-action) 10%, transparent);
  color: var(--guide-color-action);
}

/* Body centers a comfortable reading column on ultra-wide monitors. */
.guide-dlg--full .guide-dlg-body {
  padding: clamp(16px, 3vw, 40px);
}
.guide-dlg--full .guide-states-modal-body,
.guide-dlg--full .guide-xwalk-body {
  max-width: 1440px;
  margin: 0 auto;
}

/* Staggered fade-up of the top-level content blocks on open. */
.guide-dlg--full .guide-states-modal-body > *,
.guide-dlg--full .guide-xwalk-body > * {
  animation: guide-states-rise var(--guide-dur-slow, 320ms) var(--guide-ease-out, cubic-bezier(0.22, 1, 0.36, 1)) both;
}
.guide-dlg--full .guide-xwalk-body > *:nth-child(1) { animation-delay: calc(var(--guide-stagger, 60ms) * 0); }
.guide-dlg--full .guide-xwalk-body > *:nth-child(2) { animation-delay: calc(var(--guide-stagger, 60ms) * 1); }
.guide-dlg--full .guide-xwalk-body > *:nth-child(3) { animation-delay: calc(var(--guide-stagger, 60ms) * 2); }
.guide-dlg--full .guide-xwalk-body > *:nth-child(4) { animation-delay: calc(var(--guide-stagger, 60ms) * 3); }

/* ── 2. State Library content polish (scope: .guide-states-modal-body) ─────
   The DOM is rendered by src/state-library-core.js; we only restyle it for
   the larger canvas. On wide screens the compare table and the all-state
   card grid sit side by side; everything stacks on narrow screens. */
.guide-states-modal-body .pblock { margin: 0; }
.guide-states-modal-body .pb-head { padding-top: 0; }

@media (min-width: 1024px) {
  .guide-states-modal-body .sl {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    grid-template-areas:
      "subtabs subtabs"
      "intro   intro"
      "picker  picker"
      "compare cards"
      "cite    cite";
    column-gap: var(--guide-sp-6, 24px);
    row-gap: var(--guide-sp-4, 16px);
    align-items: start;
  }
  .guide-states-modal-body .sl-subtabs { grid-area: subtabs; }
  .guide-states-modal-body .sl-intro   { grid-area: intro; margin: 0; }
  .guide-states-modal-body .sl-picker  { grid-area: picker; margin: 0; }
  .guide-states-modal-body .sl-compare { grid-area: compare; position: sticky; top: 0; }
  .guide-states-modal-body .sl-cards   { grid-area: cards; }
  .guide-states-modal-body .mitigate-citation { grid-area: cite; }
}

.guide-states-modal-body .sl-intro {
  font-size: var(--guide-fs-base);
  line-height: 1.6;
  color: var(--guide-color-text-secondary, #4A4A52);
}

/* Glassy sub-panels + bigger type for the compare table. */
.guide-states-modal-body .sl-compare {
  background: var(--guide-color-raised);
  border: 1px solid var(--guide-glass-edge, rgba(255, 255, 255, 0.18));
  border-radius: var(--guide-radius-xl, 14px);
  box-shadow: var(--guide-shadow-raised);
  padding: var(--guide-sp-5, 20px);
}
.guide-states-modal-body .sl-flag { width: 38px; height: 38px; font-size: var(--guide-fs-xs); }
.guide-states-modal-body .sl-flag-name { font-size: var(--guide-fs-base); }
.guide-states-modal-body .sl-compare-cell { font-size: var(--guide-fs-sm); }
/* Widen the compare grid only above the base single-column breakpoint
   (state-library.css collapses .sl-compare-* to 1 column at ≤720px). */
@media (min-width: 721px) {
  .guide-states-modal-body .sl-compare-head,
  .guide-states-modal-body .sl-compare-row {
    grid-template-columns: 180px 1fr 1fr;
    gap: var(--guide-sp-4, 16px);
  }
}

/* Hover morph on pickers, sub-tabs, and explainer cards. */
.guide-states-modal-body .sl-pick,
.guide-states-modal-body .sl-subtab,
.guide-states-modal-body .sl-card {
  transition:
    transform var(--guide-dur-fast, 140ms) var(--guide-ease-out, cubic-bezier(0.22, 1, 0.36, 1)),
    box-shadow var(--guide-dur-fast, 140ms) var(--guide-ease-out, cubic-bezier(0.22, 1, 0.36, 1)),
    border-color var(--guide-dur-fast, 140ms) ease;
}
.guide-states-modal-body .sl-pick:hover,
.guide-states-modal-body .sl-subtab:hover,
.guide-states-modal-body .sl-card:hover {
  box-shadow: var(--guide-shadow-raised);
}
.guide-states-modal-body .sl-pick { padding: 8px 14px 8px 8px; font-size: var(--guide-fs-sm); }
.guide-states-modal-body .sl-card {
  background: var(--guide-color-raised);
  border-color: var(--guide-glass-edge, rgba(255, 255, 255, 0.18));
}

/* ── 3. Crosswalk / case-law / legislation polish (scope: .guide-xwalk-body)
   Markup is de-inlined into .xw-* classes in src/multi-state-crosswalk.js. */
.guide-xwalk-body .xw-intro {
  margin: 0 0 var(--guide-sp-4, 16px);
  font-size: var(--guide-fs-base);
  line-height: 1.6;
  color: var(--guide-color-text-secondary, #4A4A52);
}
.guide-xwalk-body .xw-source {
  margin: var(--guide-sp-4, 16px) 0 0;
  font-size: var(--guide-fs-xs);
  color: var(--guide-color-text-tertiary, #5C5C64);
}
.guide-xwalk-body .xw-empty {
  text-align: center;
  padding: var(--guide-sp-8, 40px);
  color: var(--guide-color-text-tertiary, #5C5C64);
}

/* Rating chips — MT ahead / comparable / behind (token-driven). */
.guide-xwalk-body .xw-legend {
  display: flex;
  align-items: center;
  gap: var(--guide-sp-2, 8px);
  margin-bottom: var(--guide-sp-3, 12px);
}
.guide-xwalk-body .xw-legend-label {
  font-size: var(--guide-fs-xs);
  font-weight: 700;
  color: var(--guide-color-text-tertiary, #5C5C64);
}
.guide-xwalk-body .xw-rating {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: var(--guide-radius-sm, 6px);
  font-size: var(--guide-fs-2xs);
  font-weight: 700;
  vertical-align: middle;
  color: var(--guide-color-text-on-accent, #fff);
}
.guide-xwalk-body .xw-rating--ahead  { background: var(--guide-color-status-ok, #157347); }
.guide-xwalk-body .xw-rating--eq     { background: var(--guide-color-status-mute, #6b7280); }
.guide-xwalk-body .xw-rating--behind { background: var(--guide-color-status-warn, #B45309); }

/* Comparison table — glass card, sticky head + sticky topic column. */
.guide-xwalk-body .xw-table-wrap {
  max-height: 64vh;
  overflow: auto;
  border: 1px solid var(--guide-glass-edge, rgba(255, 255, 255, 0.18));
  border-radius: var(--guide-radius-xl, 14px);
  box-shadow: var(--guide-shadow-raised);
  background: var(--guide-color-raised);
}
.guide-xwalk-body .xw-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}
.guide-xwalk-body .xw-thead { position: sticky; top: 0; z-index: 3; }
.guide-xwalk-body .xw-th {
  padding: 12px 14px;
  text-align: left;
  font-size: var(--guide-fs-xs);
  font-weight: 700;
  color: var(--guide-color-text-on-accent, #fff);
  background: var(--guide-color-mt-slate-deep, #2A4361);
  white-space: nowrap;
}
.guide-xwalk-body .xw-th--mt { background: var(--guide-color-action); }
.guide-xwalk-body .xw-th--topic {
  position: sticky;
  left: 0;
  z-index: 4;
  min-width: 190px;
}
.guide-xwalk-body .xw-td {
  padding: 12px 14px;
  font-size: var(--guide-fs-sm);
  vertical-align: top;
  min-width: 180px;
  border-bottom: 1px solid var(--guide-color-border-subtle, rgba(0, 0, 0, 0.06));
  color: var(--guide-color-text-secondary, #4A4A52);
}
.guide-xwalk-body .xw-row:nth-child(even) .xw-td { background: var(--guide-color-bg-1, #F2EFE8); }
.guide-xwalk-body .xw-td--topic {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 190px;
  text-align: left;
  background: var(--guide-color-bg-3, #F7F5F0);
}
.guide-xwalk-body .xw-topic {
  display: block;
  font-size: var(--guide-fs-sm);
  font-weight: 700;
  color: var(--guide-color-text-primary, #1A1A1F);
}
.guide-xwalk-body .xw-topic-sub {
  display: block;
  margin-top: 3px;
  font-size: var(--guide-fs-2xs);
  font-weight: 400;
  color: var(--guide-color-text-tertiary, #5C5C64);
}
.guide-xwalk-body .xw-td--mt {
  background: var(--guide-color-paper-2);
}
.guide-xwalk-body .xw-cell-val { display: inline; }

/* Search + filter controls. */
.guide-xwalk-body .xw-search {
  width: 100%;
  padding: 11px 16px;
  margin-bottom: var(--guide-sp-4, 16px);
  font: inherit;
  font-size: var(--guide-fs-md);
  color: var(--guide-color-text-primary, #1A1A1F);
  background: var(--guide-color-surface, #fff);
  border: 1px solid var(--guide-color-border-default, rgba(0, 0, 0, 0.10));
  border-radius: var(--guide-radius-lg, 12px);
  box-sizing: border-box;
  transition: border-color var(--guide-dur-fast, 140ms) ease, box-shadow var(--guide-dur-fast, 140ms) ease;
}
.guide-xwalk-body .xw-search:focus {
  outline: none;
  border-color: var(--guide-color-action);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--guide-color-action) 10%, transparent);
}
.guide-xwalk-body .xw-filters {
  display: flex;
  gap: var(--guide-sp-4, 16px);
  flex-wrap: wrap;
  margin-bottom: var(--guide-sp-4, 16px);
}
.guide-xwalk-body .xw-filter {
  display: inline-flex;
  align-items: center;
  gap: var(--guide-sp-2, 8px);
  font-size: var(--guide-fs-xs);
  font-weight: 700;
  color: var(--guide-color-text-secondary, #4A4A52);
}
.guide-xwalk-body .xw-select {
  font: inherit;
  font-size: var(--guide-fs-sm);
  padding: 8px 12px;
  color: var(--guide-color-text-primary, #1A1A1F);
  background: var(--guide-color-surface, #fff);
  border: 1px solid var(--guide-color-border-default, rgba(0, 0, 0, 0.10));
  border-radius: var(--guide-radius-md, 8px);
}

/* Card grids for case law + legislation. */
.guide-xwalk-body .xw-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--guide-sp-3, 12px);
}
.guide-xwalk-body .xw-card {
  display: block;
  padding: var(--guide-sp-4, 16px);
  background: var(--guide-color-raised);
  border: 1px solid var(--guide-glass-edge, rgba(255, 255, 255, 0.18));
  border-radius: var(--guide-radius-lg, 12px);
  text-decoration: none;
  color: var(--guide-color-text-primary, #1A1A1F);
  transition:
    transform var(--guide-dur-fast, 140ms) var(--guide-ease-out, cubic-bezier(0.22, 1, 0.36, 1)),
    box-shadow var(--guide-dur-fast, 140ms) var(--guide-ease-out, cubic-bezier(0.22, 1, 0.36, 1)),
    border-color var(--guide-dur-fast, 140ms) ease;
}
.guide-xwalk-body .xw-card:hover {
  box-shadow: var(--guide-shadow-overlay);
  border-color: color-mix(in srgb, var(--guide-color-action) 10%, transparent);
}
.guide-xwalk-body .xw-card-head {
  display: flex;
  justify-content: space-between;
  gap: var(--guide-sp-3, 12px);
  margin-bottom: var(--guide-sp-1, 4px);
}
.guide-xwalk-body .xw-card-title { font-size: var(--guide-fs-md); font-weight: 700; }
.guide-xwalk-body .xw-badge {
  font-size: var(--guide-fs-2xs);
  padding: 3px 9px;
  background: var(--guide-color-mt-slate-deep, #2A4361);
  color: var(--guide-color-text-on-accent, #fff);
  border-radius: var(--guide-radius-sm, 6px);
  font-weight: 700;
  white-space: nowrap;
  align-self: flex-start;
}
.guide-xwalk-body .xw-card-cite,
.guide-xwalk-body .xw-card-topic {
  font-size: var(--guide-fs-2xs);
  color: var(--guide-color-text-tertiary, #5C5C64);
  margin-bottom: var(--guide-sp-2, 8px);
}
.guide-xwalk-body .xw-card-line { margin: 0 0 var(--guide-sp-1, 4px); font-size: var(--guide-fs-sm); }
.guide-xwalk-body .xw-card-why,
.guide-xwalk-body .xw-card-summary {
  margin: 0;
  font-size: var(--guide-fs-xs);
  color: var(--guide-color-text-secondary, #4A4A52);
}
.guide-xwalk-body .xw-status {
  font-size: var(--guide-fs-2xs);
  padding: 3px 9px;
  border-radius: var(--guide-radius-sm, 6px);
  font-weight: 700;
  white-space: nowrap;
  color: var(--guide-color-text-on-accent, #fff);
  align-self: flex-start;
}
.guide-xwalk-body .xw-status--enacted { background: var(--guide-color-status-ok, #157347); }
.guide-xwalk-body .xw-status--pending { background: var(--guide-color-status-warn, #B45309); }

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .guide-dlg-backdrop:has(.guide-dlg--full) .guide-dlg--full,
  .guide-dlg--full .guide-states-modal-body > *,
  .guide-dlg--full .guide-xwalk-body > * {
    animation: none;
    transition: opacity var(--guide-dur-base, 180ms) ease;
  }
}
