/* Holloway Hell — app.css
   Palette, type, and components per docs/brandbook.md. */

@font-face {
  font-family: "Anton";
  src: url("/static/fonts/Anton-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Color */
  --bg: #0b0b0d;
  --surface: #16161a;
  --surface-2: #1d1d22;
  --border: #2a2a30;
  --text: #e8e6e1;
  --muted: #8a8a93;
  --accent-ui: #d9d2c5;
  --accent-ui-hover: #efe9dd;
  --danger: #7a1f2b;
  --danger-hover: #93273a;
  /* Alias kept for any lingering wide references; points at danger red
     (signature color), NOT the new UI workhorse. Prefer --accent-ui or
     --danger explicitly in new code. */
  --accent: var(--danger);
  --accent-hover: var(--danger-hover);
  --success: #3f8f5f;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;

  --bp-tablet: 768px;
  --sidebar-w: 220px;
  --topbar-h: 56px;

  --font-display: "Anton", Impact, "Arial Narrow Bold", sans-serif;
  --font-body: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
}

h1, h2, h3, .brand-heading {
  font-family: var(--font-display);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 0 0 var(--sp-3);
  color: var(--text);
}

a { color: var(--accent-ui); }
a:hover { color: var(--accent-ui-hover); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--accent-ui);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------- */
/* Layout: app shell (base.html)                                          */
/* ---------------------------------------------------------------------- */

.app-shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 var(--sp-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.sidebar__logo img {
  height: 28px;
  display: block;
}

.sidebar__nav {
  display: flex;
  gap: var(--sp-2);
}

.sidebar__link {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-family: var(--font-display);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: 0.9rem;
}

.sidebar__link:hover {
  color: var(--text);
  background: var(--surface-2);
}

.sidebar__link.is-active {
  color: var(--accent-ui);
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--accent-ui);
}

@media (max-width: 767px) {
  .sidebar__link.is-active {
    box-shadow: inset 0 3px 0 var(--accent-ui);
  }
}

.sidebar__logout {
  margin: 0;
}

.sidebar__logout .btn {
  min-height: 40px;
  padding: 0 var(--sp-3);
}

.main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-4) var(--sp-7);
}

@media (min-width: 768px) {
  .app-shell {
    flex-direction: row;
  }

  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    width: var(--sidebar-w);
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    border-bottom: none;
    border-right: 1px solid var(--border);
    padding: var(--sp-4);
    gap: var(--sp-5);
  }

  .sidebar__logo {
    display: flex;
    justify-content: center;
    padding: var(--sp-3) 0 var(--sp-4);
  }

  .sidebar__logo img { height: 40px; }

  .sidebar__nav {
    flex-direction: column;
  }

  .sidebar__link { justify-content: flex-start; }

  .sidebar__logout {
    margin-top: auto;
  }

  .sidebar__logout .btn { width: 100%; }

  .main {
    padding: var(--sp-6) var(--sp-6) var(--sp-7);
  }
}

/* ---------------------------------------------------------------------- */
/* Buttons                                                                 */
/* ---------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: 0 var(--sp-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.btn:hover { background: var(--border); }

.btn-primary {
  background: var(--accent-ui);
  border-color: var(--accent-ui);
  color: #0b0b0d;
}
.btn-primary:hover { background: var(--accent-ui-hover); border-color: var(--accent-ui-hover); }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover { background: var(--surface-2); }

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

/* Single red hero CTA — reserved for "Download PDF" on the builder page.
   Do not reuse for other primary actions; primary actions use .btn-primary
   (bone). See docs/brandbook.md Color System notes. */
.btn-hero-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-hero-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }

.btn-icon {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
}

.btn-sm {
  min-height: 36px;
  padding: 0 var(--sp-3);
  font-size: 0.85rem;
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
}

.select-sm {
  min-height: 36px;
  width: auto;
  max-width: 190px;
  padding-top: 0;
  padding-bottom: 0;
  font-size: 0.85rem;
}

/* Ghost "no border, no bg" text-only button — used for the bulk-tuning
   popover's Cancel action, which sits next to a bone .btn-primary Apply and
   shouldn't compete visually with it. Not part of the .btn family (no
   min-height/padding box) since it's inline text, not a tap-target-sized
   button; still keeps 44px min-height for thumb accessibility. */
.btn-text {
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.85rem;
  min-height: 44px;
  padding: 0 var(--sp-2);
  cursor: pointer;
}
.btn-text:hover,
.btn-text:focus-visible {
  color: var(--text);
}

