/* ==========================================================================
   layout.css — WINAMP 2026
   Clean dark layout with generous spacing and clear visual hierarchy.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Page Background
   -------------------------------------------------------------------------- */
body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  background: var(--bg-page);
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   Main Player Container
   -------------------------------------------------------------------------- */
.player {
  width: 100%;
  max-width: var(--container-max-width);
  background: var(--bg-player);
  border-radius: var(--radius-outer);
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.5),
    0 0 60px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

/* Remove the old noise/scanbeam overlays - keep it clean */
.player-noise,
.player-scanbeam {
  display: none;
}

/* --------------------------------------------------------------------------
   Section Separators — Clear 1px borders between sections
   -------------------------------------------------------------------------- */
.lcd-section,
.viz-container,
.seek-bar-container,
.controls-section,
.eq-panel,
.fx-panel,
.playlist-panel {
  border-bottom: 1px solid var(--border);
}

/* Last visible panel shouldn't have bottom border */
.playlist-panel,
.player > *:last-child {
  border-bottom: none;
}

/* Remove old groove styles */
.player > .title-bar {
  border-top: none;
  box-shadow: none;
}

/* --------------------------------------------------------------------------
   Title Bar
   -------------------------------------------------------------------------- */
.title-bar {
  height: 32px;
  background: linear-gradient(180deg, var(--bg-panel), var(--bg-deep));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
  position: relative;
  border-bottom: 1px solid var(--border);
}

.title-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.title-bar-logo {
  font-size: 16px;
  color: var(--accent);
  line-height: 1;
  text-shadow: 0 0 8px var(--accent-glow);
}

.title-bar-text {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
  text-transform: uppercase;
  white-space: nowrap;
  text-shadow:
    0 0 6px var(--accent-glow),
    0 0 12px var(--accent-glow-wide);
}

.title-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-bar-version {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

.title-bar-dots {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.chrome-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* --------------------------------------------------------------------------
   LCD Section
   -------------------------------------------------------------------------- */
.lcd-section {
  padding: 14px 14px;
  border-top: none;
  box-shadow: none;
}

/* --------------------------------------------------------------------------
   Controls Section
   -------------------------------------------------------------------------- */
.controls-section {
  padding: 8px 10px 10px;
  border-top: none;
  box-shadow: none;
}

/* --------------------------------------------------------------------------
   EQ Panel
   -------------------------------------------------------------------------- */
.eq-panel {
  overflow: hidden;
  border-top: none;
  box-shadow: none;
}

/* --------------------------------------------------------------------------
   Playlist Section
   -------------------------------------------------------------------------- */
.playlist-panel {
  border-top: none;
  box-shadow: none;
}

/* --------------------------------------------------------------------------
   Bottom Grip
   -------------------------------------------------------------------------- */
.player-grip {
  display: flex;
  justify-content: center;
  gap: 3px;
  padding: 4px 0 6px;
  background: var(--bg-panel);
}

.player-grip span {
  width: 16px;
  height: 2px;
  border-radius: 1px;
  background: var(--border);
}

/* --------------------------------------------------------------------------
   Theater Mode
   -------------------------------------------------------------------------- */
.player.theater-mode {
  position: fixed;
  inset: 0;
  max-width: none;
  border-radius: 0;
  /* Stay below the floating mobile-nav (z-index 1000) so the user can
     always tap VIS again to exit, plus EQ/FX/PL stay reachable. */
  z-index: 900;
  display: flex;
  flex-direction: column;
  transform: none;
}

.player.theater-mode .viz-container {
  flex: 1;
}

/* --------------------------------------------------------------------------
   Mobile Layout (<540px)
   -------------------------------------------------------------------------- */
@media (max-width: 540px) {
  body {
    padding: 0;
    align-items: flex-start;
    /* iOS safe-area: keeps content out from under the notch/Dynamic
       Island at the top. The bottom inset is consumed by mobile-nav. */
    padding-top: env(safe-area-inset-top);
  }

  .player {
    max-width: 100%;
    border-radius: 0;
    border: none;
    box-shadow: none;
    /* Fullscreen on mobile — dvh tracks the dynamic viewport so the
       layout doesn't jump when Safari's URL bar shows/hides. */
    min-height: 100vh;
    min-height: 100dvh;
    height: 100dvh;
    /* Make .player a flex column so the active .panel can `flex: 1`
       and fill the space between the LCD/controls and the bottom nav. */
    display: flex;
    flex-direction: column;
  }

  /* The active panel (Player / Playlist / EQ / Search / etc.) fills
     all remaining vertical space below the LCD + controls and above
     the bottom mobile nav. Without this, panels collapsed to their
     content height and the screen looked cropped. */
  .panel.is-visible {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;          /* lets children with overflow scroll */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Playlist panel on phones: when it's the active mobile panel, fill
     the column and let the inner track list use the whole vertical
     space instead of stopping at the desktop 220px cap. */
  #playlist-panel:not([hidden]) {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  #playlist-panel:not([hidden]) .playlist-tracks {
    max-height: none;
    flex: 1 1 auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
  }

  /* Mobile bottom navigation — floats above content, stays visible
     even when iOS Safari's URL bar is showing or theater-mode is on. */
  .mobile-nav {
    display: flex;
    position: fixed;
    /* Floating — small inset from the screen edges, lifted off the
       home indicator. The interactive-widget=resizes-content viewport
       hint keeps this above the iOS Safari URL bar at all times. */
    left: 8px;
    right: 8px;
    bottom: calc(env(safe-area-inset-bottom) + 8px);
    z-index: 1000;
    background: color-mix(in srgb, var(--bg-panel) 92%, transparent);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    border: 1px solid var(--border);
    border-radius: 14px;
    height: 52px;
    box-shadow:
      0 6px 24px rgba(0, 0, 0, 0.45),
      0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    overflow: hidden;
  }

  .mobile-nav-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color var(--transition-fast), background var(--transition-fast);
    position: relative;
  }

  .mobile-nav-btn:hover {
    background: rgba(255, 255, 255, 0.03);
  }

  .mobile-nav-btn.is-active {
    color: var(--accent);
    text-shadow: 0 0 8px var(--accent-glow);
  }

  .mobile-nav-btn.is-active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    border-radius: 1px;
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent-glow);
    pointer-events: none;
  }

  .player {
    /* Reserve room for the floating bottom nav (52px height + 8px
       gap above + 8px below) plus the iOS home-indicator safe area,
       so the last bit of content isn't hidden behind the nav. */
    padding-bottom: calc(68px + env(safe-area-inset-bottom));
  }

  .panel {
    display: none;
  }

  .panel.is-visible {
    display: block;
  }

  /* Feature bar — tighter on mobile */
  .feature-bar {
    gap: 3px;
    padding: 6px 6px;
  }

  .feature-btn {
    padding: 0 5px;
    height: 26px;
    font-size: 9px;
    letter-spacing: 0;
  }

  .feature-divider {
    height: 14px;
  }

  /* LCD — scale down time for narrow screens */
  .lcd-time {
    font-size: 28px;
  }

  .lcd-marquee {
    font-size: 13px;
  }

  /* Slider labels tighter */
  .slider-row {
    gap: 8px;
    padding: 6px 8px;
  }

  .slider-label {
    min-width: 22px;
    font-size: 9px;
  }

  /* Transport buttons tighter */
  .transport-row {
    gap: 4px;
  }

  .transport-btn {
    padding: 4px 8px;
    min-width: 34px;
    height: 34px;
  }

  .transport-spacer {
    width: 6px;
  }

  /* Character panel grid */
  .character-picker {
    grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
    gap: 4px;
  }
}

