/* sections-c.css — Pokémon Deep Dive (drawer), Team Sheet Library,
   My Team Scanner, Data & Methodology. Owned by the sections-c agent.
   Uses only tokens/classes from app.css. */

/* Same grid-blowout fix as sections-a/b: let the track shrink so nested
   wide tables/grids scroll within .table-wrap instead of widening the page. */
main.grid .section[data-section="library"],
main.grid .section[data-section="scanner"],
main.grid .section[data-section="methodology"] {
  min-width: 0;
}

.lib-btn,
[data-section="deepdive"] .ddv-picker__label input,
.scn-input textarea {
  font-family: inherit;
}

/* ---------- shared small bits ---------- */
.lib-btn {
  background: var(--surface-2); border: 2px solid var(--frame); border-radius: var(--radius);
  padding: 6px 10px; font-family: var(--font-label); font-size: var(--fs-small); color: var(--ink);
  cursor: pointer;
}
[data-skin="pro"] .lib-btn { border: 1px solid var(--border); }
.lib-btn:hover { background: var(--accent); color: var(--surface-1); border-color: var(--accent); }
.lib-btn--wide { padding-left: var(--space-4); padding-right: var(--space-4); }

/* ================= deep dive (drawer) ================= */
.ddv-picker {
  display: flex; flex-direction: column; gap: 4px;
  padding-bottom: var(--space-3); margin-bottom: var(--space-3);
  border-bottom: 2px solid var(--frame); position: sticky; top: 0; background: var(--surface-1); z-index: 2;
}
[data-skin="pro"] .ddv-picker { border-bottom: 1px solid var(--border); }
.ddv-picker__label { font-family: var(--font-label); font-size: var(--fs-small); color: var(--muted); text-transform: uppercase; }
.ddv-picker input[type="search"] {
  background: var(--surface-2); color: var(--ink); border: 2px solid var(--frame); border-radius: var(--radius);
  padding: 6px 8px; font-family: var(--font-body); font-size: var(--fs-body);
}
[data-skin="pro"] .ddv-picker input[type="search"] { border: 1px solid var(--border); }

.ddv-content { display: flex; flex-direction: column; gap: var(--space-4); }
.ddv-block .card__body { display: flex; flex-direction: column; gap: var(--space-2); }

