/*
 * Aktuális setlist (js/screens/live/LiveSetlistScreen.js) and the „Dal beszúrása” dialog
 * (QuickInsertDialog.js). Built to be scanned on a music stand: compact, equal-height rows in
 * columns (top to bottom, then the next column), a strongly highlighted current song, and states
 * told apart by icon and style, not only colour. Text is never shrunk to fit more songs: the
 * number of columns adapts instead (computed in JS), and the list scrolls when not all fit.
 * Light-theme refinements: LiveSetlistScreen.light.css.
 */

/* Wide screens: use the width for more columns instead of the usual content width */
.page.live--compact {
  max-width: 120rem;
}

/* Row height: one value for every row. Touch screens get taller rows (larger targets). */
.live--compact {
  --live-row-h: 2.375rem; /* 38 px */
  --live-title-size: 0.9375rem; /* 15 px */
}

@media (pointer: coarse) {
  .live--compact {
    --live-row-h: 2.875rem; /* 46 px */
    --live-title-size: 1rem;
  }
}

/* ---------- The single toolbar row ---------- */

/* Little space above the toolbar: the height belongs to the song list */
.page.page--content.live--compact {
  padding-top: var(--space-2);
}

.live-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2) var(--space-5);
  min-height: 3rem;
  margin-bottom: var(--space-2);
}

.live-bar__identity {
  display: flex;
  flex: 1 1 auto;
  align-items: baseline;
  gap: var(--space-3);
  min-width: 0;
}

.live-bar__title {
  flex-shrink: 0;
  margin: 0;
  font-size: var(--text-lg);
  line-height: var(--leading-tight);
  white-space: nowrap;
}

.live-bar__concert {
  min-width: 0;
  overflow: hidden;
  font-size: var(--text-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text-muted);
}

/* Remaining planned time: prominent but compact; the full sentence is its accessible label */
.live-bar__time {
  display: flex;
  flex-shrink: 0;
  align-items: baseline;
  gap: var(--space-2);
  margin: 0;
  white-space: nowrap;
}

.live-bar__time-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-text-subtle);
}

.live-bar__time-value {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  line-height: var(--leading-tight);
}

.live-bar__partial-long {
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  color: var(--color-text-muted);
}

.live-bar__partial-short {
  display: none;
}

.live-bar__count {
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
}

.live-bar__actions {
  display: flex;
  flex-shrink: 0;
  gap: var(--space-2);
}

/* Touch screens: at least 44 × 44 px targets */
@media (pointer: coarse) {
  .live-bar__button {
    min-width: 2.75rem;
    min-height: 2.75rem;
  }
}

/* Unavailable actions: dimmed, still focusable, announced via aria-disabled */
.live .btn[aria-disabled='true'] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Feedback floats at the bottom of the screen: it never takes height from the list */
.live__status {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: min(36rem, calc(100vw - 2 * var(--space-4)));
  margin: 0;
  padding: var(--space-2) var(--space-4);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface-1);
  box-shadow: var(--shadow-modal);
  font-size: var(--text-sm);
  color: var(--color-text);
  transform: translateX(-50%);
  pointer-events: none;
}

.live__status:empty {
  padding: 0;
  border: 0;
  box-shadow: none;
}

.live__status svg {
  flex-shrink: 0;
  color: var(--color-accent);
}

/* No active setlist */
.live__back {
  margin-left: calc(-1 * var(--space-4));
}

.live__title {
  margin-top: var(--page-title-gap);
  font-size: var(--text-xl);
}

.live__empty {
  margin-top: var(--space-4);
  padding: var(--space-8) var(--space-6);
  color: var(--color-text-muted);
  text-align: center;
}

/* ---------- The programme: equal rows in columns ---------- */

.live-list {
  padding: var(--space-2);
}

/*
 * Column-major grid: --live-rows rows per column (set by layoutList), so the song order runs
 * top to bottom, then continues in the next column. Every row has the same height.
 */
.live-grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(var(--live-rows, 1), var(--live-row-h));
  grid-template-columns: repeat(var(--live-columns, 1), minmax(0, 1fr));
  gap: 2px var(--space-4);
  max-width: calc(var(--live-columns, 1) * 32rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Every song fits: no scrollbar (only a sub-pixel rounding would trigger one) */
body.has-contained-scroll .live-grid[data-fits='true'] {
  overflow-y: hidden;
}

.live-row {
  display: grid;
  grid-template-columns: 2.1rem minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: var(--space-1);
  height: var(--live-row-h);
  min-width: 0;
  padding: 0 0 0 var(--space-1);
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
}

.live-row:hover {
  background: var(--color-surface-2);
}

.live-row__position {
  padding-right: var(--space-1);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--color-text-subtle);
}

.live-row__title {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
  height: 100%;
  font-size: var(--live-title-size);
  line-height: var(--leading-tight);
}

/* Jump target (page-turners): the whole title area, as tall as the row */
.live-row__title--button {
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: var(--live-title-size);
  text-align: left;
  cursor: pointer;
}

