/* needleBaseStyles.css — Cratoora Needle
   Flat shell architecture — no stereo-shell wrapper.
   Desktop chrome (header, sidebar, footer) are light DOM elements
   positioned via CSS. Single #needleContent outlet handles all viewports.
*/

/* ═══════════════════════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════════════════════ */
* {
  margin: 0;
  padding: 0;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

:root {
  position: relative;
  font-size: 62.5%; /* 1rem = 10px */
}

img { max-width: 100%; height: auto; }

body.stereo-layout {
  background: #0a0a0a;
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem;
  color: #fff;
  overflow-x: hidden;
  /* Mobile: body scrolls. Desktop: fixed viewport. needleSpecificStyles.css
     sets height:100dvh which is correct for desktop only.
     needleStyles mobile override corrects it to auto. */
}

/* ═══════════════════════════════════════════════════════════════
   PLAYER BAR
═══════════════════════════════════════════════════════════════ */
.player-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 300;
  background: #181818;
  border-top: 1px solid #2a2a2a;
  height: 90px;
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  padding: 0 1.5rem; gap: 1rem;
  -webkit-transform: translateY(100%); transform: translateY(100%);
  -webkit-transition: -webkit-transform 0.4s cubic-bezier(0.23,1,0.32,1);
  transition: transform 0.4s cubic-bezier(0.23,1,0.32,1);
}
.player-bar.visible { -webkit-transform: translateY(0); transform: translateY(0); }
body.player-active { padding-bottom: 90px; }

