/* Layout fit: keeps card content inside its card at phone, iPad and desktop
   widths. Loads last so it can correct earlier sheets without rewriting them.
   Components size themselves from their own width (container queries), not the
   viewport, because the sidebar changes how much room the content gets. */

/* ---------- Home: "Your current week" card ---------- */
.study-resume {
  border-left: 1px solid var(--line);
  border-radius: var(--r-card, 12px);
  box-shadow: inset 4px 0 0 var(--accent);
  padding: 24px 28px 22px 32px;
}
.study-resume h2 { margin: 6px 0 8px; }
.study-resume > p { max-width: 760px; margin: 0; }
.study-resume .actions { margin: 18px 0 16px; gap: 10px; }
.study-resume > p.small { line-height: 1.55; }
.study-resume > :last-child { margin-bottom: 0; }
@media (max-width: 760px) {
  .study-resume { padding: 20px 18px 18px 22px; }
  .study-resume .actions .button { flex: 1 1 100%; justify-content: center; text-align: center; }
}

/* Home cards share one corner radius (they mixed 8px and 22px). */
.study-mode-tabs a, .study-map > * { border-radius: var(--r-card, 12px); }

/* ---------- Anatomy Lab: joint ROM explorer ---------- */
.rom-lab { container-type: inline-size; container-name: romlab; }
.rom-detail { container-type: inline-size; container-name: romcard; min-width: 0; }

/* Two columns only when the lab itself has room, not the viewport. */
@container romlab (max-width: 700px) {
  .rom-workspace { grid-template-columns: 1fr; }
}

/* Gauge and reference table read as one figure. */
.rom-figure { display: grid; gap: 6px 28px; align-items: center; margin: 10px 0 16px; }
.rom-figure .rom-gauge { width: 100%; max-width: 300px; margin: 0; }
.rom-figure .rom-norms { width: 100%; max-width: none; margin: 0; }
.rom-axis { font-size: 11px; }
@container romcard (min-width: 460px) {
  .rom-figure { grid-template-columns: minmax(200px, 280px) minmax(0, 1fr); }
}
@container romcard (max-width: 459px) {
  .rom-figure .rom-gauge { max-width: 260px; justify-self: center; }
  .rom-facts div { grid-template-columns: 1fr; gap: 2px; }
}

