/* Layout only. Colours, type and components come from designsystem.css. */

body {
  background: var(--surface);
  color: var(--text-primary);
  margin: 0;
}

.app-header-shell {
  display: contents;
}

.app-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  padding-top: env(safe-area-inset-top);
}

.page {
  padding: var(--space-4) var(--space-4) var(--space-16);
  max-width: 72rem;
  margin: 0 auto;
}

.record-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4) var(--space-3);
}

.record-card {
  height: 100%;
  gap: var(--space-1);
}

.record-artist,
.record-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-card .ds-card-title,
.record-card .ds-card-body {
  margin: 0;
}

.record-title {
  color: var(--text-secondary);
}

.record-price {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.detail-cover {
  width: 100%;
  max-width: 20rem;
  margin: 0 auto;
}

.price-table td:last-child,
.price-table th:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.price-table tr[data-current] td {
  background: var(--surface-selected);
}

@media (min-width: 30rem) {
  .record-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 48rem) {
  .page { padding-inline: var(--space-8); }
  .record-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-6) var(--space-4); }
  .toolbar { position: sticky; top: 3.5rem; z-index: 1; background: var(--surface); padding-block: var(--space-2); }
}

@media (min-width: 64rem) {
  .record-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

.ds-sheet:not([data-side="bottom"]) .ds-sheet-grip {
  display: none;
}

/* Components set their own display; the hidden attribute must still win. */
[hidden] {
  display: none !important;
}

.app-tabs {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 3;
  padding-bottom: max(var(--space-1), env(safe-area-inset-bottom));
}

.page {
  padding-bottom: calc(var(--space-16) + 4rem);
}

.order-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
}

.order-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  flex: 1 1 14rem;
}

.order-items {
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

@media (min-width: 48rem) {
  .app-header-shell {
    display: block;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--glass-chrome-bg);
    -webkit-backdrop-filter: var(--glass-filter);
    backdrop-filter: var(--glass-filter);
    border-bottom: var(--border-hairline) solid var(--border-subtle);
  }

  .app-header-inner {
    max-width: 72rem;
    margin: 0 auto;
    padding: 0 var(--space-8);
    height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
  }

  .app-bar {
    display: contents;
  }

  .app-bar .ds-app-bar-title {
    order: 1;
    min-width: 8rem;
    margin: 0;
    padding: 0;
    font-size: var(--typography-size-heading-3);
    font-weight: var(--typography-weight-semibold);
    line-height: 1;
    color: var(--text-primary);
  }

  .app-tabs {
    position: static;
    order: 2;
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1);
    background: var(--surface-sunken);
    border: var(--border-hairline) solid var(--border-subtle);
    border-radius: var(--radius-pill);
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .app-tabs .ds-tab-bar-item {
    position: relative;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-2);
    min-height: 2.25rem;
    min-width: 0;
    padding: 0 var(--space-4);
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--typography-size-label);
    font-weight: var(--typography-weight-medium);
    transition: color var(--motion-toggle), background var(--motion-toggle), box-shadow var(--motion-toggle);
  }

  .app-tabs .ds-tab-bar-item:hover {
    color: var(--text-primary);
  }

  .app-tabs .ds-tab-bar-item[aria-current="page"] {
    background: var(--surface-raised);
    color: var(--text-primary);
    box-shadow: var(--elevation-1);
    font-weight: var(--typography-weight-semibold);
  }

  .app-tabs .ds-tab-bar-item .ds-icon {
    width: 1rem;
    height: 1rem;
  }

  .app-tabs .ds-tab-bar-badge {
    position: static;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.125rem;
    height: 1.125rem;
    padding: 0 var(--space-1);
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: var(--accent-contrast);
    font-size: 0.6875rem;
    line-height: 1;
    margin-left: var(--space-1);
  }

  .app-bar .ds-app-bar-actions {
    order: 3;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-1);
    min-width: 8rem;
  }

  .page {
    padding-bottom: var(--space-16);
  }
}

.pick-filter {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  align-items: end;
}

.pick-order {
  grid-column: 1 / -1;
  justify-self: start;
}

#sell.page {
  max-width: none;
}

.pick {
  display: grid;
  gap: var(--space-6);
}

.pick-cover {
  width: 100%;
  max-width: 32rem;
}

/* On a laptop or desktop the Sell view fits one screen: the columns scroll, the page does not. */
@media (min-width: 48rem) {
  body:has(#sell:not([hidden])) {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }

  #sell.page:not([hidden]) {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
    box-sizing: border-box;
    padding-bottom: var(--space-4);
  }

  .pick-filter {
    grid-template-columns: repeat(2, minmax(0, 12rem)) auto;
  }

  .pick-order {
    grid-column: auto;
  }

  #pickBody {
    flex: 1;
    min-height: 0;
    container-type: size;
  }

  .pick {
    height: 100%;
    grid-template-columns: min(36cqw, 100cqh) minmax(14rem, 1fr) minmax(0, 1.4fr);
    align-items: start;
  }

  .pick-cover {
    max-width: none;
  }

  .pick-main .pick-actions {
    position: sticky;
    bottom: 0;
    padding-block: var(--space-2);
    background: var(--surface);
  }

  .pick-main,
  .pick-listen {
    max-height: 100cqh;
    min-height: 0;
    overflow-y: auto;
  }
}

.pick-tracks {
  margin: 0;
}

.pick-actions .ds-button {
  flex: 1 1 0;
}

.pick-player-wrap {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-small);
  overflow: hidden;
  background: var(--surface-sunken);
}

.pick-player {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.pick-track {
  justify-content: flex-start;
  text-align: left;
  width: 100%;
}

.pick-track[aria-pressed="true"] {
  font-weight: 600;
}