.ddv-head { display: flex; gap: var(--space-4); align-items: flex-start; flex-wrap: wrap; }
.ddv-sprite-lg { flex: none; }
.ddv-sprite-lg img { image-rendering: pixelated; }
.ddv-info { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; flex: 1; }
.ddv-info h3 { font-size: var(--fs-head-lg); text-transform: uppercase; }
.ddv-types { display: flex; gap: 6px; flex-wrap: wrap; }
.ddv-types .pill { border: 0; }
.ddv-kpis { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.ddv-winrate { display: flex; gap: var(--space-4); }
.ddv-note { color: var(--muted); font-size: var(--fs-small); font-family: var(--font-body); }

.ddv-stat-row { display: grid; grid-template-columns: 44px 1fr 40px; align-items: center; gap: var(--space-2); font-size: var(--fs-small); }
.ddv-stat-track { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.ddv-stat-fill { height: 100%; background: var(--seq-4); border-radius: 4px; }

/* bar list (items / abilities / moves / sets / counters) */
.bar-list { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 1fr) minmax(80px, 2fr) 52px; align-items: center; gap: var(--space-2); font-size: var(--fs-small); }
.bar-row.is-clickable { cursor: pointer; border-radius: var(--radius); }
.bar-row.is-clickable:hover, .bar-row.is-clickable:focus-visible { background: var(--surface-2); }
.bar-row__label { display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row__track { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-row__fill { height: 100%; background: var(--seq-4); border-radius: 4px; }
.bar-row__val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

.sprite-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: var(--space-2); }
.sprite-cell {
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
  background: var(--surface-2); border: 2px solid var(--frame); border-radius: var(--radius); padding: var(--space-2);
  cursor: pointer; font-size: var(--fs-small); color: var(--ink);
}
[data-skin="pro"] .sprite-cell { border: 1px solid var(--border); }
.sprite-cell:hover, .sprite-cell:focus-visible { background: var(--accent); color: var(--surface-1); }
.sprite-cell span { max-width: 68px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ================= team sheet library ================= */
.lib-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.lib-toolbar__label { display: flex; align-items: center; gap: 6px; font-family: var(--font-label); font-size: var(--fs-small); color: var(--muted); text-transform: uppercase; }
.lib-toolbar input[type="search"], .lib-toolbar select {
  background: var(--surface-2); color: var(--ink); border: 2px solid var(--frame); border-radius: var(--radius);
  padding: 6px 8px; font-family: var(--font-body); font-size: var(--fs-small);
}
[data-skin="pro"] .lib-toolbar input[type="search"], [data-skin="pro"] .lib-toolbar select { border: 1px solid var(--border); }

.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-4); }
.lib-card {
  display: flex; flex-direction: column; gap: var(--space-2); position: relative;
  background: var(--surface-2); border: 2px solid var(--frame); border-radius: var(--radius); padding: var(--space-3);
}
[data-skin="pro"] .lib-card { border: 1px solid var(--border); }
.lib-card--gold { border-color: var(--accent-2); box-shadow: 0 0 0 2px var(--accent-2); }
.lib-badge {
  position: absolute; top: -10px; right: var(--space-2); background: var(--accent-2); color: var(--ink);
  font-family: var(--font-label); font-size: 10px; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 8px; border: 2px solid var(--frame);
}
[data-skin="pro"] .lib-badge { border: 1px solid var(--border); }

.lib-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.lib-card__who { display: flex; flex-direction: column; min-width: 0; }
.lib-card__player { font-family: var(--font-label); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-card__country { color: var(--muted); font-size: var(--fs-small); }
.lib-tier { background: var(--muted); text-transform: uppercase; flex: none; }
.lib-tier--worlds, .lib-tier--international { background: var(--accent); }
.lib-tier--regional { background: var(--accent-2); color: var(--ink); }
.lib-tier--online { background: var(--muted); }

.lib-card__meta { display: flex; flex-wrap: wrap; gap: var(--space-2); font-size: var(--fs-small); color: var(--ink-2); }
.lib-card__event { flex: 1 1 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

.lib-mons { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.lib-mon {
  display: flex; flex-direction: column; align-items: center; gap: 2px; background: var(--surface-1);
  border: 0; border-radius: var(--radius); padding: 4px; cursor: pointer;
}
.lib-mon:hover, .lib-mon:focus-visible { background: var(--surface-0); }
.lib-mon__item { font-size: 11px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lib-arch { align-self: flex-start; background: var(--seq-5); border: 0; cursor: pointer; }
.lib-card__actions { display: flex; gap: var(--space-2); margin-top: auto; }

.lib-loadmore-wrap { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); margin-top: var(--space-4); }
.lib-count { color: var(--muted); font-size: var(--fs-small); }

/* ================= my team scanner ================= */
.scn-input { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.scn-input__label { font-family: var(--font-label); font-size: var(--fs-small); color: var(--muted); text-transform: uppercase; }
.scn-textarea {
  background: var(--surface-2); color: var(--ink); border: 2px solid var(--frame); border-radius: var(--radius);
  padding: var(--space-2); font-family: var(--font-body); font-size: var(--fs-small); resize: vertical;
}
[data-skin="pro"] .scn-textarea { border: 1px solid var(--border); }
.scn-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.scn-results { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
/* Wide screens: pair related cards (one column below 1200px, where grid-area is ignored). */
@media (min-width: 1200px) {
  .scn-results {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "parsed  arch"
      "weak    weak"
      "threats speed"
      "mpoke   items"
      "march   picks"
      "link    closest";
  }
  /* Half-width cards: the best/worst matchup lists stack. */
  .scn-results .scn-cols { grid-template-columns: 1fr; }
}
/* weakest link: the 'Instead' cell wraps instead of running off a half-width card */
.scn-arch-table td:last-child { white-space: normal; min-width: 12ch; }
@media (max-width: 1199px) { .scn-results > .scn-block { grid-area: auto !important; } }
.scn-results > .empty-state { grid-column: 1 / -1; }
.scn-block .card__body { display: flex; flex-direction: column; gap: var(--space-2); }

.scn-parsed { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: var(--space-2); }
.scn-mon { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; font-size: var(--fs-small); }
.scn-mon__name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scn-mon__item { color: var(--muted); font-size: 11px; }
.scn-mon--unknown { outline: 2px dashed var(--status-critical); border-radius: var(--radius); padding: 4px; }
.scn-mon__flag { color: var(--status-critical); font-size: 10px; text-transform: uppercase; }

.scn-legend { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-2); }
.scn-legend__item { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-small); color: var(--ink-2); }
.scn-legend__swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }

table.scn-grid th, table.scn-grid td { text-align: center; }
table.scn-grid td.scn-cell { font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600; }

.scn-threats { display: flex; flex-direction: column; gap: var(--space-2); }
.scn-threat { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--grid); }
.scn-threat:last-child { border-bottom: 0; }
.scn-threat__info { display: flex; flex-direction: column; min-width: 0; }
.scn-threat__name { font-family: var(--font-label); }
.scn-threat__reason { color: var(--muted); font-size: var(--fs-small); }

.scn-speedrows { display: flex; flex-direction: column; gap: var(--space-2); }
.scn-speedrow { display: grid; grid-template-columns: 120px minmax(130px, 320px) 1fr 120px; align-items: center; gap: var(--space-2); font-size: var(--fs-small); }
.scn-speedrow__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scn-speedrow__val { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.scn-speedrow__track { position: relative; height: 6px; background: var(--surface-2); border-radius: 3px; }
.scn-speedrow__dot { position: absolute; top: -3px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); transform: translateX(-50%); }
.scn-speedrow__pct { color: var(--muted); text-align: right; }

.scn-closest { display: flex; flex-direction: column; gap: var(--space-2); }
.scn-closest__item { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--grid); }
.scn-closest__item:last-child { border-bottom: 0; }
.scn-closest__info { display: flex; flex-direction: column; min-width: 0; }

@media (max-width: 480px) {
  .scn-speedrow { grid-template-columns: 1fr; row-gap: 2px; }
  .lib-mons { grid-template-columns: repeat(2, 1fr); }
}

/* scanner evidence cards */
.scn-arch { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--space-2); }
.scn-arch__label { font-family: var(--font-label); font-size: var(--fs-h3, 1.1rem); color: var(--ink); }
.scn-sub { margin: 0 0 var(--space-1); font-family: var(--font-label); font-size: var(--fs-small); text-transform: uppercase; color: var(--muted); }
.scn-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.scn-col { display: flex; flex-direction: column; min-width: 0; }
.scn-mrow, .scn-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--grid); min-width: 0; }
.scn-mrow:last-child, .scn-item:last-child { border-bottom: 0; }
.scn-item { align-items: flex-start; }
.scn-ml { display: inline-flex; align-items: center; gap: var(--space-1); flex: none; min-width: 0; }
.scn-mrow .scn-ml { flex: 0 1 170px; }
.scn-item .scn-ml { flex: 0 0 170px; }
.scn-mrow__stat { font-size: var(--fs-small); color: var(--ink-2); font-variant-numeric: tabular-nums; min-width: 0; }
.scn-mrow__stat strong { color: var(--ink); }
.scn-link { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: var(--ink); cursor: pointer; text-decoration: underline dotted var(--muted); text-underline-offset: 3px; text-align: left; }
.scn-link:hover, .scn-link:focus-visible { color: var(--accent); }
.scn-tag { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 11px; font-family: var(--font-label); border: 1px solid var(--border); color: var(--ink-2); background: var(--surface-2); max-width: 100%; overflow-wrap: anywhere; }
.scn-tag--good { border-color: var(--status-good); color: var(--ink); }
.scn-tag--bad { border-color: var(--status-critical); color: var(--ink); }
.scn-tag--unclear, .scn-tag--none { color: var(--muted); }
.scn-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.scn-arch-table th, .scn-arch-table td { white-space: normal; }
.scn-arch-table tbody tr { cursor: default; }
.scn-row--good { box-shadow: inset 3px 0 0 var(--status-good); }
.scn-row--bad { box-shadow: inset 3px 0 0 var(--status-critical); }
.scn-warn { border: 1px solid var(--status-critical); border-radius: var(--radius); padding: var(--space-2); font-size: var(--fs-small); color: var(--ink); background: color-mix(in srgb, var(--status-critical) 12%, var(--surface-2)); }
.scn-items { display: flex; flex-direction: column; }
.scn-item__info { flex: 1 1 0; display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: var(--fs-small); color: var(--ink-2); }
.scn-ok { color: var(--status-good); }
.scn-note { color: var(--status-warning); }
.scn-sug { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.scn-sug__item--blocked { color: var(--muted); }
.scn-sug__item--blocked .scn-link { text-decoration-style: line-through; }
@media (max-width: 720px) {
  .scn-cols { grid-template-columns: 1fr; }
  .scn-item { flex-direction: column; gap: var(--space-1); }
  .scn-item .scn-ml, .scn-mrow .scn-ml { flex: none; }
  .scn-mrow { flex-direction: column; align-items: flex-start; gap: var(--space-1); }
}

/* ================= methodology ================= */
.mth-block .card__body { display: flex; flex-direction: column; gap: var(--space-2); }
.mth-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.mth-sources { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.mth-fact-list { display: grid; grid-template-columns: 1fr; gap: 2px 0; margin: 0; }
.mth-fact-list dt { font-family: var(--font-label); font-size: var(--fs-small); color: var(--ink); margin-top: var(--space-2); }
.mth-fact-list dd { margin: 0 0 0 0; color: var(--ink-2); font-size: var(--fs-small); }
.mth-arch-list { display: grid; grid-template-columns: 1fr; gap: 2px 0; margin: 0; }
.mth-arch-list dt { font-family: var(--font-label); margin-top: var(--space-2); }
.mth-arch-list dd { margin: 0; color: var(--ink-2); font-size: var(--fs-small); }
.mth-disclaimer { color: var(--muted); font-size: var(--fs-small); }
