/* =========================================================================
   jamesdshin.com — styles
   Retheme by editing the tokens in :root (start with --accent).
   ========================================================================= */

:root {
  /* Color */
  --bg:            #0B0B0F;
  --bg-deep:       #050507;  /* gutter behind the panels */
  --bg-elevated:   #15151C;
  --bg-hover:      #1E1E28;
  --bg-highlight:  #262633;
  --border:        #2A2A36;
  --text:          #F5F5F7;
  --text-muted:    #A1A1AE;
  --text-subtle:   #7C7C8A;  /* lightened from #6E6E7C to meet 4.5:1 contrast on --bg */
  --accent:        #4F7CFF;
  --accent-hover:  #6B92FF;
  --accent-contrast: #FFFFFF;
  --live:          #FF4D5E;
  --success:       #3DDC97;

  /* Type */
  --font-display: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --fs-hero: clamp(48px, 9vw, 96px);
  --fs-h2: 24px;
  --fs-h3: 16px;
  --fs-body: 15px;
  --fs-small: 13px;
  --fs-micro: 11px;

  /* Space */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;

  /* Shape */
  --r-card: 12px;
  --r-art: 8px;
  --r-pill: 999px;

  /* Layout */
  --sidebar-w: 240px;
  --np-h: 72px;
  --topbar-h: 64px;
  --tab-h: 0px;
  --gutter: 8px;
  --content-max: 1200px;
  --page-pad: var(--s-6);

  /* Motion */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --t-hover: 150ms;
  --t-panel: 250ms;
  --t-page: 400ms;
}

/* ---------- Reset & base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden; /* the main panel scrolls, not the page */
}

