/* ============================================================
   CAV PATHOLOGY · IHD · Coronary Territory Panels styling
   Scoped to the Foundations page (#cavIhdFoundationsTopicContent).
   Donut + 12-lead grid that sit below the 2a heart inside
   #mapper-mount. Cardio Cram's Coronary Grid look, remapped onto
   Arcanium theme tokens (dark-ready); artery hues from the
   canonical palette via per-element CSS custom props.
   ============================================================ */

#cavIhdFoundationsTopicContent .ctp { display: block; margin-top: 22px; }

/* ---------- Side-by-side layout: heart | donut | grid ----------
   #mapper-mount has exactly two direct children — the 2a heart (.hvo)
   and the 2b panels host (.ctp-host, whose .ctp-row holds donut+grid).
   Lay them out as one row so all three panels sit side by side (as the
   Prompt-2 mapper did); the heart is shrunk to make room. */
#cavIhdFoundationsTopicContent #mapper-mount {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    align-items: flex-start;
}
#cavIhdFoundationsTopicContent #mapper-mount > .hvo {
    flex: 0 0 250px;
    max-width: 250px;
    margin-top: 0;
    --heart-h: 360px;       /* smaller heart (≈241px wide) so all three fit */
}
#cavIhdFoundationsTopicContent #mapper-mount > .ctp-host {
    flex: 1 1 380px;
    min-width: 0;
}
#cavIhdFoundationsTopicContent #mapper-mount .ctp { margin-top: 0; }

#cavIhdFoundationsTopicContent .ctp-row {
    display: grid;
    grid-template-columns: minmax(200px, 280px) 1fr;
    gap: 18px;
    align-items: start;
}
#cavIhdFoundationsTopicContent .ctp-col {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-soft);
    padding: 14px 14px 16px;
    min-width: 0;
}
#cavIhdFoundationsTopicContent .ctp-panel-head {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted-strong);
    margin-bottom: 8px;
}

/* ---------- Donut ---------- */
#cavIhdFoundationsTopicContent .ctp-donut-svg { width: 100%; height: auto; display: block; max-width: 300px; margin: 0 auto; overflow: visible; }
#cavIhdFoundationsTopicContent .ctp-epi { fill: rgba(120,144,196,0.08); stroke: rgba(71,84,103,0.45); stroke-width: 1.5; }
#cavIhdFoundationsTopicContent .ctp-endo { fill: var(--surface-strong); stroke: rgba(71,84,103,0.45); stroke-width: 1.25; pointer-events: none; }
#cavIhdFoundationsTopicContent .ctp-wedge {
    fill: rgba(120,144,196,0.16);
    stroke: var(--surface-strong);
    stroke-width: 1.5;
    cursor: pointer;
    transition: fill 140ms ease, stroke 140ms ease;
}
#cavIhdFoundationsTopicContent .ctp-wedge:hover { fill: rgba(120,144,196,0.3); }
#cavIhdFoundationsTopicContent .ctp-wedge.is-active { stroke-width: 2.5; }
#cavIhdFoundationsTopicContent .ctp-rv { fill: rgba(120,144,196,0.12); }
#cavIhdFoundationsTopicContent .ctp-wedge:focus { outline: none; }
#cavIhdFoundationsTopicContent .ctp-wedge:focus-visible { outline: none; stroke: var(--accent); stroke-width: 2.5; }
#cavIhdFoundationsTopicContent .ctp-wedge-label { fill: var(--muted-strong); font-size: 8.5px; font-weight: 700; pointer-events: none; }
#cavIhdFoundationsTopicContent .ctp-rv-label { fill: var(--muted); }
#cavIhdFoundationsTopicContent .ctp-donut-center { fill: var(--muted-strong); font-size: 9px; font-weight: 700; pointer-events: none; }
#cavIhdFoundationsTopicContent .ctp-post-badge circle { fill: #b45309; }
#cavIhdFoundationsTopicContent .ctp-post-badge-p { fill: #fff; font-size: 11px; font-weight: 800; }
#cavIhdFoundationsTopicContent .ctp-post-badge-label { fill: var(--muted-strong); font-size: 11px; font-weight: 700; }
#cavIhdFoundationsTopicContent .ctp-donut-hint { font-size: 12px; color: var(--muted); margin: 10px 0 0; text-align: center; min-height: 2.4em; }
#cavIhdFoundationsTopicContent .ctp-donut-hint.is-line { color: var(--text); font-weight: 600; }

