/* The frame every page sits in, after tools.css: the header (Melete, the Watch | Listen | Manage
   switch, the side's entries, Search and the account menu), then the pieces every page shares
   (placeholders while loading, the empty and failed states, cut names, and the managing side's
   state marks). Tokens are in app.css. */

/* Header: one row on wide screens; narrower, the side's entries take a line of their own, and
   wrap rather than scroll out of view. On a phone it scrolls away with the page, leaving the
   screen to the page and the music bar. */
.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-2) var(--space-5);
  background: var(--surface);
  border-block-end: 1px solid var(--line);
}
.wordmark {
  font-size: var(--step-1);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
}
.sides {
  display: inline-flex;
  flex: none;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.sides a {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0 var(--space-3);
  border-radius: 999px;
  color: var(--muted);
  font-size: var(--step--1);
  font-weight: 600;
  text-decoration: none;
}
.sides a:hover { color: var(--text); }
.sides a[aria-current="true"] { background: var(--accent); color: var(--accent-ink); }
.entries { flex: 1; min-width: 0; }
.entries ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-1);
}
.entries a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 2.5rem;
  padding: 0 var(--space-3);
  white-space: nowrap;
  text-decoration: none;
  color: var(--muted);
}
.entries a:hover { color: var(--text); }
.entries a[aria-current="page"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.bar-end { display: flex; align-items: center; gap: var(--space-2); margin-inline-start: auto; }
.palette-open { gap: var(--space-2); color: var(--muted); }
.palette-open svg { width: 1.125rem; height: 1.125rem; fill: currentColor; }
.palette-open:hover { color: var(--text); }
kbd {
  padding: 0 var(--space-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  font: var(--step--1) / 1.6 var(--font-body);
  color: var(--muted);
}
.account { position: relative; color: var(--muted); }
.account summary {
  display: flex;
  align-items: center;
  min-height: 2.5rem;
  max-width: 12rem;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-s);
  cursor: pointer;
  list-style: none;
}
.account summary::-webkit-details-marker { display: none; }
.account summary::after { content: ""; flex: none; margin-inline-start: var(--space-2); border: 5px solid transparent; border-block-start-color: currentColor; translate: 0 3px; }
.account summary:hover, .account[open] summary { color: var(--text); background: var(--surface-raised); }
.account-menu {
  position: absolute;
  inset-inline-end: 0;
  inset-block-start: calc(100% + var(--space-1));
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-1);
  min-width: 12rem;
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow);
}
.account-menu a { padding: var(--space-2) var(--space-3); border-radius: var(--radius-s); color: var(--text); text-decoration: none; }
.account-menu a:hover { background: var(--surface-raised); }
.account-menu hr { width: 100%; margin: var(--space-1) 0; border: 0; border-block-start: 1px solid var(--line); }

/* A health word beside a Manage service: its mark says the level as well as its colour. */
.entries .state { font-size: var(--step--1); }

@media (max-width: 64rem) {
  .bar { padding-inline: var(--space-4); }
  .entries { order: 5; flex-basis: 100%; margin-inline: calc(-1 * var(--space-3)); }
}
@media (max-width: 40rem) {
  .bar { position: static; gap: var(--space-2); }
  /* Watch's Home is the same place, one tap away. */
  .wordmark { display: none; }
  .sides a { padding: 0 var(--space-2); }
  .palette-open kbd { display: none; }
  .palette-open { padding-inline: var(--space-3); }
  /* The magnifier says it; the word stays for screen readers. */
  .palette-open .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .account summary { max-width: 5.5rem; padding-inline: var(--space-2); }
  .entries a { min-height: 2.25rem; padding: 0 var(--space-2); font-size: var(--step--1); }
}

/* The frame: a sidebar beside the page at 1100 px and wider (Listen, each Manage service);
   narrower, a menu button above the page opens the same list, under it, or as a sheet from the
   foot of a phone's screen (sidebar.js). */
.sidebar { display: none; }
@media (min-width: 68.75rem) {
  .frame.with-sidebar { display: grid; grid-template-columns: 15rem minmax(0, 1fr); }
  .frame.with-sidebar .sidebar {
    display: block;
    position: sticky;
    top: var(--header-height, 0px);
    align-self: start;
    height: calc(100vh - var(--header-height, 0px) - var(--player-height, 0px));
    overflow-y: auto;
    padding: var(--space-4) var(--space-3);
    background: var(--surface);
    border-inline-end: 1px solid var(--line);
  }
  .frame.with-sidebar .fold { display: none; }
}
.frame-main { min-width: 0; }
.sidebar-title { margin: 0 0 var(--space-2); padding-inline: var(--space-3); font-size: var(--step-1); font-weight: 700; }
.sidebar-heading { margin: var(--space-4) 0 var(--space-1); padding-inline: var(--space-3); font-size: var(--step--1); font-weight: 600; color: var(--muted); }
.sidebar ul, .fold-menu ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; }
/* A grid item is as wide as its content unless told otherwise: without this a long name widens
   the column instead of being cut with "…". */