/* Measured-value row: input and result wrap cleanly. */
.rom-check label { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.rom-check input { width: 5.5em; }
.rom-check-result { flex: 1 1 220px; min-width: 0; }

.rom-facts dd, .rom-baseball p, .rom-plane { overflow-wrap: anywhere; }

/* ---------- Card footers (course units, interview cases, lessons) ---------- */
.lesson-card .card-bottom { align-items: flex-end; flex-wrap: wrap; }
.lesson-card .card-bottom > * { min-width: 0; text-wrap: pretty; }
.lesson-card .card-bottom > :last-child:not(:first-child) { margin-left: auto; text-align: right; white-space: nowrap; }

/* ---------- Strips that used to clip at the screen edge ---------- */
@media (max-width: 760px) {
  /* Joint picker: wrap the chips so every joint is visible. */
  .rom-joints { flex-wrap: wrap; overflow: visible; padding-bottom: 0; }

  /* Delivery and swing phases wrap into a grid by container width; see joints.css (.dl-timeline). */

  /* Case episodes: a 2 x 2 grid instead of a half-hidden second card. */
  .bb-episode-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .bb-episode-nav button { min-width: 0; }

  /* Lesson steps: four tabs fit on one line. */
  .lesson-toolbar { gap: 2px; }
  .lesson-toolbar .step-tab { padding-left: 10px; padding-right: 10px; }
}

/* ---------- Curriculum coverage table: stacked on phones ---------- */
@media (max-width: 760px) {
  .table-scroll:has(.baseball-coverage) { overflow: visible; }
  .baseball-coverage, .baseball-coverage tbody, .baseball-coverage tr, .baseball-coverage td { display: block; width: auto; }
  .baseball-coverage thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .baseball-coverage tr { padding: 14px 0; border-bottom: 1px solid var(--line); }
  .baseball-coverage td { border: 0; padding: 2px 0; }
  .baseball-coverage td:first-child { font-weight: 650; margin-bottom: 6px; }
  .baseball-coverage td:nth-child(2)::before,
  .baseball-coverage td:nth-child(3)::before {
    display: block; margin-top: 6px; font-family: var(--label, inherit); font-size: .7rem;
    letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  }
  .baseball-coverage td:nth-child(2)::before { content: "Available now"; }
  .baseball-coverage td:nth-child(3)::before { content: "Still needs development or observation"; }
}

/* Search: Anatomy Lab matches sit in their own group at the top of the results. */
#anatomy-search:empty{display:none}
#anatomy-search .search-group{margin:0 0 2px;font:650 15px/1.4 var(--sans);color:var(--muted)}
#anatomy-search{padding-bottom:10px;margin-bottom:6px;border-bottom:1px solid var(--line)}

/* Today: where you stopped, and today's recall, side by side when there is room. */
.today-row{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:14px;margin:18px 0}
.today-row>div:empty{display:none}
.today-row:not(:has(a)){display:none}
.recall-today,.resume-today{position:relative;display:grid;gap:4px;height:100%;padding:18px 44px 18px 20px;border:1px solid var(--line);border-radius:var(--radius,16px);background:var(--card);color:var(--ink);text-decoration:none}
.recall-today:hover,.resume-today:hover{border-color:var(--accent)}
.recall-today .eyebrow,.resume-today .eyebrow{margin:0}
.recall-today strong,.resume-today strong{font:650 18px/1.3 var(--sans)}
.recall-today>span:not(.eyebrow):not(.recall-go),.resume-today>span:not(.eyebrow):not(.recall-go){font-size:14px;line-height:1.5;color:var(--muted)}
.recall-go{position:absolute;right:18px;top:50%;transform:translateY(-50%);font-size:20px;color:var(--accent)}
.nav-count{display:inline-block;min-width:20px;margin-left:6px;padding:1px 6px;border-radius:999px;background:var(--accent);color:#fff!important;-webkit-text-fill-color:#fff;font:650 11px/1.6 var(--sans);text-align:center;vertical-align:1px}
.nav-count[hidden]{display:none}

/* Resume reading */
.resume-pill{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 8px;width:100%;max-width:760px;margin:6px 0 20px;padding:12px 16px;border:1px solid var(--accent);border-radius:14px;background:var(--light,var(--card));color:var(--ink);font:500 15px/1.4 var(--sans);text-align:left;cursor:pointer}
.resume-pill strong{font-weight:650}
.resume-pill .resume-meta{color:var(--muted);font-size:13px}
.resume-pill:hover{background:var(--card)}
.resume-pill:focus-visible{outline:2px solid var(--accent);outline-offset:2px}

/* Daily recall */
.recall-lab{display:grid;gap:18px;max-width:820px}
.recall-stats{margin:0}
.recall-card{padding:26px;border:1px solid var(--line);border-left:4px solid var(--accent);border-radius:var(--radius,16px);background:var(--card)}
.recall-card .eyebrow{margin:0 0 10px}
.recall-front{margin:0 0 14px;font:600 22px/1.35 var(--sans);letter-spacing:-.01em}
.recall-hint{margin:0 0 16px;color:var(--muted);font-size:15px}
.recall-back{display:grid;gap:12px;margin:0 0 14px;padding:16px 0 0;border-top:1px solid var(--line)}
.recall-back div{display:grid;grid-template-columns:140px 1fr;gap:4px 14px}
.recall-back dt{color:var(--muted);font:600 13px/1.6 var(--sans)}
.recall-back dd{margin:0;font-size:16px;line-height:1.55}
.recall-open{margin:0 0 16px;font-size:14px}
.recall-grades{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.recall-grades .button{display:grid;gap:2px;justify-items:start;height:auto;padding:12px 14px;text-align:left;position:relative}
.recall-grades .button small{font-size:12px;font-weight:500;opacity:.8}
.recall-lab kbd{font:600 11px/1 var(--label,monospace);padding:3px 5px;border:1px solid currentColor;border-radius:5px;opacity:.55;margin-left:8px}
.recall-grades kbd{position:absolute;right:10px;top:10px;margin:0}
.recall-done h2{margin:0 0 8px}
.recall-done p{margin:0 0 14px}
.recall-undo{margin:-6px 0 0;font-size:14px}
.recall-settings{padding:14px 18px;border:1px solid var(--line);border-radius:14px;background:var(--card)}
.recall-settings summary{cursor:pointer;font-weight:650}
.recall-decks{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:8px 16px;margin:14px 0}
.recall-decks label,.recall-pace{display:flex;align-items:center;gap:8px;font-size:15px}
.recall-pace select{min-height:40px;padding:4px 10px;border:1px solid var(--line);border-radius:10px;background:var(--card);color:var(--ink)}
@media (hover:none){.recall-lab kbd{display:none}}
@media (max-width:560px){.recall-card{padding:20px}.recall-front{font-size:19px}.recall-back div{grid-template-columns:1fr}.recall-grades{grid-template-columns:1fr}.recall-grades .button{grid-template-columns:auto 1fr;align-items:baseline;gap:10px}}

/* Sync between devices (Progress page) */
.sync-panel{border:1px solid var(--line);border-radius:var(--r-card,20px);background:var(--card);padding:18px 20px;margin:18px 0;display:grid;gap:10px}
.sync-panel:empty{display:none}
.sync-panel h2{margin:0;font-size:1.15rem}
.sync-panel p{margin:0}
.sync-line{display:flex;align-items:center;flex-wrap:wrap;gap:8px}
.sync-dot{width:10px;height:10px;border-radius:50%;background:var(--muted);flex:none}
.sync-dot.sync-idle{background:var(--accent)}
.sync-dot.sync-working{background:var(--accent);animation:sync-pulse 1s ease-in-out infinite}
.sync-dot.sync-error,.sync-dot.sync-conflict{background:#c2410c}
.sync-detail{font-size:.9rem;color:var(--muted)}
.sync-panel .actions{margin:4px 0 0}
@keyframes sync-pulse{50%{opacity:.35}}
@media (prefers-reduced-motion:reduce){.sync-dot.sync-working{animation:none}}
.sync-dialog{position:fixed;inset:0;z-index:1000;display:grid;place-items:end center;background:rgba(10,20,15,.45);padding:16px}
.sync-sheet{width:min(520px,100%);background:var(--card);color:var(--ink);border:1px solid var(--line);border-radius:var(--r-card,20px);padding:20px 22px;display:grid;gap:12px;box-shadow:0 18px 50px rgba(0,0,0,.28)}
.sync-sheet h2{margin:0;font-size:1.2rem}
.sync-sheet p{margin:0}
.sync-sheet .actions{display:grid;gap:8px;margin:4px 0 0}
.sync-sheet .actions .button{width:100%;justify-content:center;text-align:center}
@media (min-width:700px){.sync-dialog{place-items:center}}

/* Chapter and case pictures: the label, title, button and sources line sat flush against the card
   edge (no padding) and used three different text sizes. One inset and one type scale for all of them. */
.teaching-graphic { --gfx-pad: 24px; }
.teaching-graphic > .eyebrow { display: block; margin: 20px var(--gfx-pad) 0; }
.teaching-graphic > h3 { margin: 8px var(--gfx-pad) 18px; font-size: 20px; line-height: 1.3; overflow-wrap: anywhere; }
.teaching-graphic .memory-cue { margin: 20px var(--gfx-pad); }
.teaching-graphic .memory-cue strong { font-size: 17px; line-height: 1.35; }
.teaching-graphic .memory-cue p { font-size: 15px; line-height: 1.55; }
.teaching-graphic > figcaption, .teaching-graphic > .graphic-covered { padding: 0 var(--gfx-pad) 16px; margin: 0; font-size: 14px; line-height: 1.6; }
.teaching-graphic > .button { margin: 0 var(--gfx-pad) 18px; }
.teaching-graphic > details { margin: 0; padding: 14px var(--gfx-pad) 16px; border-top: 1px solid var(--line); font-size: 15px; }
.teaching-graphic > details > summary { font-size: 15px; font-weight: 650; cursor: pointer; }
.teaching-graphic > details[open] > summary { margin-bottom: 10px; }
@media (max-width: 640px) { .teaching-graphic { --gfx-pad: 18px; } .teaching-graphic > h3 { font-size: 19px; } }

/* Type floor: no label, tag or table heading in the hub is set smaller than 12px. */
#main :is(.eyebrow, .tag, .badge, .part-chip, .study-part-num, .study-status, .path-number, .rom-hint, .dl-num, kbd, th),
#main .dl-timeline small, .study-trail .part-chip, .sidebar .nav-count { font-size: 12px; }
#main :is(.source-card, .bb-case-card, .bb-stage) span:not([class]) { font-size: max(12px, 1em); }