/* ---------------------------------------------------------------------- */
/* Forms                                                                   */
/* ---------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-bottom: var(--sp-4);
}

.field label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.input,
.select,
textarea {
  min-height: 44px;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  width: 100%;
}

.input::placeholder { color: var(--muted); }

.input:focus,
.select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-ui);
  box-shadow: 0 0 0 3px rgba(217, 210, 197, 0.25);
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: var(--sp-6);
}

/* ---------------------------------------------------------------------- */
/* Flash / errors                                                          */
/* ---------------------------------------------------------------------- */

.flash-error {
  border-left: 4px solid var(--danger);
  background: rgba(122, 31, 43, 0.18);
  color: var(--text);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm);
  margin-bottom: var(--sp-4);
  font-size: 0.95rem;
}

/* ---------------------------------------------------------------------- */
/* Login (login.html — standalone, no sidebar)                             */
/* ---------------------------------------------------------------------- */

.login-hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.login-hero__brand {
  min-height: 45vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6) var(--sp-4);
  background:
    radial-gradient(ellipse at 50% 40%, rgba(122, 31, 43, 0.5), transparent 60%),
    linear-gradient(160deg, #17070a 0%, #0b0b0d 55%, #0b0b0d 100%);
  position: relative;
  overflow: hidden;
}

.login-hero__brand::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.02) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.02) 0 1px, transparent 1px 3px);
  pointer-events: none;
}

.login-hero__brand img {
  width: min(70vw, 360px);
  filter: drop-shadow(0 0 40px rgba(122, 31, 43, 0.6));
  position: relative;
  z-index: 1;
}

.login-hero__form {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6) var(--sp-4);
  background: var(--bg);
}

.login-form {
  width: 100%;
  max-width: 340px;
}

.login-form h1 {
  font-size: 1.5rem;
  margin-bottom: var(--sp-4);
  text-align: center;
}

.login-form .btn { width: 100%; margin-top: var(--sp-2); }

@media (min-width: 768px) {
  .login-hero { flex-direction: row; }
  .login-hero__brand { min-height: 100vh; flex: 1; }
  .login-hero__form { flex: 1; }
}

/* ---------------------------------------------------------------------- */
/* Repertoire table                                                        */
/* ---------------------------------------------------------------------- */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.filter-row {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}

.filter-row .input { max-width: 320px; }

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
  background: var(--surface);
}

.table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  text-align: left;
  padding: var(--sp-3);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.table tbody tr.is-editing { background: var(--surface-2); cursor: default; }
.table tbody tr.is-new-row { cursor: default; }

.table td .input,
.table td .select {
  min-height: 38px;
  padding: var(--sp-1) var(--sp-2);
}

.row-actions {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
}

/* Tuning column header: small muted "set all" affordance + anchored popover.
   Replaces the old always-visible toolbar bulk-tuning control (see
   docs/brandbook.md Component Patterns — Table). */
.th-tuning {
  position: relative;
  white-space: nowrap;
}

.th-tuning-label { margin-right: var(--sp-1); }

.bulk-tuning-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}
.bulk-tuning-toggle:hover,
.bulk-tuning-toggle[aria-expanded="true"] {
  color: var(--accent-ui);
  border-color: var(--border);
  background: var(--surface);
}
.bulk-tuning-toggle:focus-visible {
  outline: none;
  border-color: var(--accent-ui);
  box-shadow: 0 0 0 3px rgba(217, 210, 197, 0.25);
}

.bulk-tuning-popover[hidden] { display: none; }

.bulk-tuning-popover {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: var(--sp-2);
  z-index: 20;
  width: 240px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
  font-size: 0.9rem;
  cursor: default;
}

.bulk-tuning-note {
  color: var(--muted);
  font-size: 0.8rem;
}

.bulk-tuning-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.bulk-tuning-actions .btn-primary { flex: 1; }

@media (max-width: 767px) {
  .bulk-tuning-popover {
    right: auto;
    left: 0;
    width: min(260px, calc(100vw - var(--sp-5)));
  }
}

.empty-state {
  padding: var(--sp-6);
  text-align: center;
  color: var(--muted);
}

/* ---------------------------------------------------------------------- */
/* Playlists cards                                                         */
/* ---------------------------------------------------------------------- */

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-4);
}

@media (min-width: 560px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  transition: border-color .15s ease;
}

.card:hover { border-color: var(--accent-ui); }

