/* ── Guide Section Modal ──────────────────────────────────────────────
   Shows one section of an Academy guide page (#rules, #fibonacci, …) in
   a modal, fetched live from that guide — see
   assets/js/components/guide-section-modal.js.

   The injected section's own styling comes from modules/guide.css
   (.guide-section, .rule-card, .guide-table, .wave--*) and, for the
   guest registration gate this can also surface, pages/guide/
   guide-page.css (.ew-guide-gate*). Both are enqueued alongside this
   file on the pages that use it. Nothing here restyles that markup —
   this file is only the modal shell and the trigger chips.

   z-index sits just under gallery-lightbox.css (999999) and above the
   intel page's own .intel-lightbox (99999), so a guide section opens
   over the page chrome but never fights the image lightbox.
   ─────────────────────────────────────────────────────────────────── */

.ewi-gsm {
    position: fixed;
    inset: 0;
    z-index: 999998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.72);
}

/* REQUIRED, not a nicety: the modal is shown/hidden via the `hidden`
   attribute, and the UA stylesheet's [hidden]{display:none} loses to the
   author `display:flex` above. Without this rule `el.hidden = true` has
   no visual effect at all and the overlay can never be dismissed.
   Specificity (0,2,0) beats .ewi-gsm (0,1,0), so it wins on its own
   merits rather than on source order. */
.ewi-gsm[hidden] { display: none; }

/* Stops the page behind scrolling while a section is open. */
body.ewi-gsm-open { overflow: hidden; }

.ewi-gsm__dialog {
    display: flex;
    flex-direction: column;
    width: 100%;
    /* Wide enough for the guides' Fibonacci/rules tables, which are the
       whole point of opening this — they don't fit the 45% data column
       these chips are triggered from. */
    max-width: 820px;
    max-height: 85vh;
    background: var(--bg, #0a0f1a);
    border: 1px solid var(--border, #2a2a2a);
    border-radius: 12px;
    overflow: hidden;
}

.ewi-gsm__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
    padding: 14px 18px;
    background: var(--bg-alt, #111);
    border-bottom: 1px solid var(--border, #2a2a2a);
}

.ewi-gsm__title {
    margin: 0;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted, #888);
}

.ewi-gsm__close {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--border, #2a2a2a);
    border-radius: 50%;
    background: none;
    color: var(--text-muted, #888);
    font-size: 0.75rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.ewi-gsm__close:hover {
    color: var(--text, #e0e0e0);
    border-color: var(--text-muted, #888);
}

.ewi-gsm__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 18px;
}

/* Guide tables are wider than this dialog on narrow screens — they scroll
   in their own container rather than forcing the dialog (or the page
   behind it) to scroll sideways. .table-wrap is the guides' own wrapper;
   the bare-table rule covers any section that doesn't use it. */
.ewi-gsm__body .table-wrap,
.ewi-gsm__body table {
    overflow-x: auto;
    max-width: 100%;
}

/* The guides space sections for a full-width article column; inside the
   modal the section IS the content, so drop its outer margin. */
.ewi-gsm__body .guide-section {
    margin: 0;
}

.ewi-gsm__status {
    margin: 0;
    padding: 24px 0;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted, #888);
}

.ewi-gsm__status a { color: var(--accent, #4da3ff); }

/* ── Trigger chips ─────────────────────────────────────────────────
   Emitted by the Structure Guide tab on both template-single.php and
   intel-template.php, so these are deliberately namespace-neutral
   (neither as-* nor intel-*) and token-driven — they have to look at
   home in both. */

.ewi-gsm-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
}

/* Defensive only — NOT the fix for any observed bug. Added while chasing
   a "chips don't respond to taps" report that was eventually traced to
   something else entirely: on the intel pages the modal's JS was never
   enqueued at all (the guide assets had been added only to
   intel-shortcode.php's hook, gated on has_shortcode(), which never
   passes for templates that build [ewi_intel] in PHP — see
   includes/theme/enqueue.php's page-markets block). Tap interception was
   investigated and DISPROVEN, so nothing here is load-bearing.

   Kept because the overlap it guards against is real in principle:
   footer.php's .ewi-bottom-nav (position:fixed, z-index:1200, no
   page-type guard, present below 960px) and the scroll-triggered
   .ewi-sticky-bar (z-index:1100) can share an on-screen band with these
   triggers. position:relative does nothing to layout on its own — it
   only gives z-index a stacking context to apply in — and 1201 clears
   both bars while staying far below the modal overlay's own 999998.
   [data-guide-section] covers the lead action button and every chip on
   both pages in one rule, since both carry that attribute. */
[data-guide-section] {
    position: relative;
    z-index: 1201;
}

.ewi-gsm-chip {
    padding: 5px 12px;
    border: 1px solid var(--border, #2a2a2a);
    border-radius: 999px;
    background: none;
    color: var(--text-muted, #888);
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.ewi-gsm-chip:hover {
    color: var(--text, #e0e0e0);
    border-color: var(--accent, #4da3ff);
    background: rgba(77, 163, 255, 0.08);
}

.ewi-gsm-chips__label {
    margin: 0 0 6px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted, #888);
}

@media (max-width: 640px) {
    .ewi-gsm { padding: 12px; }
    .ewi-gsm__dialog { max-height: 92vh; }
}