img, svg { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p, ul, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
:focus:not(:focus-visible) { outline: none; }

::selection { background: color-mix(in srgb, var(--accent) 55%, transparent); }

/* ---------- Type helpers ---------- */

.micro {
  font-size: var(--fs-micro);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.h2 {
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.muted { color: var(--text-muted); }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.subtle { color: var(--text-subtle); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Skip link ---------- */

.skip-link {
  position: fixed;
  top: var(--s-2); left: var(--s-2);
  z-index: 100;
  padding: var(--s-2) var(--s-4);
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: var(--r-pill);
  font-weight: 600;
  transform: translateY(-200%);
  transition: transform var(--t-hover) var(--ease);
}
.skip-link:focus-visible { transform: none; }

/* =========================================================================
   App layout
   ========================================================================= */

.app {
  display: grid;
  height: 100vh;
  height: 100dvh;
  padding: var(--gutter) var(--gutter) 0;
  gap: var(--gutter);
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) var(--np-h);
  grid-template-areas:
    "side main"
    "np   np";
}

.sidebar     { grid-area: side; }
.main        { grid-area: main; }
.now-playing { grid-area: np; }
.tabbar      { grid-area: tabs; display: none; }

/* ---------- Sidebar ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--gutter);
  min-height: 0;
}
.sidebar > * {
  background: var(--bg-elevated);
  border-radius: var(--r-card);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-4) var(--s-2);
  border-radius: var(--r-card) var(--r-card) 0 0;
  margin-bottom: calc(-1 * var(--gutter));
}
.brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 50%, #000));
  color: var(--accent-contrast);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.nav {
  display: flex;
  flex-direction: column;
  padding: var(--s-2);
  border-radius: 0 0 var(--r-card) var(--r-card);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-3);
  border-radius: var(--r-art);
  color: var(--text-muted);
  font-weight: 600;
  transition: color var(--t-hover) var(--ease), background var(--t-hover) var(--ease);
}
.nav-item:hover { color: var(--text); }
.nav-item[aria-current="page"] { color: var(--text); }
.nav-icon { display: grid; place-items: center; flex: none; width: 24px; height: 24px; }

.library {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: var(--s-2);
}
.library-title {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-3);
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--text-muted);
}
.library-list {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-highlight) transparent;
}
.library-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2);
  border-radius: var(--r-art);
  transition: background var(--t-hover) var(--ease);
}
.library-item:hover { background: var(--bg-hover); }
.library-item[aria-current="page"] { background: var(--bg-highlight); }
.library-item[aria-current="page"] .library-name { color: var(--accent-hover); }
.library-art { flex: none; width: 44px; height: 44px; }
.library-text { display: flex; flex-direction: column; min-width: 0; }
.library-name, .library-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.library-name { font-weight: 500; }
.library-sub { font-size: var(--fs-small); color: var(--text-muted); }

/* ---------- Main ---------- */

.main {
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
  border-radius: var(--r-card);
  scrollbar-width: thin;
  scrollbar-color: var(--bg-highlight) transparent;
  outline: none;
}
.view {
  min-height: 100%;
  padding-bottom: var(--s-7);
}

/* ---------- Now-playing bar ---------- */

.now-playing {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr);
  align-items: center;
  gap: var(--s-4);
  padding: 0 var(--s-3);
}
.np-current, .np-next {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-width: 0;
  padding: var(--s-1);
  border-radius: var(--r-art);
  transition: background var(--t-hover) var(--ease);
}
.np-current:hover, .np-next:hover { background: var(--bg-elevated); }
.np-next { justify-self: end; }
.np-art { flex: none; width: 52px; height: 52px; }
.np-art--sm { width: 40px; height: 40px; }
.np-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.np-meta--right { text-align: right; align-items: flex-end; }
.np-label { font-size: 10px; }
.np-title, .np-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.np-title { font-weight: 600; font-size: 14px; }
.np-sub { font-size: var(--fs-small); color: var(--text-muted); }

/* ---------- Mobile tab bar ---------- */

.tabbar {
  justify-content: space-around;
  align-items: stretch;
  background: linear-gradient(to top, var(--bg-deep) 60%, transparent);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}
.tab[aria-current="page"] { color: var(--text); }
.tab-icon { display: grid; place-items: center; width: 24px; height: 24px; }

/* =========================================================================
   Artwork (real or generated covers)
   ========================================================================= */

.art {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--r-art);
  object-fit: cover;
  background: var(--bg-highlight);
}
.art--gen {
  --c: var(--accent);
  position: relative;
  overflow: hidden;
  container-type: inline-size;
  isolation: isolate;
  background:
    radial-gradient(120% 90% at 85% 10%, color-mix(in srgb, var(--c) 70%, #fff 30%) 0%, transparent 55%),
    linear-gradient(145deg, var(--c) 0%, color-mix(in srgb, var(--c) 45%, #000) 100%);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.06);
}
/* Geometric accent ring */
.art--gen::before {
  content: '';
  position: absolute;
  width: 78%;
  aspect-ratio: 1;
  right: -26%;
  top: -22%;
  border-radius: 50%;
  border: 1.5px solid rgb(255 255 255 / 0.28);
  z-index: -1;
}
/* Film grain */
.art--gen::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.22;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.art-title {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 7%;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15cqi;
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: #fff;
  text-shadow: 0 1px 12px rgb(0 0 0 / 0.25);
  overflow-wrap: break-word;
  text-align: left;
}
.art-mono {
  display: none;
  position: absolute;
  inset: 0;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 38cqi;
  letter-spacing: -0.04em;
  color: #fff;
}
/* Tiny thumbnails: show a monogram instead of the full title */
@container (max-width: 72px) {
  .art-title { display: none; }
  .art-mono { display: grid; }
}

/* =========================================================================
   Buttons
   ========================================================================= */

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  color: var(--text-muted);
  transition: color var(--t-hover) var(--ease), background var(--t-hover) var(--ease);
}
.icon-btn:hover { color: var(--text); background: var(--bg-hover); }

/* =========================================================================
   Overlays (shared by Recap, Places, video modal, drawers)
   ========================================================================= */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: var(--s-5);
  background: rgb(5 5 7 / 0.78);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity var(--t-panel) var(--ease);
}
.overlay.is-open { opacity: 1; }

/* ---------- Search bar ---------- */

.view[data-view="search"] { padding-top: var(--topbar-h); }
.search-bar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-4) var(--page-pad);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
}
.search-icon {
  position: absolute;
  left: calc(var(--page-pad) + 14px);
  color: var(--text-muted);
  pointer-events: none;
}
.search-icon svg { width: 20px; height: 20px; }
.search-input {
  width: 100%;
  max-width: 480px;
  height: 48px;
  padding: 0 var(--s-4) 0 44px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--bg-highlight);
  color: var(--text);
  transition: border-color var(--t-hover) var(--ease);
}
.search-input::placeholder { color: var(--text-subtle); }
.search-input:hover { border-color: var(--text-subtle); }
.search-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