.card__title {
  font-family: var(--font-display);
  text-transform: uppercase;
  font-size: 1.2rem;
  letter-spacing: 0.02em;
}

.card__meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.card__count {
  color: var(--accent-ui);
  font-size: 0.85rem;
  font-weight: 600;
}

.card__actions {
  margin-top: var(--sp-2);
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.card__actions .btn { flex: 1; }

/* ---------------------------------------------------------------------- */
/* Playlist builder                                                        */
/* ---------------------------------------------------------------------- */

.builder-header {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
}

@media (min-width: 768px) {
  .builder-header { grid-template-columns: 2fr 1fr 1fr; align-items: end; }
}

.builder-header .field { margin-bottom: 0; }

.save-status {
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 1.2em;
}
.save-status.is-saving { color: var(--accent-ui); }
.save-status.is-saved { color: var(--success); }
.save-status.is-error { color: var(--danger); }

.search-wrap {
  position: relative;
  margin-bottom: var(--sp-5);
}

.typeahead {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-height: 320px;
  overflow-y: auto;
  z-index: 30;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.typeahead__item {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
  min-height: 44px;
  align-items: center;
}

.typeahead__item:last-child { border-bottom: none; }

.typeahead__item:hover,
.typeahead__item.is-active {
  background: var(--surface);
  border-left: 3px solid var(--accent-ui);
  padding-left: calc(var(--sp-3) - 3px);
}

.typeahead__item.is-added {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.typeahead__tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
}

.typeahead__key {
  color: var(--muted);
  font-size: 0.85rem;
}

.plist-count {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: var(--sp-3);
}

.plist {
  list-style: none;
  margin: 0 0 var(--sp-6);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.plist-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
}

.plist-item.sortable-ghost {
  outline: 2px dashed var(--accent-ui);
  outline-offset: -2px;
  opacity: 0.6;
}

.plist-item__handle {
  cursor: grab;
  color: var(--muted);
  font-size: 1.2rem;
  padding: 0 var(--sp-2);
  touch-action: none;
  min-width: 32px;
  text-align: center;
}

.plist-item__info {
  min-width: 0;
}

.plist-item__pos {
  color: var(--accent-ui);
  font-family: var(--font-display);
  margin-right: var(--sp-2);
}

.plist-item__title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plist-item__sub {
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.plist-item__guest {
  min-width: 120px;
  max-width: 160px;
}

.plist-item__controls {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 560px) {
  .plist-item { grid-template-columns: auto 1fr; grid-template-areas: "handle info" "controls controls"; }
  .plist-item__handle { grid-area: handle; }
  .plist-item__info { grid-area: info; }
  .plist-item__controls { grid-area: controls; justify-content: flex-start; margin-top: var(--sp-2); }
}

/* ---------------------------------------------------------------------- */
/* "Still in the pool" chip cloud                                          */
/* ---------------------------------------------------------------------- */

.pool-section {
  margin-top: var(--sp-6);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}

.pool-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-3);
}

.pool-section__label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.pool-section__count {
  color: var(--accent-ui);
}

.pool-sort {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pool-sort__divider {
  color: var(--border);
}

.pool-sort__btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}

.pool-sort__btn:hover {
  color: var(--text);
}

.pool-sort__btn.is-active {
  color: var(--accent-ui);
  font-weight: 700;
}

.pool-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.pool-cloud__empty {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
  padding: var(--sp-3) 0;
}

.pool-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  height: 32px;
  padding: 0 var(--sp-3);
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: opacity .15s ease, transform .15s ease, border-color .15s ease;
}

.pool-chip__add {
  color: var(--muted);
  font-weight: 700;
  transition: color .15s ease;
}

.pool-chip__artist {
  color: var(--muted);
  font-size: 0.8rem;
}

.pool-chip__dot {
  color: var(--muted);
}

.pool-chip:hover,
.pool-chip:focus-visible {
  border-color: var(--accent-ui);
  transform: translateY(-1px);
}

.pool-chip:hover .pool-chip__add,
.pool-chip:focus-visible .pool-chip__add {
  color: var(--accent-ui);
}

.pool-chip.is-dimmed {
  opacity: 0.3;
}

.pool-chip.is-removing {
  opacity: 0;
  transform: scale(0.85);
}

.toast {
  position: fixed;
  left: var(--sp-4);
  right: var(--sp-4);
  bottom: var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-ui);
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
  z-index: 40;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (min-width: 768px) {
  .toast { left: auto; width: 320px; }
}
