/* ─── Custom title bar — Linux (decorations: false) + macOS (titleBarStyle: Overlay) ─── */
:root {
  --titlebar-height: 32px;
}

.app-shell[data-titlebar] {
  grid-template-rows: var(--titlebar-height) minmax(0, 1fr) var(--player-height);
  grid-template-areas:
    "titlebar titlebar titlebar"
    "sidebar  main     queue"
    "player   player   player";
}

/* When player bar is floating with titlebar, content extends to bottom */
.app-shell[data-titlebar].floating-player {
  grid-template-rows: var(--titlebar-height) minmax(0, 1fr);
  grid-template-areas:
    "titlebar titlebar titlebar"
    "sidebar  main     queue";
}

/* Resize grips — Linux only; replace the native GTK grips lost when
   decorations: false. macOS keeps its native window-edge resize. */
.app-shell[data-titlebar-platform='linux']::before,
.app-shell[data-titlebar-platform='linux']::after {
  content: '';
  position: fixed;
  bottom: 0;
  width: 14px;
  height: 14px;
  pointer-events: none;
  background-image: radial-gradient(circle, var(--text-muted) 1.5px, transparent 1.5px);
  background-size: 4px 4px;
  opacity: 0.35;
  z-index: 9999;
}
.app-shell[data-titlebar-platform='linux']::before { left: 0; }
.app-shell[data-titlebar-platform='linux']::after  { right: 0; }

.titlebar {
  grid-area: titlebar;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 6px 0 12px;
  height: var(--titlebar-height);
  user-select: none;
}

.titlebar-track {
  position: absolute;
  /* Centre without translateX: a transform promotes the label to its own
     compositing layer, which drops macOS subpixel antialiasing and lands it
     on half-pixels — the text ends up frayed/grainy. Auto-margins between
     left:0/right:0 keep it centred and pixel-snapped on both platforms. */
  left: 0;
  right: 0;
  width: fit-content;
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 40%;
  pointer-events: none;
  padding: 3px 10px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.titlebar-track:empty {
  display: none;
}

.titlebar-track-state {
  font-size: 9px;
  color: var(--accent);
  flex-shrink: 0;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.6);
}

.titlebar-track-text {
  font-size: 11px;
  color: #ececec;
  max-width: 100%;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
}

.titlebar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  flex: 0 0 auto;
}

/* Shared base — each style below overrides shape, fill and glyph colour. */
.titlebar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: filter var(--transition-fast), box-shadow var(--transition-fast),
    background var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast), opacity var(--transition-fast);
}

.titlebar-btn svg {
  width: 10px;
  height: 10px;
  display: block;
}

.titlebar-btn:active {
  filter: brightness(0.92);
}

.titlebar-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent);
}

/* ── dots / dotsGlyph — colour-circle window buttons ── */
[data-btnstyle="dots"] .titlebar-btn,
[data-btnstyle="dotsGlyph"] .titlebar-btn {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  color: rgba(0, 0, 0, 0.55);
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.18);
}
[data-btnstyle="dots"] .titlebar-btn svg,
[data-btnstyle="dotsGlyph"] .titlebar-btn svg {
  width: 8px;
  height: 8px;
}
[data-btnstyle="dots"] .titlebar-btn-close,
[data-btnstyle="dotsGlyph"] .titlebar-btn-close    { background: #ff5f57; }
[data-btnstyle="dots"] .titlebar-btn-minimize,
[data-btnstyle="dotsGlyph"] .titlebar-btn-minimize { background: #febc2e; }
[data-btnstyle="dots"] .titlebar-btn-maximize,
[data-btnstyle="dotsGlyph"] .titlebar-btn-maximize { background: #28c840; }
[data-btnstyle="dots"] .titlebar-btn:hover,
[data-btnstyle="dotsGlyph"] .titlebar-btn:hover    { filter: brightness(1.1); }
[data-btnstyle="dots"] .titlebar-btn-close:hover,
[data-btnstyle="dotsGlyph"] .titlebar-btn-close:hover    { box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.18), 0 0 6px rgba(255, 95, 87, 0.75); }
[data-btnstyle="dots"] .titlebar-btn-minimize:hover,
[data-btnstyle="dotsGlyph"] .titlebar-btn-minimize:hover { box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.18), 0 0 6px rgba(254, 188, 46, 0.75); }
[data-btnstyle="dots"] .titlebar-btn-maximize:hover,
[data-btnstyle="dotsGlyph"] .titlebar-btn-maximize:hover { box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.18), 0 0 6px rgba(40, 200, 64, 0.75); }
/* dots: glyphs reveal on hover (authentic); dotsGlyph: always shown */
[data-btnstyle="dots"] .titlebar-btn svg { opacity: 0; }
[data-btnstyle="dots"] .titlebar-controls:hover .titlebar-btn svg,
[data-btnstyle="dots"]:hover .titlebar-btn svg { opacity: 1; }
[data-btnstyle="dotsGlyph"] .titlebar-btn svg { opacity: 0.85; }

/* ── flat — full-height rectangular buttons, red close hover ── */
.titlebar-controls[data-btnstyle="flat"] { gap: 0; padding: 0; margin-right: -6px; }
[data-btnstyle="flat"] .titlebar-btn {
  width: 30px;
  height: var(--titlebar-height);
  border-radius: 0;
}
[data-btnstyle="flat"] .titlebar-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
[data-btnstyle="flat"] .titlebar-btn-close:hover { background: #e81123; color: #fff; }

/* ── pill — soft circular monochrome buttons ── */
[data-btnstyle="pill"] .titlebar-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-hover);
}
[data-btnstyle="pill"] .titlebar-btn:hover { filter: brightness(1.18); color: var(--text-primary); }
[data-btnstyle="pill"] .titlebar-btn-close:hover { background: #e01b24; color: #fff; filter: none; }

/* ── outline — square bordered buttons, accent hover ── */
[data-btnstyle="outline"] .titlebar-btn {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
[data-btnstyle="outline"] .titlebar-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
[data-btnstyle="outline"] .titlebar-btn-close:hover {
  border-color: #e01b24;
  color: #e01b24;
  background: color-mix(in srgb, #e01b24 12%, transparent);
}

/* ── glyph — themed monochrome, no fill, blends with the app ── */
[data-btnstyle="glyph"] .titlebar-btn {
  width: 22px;
  height: 22px;
  border-radius: 6px;
}
[data-btnstyle="glyph"] .titlebar-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
[data-btnstyle="glyph"] .titlebar-btn-close:hover { background: var(--bg-hover); color: #ff5f57; }

/* Resizer handles must start below the titlebar */
.app-shell[data-titlebar] .resizer {
  top: var(--titlebar-height);
}