.player-progress { position: absolute; top: 0; left: 0; right: 0; height: 3px; background: rgba(255,255,255,0.08); cursor: pointer; }
.player-progress-fill { height: 100%; width: 0%; background: #8B5CF6; -webkit-transition: width 0.5s linear; transition: width 0.5s linear; pointer-events: none; }
.player-thumb { width: 52px; height: 52px; border-radius: 6px; background: linear-gradient(135deg,#8B5CF6,#D97706); display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; font-size: 1.4rem; -webkit-flex-shrink: 0; flex-shrink: 0; }
.player-info { -webkit-flex: 1; flex: 1; min-width: 0; }
.player-title { font-size: 0.88rem; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-artist { font-size: 0.72rem; color: rgba(255,255,255,0.5); margin-top: 2px; }
.player-controls { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; gap: 0.35rem; -webkit-flex-shrink: 0; flex-shrink: 0; }
.player-btn { width: 36px; height: 36px; border-radius: 50%; border: none; background: none; color: rgba(255,255,255,0.65); display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; cursor: pointer; -webkit-transition: color 0.15s, background 0.15s; transition: color 0.15s, background 0.15s; }
.player-btn:hover { color: #fff; background: rgba(255,255,255,0.08); }
.player-btn.play-pause { width: 42px; height: 42px; background: #fff; color: #080808; }
.player-btn.play-pause:hover { background: rgba(255,255,255,0.88); }

/* ═══════════════════════════════════════════════════════════════
   MODALS
═══════════════════════════════════════════════════════════════ */
.create-crate-overlay,
.crate-auth-overlay {
  position: fixed; inset: 0; z-index: 800;
  background: rgba(0,0,0,0.75);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  -webkit-justify-content: center; justify-content: center;
  padding: 1.25rem; opacity: 0; pointer-events: none;
  -webkit-transition: opacity 0.22s ease; transition: opacity 0.22s ease;
}
.create-crate-overlay.open,
.crate-auth-overlay.open { opacity: 1; pointer-events: auto; }
.create-crate-modal, .crate-auth-modal {
  background: #282828; border-radius: 16px; padding: 1.5rem; width: min(360px, 100%);
  -webkit-transform: scale(0.95); transform: scale(0.95);
  -webkit-transition: -webkit-transform 0.25s cubic-bezier(0.23,1,0.32,1);
  transition: transform 0.25s cubic-bezier(0.23,1,0.32,1);
}
.create-crate-overlay.open .create-crate-modal,
.crate-auth-overlay.open .crate-auth-modal { -webkit-transform: scale(1); transform: scale(1); }

/* ═══════════════════════════════════════════════════════════════
   PREVIEW BANNER
═══════════════════════════════════════════════════════════════ */
.cr-preview-banner {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 250;
  background: #1d1d1d; border-top: 1px solid rgba(255,255,255,0.1);
  padding: 0.85rem 1.5rem;
  padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  -webkit-justify-content: space-between; justify-content: space-between;
  gap: 1rem;
  -webkit-transform: translateY(100%); transform: translateY(100%);
  -webkit-transition: -webkit-transform 0.45s cubic-bezier(0.23,1,0.32,1);
  transition: transform 0.45s cubic-bezier(0.23,1,0.32,1);
}
.cr-preview-banner.visible { -webkit-transform: translateY(0); transform: translateY(0); }

/* ═══════════════════════════════════════════════════════════════
   UPDATE BANNER
═══════════════════════════════════════════════════════════════ */
.update-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: #8B5CF6; color: #fff; padding: 0.75rem; text-align: center;
  -webkit-transform: translateY(-100%); transform: translateY(-100%);
  -webkit-transition: -webkit-transform 0.3s ease; transition: transform 0.3s ease;
}
.update-banner.visible { -webkit-transform: translateY(0); transform: translateY(0); }

/* ═══════════════════════════════════════════════════════════════
   PWA INSTALL PROMPT
═══════════════════════════════════════════════════════════════ */
.pwa-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.55);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  -webkit-justify-content: center; justify-content: center;
  -webkit-transition: opacity 0.25s ease; transition: opacity 0.25s ease;
}
.pwa-overlay.visible { opacity: 1; pointer-events: auto; }
.pwa-install-popup {
  width: min(360px, 90%); background: #111; border-radius: 18px;
  padding: 1.75rem 1.5rem 1.5rem; box-shadow: 0 20px 60px rgba(0,0,0,0.55);
  -webkit-transform: translateY(20px); transform: translateY(20px);
  -webkit-transition: -webkit-transform 0.28s cubic-bezier(0.25,1,0.5,1);
  transition: transform 0.28s cubic-bezier(0.25,1,0.5,1);
}
.pwa-overlay.visible .pwa-install-popup { -webkit-transform: translateY(0); transform: translateY(0); }
.pwa-install-header { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.pwa-install-icon { width: 52px; height: 52px; border-radius: 12px; }
.pwa-install-title { font-size: 1.1rem; font-weight: 800; font-family: "Syne", sans-serif; color: #fff; }
.pwa-install-sub { font-size: 0.85rem; color: rgba(255,255,255,0.55); margin-top: 2px; }
.pwa-install-body { font-size: 0.85rem; color: rgba(255,255,255,0.65); line-height: 1.55; margin-bottom: 1.5rem; }
.pwa-install-actions { display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; gap: 0.65rem; }
.pwa-btn-install { padding: 0.75rem; background: #8B5CF6; color: #fff; font-size: 0.9rem; font-weight: 700; border-radius: 999px; border: none; cursor: pointer; -webkit-transition: background 0.15s; transition: background 0.15s; }
.pwa-btn-install:hover { background: #7C3AED; }
.pwa-btn-later { padding: 0.75rem; background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.75); font-size: 0.9rem; font-weight: 600; border-radius: 999px; border: none; cursor: pointer; -webkit-transition: background 0.15s; transition: background 0.15s; }
.pwa-btn-later:hover { background: rgba(255,255,255,0.14); }

/* ═══════════════════════════════════════════════════════════════
   MOBILE SHELL  ≤ 768px
═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Body IS the scroll container — Spotify/Tidal pattern.
     needleSpecificStyles.css base sets height:100dvh which this overrides. */
  body.stereo-layout {
    overflow-y: auto;
    overflow-x: hidden;
    height: auto !important;
    min-height: 100dvh;
    padding-top: 56px;    /* clears fixed navbar */
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); /* clears tabbar */
    width: 100%;
    max-width: 100vw;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }

  /* Navbar — fixed top */
  cratoora-needle-mobile-navbar-view {
    display: block;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
    height: 56px;
  }

  /* Slidebar — off-screen drawer */
  cratoora-needle-mobile-slidebar-view {
    display: block;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    z-index: 1200;
    -webkit-transform: translateX(-100%); transform: translateX(-100%);
    -webkit-transition: -webkit-transform 0.32s cubic-bezier(0.23,1,0.32,1);
    transition: transform 0.32s cubic-bezier(0.23,1,0.32,1);
    pointer-events: none;
  }
  cratoora-needle-mobile-slidebar-view.open {
    -webkit-transform: translateX(0); transform: translateX(0);
    pointer-events: auto;
  }

  /* Tabbar — fixed bottom */
  cratoora-needle-mobile-tabbar-view {
    display: block;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 1000;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  /* Mobile footer — block flow above tabbar */
  cratoora-needle-mobile-footer {
    display: block;
    width: 100%;
  }

  /* Route outlet — plain block, body scrolls */
  #needleContent {
    display: block !important;
    -webkit-flex: none !important;
    flex: none !important;
    overflow-y: visible !important;
    width: 100%;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    background: #0a0a0a;
  }

  /* Backdrop */
  #sidebarBackdrop {
    display: block;
    position: fixed; inset: 0; z-index: 1190;
    background: rgba(0,0,0,0.6);
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    opacity: 0; pointer-events: none;
    -webkit-transition: opacity 0.3s ease; transition: opacity 0.3s ease;
  }
  #sidebarBackdrop.visible { opacity: 1; pointer-events: auto; }

  /* Hide desktop chrome (corrected selectors) */
  cratoora-needle-header,
  cratoora-needle-sidebar,
  cratoora-needle-tabdesk-footer-view {
    display: none !important;
  }

  /* Preview banner hidden on mobile */
  #crPreviewBanner { display: none !important; }

  /* Player bar sits above tabbar */
  .player-bar {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
    z-index: 400 !important;
  }
  body.player-active {
    padding-bottom: calc(64px + 90px + env(safe-area-inset-bottom, 0px));
  }
}

/* ═══════════════════════════════════════════════════════════════
   DESKTOP/TABLET  ≥ 769px
   Flat shell: header fixed top, sidebar fixed left,
   #needleContent fills remaining space, tabdesk-footer at bottom.
═══════════════════════════════════════════════════════════════ */
@media (min-width: 769px) {

  body.stereo-layout {
    overflow: hidden;
    height: 100dvh;
  }

  /* Mobile chrome hidden */
  cratoora-needle-mobile-navbar-view,
  cratoora-needle-mobile-slidebar-view,
  cratoora-needle-mobile-tabbar-view,
  cratoora-needle-mobile-footer {
    display: none !important;
  }

  /* Desktop sidebar — fixed left panel */
  cratoora-needle-sidebar {
    display: block;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 240px;
    z-index: 100;
    background: #121212;
    border-radius: 0 10px 10px 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
  }

  /* Desktop header — fixed top, left of sidebar */
  cratoora-needle-header {
    display: block;
    position: fixed;
    top: 0;
    left: 240px;
    right: 0;
    z-index: 100;
    height: 56px;
    background: rgba(18,18,18,0.92);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }

  /* Route outlet — fills space beside sidebar, below header */
  #needleContent {
    display: block;
    position: fixed;
    top: 56px;      /* below header */
    left: 240px;    /* beside sidebar */
    right: 0;
    bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    background: #121212;
    border-radius: 10px 0 0 0;
  }

  /* Sidebar backdrop not needed on desktop */
  #sidebarBackdrop { display: none !important; }

  /* Preview banner visible on desktop */
  #crPreviewBanner {
    display: -webkit-flex;
    display: flex;
  }
}