/* Studies (js/studies.js): Master Design "Studies · working page", boards CHOSEN · 1E (Library) and 2D (Asked for);
   design system patterns.md "Studies pages", "Cards", "Buttons and controls". Phone first; a computer (768 px and up)
   gets the eyebrows, the search box and the wide words; 1024 px and up gets the fluid page with 64 px margins, the
   card grid (3 columns at 1440, 4 at 1920) and the Details panel on the right. Only theme tokens. */

/* The page's own root and heading rules carry its tab classes: settings.css (loaded after this) also styles .st and
   .st-h1, and its gap: 0 is what let the filter row and the cards touch (round 2 item 24). 16 px between the rows,
   at every size: under the tabs' line, and between the filter row and the cards. */
.st:is(.st-library, .st-asked) { display: flex; flex-direction: column; gap: 16px; padding-top: 2px; font: inherit; }
.st-wide-only { display: none; }
.st-grow { flex: 1; }

/* ---- head, Ask, tabs ---- */
.st-head { display: flex; align-items: center; gap: 12px; }
.st-head .st-h1 { flex: 1; margin: 0; padding: 0; font: 500 32px/1.1 var(--read); }
.st-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--raised); color: var(--text);
  font: 500 14px var(--ui); text-decoration: none; cursor: pointer;
}
.st-btn .i { width: 18px; height: 18px; }
.st-btn:focus-visible, .st-chip:focus-visible, .st-lnk:focus-visible, .st-tab:focus-visible, .st-card:focus-visible, .st-row:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}
.st-btn-pri { background: var(--gold); border-color: var(--gold); color: var(--ground); font-weight: 600; }
.st-btn-q { background: none; }
.st-btn-full { width: 100%; }
.st-tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); }
.st-tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 0; margin-bottom: -1px; border-bottom: 2px solid transparent;
  font: 500 16px var(--ui); color: var(--muted); text-decoration: none; white-space: nowrap;
}
.st-tab:hover { color: var(--text); }
.st-tab[aria-current="page"] { color: var(--text); border-bottom-color: var(--gold); }

/* ---- the filter row ---- */
.st-fbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.st-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--chip-border); background: var(--ground); color: var(--chip-text); font: 500 13px var(--ui); cursor: pointer;
}
.st-chip small { color: var(--faint); font: inherit; margin-left: 2px; }
.st-chip[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); background: var(--keywash); }
.st-filter-btn { min-height: 36px; }
.st-filter-btn .i { width: 16px; height: 16px; }
.st-filter-btn.st-on { border-color: var(--gold); color: var(--gold); }
.st-search-box { display: none; align-items: center; gap: 8px; height: 40px; padding: 0 12px; flex: 1 1 100%; min-width: 0;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--panel); color: var(--muted); }
.st-search-box .i { width: 18px; height: 18px; }
.st-search { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); font: 400 16px var(--ui); outline: none; }
.st-search-box:focus-within { border-color: var(--gold); }
.st-fbar.st-searching .st-search-box { display: flex; order: 9; }

/* ---- study cards (1E) ---- */
.st-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.st-card, .st-acard {
  display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; color: var(--text); text-decoration: none;
}
a.st-card:hover { background: var(--raised); }
/* A phone card is the computer card in one column (round 1 item 5): the eyebrow row with the tag on its right,
   the title (20 px) larger than the point (16 px). */