/* ---------- Toast ---------- */

.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(var(--np-h) + var(--tab-h) + var(--s-5));
  transform: translateX(-50%);
  z-index: 80;
  display: grid;
  gap: var(--s-2);
  pointer-events: none;
}
.toast {
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-pill);
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.4);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--t-panel) var(--ease), transform var(--t-panel) var(--ease);
}
.toast.is-visible { opacity: 1; transform: none; }

/* =========================================================================
   Phase 1 placeholders (replaced in later phases)
   ========================================================================= */

.placeholder {
  max-width: var(--content-max);
  padding: var(--s-6) var(--page-pad);
  display: grid;
  gap: var(--s-3);
}
.hero-gradient {
  max-width: none;
  padding-top: var(--s-8);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 45%, var(--bg)) 0%, var(--bg) 100%);
}
.placeholder-title {
  font-family: var(--font-display);
  font-size: var(--fs-hero);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}
.placeholder-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--s-3);
  margin-top: var(--s-4);
  max-width: 900px;
}
.placeholder-stats div {
  padding: var(--s-3) var(--s-4);
  background: rgb(0 0 0 / 0.25);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
}
.placeholder-stats dt { font-size: var(--fs-small); color: var(--text-muted); }
.placeholder-stats dd { font-weight: 600; font-variant-numeric: tabular-nums; }
.album-placeholder {
  max-width: none;
  grid-template-columns: 200px 1fr;
  align-items: end;
  gap: var(--s-5);
  padding-top: var(--s-8);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 55%, var(--bg)) 0%, var(--bg) 100%);
}
.album-placeholder .placeholder-title { font-size: clamp(36px, 6vw, 72px); }
.album-placeholder-art { box-shadow: 0 16px 48px rgb(0 0 0 / 0.5); border-radius: var(--r-art); }
.overlay--placeholder .placeholder-dialog {
  position: relative;
  width: min(480px, 100%);
  display: grid;
  gap: var(--s-3);
  padding: var(--s-6);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
}
.placeholder-close { position: absolute; top: var(--s-3); right: var(--s-3); }

/* =========================================================================
   Responsive
   ========================================================================= */

/* Tablet: sidebar collapses to an icon rail */
@media (max-width: 1023px) {
  :root { --sidebar-w: 72px; --page-pad: var(--s-5); }
  .brand { justify-content: center; padding: var(--s-4) 0 var(--s-2); }
  .brand-name, .nav-label, .library-text { display: none; }
  .nav { align-items: center; }
  .nav-item, .library-title { justify-content: center; padding: var(--s-3); }
  .library-item { justify-content: center; padding: 6px; }
  .library-art { width: 44px; height: 44px; }
  .now-playing { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
}

/* Mobile: no sidebar, slim now-playing bar above a bottom tab bar */
@media (max-width: 767px) {
  :root { --np-h: 56px; --tab-h: 60px; --gutter: 0px; --page-pad: var(--s-4); --fs-h2: 20px; }
  .app {
    padding: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) var(--np-h) calc(var(--tab-h) + env(safe-area-inset-bottom));
    grid-template-areas: "main" "np" "tabs";
  }
  .sidebar { display: none; }
  .main { border-radius: 0; }
  .tabbar { display: flex; }
  .now-playing {
    grid-template-columns: minmax(0, 1fr);
    margin: 0 var(--s-2);
    padding: 0 var(--s-1);
    background: color-mix(in srgb, var(--accent) 22%, var(--bg-elevated));
    border-radius: var(--r-art);
  }
  .np-center, .np-next { display: none; }
  .np-art { width: 40px; height: 40px; }
  .np-label { display: none; }
  .album-placeholder { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; }
  .album-placeholder-art { width: 200px; }
}

/* =========================================================================
   Reduced motion
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