/* donut column: title pinned at top (black, centered); wheel centered below */
#cavIhdFoundationsTopicContent .ctp-donut-col {
    align-self: stretch;
    display: flex;
    flex-direction: column;
}
#cavIhdFoundationsTopicContent .ctp-donut-head {
    color: var(--text);
    text-align: center;
}
#cavIhdFoundationsTopicContent .ctp-donut-figure {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Result box below the heart — artery title (its hue) + black, labeled body */
#cavIhdFoundationsTopicContent .hvo-result {
    width: 100%;
    border: 1px solid var(--line);
    border-left: 4px solid var(--rc, var(--accent));
    background: var(--surface-strong);
    border-radius: 12px;
    padding: 10px 13px;
}
#cavIhdFoundationsTopicContent .hvo-result-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--rc, var(--text));
    margin-bottom: 6px;
    line-height: 1.25;
}
#cavIhdFoundationsTopicContent .hvo-result-row {
    font-size: 13px;
    color: var(--text);
    line-height: 1.45;
    margin-top: 4px;
}
#cavIhdFoundationsTopicContent .hvo-result-lbl {
    display: inline-block;
    min-width: 58px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-strong);
    margin-right: 2px;
}

/* ---------- Grid toolbar ---------- */
#cavIhdFoundationsTopicContent .ctp-gridbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
#cavIhdFoundationsTopicContent .ctp-modes { display: inline-flex; gap: 6px; }
#cavIhdFoundationsTopicContent .ctp-mode-btn {
    appearance: none;
    border: 1.5px solid var(--line);
    background: var(--surface-strong);
    color: var(--text);
    font-size: 13px; font-weight: 600;
    padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
#cavIhdFoundationsTopicContent .ctp-mode-btn.is-active { background: #db2777; border-color: #db2777; color: #fff; }
#cavIhdFoundationsTopicContent .ctp-mode-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#cavIhdFoundationsTopicContent .ctp-gridbar-hint { font-size: 12.5px; color: var(--muted); }

/* ---------- Grid cards ---------- */
#cavIhdFoundationsTopicContent .ctp-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
#cavIhdFoundationsTopicContent .ctp-card {
    border: 2px solid var(--line);
    background: var(--surface-strong);
    border-radius: 10px;
    padding: 10px 10px 12px;
    min-height: 88px;
    transition: opacity 120ms ease, border-color 120ms ease, background 120ms ease;
}
#cavIhdFoundationsTopicContent .ctp-card.is-shown { border-color: var(--ac); background: color-mix(in srgb, var(--ac) 8%, var(--surface-strong)); }
#cavIhdFoundationsTopicContent .ctp-card.is-dim { opacity: 0.25; }
#cavIhdFoundationsTopicContent .ctp-card.is-post.is-shown { box-shadow: 0 0 0 2px var(--surface-strong), 0 0 0 4px #b45309; }
#cavIhdFoundationsTopicContent .ctp-card.is-match { opacity: 1; }
#cavIhdFoundationsTopicContent .ctp-card[role="button"] { cursor: pointer; }
#cavIhdFoundationsTopicContent .ctp-card[role="button"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#cavIhdFoundationsTopicContent .ctp-card-lead { font-size: 15px; font-weight: 800; color: var(--text); }
#cavIhdFoundationsTopicContent .ctp-card-qrs { width: 100%; height: 20px; margin: 2px 0; display: block; }
#cavIhdFoundationsTopicContent .ctp-card-terr { font-size: 11.5px; color: var(--muted); }
#cavIhdFoundationsTopicContent .ctp-card-art { font-size: 13px; font-weight: 800; color: var(--ac); }
#cavIhdFoundationsTopicContent .ctp-card-post { font-size: 9.5px; font-weight: 800; color: #b45309; margin-top: 3px; line-height: 1.25; }
#cavIhdFoundationsTopicContent .ctp-card-hint { font-size: 11px; color: var(--muted); font-style: italic; }

/* ---------- Legend ---------- */
#cavIhdFoundationsTopicContent .ctp-legend { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
#cavIhdFoundationsTopicContent .ctp-legend-btn {
    border: 2px solid var(--lc);
    background: var(--surface-strong);
    color: var(--lc);
    border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 700; cursor: pointer;
}
#cavIhdFoundationsTopicContent .ctp-legend-btn.is-active { background: var(--lc); color: #fff; }
#cavIhdFoundationsTopicContent .ctp-legend-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Callout + summary ---------- */
#cavIhdFoundationsTopicContent .ctp-callout {
    margin-top: 16px;
    background: rgba(180, 83, 9, 0.08);
    border: 1px solid #b45309;
    border-radius: 10px;
    padding: 11px 15px;
}
#cavIhdFoundationsTopicContent .ctp-callout-title { font-size: 12.5px; font-weight: 800; color: #b45309; margin-bottom: 4px; }
#cavIhdFoundationsTopicContent .ctp-callout-body { font-size: 13px; color: var(--text); line-height: 1.5; }
#cavIhdFoundationsTopicContent .ctp-summary { margin-top: 10px; font-size: 12.5px; color: var(--muted-strong); line-height: 1.5; }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
    #cavIhdFoundationsTopicContent .ctp-row { grid-template-columns: 1fr; }
    #cavIhdFoundationsTopicContent .ctp-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    #cavIhdFoundationsTopicContent .ctp-wedge,
    #cavIhdFoundationsTopicContent .ctp-card { transition: none; }
}