@media (min-width: 541px) {
  .mobile-nav,
  .mini-player {
    display: none;
  }
}

/* Floating mini-player (mobile only). Hidden by default — JS toggles
   the [hidden] attribute on/off based on the active panel and whether
   a track is loaded. */
.mini-player {
  display: none;
}

@media (max-width: 540px) {
  .mini-player:not([hidden]) {
    display: flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    left: 8px;
    right: 8px;
    /* Sits 8px above the floating nav (52px tall, 8px gap from edge,
       safe-area inset). 52 + 8 + 8 = 68px above the safe-area baseline. */
    bottom: calc(env(safe-area-inset-bottom) + 68px);
    z-index: 1001;
    padding: 8px 10px;
    background: color-mix(in srgb, var(--bg-panel) 92%, transparent);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow:
      0 6px 24px rgba(0, 0, 0, 0.45),
      0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    /* When a track is playing, the accent edge pulses subtly so the
       user sees activity at a glance even with the panel hidden. */
    overflow: hidden;
  }

  .mini-player-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    background: transparent;
    border: none;
    padding: 2px 4px;
    cursor: pointer;
    color: inherit;
    text-align: left;
  }

  .mini-player-title {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-shadow: 0 0 6px var(--accent-glow-wide);
  }

  .mini-player-artist {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .mini-player-artist:empty {
    display: none;
  }

  .mini-player-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
  }

  .mini-player-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--text-primary);
    cursor: pointer;
    transition:
      background var(--transition-fast),
      border-color var(--transition-fast),
      color var(--transition-fast);
    padding: 0;
  }

  .mini-player-btn svg {
    fill: currentColor;
  }

  .mini-player-btn:hover,
  .mini-player-btn:active {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border);
    color: var(--accent);
  }

  .mini-player-play {
    color: var(--accent);
  }

  .mini-player-btn.is-disabled,
  .mini-player-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
  }

  /* Bump the player's mobile padding-bottom further when the mini-player
     is active so the last bit of panel content isn't hidden behind it. */
  body:has(#mini-player:not([hidden])) .player {
    padding-bottom: calc(124px + env(safe-area-inset-bottom));
  }

  /* ------------------------------------------------------------------
     Hardware-skin neutralization on non-player mobile panels.
     Every hardware skin (gameboy, cassette, crt, mickey, fliptac,
     cordless, pollypocket, tamagotchi) wraps the .player in a fake
     case with heavy bottom-padding for d-pads, antennas, keypads, etc.
     On mobile that swallows panel space and makes EQ/FX/PL/VIS
     unusable. While the user is on a non-player panel, drop the case
     decoration and reset padding so panels render full-screen. The
     case + decoration come back the moment the user taps Player.
     !important is needed to overcome each skin's per-skin specificity
     since layout.css loads before the skin-hardware-*.css files.
     ------------------------------------------------------------------ */
  body.is-mobile-on-panel #player.has-hardware {
    padding: 0 !important;
    background: var(--bg-player) !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
  body.is-mobile-on-panel .hw-overlay {
    display: none !important;
  }

  /* EQ nav button hints at its viz-mode-cycle role while theater is on.
     The label gets a small "MODE" subtitle and the icon glows so the
     user knows tapping it cycles visualizer modes. */
  body.is-viz-mode .mobile-nav-btn[data-panel="eq"]::after {
    content: 'MODE';
    position: absolute;
    bottom: 2px;
    left: 0;
    right: 0;
    font-size: 7px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--accent);
    text-shadow: 0 0 4px var(--accent-glow);
    background: none;
    box-shadow: none;
    border-radius: 0;
    height: auto;
  }
  body.is-viz-mode .mobile-nav-btn[data-panel="eq"] {
    color: var(--accent);
    text-shadow: 0 0 6px var(--accent-glow);
  }
}
