/* The styles every page shares: the app (index.html, with app.css after this) and the live gig
   pages (the DJ view, the dancers' pages, the venue screen, with live.css after this): the tokens,
   the base, forms, buttons, messages, and what both kinds of page use (status dots, row menus,
   switches, chips, dialogs). A rule goes in the file of the pages that use its classes;
   test/ui.test.js checks the main ones. */

/* Brand: Playlist Tools logo kit (brand/README.md). The logo's coral #FF5A36 is also the
   interface accent. Surfaces are on a warm, nearly neutral grey: translucent cards with a thin
   light edge (--card, --edge), not blurred, and lighter tiles inside them (--tile); only what
   floats over the page (the player, the bars) is frosted glass (--glass).
   Each token is light-dark(light, dark): the page follows the system unless Settings stores
   a choice (js/theme.js sets data-theme). Text on --accent uses --accent-text; accent-coloured
   text uses --accent-ink (both WCAG AA). Contrast is measured against the cards as they look. */

@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 500 800;
  font-display: swap;
  src: url(fonts/bricolage-grotesque-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 500 800;
  font-display: swap;
  src: url(fonts/bricolage-grotesque-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light dark;
  --coral: #FF5A36;
  --bg: light-dark(#E9E6E2, #1B1A19);
  --glow-1: light-dark(#FBFAF8, #3A3634); /* soft light behind the glass, top left */
  --glow-2: light-dark(#F1E6DF, #2C2522); /* a hint of the coral, top right */
  --card: light-dark(rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.07));
  --edge: light-dark(rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.12));
  --tile: light-dark(rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.055));
  --tile-edge: light-dark(rgba(33, 30, 28, 0.08), rgba(255, 255, 255, 0.09));
  --raised: light-dark(rgba(33, 30, 28, 0.05), rgba(255, 255, 255, 0.09));
  --solid: light-dark(#F7F5F3, #2A2827); /* dialogs: no glass, nothing behind to blur */
  --field: light-dark(rgba(255, 255, 255, 0.85), rgba(0, 0, 0, 0.2));
  --text: light-dark(#211E1C, #ECE8E3);
  --muted: light-dark(#5E5853, #B4AEA8);
  --border: light-dark(rgba(33, 30, 28, 0.1), rgba(255, 255, 255, 0.1));
  --field-border: light-dark(#857F7A, #857F7A); /* 3.18:1 on the light page (fields sit on it now) */
  --accent: light-dark(#C63D16, #FF6A47);
  --accent-text: light-dark(#FFFFFF, #1E1C1B);
  --accent-ink: light-dark(#B5370F, #FF8466);
  --accent-soft: light-dark(rgba(198, 61, 22, 0.1), rgba(255, 106, 71, 0.16));
  --tonal: light-dark(#2B2826, #E6E1DB);
  --tonal-text: light-dark(#FFFFFF, #1E1C1B);
  --bar: light-dark(#7A746E, #827D78); /* chart bars: at least 3:1 on the page in both themes (3.7 and 4.3) */
  --key-mixes: light-dark(color-mix(in srgb, var(--accent) 72%, var(--solid)), color-mix(in srgb, var(--accent) 35%, var(--text))); /* Stats › Key: the keys that mix with the picked one: 3:1 on the card in light mode, lighter than the accent in dark */
  --mark-ink: var(--text);
  --mark-ring: light-dark(#5A5551, #D7D2CC);
  /* The What was that song? record: dark in both modes; on dark a fine light edge shows its shape. */
  --record: light-dark(#211E1C, #16142B);
  --record-edge: light-dark(transparent, #D8D4E8);
  --record-groove: light-dark(#5A5551, #4A4766);
  --warn-bg: light-dark(#FBEBC8, rgba(245, 185, 74, 0.16));
  --warn-text: light-dark(#7A4D00, #F5C76A);
  --err-bg: light-dark(#FBE0D8, rgba(255, 106, 71, 0.16));
  --err-text: light-dark(#A12A10, #FFA088);
  --ok: light-dark(#23753A, #7BD992);
  --ok-soft: light-dark(rgba(35, 117, 58, 0.12), rgba(123, 217, 146, 0.16));
  --rail: light-dark(rgba(255, 255, 255, 0.4), rgba(0, 0, 0, 0.25));
  --header-bg: light-dark(rgba(240, 238, 235, 0.72), rgba(27, 26, 25, 0.62));
  --shadow: inset 0 0 0 1px var(--edge), 0 1px 2px light-dark(rgba(60, 50, 40, 0.05), rgba(0, 0, 0, 0.2)), 0 16px 40px light-dark(rgba(60, 50, 40, 0.1), rgba(0, 0, 0, 0.28));
  --glass: blur(28px) saturate(1.4);
  --backdrop: light-dark(rgba(33, 30, 28, 0.4), rgba(0, 0, 0, 0.6));
  --paper: #FFFFFF; /* behind QR codes, in both modes: scanners need dark on light */
  /* One radius scale: controls 10px, panels 16px, floating things (player, dialogs) 22px. */
  --radius-control: 10px;
  --radius: 16px;
  --radius-float: 22px;
  --row-pad: 10px; /* above and below a row in a list */
  --radius-sm: 12px;
  --heading-font: 'Bricolage Grotesque', 'Helvetica Neue', Arial, sans-serif;
  /* One spacing scale, on a 4px grid (8px for most things, 4px steps for fine ones). Every gap,
     margin and padding is one of these; only 1–2px hairlines and nudges stay a number. */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s7: 28px; --s8: 32px;
  --s10: 40px; --s12: 48px; --s14: 56px; --s16: 64px; --s20: 80px;
  /* One type scale: a caption (chart axes, chips), small text (notes, a row's details, small
     buttons), body text, a part's heading, a figure or lead, a section's title, a big title, the
     page's title. The venue screen's and the dancers' logo's sizes follow the window (clamp). */
  --fs-caption: 12px; --fs-small: 14px; --fs-body: 15px; --fs-part: 16px; --fs-lead: 18px;
  --fs-section: 20px; --fs-title: 24px; --fs-page: 28px;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
::placeholder { color: var(--muted); opacity: 1; } /* the browser's grey is too faint in dark mode */
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 700px at 8% -12%, var(--glow-1), transparent 62%),
    radial-gradient(900px 600px at 104% 0%, var(--glow-2), transparent 58%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: var(--fs-body)/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--heading-font); letter-spacing: -0.02em; line-height: 1.2; }
h2 { margin: 0 0 var(--s2); font-size: var(--fs-page); font-weight: 800; }
/* Headings in four sizes: the page 28px, a result's, item's or section's title 20px, a part in it 16px, a label 14px. */
h3 { margin: 0 0 var(--s4); font-size: var(--fs-part); font-weight: 700; }
h4 { margin: var(--s4) 0 var(--s2); font-size: var(--fs-part); font-weight: 700; } /* a part: the same size as the tool pages' (.result h3, .group h3) */
/* One style for links in text: the accent, underlined (thicker on hover). Links that are names in
   a list (songs, playlists, artists, the menu) keep the text's colour, underlined on hover. */
a { color: var(--accent-ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible, .row-menu > summary:focus-visible, .segmented input:focus-visible + span { outline: 2px solid var(--accent-ink); outline-offset: 2px; } /* the menu's ⋯ and a switch's option: their own outline is none */
.small { font-size: var(--fs-small); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
.muted { color: var(--muted); margin: 0; }
.menu-icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@keyframes pulse { 50% { opacity: .35; } }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--tonal); color: var(--tonal-text);
  font: 700 var(--fs-small)/1 var(--heading-font);
}
/* A picture over the initial; it only shows once it has loaded (core.js showAvatar). */
.avatar { position: relative; overflow: hidden; flex: none; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .2s; }
.avatar.has-picture img { opacity: 1; }

/* ---------- Layout ---------- */
:root { --sticky-top: 0px; } /* what is pinned at the top of the page: nothing, the top bar on a phone */
main { max-width: 1080px; margin: 0 auto; padding: var(--s2) var(--s8) var(--s20); }
.card {
  background: var(--card);
  border-radius: var(--radius); /* no blur: only floating things (player, bars, dialogs) have it */
  box-shadow: var(--shadow);
  padding: var(--s6);
  margin-top: var(--s4);
}
.card > .muted:first-of-type { margin-bottom: var(--s1); }
/* Empty states */
.empty { text-align: center; padding: var(--s12) var(--s6); }
.empty .muted { margin-bottom: var(--s5); }

/* ---------- Forms ---------- */
.row { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: var(--s4); }
.stack label, .field label { display: grid; gap: var(--s2); font-size: var(--fs-small); font-weight: 550; color: var(--muted); }
.stack button { justify-self: start; }
input, select, textarea {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 var(--s3);
  border: 1px solid var(--field-border);
  border-radius: var(--radius-control);
  background: var(--field);
  color: var(--text);
  font: inherit;
}
select option, select optgroup { background: var(--solid); color: var(--text); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 1px; border-color: transparent; }
input[type="checkbox"], input[type="radio"] { flex: none; width: 20px; height: 20px; padding: 0; accent-color: var(--accent); }
input[type="checkbox"] { width: 24px; height: 24px; } /* WCAG 2.5.8: a 24px target, also alone in a table cell */
input.short, select.short { flex: 0 0 150px; }
/* Number fields: the app's own up/down buttons (core.js stepper) instead of the browser's */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- Buttons ---------- */
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  height: 44px;
  padding: 0 var(--s4);
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  transition: filter .15s, background-color .15s, transform .05s;
}
button:hover:not(:disabled), .button:hover { filter: brightness(1.06); }
button:active:not(:disabled) { transform: translateY(1px); }
button.secondary, .button.secondary { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--field-border); font-weight: 550; }
button.secondary:hover:not(:disabled), .button.secondary:hover { background: var(--tile); filter: none; }
button.ghost { background: transparent; color: var(--muted); font-weight: 550; }
button.ghost:hover:not(:disabled) { color: var(--text); background: var(--raised); filter: none; }
button.small, .button.small { height: 36px; padding: 0 var(--s4); font-size: var(--fs-small); } /* also a link or a menu's ⋯ (a summary) that looks like one */
button:disabled { opacity: .5; cursor: progress; }
/* Deleting or removing (the confirm dialog, dom.js confirmAction): in the error colours, quieter than the
   main action beside it. Both kinds of page ask: the app, and the DJ view. */
button.danger { background: var(--err-bg); color: var(--err-text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--err-text) 40%, transparent); }
/* A message about what a button did, right under its row (core.js say). */
.inline-error { margin: var(--s2) 0 0; padding: var(--s2) var(--s4); border-radius: var(--radius-sm); background: var(--err-bg); color: var(--err-text); font-size: var(--fs-small); }

/* ---------- Streaming services ---------- */
/* The services' own logo marks (brand/services/README.md: colours and sizes follow their brand rules).
   The SVG is a mask, so the colour comes from the background colour below. */
.service-icon { width: 28px; height: 28px; flex: none; margin: 0 var(--s1); }
.service-icon.spotify {
  background: light-dark(#000000, #FFFFFF);
  -webkit-mask: url(brand/services/spotify.svg) center / contain no-repeat;
  mask: url(brand/services/spotify.svg) center / contain no-repeat;
}
.service-icon.tidal {
  background: light-dark(#000000, #FFFFFF);
  -webkit-mask: url(brand/services/tidal.svg) center / contain no-repeat;
  mask: url(brand/services/tidal.svg) center / contain no-repeat;
}
table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); }
th {
  text-align: left; padding: var(--s2) var(--s2);
  font-size: var(--fs-small); font-weight: 600;
  color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { text-align: left; padding: var(--s2) var(--s2); border-bottom: 1px solid var(--border); white-space: nowrap; }
td:first-child, td:nth-child(2) { white-space: normal; }
tbody tr:hover td { background: color-mix(in srgb, var(--raised) 60%, transparent); }
td input { width: 76px; height: 36px; flex: none; text-align: right; padding: 0 var(--s2); }
/* A row's actions in a menu: the button, then a short list under it, right-aligned. */
.row-menu { position: relative; display: inline-block; text-align: left; }
.row-menu > summary { list-style: none; cursor: pointer; }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu > summary::after {
  content: ""; width: 12px; height: 12px; background: currentColor;
  -webkit-mask: url(icons/chevron-down.svg) center / contain no-repeat; mask: url(icons/chevron-down.svg) center / contain no-repeat;
}
.row-menu > summary.more::after { content: none; } /* "⋯" says it already */
.row-menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 6; min-width: 180px;
  display: grid; gap: 2px; padding: var(--s2); border-radius: var(--radius-sm);
  background: var(--solid); box-shadow: var(--shadow);
}
.row-menu-list button { justify-content: flex-start; width: 100%; white-space: nowrap; text-align: left; }
.row-menu-list > a { display: flex; align-items: center; height: 36px; padding: 0 var(--s4); color: var(--text); font-size: var(--fs-small); text-decoration: none; white-space: nowrap; } /* going somewhere from a menu (the DJ view's Gigs): a link, as tall as its buttons */
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s2); flex: 1 1 180px; min-width: 0; } /* the column shrinks with the field, so nothing sticks out */
.check { display: grid; gap: var(--s3); padding: var(--s4) 0; border-top: 1px solid var(--border); } /* rows in the tile, not raised boxes: two surfaces at most */
.check:first-child { border-top: 0; padding-top: var(--s1); }
.time { flex: none; font-variant-numeric: tabular-nums; }
@keyframes tap { from { background: var(--accent-soft); } }
/* A choice of a few options as one control (the listening period) */
.segmented[hidden] { display: none; }
.segmented { display: inline-flex; padding: var(--s1); border-radius: 999px; background: var(--raised); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: var(--s2) var(--s4); border-radius: 999px; font-size: var(--fs-small); font-weight: 550; cursor: pointer; color: var(--muted); }
.segmented input:checked + span { background: var(--accent); color: var(--accent-text); }
/* A finger, not a pointer (a phone, an iPad): the switches and ▶ 44 px, as Apple's guidelines ask. */
@media (pointer: coarse) {
  .segmented span { padding: var(--s3) var(--s4); line-height: 20px; }
  button.small, .button.small, .row-menu-list > a { height: 44px; }
  a.go { padding: var(--s3) 0; } /* inline: bigger to tap, the row as tall */
}
.chip { display: inline-block; border-radius: 999px; padding: 2px var(--s2); font-size: var(--fs-caption); box-shadow: inset 0 0 0 1px var(--border); color: var(--muted); }

/* ---------- Sync ---------- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Import list ---------- */
textarea { height: auto; min-height: 180px; padding: var(--s2) var(--s3); resize: vertical; font-variant-numeric: tabular-nums; line-height: 1.5; }
input[type="file"] { height: auto; padding: var(--s1) var(--s2); line-height: 32px; } /* as tall as its button, the button inside it */
/* The file picker's button looks like the other secondary buttons; the chosen file's name beside it. */
input[type="file"]::file-selector-button {
  margin-right: var(--s3); padding: 0 var(--s4); height: 32px; vertical-align: middle; border: 0; border-radius: 999px; cursor: pointer;
  font: inherit; font-weight: 550; background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--field-border);
}
input[type="file"]::file-selector-button:hover { background: var(--tile); }
/* A link that stands alone and goes somewhere (a row's action): an arrow says so; in a sentence, no arrow. */
.go::after { content: '›' / ''; display: inline-block; margin-left: var(--s1); } /* inline-block: not underlined */
.checklist {
  list-style: none; margin: var(--s3) 0; padding: var(--s2) var(--s3);
  max-height: 320px; overflow-y: auto;
  border-radius: var(--radius-sm); background: var(--tile); box-shadow: inset 0 0 0 1px var(--tile-edge);
}
.checklist li { padding: var(--s1) 0; }
.checklist label { cursor: pointer; display: inline-flex; align-items: center; gap: var(--s2); }
/* Making a playlist: the same small dialog everywhere (core.js makePlaylistDialog). */
/* Every dialog (make a playlist, confirm, password, the Sync setup: .wide). */
.dialog { border: none; border-radius: var(--radius-float); padding: var(--s6); width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; scroll-padding-bottom: 80px; background: var(--solid); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: var(--backdrop); }
.confirm-text { margin: 0; white-space: pre-line; } /* the confirm dialog's question, its paragraphs kept */
/* When a dialog scrolls (a phone), its buttons stay in sight at its bottom edge. */
.dialog form > .row:last-child { position: sticky; bottom: -24px; z-index: 1; margin: calc(-1 * var(--s3)) 0 calc(-1 * var(--s6)); padding: var(--s3) 0 var(--s6); background: var(--solid); }
.dialog h3 { margin: 0; }
@media (max-width: 760px) {
  :root { --sticky-top: 60px; --tabbar: calc(58px + env(safe-area-inset-bottom)); }
  html { scroll-padding-bottom: calc(var(--tabbar) + 16px); }
  main { padding: var(--s1) var(--s4) calc(var(--s16) + var(--tabbar)); }
  h2 { font-size: var(--fs-title); }
  .card { padding: var(--s4); }
}
.task-what { display: grid; flex: 1 1 260px; min-width: 0; }
.task-title { font-weight: 600; overflow-wrap: anywhere; }
/* One small dot says a row's state: red failed, amber to look at, accent running, hollow waiting, green
   all well; what went fine has none (an empty one keeps the rows lined up). */
.state-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; display: inline-block; transform: translateY(-1px); }
.state-dot.err { background: var(--err-text); }
.state-dot.warn { background: var(--warn-text); }
.state-dot.ok { background: var(--ok); }
/* A gig's guest DJs (Gigs, the DJ view): one row each, its buttons at the right. */
.bridge-keys { list-style: none; margin: var(--s3) 0 0; padding: 0; }
.bridge-keys > li { padding: var(--row-pad) 2px; border-top: 1px solid var(--border); }
.bridge-key { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s3); }
.bridge-key-name { font-weight: 600; }
.bridge-key > button { margin-left: auto; }
.bridge-key > button + button { margin-left: 0; }
/* A pairing code (js/pairing.js): big, for typing into the bridge or reading out in the booth. */
/* What was that song?'s mark (its record): the live pages', and the app's for a DJ-only account. */
.wwts-disc { fill: var(--record); }
.wwts-edge { fill: none; stroke: var(--record-edge); stroke-width: 1.4; }
.wwts-groove { fill: none; stroke: var(--record-groove); stroke-width: 1.6; }
.wwts-label { fill: var(--coral); }
.wwts-question { fill: none; stroke: var(--paper); stroke-width: 4.6; stroke-linecap: round; stroke-linejoin: round; }
.wwts-dot { fill: var(--paper); }
.pairing-box { display: grid; gap: var(--s2); }
.pairing-box p { margin: 0; }
.pairing-code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: clamp(30px, 8vw, 40px); font-weight: 700; letter-spacing: 0.12em; text-align: center; padding: var(--s4) var(--s2); background: var(--tile); border: 1px solid var(--tile-edge); border-radius: 14px; color: var(--text); user-select: all; }
.pairing-key { font-size: var(--fs-small); }
.pairing-key > summary { cursor: pointer; color: var(--muted); }
.pairing-key label { display: block; margin: var(--s2) 0 var(--s2); font-weight: 400; }
.pairing-key input { width: 100%; }
