/* Deep dive panel + the story surfaces that share its parts (the analysis
   page's read card, source row and action cards; the ticker page's Deep dive
   row). Unlayered on purpose: theme-dark.css resets `span`, `p` and `a`
   colour with unlayered (0,1,2) rules, so anything coloured here carries at
   least that specificity. */

/* ── Dark theme: the "strong" direction tokens are light-theme values
   (dark green / dark red) that fall to ~3:1 on the navy card; remap them for
   the analysis page and the panel the way the ticker page already does. */
html.theme-dark body[data-cmm-page="analysis"], html.theme-dark .cmm-dive { --bull-strong: #86efac; --bear-strong: #f87171; }

/* ── The panel ── */
.cmm-dive { position: fixed; inset: 0; z-index: 11000; background: rgb(0 0 0 / .36); display: flex; justify-content: flex-end; }
.cmm-dive *, .cmm-dive *::before, .cmm-dive *::after { box-sizing: border-box; min-width: 0; }
.cmm-dive-panel { width: 100%; height: 100%; height: 100dvh; display: flex; flex-direction: column; background: var(--bg-card); color: var(--text-primary); box-shadow: var(--elev-4); padding-top: env(safe-area-inset-top); }
@media (min-width: 1024px) { .cmm-dive-panel { width: 640px; max-width: 100%; } }
.cmm-dive-panel header { display: flex; gap: 8px; align-items: center; padding: 8px 12px; flex-shrink: 0; }
.cmm-dive-panel header h2 { margin: 0; font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.cmm-dive-panel button { font: inherit; cursor: pointer; color: inherit; }
.cmm-dive-panel header button { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; min-height: 44px; padding: 8px 6px; font-weight: 500; border-radius: 10px; }
.cmm-dive-panel header button:hover { background: var(--bg-hover); }
.cmm-dive-panel header button > i { font-size: 18px; }
.cmm-dive-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 24px calc(24px + env(safe-area-inset-bottom)); overflow-wrap: anywhere; font-size: 16px; line-height: 1.6; }
.cmm-dive :focus-visible, [data-open-dive]:focus-visible { outline: 3px solid var(--brand-500); outline-offset: 3px; }

/* ── Reader ── */
.cmm-dive-headline { margin: 0 0 20px; font-size: 26px; letter-spacing: -.02em; line-height: 1.3; }
.cmm-dive-companies { display: flex; overflow-x: auto; gap: 8px; padding: 4px 2px 12px; margin-bottom: 12px; }
.cmm-dive-companies button { flex-shrink: 0; border-radius: 24px; background: var(--bg-card); padding: 10px 16px; min-height: 44px; border: 1px solid var(--border-color); font-weight: 600; }
.cmm-dive-companies button[aria-pressed="true"] { border-color: var(--brand-500); background: color-mix(in srgb, var(--brand-500) 8%, var(--bg-card)); }
/* The read tile: the same tint, arrow and colour as the read card on the page. */
.cmm-dive-read { display: flex; align-items: center; gap: 12px; margin: 0 0 24px; }
.cmm-dive-read > i { display: grid; place-items: center; width: 50px; height: 50px; flex-shrink: 0; border-radius: 14px; font-size: 24px; background: var(--bg-hover); color: var(--text-secondary); }
.cmm-dive-read > div { display: grid; gap: 2px; min-width: 0; }
.cmm-dive-read .cmm-dive-company-title { margin: 0; font-size: 16px; line-height: 1.4; color: var(--text-primary); }
.cmm-dive-read p, .cmm-dive .cmm-dive-read p { margin: 0; font-size: 14px; font-weight: 700; color: var(--text-secondary); }
.cmm-dive-read.is-bull > i { background: var(--bull-soft); color: var(--bull-strong); }
.cmm-dive-read.is-bear > i { background: var(--bear-soft); color: var(--bear-strong); }
.cmm-dive-read.is-bull p, .cmm-dive .cmm-dive-read.is-bull p { color: var(--bull-strong); }
.cmm-dive-read.is-bear p, .cmm-dive .cmm-dive-read.is-bear p { color: var(--bear-strong); }
.cmm-dive-section { margin-bottom: 24px; }
.cmm-dive-section h3 { display: flex; align-items: baseline; gap: 8px; font-size: 15px; margin: 0 0 6px; }
.cmm-dive-section h3 > i, .cmm-dive-evidence-title > i { color: var(--brand-500); font-size: 15px; flex-shrink: 0; }
.cmm-dive-section p { margin: 0; white-space: pre-line; line-height: 1.6; }
.cmm-dive-interpretation { border-left: 2px solid var(--brand-500); padding-left: 16px; }
.cmm-dive-meta, .cmm-dive .cmm-dive-meta { color: var(--text-secondary); font-size: 13px; }

/* ── The outcome panel (the same soft panel the mobile reader uses) ── */
.cmm-dive-outcome { position: relative; margin: 28px 0; padding: 16px 20px; border: 1px solid var(--border-color); border-radius: 18px; background: var(--bg-hover); }
.cmm-dive-outcome > .cmm-movement-info { position: absolute; top: 6px; right: 6px; }
.cmm-dive-outcome-label, .cmm-dive .cmm-dive-outcome-label { margin: 0; font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.cmm-dive-number { display: block; margin: 2px 0 8px; font-family: var(--font-mono); font-size: 24px; line-height: 1.3; font-variant-numeric: tabular-nums; }
.cmm-dive-measurement, .cmm-dive .cmm-dive-measurement p { color: var(--text-secondary); font-size: 13px; }
.cmm-dive-measurement p { margin: 4px 0; }
.cmm-dive-measurement .cmm-tracking-state { display: block; margin-bottom: 8px; }
.cmm-dive-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.cmm-dive-outcome .cmm-dive-actions { margin-top: 10px; gap: 20px; }
.cmm-dive-actions a, .cmm-dive .cmm-dive-actions a, html.theme-dark .cmm-dive .cmm-dive-actions a { display: inline-flex; align-items: center; min-height: 44px; color: var(--brand-700); font-size: 14px; font-weight: 600; text-decoration: none; }
.cmm-dive-actions .cmm-dive-row, .cmm-dive .cmm-dive-actions .cmm-dive-row { width: auto; margin: 0; padding: 10px 0; min-height: 44px; border: 0; background: transparent; color: var(--brand-700); font-size: 14px; font-weight: 600; }
html.theme-dark .cmm-dive .cmm-dive-actions a, html.theme-dark .cmm-dive .cmm-dive-actions .cmm-dive-row, html.theme-dark .cmm-dive .cmm-dive-evidence a { color: #c4b5fd; }
.cmm-dive-actions a:hover, .cmm-dive-actions .cmm-dive-row:hover { text-decoration: underline; }
.cmm-movement-info { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; border: 0; border-radius: 12px; background: transparent; font-size: 18px; color: var(--text-secondary); cursor: pointer; }
.cmm-movement-info:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Evidence: one card shape for every row ── */
.cmm-dive-evidence-title { display: flex; align-items: center; gap: 10px; font-size: 20px; margin: 0 0 8px; }
.cmm-dive-evidence { border-top: 1px solid var(--border-color); padding-top: 16px; font-size: 14px; }
.cmm-dive-evidence .cmm-dive-meta, .cmm-dive .cmm-dive-evidence .cmm-dive-meta { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.cmm-dive-evidence h3 { color: var(--text-primary); margin: 4px 0 8px; font-size: 14px; }
.cmm-dive-evidence p, .cmm-dive .cmm-dive-evidence p { color: var(--text-secondary); font-size: 14px; line-height: 1.6; }
.cmm-dive-evidence .cmm-dive-evidence-value, .cmm-dive .cmm-dive-evidence .cmm-dive-evidence-value { font-family: var(--font-mono); font-size: 23px; color: var(--text-primary); margin: 0 0 4px; line-height: 1.3; }
.cmm-dive-evidence .cmm-dive-evidence-sub, .cmm-dive .cmm-dive-evidence .cmm-dive-evidence-sub { font-size: 13px; color: var(--text-muted); margin: 0 0 6px; }
.cmm-dive-evidence a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; color: var(--brand-700); }
.cmm-dive-evidence .cmm-dive-row { width: auto; margin: 8px 0 0; padding: 10px 14px; min-height: 44px; border: 1px solid var(--border-color); border-radius: 12px; background: transparent; font-size: 14px; font-weight: 600; }

/* ── Story rows shared with the ticker page ── */
.cmm-dive-row { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; width: 100%; padding: 14px 16px; margin: 0 0 12px; min-height: 48px; text-align: left; background: transparent; border: 1px solid var(--border-color); border-radius: 12px; color: var(--text-primary); font: inherit; text-decoration: none; cursor: pointer; }
.cmm-dive-row:hover { background: var(--bg-hover); }
.cmm-dive .cmm-dive-row { width: 100%; max-width: 100%; white-space: normal; }
.tkr-focus__dive .cmm-dive-row { width: auto; margin: 0; }
.tkr-item > details { grid-column: 1 / -1; min-width: 0; }

/* ── The read card the analysis page leads with (mirrors the mobile Glance) ── */
.cmm-dive-readcard { display: flex; flex-direction: column; gap: 12px; width: 100%; margin: 0; padding: 16px; border: 1px solid var(--border-color); border-radius: 18px; background: var(--surface-card); color: var(--text-primary); font: inherit; text-align: left; }
button.cmm-dive-readcard { cursor: pointer; transition: background-color var(--dur-fast, 140ms) var(--ease-out, ease-out); }
button.cmm-dive-readcard:hover { background: var(--bg-hover); }
.cmm-dive-readcard__row { display: flex; align-items: center; gap: 14px; }
.cmm-dive-readcard__tile { display: grid; place-items: center; width: 56px; height: 56px; flex-shrink: 0; border-radius: 16px; background: var(--surface-sunken); color: var(--text-secondary); font-size: 28px; }
.cmm-dive-readcard__text { display: flex; flex-direction: column; min-width: 0; }
.cmm-dive-readcard__word, .cmm-dive-readcard .cmm-dive-readcard__word { font-size: clamp(22px, 1.4rem + 1vw, 28px); font-weight: 800; line-height: 1.15; letter-spacing: -.02em; color: var(--text-secondary); overflow-wrap: anywhere; }
.cmm-dive-readcard__sub, .cmm-dive-readcard .cmm-dive-readcard__sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.cmm-dive-readcard__sentence, .cmm-dive-readcard .cmm-dive-readcard__sentence { font-size: 19px; line-height: 1.4; font-weight: 500; color: var(--text-primary); }
.cmm-dive-readcard.is-bull .cmm-dive-readcard__tile { background: var(--bull-soft); color: var(--bull-strong); }
.cmm-dive-readcard.is-bear .cmm-dive-readcard__tile { background: var(--bear-soft); color: var(--bear-strong); }
.cmm-dive-readcard.is-bull .cmm-dive-readcard__word { color: var(--bull-strong); }
.cmm-dive-readcard.is-bear .cmm-dive-readcard__word { color: var(--bear-strong); }

/* ── The source row: one tappable row for locked and unlocked readers ── */
.cmm-dive-source, a.cmm-dive-source, html.theme-dark a.cmm-dive-source { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 0; padding: 0 14px; border: 1px solid var(--border-color); border-radius: 12px; background: var(--surface-card); color: var(--text-secondary); font-size: 13px; text-decoration: none; }
a.cmm-dive-source:hover { background: var(--bg-hover); text-decoration: none; }
.cmm-dive-source b, .cmm-dive-source .cmm-dive-source__text b { color: var(--text-primary); font-weight: 600; }
.cmm-dive-source__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmm-dive-source > i { flex-shrink: 0; color: var(--text-muted); font-size: 14px; }

/* ── The two peer action cards (icon · label · chevron) ── */
.cmm-dive-actions--cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.cmm-dive-actions .cmm-action-card, .cmm-dive-actions a.cmm-action-card, html.theme-dark .cmm-dive-actions a.cmm-action-card { display: flex; align-items: center; gap: 10px; min-height: 48px; margin: 0; padding: 12px; border: 1px solid var(--border-color); border-radius: 12px; background: var(--surface-card); color: var(--text-primary); font: inherit; font-size: 14px; font-weight: 600; text-align: left; text-decoration: none; cursor: pointer; transition: background-color var(--dur-fast, 140ms) var(--ease-out, ease-out), border-color var(--dur-fast, 140ms) var(--ease-out, ease-out); }
.cmm-dive-actions .cmm-action-card:hover, .cmm-dive-actions a.cmm-action-card:hover, html.theme-dark .cmm-dive-actions a.cmm-action-card:hover { background: var(--bg-hover); border-color: color-mix(in srgb, var(--brand-500) 40%, var(--border-color)); color: var(--text-primary); text-decoration: none; }
.cmm-dive-actions .cmm-action-card > i:first-child { width: 20px; text-align: center; color: var(--brand-500); font-size: 16px; }
.cmm-dive-actions .cmm-action-card > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmm-dive-actions .cmm-action-card__chev { color: var(--text-muted); font-size: 12px; }
@media (max-width: 380px) { .cmm-dive-actions--cards { grid-template-columns: 1fr; } }

/* ── The movement popup ── */
.cmm-movement-popup { z-index: 11010; justify-content: center; align-items: center; padding: 16px; }
.cmm-movement-popup .cmm-dive-panel { width: 480px; max-width: 100%; height: auto; max-height: 85dvh; border-radius: 20px; }
.cmm-movement-popup header { justify-content: space-between; padding: 16px 20px 0; }
.cmm-movement-popup .cmm-dive-body { flex: 0 1 auto; padding-top: 12px; }

/* ── Motion ── */
.cmm-dive-panel button, .cmm-dive-actions a { transition: background-color 140ms, opacity 140ms; }
.cmm-dive-panel button:active, .cmm-dive-actions a:active { opacity: .65; }
.cmm-reader-enter { animation: cmm-reader-enter 140ms ease-out; }
@keyframes cmm-reader-enter { from { opacity: .65; } to { opacity: 1; } }
@media (max-width: 380px) { .cmm-dive-body { padding-inline: 18px; } .cmm-dive-outcome { padding-inline: 14px; } }
@media (prefers-reduced-motion: reduce) { .cmm-dive *, .cmm-dive, .cmm-dive-readcard, .cmm-action-card { transition: none; animation: none; scroll-behavior: auto; } }