.st-eyebrow-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.st-eyebrow { font: 600 11px/1.5 var(--ui); letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
/* .st-title, .st-note and .st-row are scoped to .st: settings.css (loaded after this) uses the same names. */
.st .st-title { font: 500 20px/1.3 var(--read); overflow-wrap: anywhere; display: inline; }
.st-dot { display: inline-block; width: 8px; height: 8px; margin-left: 8px; border-radius: 50%; background: var(--gold); vertical-align: middle; flex: none; }
.st-state .st-dot { margin-left: 0; }
.st-point { font: 400 16px/1.45 var(--read); color: var(--text-soft); }
.st-where { font: 400 13px/1.4 var(--ui); color: var(--muted); overflow-wrap: anywhere; }
.st-state { display: flex; align-items: center; gap: 10px; font: 500 13px/1.4 var(--ui); color: var(--muted); min-width: 0; }
.st-state.st-new { color: var(--gold); }
.st-state .i { width: 15px; height: 15px; }
.st-bar { flex: none; width: 72px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.st-bar span { display: block; height: 100%; background: var(--gold); }
.st-private { flex: none; }

/* ---- groups and condensed rows ---- */
.st-group { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line-strong); }
.st-group b { font: 600 12px var(--ui); letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.st-count { font: 400 13px var(--ui); color: var(--muted); }
.st-rows { display: flex; flex-direction: column; }
.st .st-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 4px 16px; min-height: 0; padding: 14px 0; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.st .st-row:hover { background: var(--panel); }
.st-row-t { flex: 1 1 100%; min-width: 0; font: 500 18px/1.3 var(--read); overflow-wrap: anywhere; }
.st-row-ref { font: 400 13px var(--ui); color: var(--muted); }
/* A phone shows one link to the Read list in place of the Recently read rows (board 1E phone). */
.st-recent, .st-recent-rows { display: none; }
.st-lnk {
  display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; cursor: pointer;
  font: 500 14px var(--ui); color: var(--gold); text-decoration: none;
}
.st-lnk .i { width: 16px; height: 16px; }
.st-read-link { align-self: flex-start; min-height: 44px; }
.st-empty { margin: 4px 0; font: 400 14px/1.5 var(--ui); color: var(--muted); }

/* ---- Asked for (2D) ---- */
.st-cards { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
/* The first section heading sits 16 px under the tabs' line: the page's gap, with no margin of its own. */
.st-cards > .st-group:first-child { margin-top: 0; }
.st-acard { cursor: pointer; gap: 8px; }
.st-acard.st-selected { border-color: var(--gold); background: var(--keywash); }
.st-request { margin: 0; font: italic 400 15px/1.45 var(--read); color: var(--text-soft); overflow-wrap: anywhere; }
.st-card-foot { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.st-swrow { display: inline-flex; align-items: center; gap: 10px; font: 500 14px var(--ui); color: var(--text); }
.st-details { min-height: 44px; }
.st-q-folded .hm-queued { display: none; }
.st-q-more { align-self: flex-start; min-height: 36px; }

/* ---- the Filter sheet and the Details sheet (a phone) ---- */
.st-scrim { position: fixed; inset: 0; z-index: 29; background: var(--ground); opacity: .72; }
.st-sheet, .st-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; max-height: 86vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px; padding: 14px 20px 24px;
  background: var(--raised); border-top: 1px solid var(--line-strong); border-radius: 20px 20px 0 0; box-shadow: var(--sheet);
}
/* Details (round 1 item 9): the body scrolls, the footer (switch, Open the study, See it as a reader) stays pinned. */
.st-panel { max-height: 90vh; max-height: 90dvh; overflow: hidden; gap: 0; padding: 0; }
.st-pbody { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 14px 20px 16px; }
.st-pfoot { flex: none; display: flex; flex-direction: column; gap: 10px; padding: 14px 20px 20px; border-top: 1px solid var(--line); }
.st-handle { align-self: center; width: 36px; height: 4px; border-radius: 2px; background: var(--chip-border); flex: none; }
.st-sheet-top { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.st-sheet-top .st-eyebrow { flex: 1; }
.st-cap { font: 600 11px var(--ui); letter-spacing: .09em; text-transform: uppercase; color: var(--faint); }
.st-cap-m { color: var(--muted); }
.st-fgroup { display: flex; flex-direction: column; gap: 8px; }
.st-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.st-ptitle { margin: 0; font: 500 22px/1.2 var(--read); overflow-wrap: anywhere; }
.st-ppoint { margin: 0; font: 400 16px/1.45 var(--read); color: var(--text-soft); }
.st-secs { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font: 400 13px/1.4 var(--ui); color: var(--muted); }
.st-hr { height: 1px; background: var(--line); }
.st-panel .st-swrow { font-size: 15px; }
.st .st-note { font: 400 13px/1.45 var(--ui); color: var(--muted); }

@media (min-width: 768px) {
  .st-wide-only { display: inline; }
  .st-narrow-only { display: none; }
  .st-head .st-h1 { font-size: 40px; }
  /* The heading keeps its 22 px over the tabs; the rows under the tabs keep the page's 16. */
  .st-head { align-items: flex-end; gap: 16px; margin-bottom: 6px; }
  .st-tabs { gap: 28px; }
  .st-search-btn { display: none; }
  .st-search-box { display: flex; flex: 0 1 280px; }
  .st-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
  .st-card, .st-acard { padding: 22px; gap: 10px; border-radius: 16px; }
  .st-card { min-height: 220px; }
  .st-card .st-eyebrow-row { display: flex; }
  .st-card .st-title { font-size: 24px; }
  .st-acard .st-title { font-size: 22px; }
  .st-card .st-point { font-size: 16px; }
  .st-card .st-where { margin-top: auto; font-size: 14px; }
  .st-bar { width: 120px; }
  .st-recent { display: flex; margin-top: 26px; }
  .st-recent-rows { display: flex; }
  .st-read-link { display: none; }
  .st .st-row { flex-wrap: nowrap; }
  .st-row-t { flex: 1 1 auto; }
  .st-row-ref { width: 260px; flex: none; font-size: 14px; }
  .st-q-folded .hm-queued { display: flex; }
  .st-q-more { display: none; }
}

@media (min-width: 1024px) {
  body[data-view="studies"] .wrap { max-width: var(--wide-max); padding: 48px var(--wide-pad) 64px; }
  .st-grid { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
  /* Details: a panel on the right, the cards move over; nothing selected is the full width (no empty column). */
  .st-has-detail .st-split { display: grid; grid-template-columns: minmax(0, 1fr) 500px; gap: 40px; align-items: start; }
  /* The panel's column runs the cards' full height, so the panel can stick under the top bar as the page scrolls. */
  .st-has-detail .st-panel-host { align-self: stretch; }
  .st-has-detail .st-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  .st-panel-scrim, .st-panel .st-handle { display: none; }
  /* Sticks under the 72 px top bar, as tall as the window less the bar and a 24 px gap (12 above, 12 below). */
  .st-panel {
    position: sticky; top: 84px; left: auto; right: auto; bottom: auto; z-index: auto; height: calc(100vh - 96px); max-height: none;
    padding: 0; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: none;
  }
  .st-pbody { padding: 28px 28px 20px; }
  .st-pfoot { padding: 16px 28px 24px; }
  .st-ptitle { font-size: 32px; line-height: 1.15; }
  .st-ppoint { font-size: 18px; }
  .st-request-full { font-size: 16px; }
  .st-secs { font-size: 14px; }
  /* The Filter sheet is a centered panel on a computer, not a strip along the bottom. */
  .st-sheet { left: 50%; right: auto; bottom: auto; top: 120px; width: 460px; transform: translateX(-50%); border: 1px solid var(--line-strong); border-radius: 16px; }
  .st-sheet .st-handle { display: none; }
}
