/* ═══════════════════════════════════════════════════════════════
   CASE FILES (casefiles.php, /casefiles/<season>)
   Builds on css/character.css (cd-* tokens, panels, tabs, buttons, the .it-*
   item markup) and css/events.css (ev-hero, ev-q stage cards, ev-foe, ev-boss,
   ev-items, ev-list ...); everything here is cf-* scoped.
   Static by design: no loaders or entrance animations.
   ═══════════════════════════════════════════════════════════════ */

.cf-k { display: block; margin: 0 0 3px; color: var(--text-3); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; }
.cd-jp .cf-k { letter-spacing: 0.2px; }
.cf-fn { display: block; margin-top: 4px; color: var(--text-3); font-size: 0.74rem; line-height: 1.4; }
.cf-b-label { background: var(--acc); color: var(--acc-ink); }
.cf-b-boss { background: rgba(232, 65, 60, 0.9); color: #fff; vertical-align: 2px; font-family: var(--font-body); letter-spacing: 0.5px; }
.cf [id] { scroll-margin-top: 12px; }

/* Hero: the 864x488 key art only sits beside the text when there is room for both (long CASE names) */
@media (min-width: 760px) and (max-width: 1099.98px) {
    .cf .ev-hero-wide { grid-template-columns: minmax(0, 1fr); }
    .cf .ev-hero-wide .ev-hero-banner { justify-self: center; max-width: 560px; }
}
@media (min-width: 1100px) { .cf .ev-hero-wide { grid-template-columns: minmax(0, 420px) minmax(0, 1fr); } }

/* ── At a glance ────────────────────────────────────────────────── */
.cf-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
@media (min-width: 576px) { .cf-facts { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.cf-facts > div { display: grid; align-content: start; gap: 2px; padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.06); min-width: 0; }
.cf-facts dt { color: var(--text-3); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.4px; }
.cf-facts dd { margin: 0; color: #fff; font: 400 1.25rem/1.2 var(--font-display); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.cd-jp .cf-facts dd { font-family: var(--font-display); }

/* ── Featured + Case File Bonus ─────────────────────────────────── */
.cf-art-toggle { flex: none; }
.cf-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.cf-card {
    display: grid;
    align-content: start;
    min-width: 0;
    overflow: hidden;
    border: 1px solid rgba(255, 213, 83, 0.22);
    border-radius: 12px;
    background: linear-gradient(160deg, rgba(255, 213, 83, 0.09), rgba(255, 255, 255, 0.02) 55%);
}
.cf-card-art { display: block; aspect-ratio: 987 / 776; overflow: hidden; background: radial-gradient(ellipse at 50% 30%, rgba(91, 149, 237, 0.25), var(--navy-mid) 70%); }
.cf-card-art img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; }
.cf-card-body { display: grid; gap: 8px; padding: 10px 12px 12px; min-width: 0; }
.cf-card-name { margin: 0; }
.cf-card-name .it-chip .it-ic { width: 46px; }
.cf-card-name .it-n { font-weight: 700; font-size: 0.95rem; white-space: normal; }
.cf-bonus { padding: 8px 10px; border-radius: 8px; background: rgba(121, 255, 128, 0.06); border: 1px solid rgba(121, 255, 128, 0.16); }
.cf-bonus .ev-skilltext { margin: 0; }
.cf-src { display: grid; gap: 3px; margin: -4px 0 0; padding: 0 0 0 16px; font-size: 0.82rem; color: var(--text-2); }
.cf-src a { color: var(--acc2); }
.cf-src a:hover { color: #fff; }
.cf-src b { color: var(--gold); font-variant-numeric: tabular-nums; }
.cf-origin { margin: 0; font-size: 0.82rem; color: var(--text-2); }
.cf-origin .cf-k { display: inline; margin-right: 4px; }
.cf-origin a { color: var(--text); }
.cf-origin a:hover { color: var(--acc2); }

/* ── Rules + help ───────────────────────────────────────────────── */
.cf-rules > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
.cf-rules dt { color: var(--gold); }
.cf-rules dd { font-size: 0.86rem; color: #d6def0; line-height: 1.5; }
.cf-rules dd .it-chip { vertical-align: -6px; }
.cf-rules dd .it-chip .it-ic { width: 24px; }
.cf-rules dd .it-chip .it-n { font-size: 0.84rem; }
@media (min-width: 576px) { .cf-rules > div { grid-template-columns: 9.5em minmax(0, 1fr); gap: 10px; } }
.cf-help { margin-top: 14px; }
.cf-help > summary, .cf-totals > summary { cursor: pointer; color: var(--acc2); font-size: 0.86rem; font-weight: 600; }
.cf-help > summary:hover, .cf-totals > summary:hover { color: #fff; }
.cf-help-list { display: grid; gap: 6px; margin-top: 10px; }
.cf-help-t { padding: 8px 12px; border-radius: 8px; background: rgba(255, 255, 255, 0.035); }
.cf-help-t > summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.cf-help-t p { margin: 8px 0 0; color: #d6def0; font-size: 0.84rem; line-height: 1.55; overflow-wrap: anywhere; }

/* ── Chapters ───────────────────────────────────────────────────── */
.cf-chtabs .cd-tab { display: inline-flex; align-items: baseline; gap: 6px; text-decoration: none; }
.cf-chtabs .cd-tab small { font-size: 0.68rem; font-weight: 600; opacity: 0.75; }
.cf-ch-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 10px; }
.cf-ch-title { margin: 0; font: 400 1.35rem/1.2 var(--font-display); color: #fff; letter-spacing: 0.3px; }
.cd-jp .cf-ch-title { letter-spacing: 0; }
.cf-ch-meta { flex: 1 1 260px; }
.cf-notice { padding: 5px 12px; font-size: 0.8rem; }
.cf-fix { margin: 0 0 10px; padding: 6px 10px; border-left: 3px solid var(--enh); border-radius: 0 8px 8px 0; background: rgba(255, 165, 82, 0.08); color: var(--text-2); font-size: 0.8rem; }
.cf-mission { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0 0 10px; padding: 8px 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.035); font-size: 0.86rem; }
.cf-mission .cf-k { margin: 0; flex-basis: 100%; }
.cf-mission > a { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.cf-mission > a:hover { color: var(--acc2); }
.cf-mission small { color: var(--text-3); font-size: 0.76rem; }
.cf-totals { margin: 0 0 6px; padding: 8px 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.025); }
.cf-tot { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 6px 14px; margin-top: 10px; }
.cf-tot .it-chip .it-ic { width: 34px; }
.cf-map-h { margin-top: 14px; }

/* The stage map: one column, in the game's order, on a thin rail */
.cf-map { position: relative; display: grid; gap: 8px; margin: 0; padding: 0 0 0 18px; list-style: none; }
.cf-map::before { content: ''; position: absolute; left: 5px; top: 10px; bottom: 10px; width: 2px; border-radius: 2px; background: rgba(255, 255, 255, 0.09); }
.cf-map > li { position: relative; min-width: 0; }
.cf-map > li::before { content: ''; position: absolute; left: -17px; top: 16px; width: 10px; height: 10px; border-radius: 50%; background: var(--navy-light); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2); }
.cf-map > li.cf-story::before { top: 11px; background: var(--gold); box-shadow: none; }
.cf-map > li:has(> .ev-q-boss)::before { background: #e8413c; box-shadow: none; }
.cf-map > li:has(> .cf-ex)::before { background: var(--acc2); box-shadow: 0 0 0 3px rgba(91, 149, 237, 0.3); }
.cf-story { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; padding: 5px 10px; border-radius: 8px; background: rgba(255, 213, 83, 0.06); color: var(--text-2); font-size: 0.84rem; }
.cf-story-ic { flex: none; color: var(--gold); }
.cf-story .st-script { flex: 1 1 100%; }               /* the dialogue takes its own line under the label */
.cf-story .st-script b { color: inherit; }
.cf-story b { color: var(--gold); font-weight: 700; }
.cf-story small { color: var(--text-3); font-size: 0.76rem; }
.cf-stage.is-target, .cf-ex.is-target, .cf-story.is-target, .cf-guest.is-target,
.cf-stage:target, .cf-ex:target, .cf-story:target, .cf-guest:target { box-shadow: 0 0 0 2px var(--gold); }
.cf-opp { display: grid; gap: 6px; padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.cf-opp > .cf-k { margin: 0; }
.cf-boss { grid-template-columns: auto minmax(0, 1fr); }
.cf-boss .ev-plate { width: 112px; }                    /* the boss plate (mhui_ev_plate_html) is wider than the 64px icon */
.cf-boss .ev-foe-ic { width: 64px; }
.cf-boss-txt { display: grid; gap: 2px; min-width: 0; }
.cf-attr { display: inline-flex; align-items: center; gap: 3px; margin-left: 4px; color: var(--text-3); font-size: 0.72rem; font-weight: 600; vertical-align: 1px; }
.cf-attr img { width: 16px; height: 16px; }
.cf-foes { margin: 0; }
.cf-stats { display: flex; flex-wrap: wrap; gap: 0 10px; color: var(--text-3); font-size: 0.74rem; line-height: 1.45; font-variant-numeric: tabular-nums; }
.cf-stats b { color: var(--text); font-weight: 600; }
.cf-boss .cf-stats { font-size: 0.8rem; }
.cf-boss .cf-stats b { color: #fff; }
.cf-traits { margin-top: 2px; }
.cf-traits > summary { font-size: 0.76rem; }
.cf-traits-body { margin-top: 6px; padding: 8px 10px; border-left: 3px solid rgba(232, 65, 60, 0.6); border-radius: 0 8px 8px 0; background: rgba(0, 0, 0, 0.2); }
.cf-traits-body p { margin: 0; padding: 0; border: 0; background: none; color: #d6def0; font-size: 0.8rem; line-height: 1.5; overflow-wrap: anywhere; }
.cf-res { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 8px 0 0; padding: 0; list-style: none; }
.cf-res li { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px 1px 4px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); font-size: 0.72rem; font-weight: 600; }
.cf-res li.cf-res-k { padding: 0 4px 0 0; background: none; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; font-size: 0.66rem; }
.cf-res img { width: 18px; height: 18px; }
.cf-res b { color: var(--up); }
.cf-gsts { gap: 6px; }
.cf-gst { display: block; width: 44px; height: 44px; overflow: hidden; border: 2px solid #8a9bb8; border-radius: 9px; background: var(--navy-light); }
.cf-gst.cf-r-sr { border-color: #e0c856; }
.cf-gst.cf-r-ur, .cf-gst.cf-r-pur { border-color: #d68bff; }
.cf-gst img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cf-gst:hover img, .cf-gst[aria-expanded="true"] img { filter: brightness(1.15); }
.cf-gst[aria-expanded="true"] { border-color: #fff; }
.cf-gst:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* EX STAGE */
.cf-ex { border-color: color-mix(in srgb, var(--acc2) 45%, transparent); background: linear-gradient(150deg, rgba(91, 149, 237, 0.14), rgba(232, 65, 60, 0.06) 45%, rgba(255, 255, 255, 0.02) 75%); }
.cf-lock { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--gold); font-size: 0.8rem; font-weight: 600; }
.cf-lock svg { flex: none; }
.cf-ex-rules { margin: -2px 0 0; color: var(--text-2); font-size: 0.8rem; }
.cf-ex-rules .it-chip { vertical-align: -6px; }
.cf-ex-rules .it-chip .it-ic { width: 24px; }
.cf-ex-rules .it-chip .it-n { font-size: 0.8rem; }
.cf-drops-w { container-type: inline-size; display: grid; gap: 6px; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.cf-drops-h { display: flex; align-items: center; gap: 8px; margin: 4px 0 0; color: #fff; font-size: 0.86rem; font-weight: 700; }
.cf-drops { width: 100%; border-collapse: collapse; font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.cf-drops th, .cf-drops td { padding: 5px 6px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, 0.06); font-size: inherit; vertical-align: middle; }
.cf-drops thead th { color: var(--text-3); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; }
.cf-drops tbody th { font-weight: 400; min-width: 0; }
.cf-drops .it-chip .it-ic { width: 32px; }
.cf-drops .it-chip .it-n { white-space: normal; font-size: 0.82rem; }
.cf-drops .ev-badge { margin-top: 2px; }
.cf-drops .cf-num { text-align: right; white-space: nowrap; }
.cf-drops td b { color: var(--gold); }
.cf-drops tr.is-key { background: rgba(255, 213, 83, 0.07); }
.cf-drops-foot { margin: 0; color: var(--text-2); font-size: 0.78rem; }
.cf-drops-foot.cf-fn { margin-top: -2px; }
@container (max-width: 420px) {
    .cf-col-box { display: none; }
    .cf-drops th, .cf-drops td { padding: 5px 4px; }
}
/* Under ~345px (320px phones) the columns no longer fit beside a long "[Title] Name Piece": each row stacks, the item
   on its own line and the numbers right-aligned under it, so names still wrap at spaces. */
@container (max-width: 235px) {
    .cf-drops, .cf-drops thead, .cf-drops tbody { display: block; }
    .cf-drops tr { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
    .cf-drops th, .cf-drops td { border-bottom: 0; }
    .cf-drops tr > :first-child { flex: 1 0 100%; padding-bottom: 0; }
    .cf-drops .cf-num { flex: 0 0 5.2em; padding-top: 2px; }
    .cf-drops thead th { white-space: normal; letter-spacing: 0; }
}

/* ── Special guests roster ──────────────────────────────────────── */
.cf-guests { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.cf-guest { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 10px; align-items: start; padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.035); min-width: 0; }
.cf-guest-body { display: grid; gap: 2px; min-width: 0; }
.cf-guest-name { margin: 0; font-weight: 700; font-size: 0.9rem; overflow-wrap: anywhere; }
.cf-guest-name a { text-decoration: none; }
.cf-guest-name a:hover { color: var(--acc2); text-decoration: underline; }
.cf-guest .cf-k { margin: 2px 0 0; color: var(--up); }
.cf-guest .ev-skilltext { margin: 0; }
.cf-where { margin: 4px 0 0; color: var(--text-2); font-size: 0.76rem; }
.cf-where .cf-k { display: inline; color: var(--text-3); margin-right: 4px; }
.cf-where a { color: var(--acc2); }

/* ── Bosses ─────────────────────────────────────────────────────── */
.cf-bossg { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.cf-bossg a { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: center; padding: 6px 8px; border-radius: 10px; background: rgba(232, 65, 60, 0.07); text-decoration: none; min-width: 0; }
.cf-bossg a:hover { background: rgba(232, 65, 60, 0.14); }
.cf-bossg a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.cf-bossg .ev-foe-ic { width: 48px; }
.cf-bossg .ev-plate { width: 72px; }
.cf-bossg-txt { display: grid; min-width: 0; font-size: 0.84rem; line-height: 1.3; }
.cf-bossg-txt b { overflow-wrap: anywhere; }
.cf-bossg-txt small { color: var(--text-3); font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.cf-bossg-txt .cf-bossg-at { color: var(--acc2); font-weight: 600; }
.cf-bossg-txt .cf-bossg-at.is-ex { color: var(--gold); }

/* ── Sidebar ────────────────────────────────────────────────────── */
.cf-toc li { display: grid; }
.cf-toc .cf-toc-ex { padding: 2px 8px 4px 22px; color: var(--text-2); font-size: 0.78rem; }
.cf-seasons span > small { display: block; color: var(--acc2); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.4px; }
.cf-seasons .is-current span > small { color: var(--gold); }
.cf-notices { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 0.82rem; }
.cf-notices li { display: grid; gap: 1px; padding: 6px 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.03); }
.cf-notices a { color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.cf-notices a:hover { color: var(--acc2); text-decoration: underline; }
.cf-notices time { color: var(--text-3); font-size: 0.72rem; font-variant-numeric: tabular-nums; }

/* ── Guest popover (js/casefiles.js) ────────────────────────────── */
.cf-pop {
    position: absolute;
    z-index: 60;
    width: min(340px, calc(100vw - 24px));
    padding: 12px 12px 10px;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    background: var(--navy-mid);
    color: var(--text);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
}
.cf-pop:focus { outline: none; }
.cf-pop:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.cf-pop-body { display: grid; gap: 4px; padding-right: 18px; }
.cf-pop-body .cf-guest-name { font-size: 0.92rem; }
.cf-pop-body .cf-k { margin: 0; color: var(--up); }
.cf-pop-body .ev-skilltext { margin: 0; }
.cf-pop-x { position: absolute; top: 4px; right: 6px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: var(--text-2); font-size: 1.2rem; line-height: 1; cursor: pointer; }
.cf-pop-x:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.cf-pop-x:focus-visible { outline: 2px solid var(--gold); }
.cf-pop-more { display: inline-block; margin-top: 8px; color: var(--acc2); font-size: 0.78rem; font-weight: 600; }
.cf-pop-more:hover { color: #fff; }