.sidebar li, .fold-menu li { min-width: 0; }
.sidebar a, .fold-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 2.5rem;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-s);
  color: var(--muted);
  text-decoration: none;
}
.sidebar a:hover, .fold-menu a:hover { color: var(--text); background: var(--surface-raised); }
.sidebar a[aria-current="page"], .fold-menu a[aria-current="page"] { color: var(--text); background: var(--surface-raised); box-shadow: inset 3px 0 0 var(--accent); }
.sidebar .count, .fold-menu .count { flex: none; color: var(--muted); font-size: var(--step--1); font-variant-numeric: tabular-nums; }
.fold { position: relative; max-width: 100rem; margin-inline: auto; padding: var(--space-3) var(--space-5) 0; }
.fold-toggle { max-width: 100%; gap: var(--space-2); }
.fold-toggle::after { content: ""; flex: none; border: 5px solid transparent; border-block-start-color: currentColor; translate: 0 3px; }
.fold-menu {
  position: absolute;
  inset: calc(100% + var(--space-1)) auto auto var(--space-5);
  z-index: 4;
  width: min(20rem, calc(100vw - 2 * var(--space-4)));
  max-height: 70vh;
  margin: 0;
  padding: var(--space-3);
  overflow-y: auto;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow);
}
.fold-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-block-end: var(--space-2); }
.fold-head .sidebar-title { margin: 0; padding: 0; }
.fold-menu:not(:modal) .fold-head button { display: none; }
.fold-menu:modal {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: none;
  max-height: 80vh;
  padding-block-end: max(var(--space-3), env(safe-area-inset-bottom));
  border-radius: var(--radius-m) var(--radius-m) 0 0;
}
.fold-menu::backdrop { background: var(--scrim); }
@media (max-width: 40rem) {
  .fold { padding-inline: var(--space-4); }
}

/* ---------- Pieces every page shares (page-parts.js) ---------- */

/* Placeholders the size of what's coming, so nothing moves when it arrives. */
.placeholders { display: grid; gap: var(--space-2); }
.placeholders.cards { grid-template-columns: repeat(auto-fill, minmax(min(10rem, 100%), 1fr)); gap: var(--space-4); }
.placeholder { background: var(--surface-raised); border-radius: var(--radius-s); }
.placeholders.rows .placeholder { height: 2.75rem; }
.placeholders.lines .placeholder { height: 1.25rem; }
.placeholders.lines .placeholder:last-child { width: 60%; }
.placeholders.cards .placeholder { aspect-ratio: 2 / 3; border-radius: var(--radius-m); }
@media (prefers-reduced-motion: no-preference) {
  .placeholder { animation: placeholder 1.6s ease-in-out infinite alternate; }
}
@keyframes placeholder { from { opacity: 1; } to { opacity: 0.55; } }

/* A page or list with nothing in it: one sentence, and a way forward. */
.empty-state { max-width: 36rem; margin-block: var(--space-6); }
.empty-state p { margin: 0 0 var(--space-3); color: var(--muted); }
.failed p { margin: 0 0 var(--space-3); }

/* One line, cut with "…"; the whole name is in its title, shown on hover. */
.clip { display: block; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* A state in words with its mark: each mark has its own shape as well as its colour. */
.state { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; }
.state .mark { flex: none; width: 0.625rem; height: 0.625rem; }
.state-have { color: var(--state-have); }
.state-have .mark { background: currentColor; border-radius: 50%; }
.state-coming { color: var(--state-coming); }
.state-coming .mark { border: 2px solid currentColor; border-radius: 50%; }
.state-waiting { color: var(--state-waiting); }
.state-waiting .mark { width: 0.55rem; height: 0.55rem; background: currentColor; rotate: 45deg; }
.state-missing { color: var(--state-missing); }
.state-missing .mark { width: 0.75rem; background: currentColor; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.state-failed { color: var(--state-missing); }
.state-failed .mark { background: currentColor; border-radius: 1px; }
.state-off { color: var(--state-off); }
.state-off .mark { height: 2px; background: currentColor; }
.state-notyet { color: var(--state-notyet); }
.state-notyet .mark { border: 2px dashed currentColor; border-radius: 50%; }
.state-key { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); margin: var(--space-5) 0 0; padding: var(--space-3) 0 0; list-style: none; border-block-start: 1px solid var(--line); font-size: var(--step--1); }

/* A button busy with what it started (hold() in page-parts.js): it keeps focus, so it's dimmed
   rather than disabled. */
button[aria-disabled="true"], .button[aria-disabled="true"] { opacity: 0.6; cursor: progress; }
