/* eli15/eli15.css — teaching drawer styling.
 *
 * Colour palette matches the rv-panel (#d38b4b accent, #824006 dark-accent,
 * #fff / #fafafa surfaces). The drawer docks to the right edge so it doesn't
 * cover the driving canvas; on narrow screens it becomes full-width.
 */

/* ─── floating action button ─────────────────────────────────────────────
   Desktop: pill with an emoji icon + a visible "Explain anything" label,
   pinned top-left as the first of two learning-tools (the guided-tour FAB
   stacks directly below). Mobile (≤720px): shrinks back to a 44px emoji
   circle pinned bottom-right so it doesn't eat screen width.
 */
.eli15-fab {
    position: fixed;
    top: 16px;            /* ≈ var(--sp-4) — eli15.css doesn't import tokens */
    left: 16px;
    right: auto;
    bottom: auto;
    z-index: 1200;
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    width: auto;
    height: auto;
    padding: 0.5em 0.9em 0.5em 0.7em;
    border-radius: 999px;
    /* WCAG 1.4.11: #d38b4b (amber-500) was 2.78:1 on the white pill bg and
       2.66:1 on the paper-0 viewport — below the 3:1 threshold for essential
       control boundaries. #a45a13 (amber-600) clears 5:1 while keeping the
       warm amber identity; style.css uses the same bump on .controlButton. */
    border: 1.5px solid #a45a13;
    background: #fff;
    color: #824006;
    font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: 0.01em;
    text-align: left;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transition: transform 120ms ease-out, background-color 120ms ease-out, box-shadow 120ms ease-out;
}
.eli15-fab-icon  { font-size: 1.1em; line-height: 1; }
.eli15-fab-label { white-space: nowrap; }
.eli15-fab:hover {
    background: #fff4e2;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
}
.eli15-fab:focus-visible {
    /* 1.4.11: focus ring must hit 3:1 against whatever surface it lands on.
       #a45a13 clears 5:1 on paper and 4:1 on surface-2 in dark mode. */
    outline: 3px solid #a45a13;
    outline-offset: 2px;
}
/* Dark-mode tweak — the legacy colors read poorly on dark paper. */
@media (prefers-color-scheme: dark) {
    .eli15-fab {
        background: #1d1a23;
        color: #f4c691;
        /* 1.4.11: 0.65 alpha was ~3.1:1 on surface-1 — borderline. 0.85
           hits ~4.5:1 with the same warm amber temperature. */
        border-color: rgba(211, 139, 75, 0.85);
    }
    .eli15-fab:hover { background: rgba(211, 139, 75, 0.16); }
}
/* Mobile: revert to emoji-only circle at bottom-right. */
@media (max-width: 720px) {
    .eli15-fab {
        top: auto;
        left: auto;
        right: 12px;
        bottom: 12px;
        width: 44px;
        height: 44px;
        padding: 0;
        border-radius: 50%;
        justify-content: center;
        font-size: 22px;
    }
    .eli15-fab-label { display: none; }
}

/* ─── badges (anywhere [data-eli15] appears) ───────────────────────────── */
[data-eli15] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Compact circular badge — a "?" glyph in an ~14px disc. Previously this
       had padding:0 0.3em + min-width:1.1em which produced a pill ~1.7em
       wide; that ate space next to every slider label. Using width=height
       with no padding gives a tidy round indicator. */
    width: 1.1em;
    height: 1.1em;
    padding: 0;
    margin-left: 0.35em;
    border-radius: 999px;
    background: #fff4e2;
    color: #824006;
    /* 1.4.11: #d38b4b was 2.55:1 against the amber-50 fill and 2.78:1 on
       white surfaces — under 3:1. The amber-50 fill alone (#fff4e2 vs white
       = 1.09:1) can't identify the pill as a control; the rim is the load-
       bearing boundary. #a45a13 (amber-600) clears 4.9:1 on amber-50. */
    border: 1px solid #a45a13;
    font-size: 0.7rem;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    vertical-align: baseline;
    user-select: none;
    transition: background-color 100ms ease-out;
    flex: 0 0 auto;
}
[data-eli15]::before { content: '?'; }
[data-eli15]:empty::before { content: '?'; }
[data-eli15]:hover { background: #ffe1b8; }
[data-eli15]:focus-visible {
    /* 1.4.11: see .eli15-fab:focus-visible. */
    outline: 2px solid #a45a13;
    outline-offset: 1px;
}

/* Hide the child text "?" we may have placed in HTML — the ::before covers
 * it — but keep the element accessible-text-wise via aria-label if set. */
[data-eli15] > * { display: none; }

/* ─── drawer surface ───────────────────────────────────────────────────── */
.eli15-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(18, 18, 22, 0.0);
    z-index: 1100;
    pointer-events: none;
    transition: background-color 180ms ease-out;
}
.eli15-backdrop.eli15-backdrop-open {
    background: rgba(18, 18, 22, 0.35);
    pointer-events: auto;
}