.live-row__title--button:focus-visible {
  outline: none;
  border-radius: var(--radius-sm);
  box-shadow: var(--focus-ring);
}

.live-row__title-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Planning flag („E” = elhagyható, dashed) and live change („+” = élőben hozzáadva, accent) */
.live-row__flag {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 2px;
  border: 1px dashed var(--color-border-control);
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: var(--weight-semibold);
  line-height: 1;
  color: var(--color-text-muted);
}

.live-row__flag--added {
  border: 1px solid var(--color-accent);
  color: var(--color-accent);
}

.live-row__status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0 var(--space-1);
}

.live-row__now {
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.02em;
}

.live-row__menu .btn {
  width: 2rem;
  height: calc(var(--live-row-h) - 4px);
}

/* States: subtle differences; the current song stands out */
.live-row--upcoming .live-row__title {
  color: var(--color-text);
}

.live-row--done .live-row__title,
.live-row--done .live-row__position {
  color: var(--color-text-subtle);
}

.live-row--done .live-row__status {
  color: var(--color-status-online);
}

.live-row--skipped .live-row__title-text {
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, currentColor 55%, transparent);
}

.live-row--skipped .live-row__title,
.live-row--skipped .live-row__position {
  color: var(--color-text-subtle);
}

.live-row--skipped .live-row__status {
  color: var(--color-status-offline);
}

.live-row--current,
.live-row--current:hover {
  border-left-color: var(--color-accent);
  background: var(--color-accent-soft);
}

.live-row--current .live-row__title {
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.live-row--current .live-row__position {
  font-weight: var(--weight-semibold);
  color: var(--color-accent-hover);
}

.live-row--current .live-row__status svg {
  color: var(--color-accent);
}

.live-row--new {
  animation: live-row-added 2.4s var(--ease-standard);
}

@keyframes live-row-added {
  from {
    background: var(--color-accent-line);
  }
}

@media (prefers-reduced-motion: reduce) {
  .live-row--new {
    animation: none;
  }
}

/* ---------- Narrower screens: the toolbar stays ONE row ---------- */

/* Tablets in portrait and small laptops: the two actions become icon buttons (tooltip + label) */
@media (max-width: 64rem) {
  .live-bar__button-text {
    display: none;
  }

  .live-bar__button {
    min-width: 2.75rem;
    padding-inline: var(--space-3);
  }

  .live-bar__time-label {
    display: none;
  }
}

/* Phones: title above the concert name in the same row; "≥" instead of "legalább" */
@media (max-width: 40rem) {
  .live-bar {
    gap: var(--space-2);
  }

  .live-bar__identity {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  .live-bar__title {
    font-size: var(--text-md);
  }

  .live-bar__concert {
    max-width: 100%;
    font-size: var(--text-xs);
  }

  .live-bar__time {
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
  }

  .live-bar__time-value {
    font-size: var(--text-lg);
  }

  .live-bar__partial-long {
    display: none;
  }

  .live-bar__partial-short {
    display: inline;
    margin-right: 1px;
    font-weight: var(--weight-regular);
    color: var(--color-text-muted);
  }

  .live-bar__count {
    font-size: var(--text-xs);
  }

  .live-bar__actions {
    gap: var(--space-1);
  }
}

/* ---------- „Dal beszúrása” dialog ---------- */

.quick-insert__search {
  margin-bottom: var(--space-4);
}

.quick-insert__position {
  margin-bottom: var(--space-3);
}

.quick-insert__where {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
}

.quick-insert__where .segmented__label {
  justify-content: center;
  width: 100%;
  height: auto;
  min-height: 2.5rem;
  padding-block: var(--space-1);
  white-space: normal;
  text-align: center;
  line-height: var(--leading-snug);
}

.quick-insert__count {
  margin-bottom: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
}

.quick-insert__list {
  max-height: min(22rem, 45vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
}

.quick-insert__option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: var(--space-3);
  width: 100%;
  min-height: 3rem;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-bottom: var(--border-width) solid var(--color-border);
  background: transparent;
  text-align: left;
}

.quick-insert__list li:last-child .quick-insert__option {
  border-bottom: 0;
}

.quick-insert__option:not(.quick-insert__option--present):hover {
  background: var(--color-surface-2);
}

.quick-insert__option--present {
  cursor: not-allowed;
}

.quick-insert__option--present .quick-insert__title {
  color: var(--color-text-muted);
}

.quick-insert__song {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.quick-insert__title,
.quick-insert__artist {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-insert__title {
  font-weight: var(--weight-medium);
}

.quick-insert__artist {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
}

.quick-insert__length {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.quick-insert__length--unknown {
  color: var(--color-text-subtle);
}

.quick-insert__add,
.quick-insert__present {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.quick-insert__add {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-accent-hover);
}

.quick-insert__present {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
}

.quick-insert__empty {
  padding: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
}

@media (max-width: 30rem) {
  .quick-insert__where {
    grid-template-columns: minmax(0, 1fr);
  }

  .quick-insert__add {
    font-size: 0; /* icon only; the button's accessible name says „Beszúrás” */
  }
}
