/* The History page, /studio/history (decision 62; src/studio/history-page/).
   The Studio's tokens (tokens.css), the Library's type ramp and the
   Dashboard's page frame (.work in studio.css). */

.hi {
  max-width: 960px;
  margin: 0 auto;
  color: var(--st-text);
  font-family: var(--st-font);
}

.hi :where(a, button, input):focus-visible {
  outline: 2px solid var(--st-accent);
  outline-offset: 1px;
}

/* ---- Header and controls ------------------------------------------------------ */

.hi-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: 24px;
}
.hi-head__text { flex: 1 1 320px; min-width: 0; }

.hi-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  width: min(100%, 320px);
}
.hi-controls[hidden] { display: none; }

.hi-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 38px;
  padding: 0 8px 0 12px;
  border-radius: 10px;
  outline: 1px solid var(--st-line);
  outline-offset: -0.5px;
  background: var(--st-surface);
  color: var(--st-text-faint);
  cursor: text;
}
.hi-search:focus-within { outline-color: var(--st-line-strong); }
.hi-search:has(.hi-search__input:focus-visible) { outline: 2px solid var(--st-accent); outline-offset: -1px; }
.hi-search > svg { width: 15px; height: 15px; flex: none; }
.hi-search__input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--st-text);
  font: 400 13px/normal var(--st-font);
}
.hi .hi-search__input:focus-visible { outline: none; }
/* The box draws the one ring; the shared focus ring (controls.css) stays off the input, as in the Library's search. */
.hi-search__input { --st-focus-ring-style: none; }
.hi-search__input::placeholder { color: var(--st-text-faint); opacity: 1; }
.hi-search__input::-webkit-search-cancel-button { display: none; }
.hi-search__kbd {
  padding: 1px 5px;
  border-radius: 4px;
  outline: 1px solid var(--st-line);
  color: var(--st-text-faint);
  font: 500 10px/16px var(--st-font-mono);
}

.hi-chips { display: flex; gap: 6px; }
.hi-chip {
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  outline: 1px solid var(--st-line);
  outline-offset: -0.5px;
  background: none;
  color: var(--st-text-dim);
  font: 500 12px/normal var(--st-font);
  cursor: pointer;
}
.hi-chip:hover { background: var(--st-surface-2); color: var(--st-text); }
.hi-chip[aria-pressed='true'] { outline-color: var(--st-accent); background: var(--st-accent-soft); color: var(--st-accent-ink); }

/* ---- Days and rows ------------------------------------------------------------------ */

.hi-days { display: flex; flex-direction: column; gap: 20px; }
.hi-day__title {
  margin: 0 0 6px;
  padding: 0 10px;
  color: var(--st-text-faint);
  font: 500 10px/normal var(--st-font-mono);
  letter-spacing: 1.3px;
  text-transform: uppercase;
}
.hi-list { margin: 0; padding: 0; list-style: none; }

.hi-row {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 56px;
  padding: 0 10px;
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
}
.hi-row:hover,
.hi-row:focus-visible { background: var(--st-surface); }

.hi-art {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 64px;
  height: 36px;
  overflow: hidden;
  border-radius: 6px;
  color: color-mix(in srgb, var(--st-on-accent) 80%, transparent);
}
.hi-art > svg { width: 15px; height: 15px; }
.hi-art--0 { background: linear-gradient(-135deg, var(--st-art-rose) 14.6%, var(--st-art-violet) 85.4%); }
.hi-art--1 { background: linear-gradient(-135deg, var(--st-art-amber) 14.6%, var(--st-art-red) 85.4%); }
.hi-art--2 { background: linear-gradient(-135deg, var(--st-art-teal) 14.6%, var(--st-art-blue) 85.4%); }
.hi-art--3 { background: linear-gradient(-135deg, var(--st-art-lime) 14.6%, var(--st-art-sky) 85.4%); }
.hi-art__thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.hi-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hi-title,
.hi-artist { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.hi-title { font: 500 14px/normal var(--st-font); }
.hi-artist { color: var(--st-text-dim); font: 400 12.5px/normal var(--st-font); }

.hi-key {
  flex: none;
  width: 44px;
  color: var(--st-chord-ink);
  font: 600 13px/normal var(--st-font);
  text-align: right;
}
/* 88px fits "EXTENSION" (86px), so the key and time line up on every row;
   full-opacity dim text for 4.5:1 (the plain tag's 67% faint is under it). */
.hi-source { flex: none; width: 88px; justify-content: center; color: var(--st-text-dim); font: 500 11px/normal var(--st-font); }
.hi-count {
  flex: none;
  width: 32px;
  color: var(--st-text-faint);
  font: 500 11px/normal var(--st-font-mono);
  text-align: right;
}
.hi-time {
  flex: none;
  width: 92px;
  color: var(--st-text-faint);
  font: 400 12px/normal var(--st-font-mono);
  text-align: right;
}

/* "Open" in place of nothing: shown on hover and focus, never shifting the row. */
.hi-open {
  flex: none;
  width: 56px;
  padding: 5px 0;
  border-radius: 7px;
  background: var(--st-accent);
  color: var(--st-on-accent);
  font: 600 12px/normal var(--st-font);
  text-align: center;
  visibility: hidden;
}
.hi-row:hover .hi-open,
.hi-row:focus-visible .hi-open { visibility: visible; }

/* ---- Loading, more and states ---------------------------------------------------- */

.hi-sentinel { height: 1px; }

/* The footer (decision 64): always under the list, saying whether everything is loaded. */
.hi-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 16px 0 32px;
  color: var(--st-text-dim);
  font: 400 12.5px/18px var(--st-font);
  text-align: center;
}
.hi-footer__count,
.hi-footer__error { margin: 0; }
.hi-more__btn {
  height: 32px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  outline: 1px solid var(--st-line-strong);
  outline-offset: -0.5px;
  background: var(--st-surface);
  color: var(--st-text);
  font: 500 12.5px/normal var(--st-font);
  cursor: pointer;
}
.hi-more__btn:hover:not(:disabled) { background: var(--st-surface-2); }
.hi-more__btn:disabled { color: var(--st-text-dim); cursor: progress; }

/* The count again, for screen readers only (announced when it settles). */
.hi-live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* A quiet action (Retry, Clear, Dismiss…) is a small secondary button (st-btn, P72), never underlined text. */
.hi-text-btn { flex: none; text-decoration: none; }

.hi-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 32px 10px;
  color: var(--st-text-dim);
}
.hi-state__text { margin: 0; font: 400 14px/20px var(--st-font); }

.hi-skeleton { display: flex; flex-direction: column; gap: 4px; }
.hi-skeleton__title { width: 72px; height: 10px; margin: 0 10px 10px; border-radius: 4px; background: var(--st-surface-2); }
.hi-skeleton__row { display: flex; align-items: center; gap: 14px; height: 56px; padding: 0 10px; }
.hi-skeleton__art { width: 64px; height: 36px; border-radius: 6px; background: var(--st-surface-2); }
.hi-skeleton__line { width: 40%; height: 12px; border-radius: 4px; background: var(--st-surface-2); }
.hi-skeleton > * { animation: hi-pulse 1.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .hi-skeleton > * { animation: none; } }
@keyframes hi-pulse { 50% { opacity: 0.5; } }

/* Narrow windows: the details fold away before the title does. */
@media (max-width: 720px) {
  .hi-count, .hi-open { display: none; }
  .hi-time { width: auto; }
  .hi-key { width: auto; }
}