.eli15-drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1101;
    width: min(460px, 92vw);
    height: 100vh;
    background: #fff;
    color: #222;
    box-shadow: -4px 0 18px rgba(0, 0, 0, 0.25);
    transform: translateX(100%);
    transition: transform 220ms ease-out;
    display: flex;
    flex-direction: column;
    font-family: Verdana, -apple-system, system-ui, sans-serif;
    font-size: 0.9rem;
    line-height: 1.5;
    overflow: hidden;
}
.eli15-drawer.eli15-drawer-open {
    transform: translateX(0);
}
/* Defensive: style.css has a global `p { line-height: .2em; }` that leaks
 * into anything we render. Scope every text element inside the drawer so
 * that cascade rule can't crush our paragraphs into illegible slivers. */
.eli15-drawer p {
    line-height: 1.5;
    margin: 0 0 0.7em 0;
}
.eli15-drawer h2, .eli15-drawer h3 { line-height: 1.25; }
@media (prefers-reduced-motion: reduce) {
    .eli15-drawer { transition: none; }
    .eli15-backdrop { transition: none; }
    .eli15-fab { transition: none; }
}

/* ─── drawer header ────────────────────────────────────────────────────── */
.eli15-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5em;
    padding: 0.9em 1em 0.75em 1em;
    background: #fff4e2;
    border-bottom: 2px solid #d38b4b;
    flex-shrink: 0;
}
.eli15-header-text { flex: 1; min-width: 0; }
.eli15-kicker {
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    /* AAA: the prior #a07e5a against the amber kicker tint was 3.43:1. */
    color: #824006;
    margin-bottom: 0.2em;
}
.eli15-title {
    font-size: 1.05rem;
    margin: 0 0 0.25em 0;
    color: #824006;
    line-height: 1.25;
}
.eli15-oneliner {
    font-size: 0.82rem;
    margin: 0;
    /* AAA: #555 on the kicker tint was 6.85:1. */
    color: #403a33;
    font-style: italic;
}
.eli15-close {
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: #824006;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.1em 0.35em;
    border-radius: 0.2em;
}
.eli15-close:hover { background: rgba(131, 64, 6, 0.08); }
.eli15-close:focus-visible {
    /* 1.4.11: see .eli15-fab:focus-visible. */
    outline: 2px solid #a45a13;
    outline-offset: 1px;
}

/* ─── drawer body ──────────────────────────────────────────────────────── */
.eli15-body {
    padding: 0.8em 1em 0.4em 1em;
    overflow-y: auto;
    flex: 1 1 auto;
}
.eli15-body p {
    line-height: 1.5;
    margin: 0 0 0.7em 0;
}
.eli15-body h3 {
    font-size: 0.95rem;
    color: #824006;
    margin: 0.8em 0 0.25em 0;
}
.eli15-body code {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.85em;
    background: #f4ead9;
    padding: 0 0.25em;
    border-radius: 0.2em;
}
.eli15-body strong { color: #222; }

.eli15-loading { color: #403a33; font-style: italic; } /* AAA: was #888 (3.54:1) */
.eli15-error { color: #933; }
.eli15-error-detail {
    background: #fff0f0;
    color: #933;
    padding: 0.4em 0.6em;
    border-radius: 0.25em;
    font-size: 0.75rem;
    white-space: pre-wrap;
}

.eli15-diagram {
    padding: 0.4em 1em 0.6em 1em;
    background: #faf5ec;
    border-top: 1px dashed #e0d3bd;
    flex-shrink: 0;
}
.eli15-ascii {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.72rem;
    line-height: 1.35;
    color: #333;
    margin: 0;
    white-space: pre;
    overflow-x: auto;
}

.eli15-related {
    padding: 0.5em 1em 0.9em 1em;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}
.eli15-related-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    /* AAA: #888 on white was 3.54:1. */
    color: #403a33;
    margin-bottom: 0.3em;
}
.eli15-related-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15em;
}
.eli15-related-link {
    color: #824006;
    text-decoration: none;
    font-size: 0.82rem;
}
.eli15-related-link:hover { text-decoration: underline; }
