/* ============================================================
   DAPS.Web — app shell styles.
   Faithful CSS translation of design-system/ui_kits/daps-streaming/Shell.jsx.
   RULE: design tokens ONLY. Every colour, font, radius, spacing, shadow and
   motion value must come from var(--…) defined in css/ds/. No hardcoded
   hex / font-family / magic numbers for anything the tokens cover.
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
}

/* ---- Accessibility: visually-hidden (screen-reader only) ---- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Accessibility: skip link ---- */
.skip-link {
  position: absolute;
  left: var(--space-2);
  top: calc(var(--space-2) * -8);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-radius: var(--radius-button);
  font-family: var(--font-body);
  font-weight: var(--fw-semibold);
  text-decoration: none;
  transition: top var(--dur-fast) var(--ease-standard);
}

.skip-link:focus {
  top: var(--space-2);
}

/* ---- Global visible magenta focus ring ---- */
:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
}

/* ============================================================
   App shell scaffold
   ============================================================ */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-primary);
}

/* ---- Top bar (60px) ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: var(--topbar-h);
  padding: 0 var(--space-5);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  z-index: 10;
}

/* Flat --accent-hero logo pill reading DAPS */
.logo-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-full);
  background: var(--accent-hero);
  color: var(--accent-hero-text);
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: var(--fs-h3);
  letter-spacing: 1.5px;
  text-decoration: none;
  white-space: nowrap;
}

.logo-pill i {
  width: 20px;
  height: 20px;
}

/* Centered search input */
.topbar-search {
  flex: 1;
  max-width: 460px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-4);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-full);
}

.topbar-search i {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.topbar-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  color: var(--text-primary);
}

.topbar-search input::placeholder {
  color: var(--text-muted);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Icon buttons (notifications, theme toggle) — 44px min target */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: var(--radius-button);
  transition: background var(--dur-fast) var(--ease-standard);
}

.icon-btn:hover {
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
}

.icon-btn i {
  width: 20px;
  height: 20px;
}

/* Teal "Create" pill with glow */
.create-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 40px;
  min-height: 40px;
  padding: 0 var(--space-4);
  border: none;
  border-radius: var(--radius-tab);
  background: var(--accent-primary);
  color: var(--text-inverse);
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-body-sm);
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--glow-teal);
  transition: background var(--dur-fast) var(--ease-standard);
}

.create-btn:hover {
  background: var(--accent-primary-hover);
}

.create-btn i {
  width: 15px;
  height: 15px;
}

/* Avatar */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-body-sm);
  overflow: hidden;
}

/* ---- Account menu (signed-in) — native <details> disclosure, keyboard-first ---- */
.account-menu {
  position: relative;
}

.account-menu__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-full);
  cursor: pointer;
  list-style: none;
}

/* Remove the default disclosure triangle. */
.account-menu__trigger::-webkit-details-marker { display: none; }
.account-menu__trigger::marker { content: ""; }

.account-menu__panel {
  position: absolute;
  inset-inline-end: 0;
  inset-block-start: calc(100% + var(--space-2));
  min-width: 180px;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-modal);
  box-shadow: var(--shadow-dropdown);
  z-index: 40;
}

.account-menu__name {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-body-sm);
  color: var(--text-primary);
  padding-block-end: var(--space-2);
  border-block-end: 1px solid var(--border-subtle);
}

.account-menu__form {
  margin: 0;
}

/* ---- Body: sidebar + main ---- */
.shell-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Left sidebar (240px, desktop >=1024px) */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  border-right: 1px solid var(--border-subtle);
  padding: var(--space-3);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.side-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border: none;
  cursor: pointer;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: var(--fw-medium);
  text-align: left;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-standard);
}

.side-item:hover {
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
}

.side-item i {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.side-item.active {
  background: color-mix(in srgb, var(--accent-primary) 16%, transparent);
  color: var(--accent-primary);
  font-weight: var(--fw-semibold);
}

.side-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-2) var(--space-2);
}

.side-heading {
  font-family: var(--font-body);
  font-size: var(--fs-label);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  padding: var(--space-1) var(--space-3);
}

/* Subscription channel rows */
.channel-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-body-sm);
  text-align: left;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-standard);
}

.channel-row:hover {
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
}

.channel-avatar {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-caption);
}

.channel-avatar .live-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 9px;
  height: 9px;
  border-radius: var(--radius-full);
  background: var(--live);
  border: 2px solid var(--bg-primary);
}

.channel-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Main region ---- */
.main-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}

/* ============================================================
   Bottom nav (mobile, 70px) — hidden on desktop
   ============================================================ */
.bottom-nav {
  display: none;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  flex: 1;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: var(--fs-caption);
  text-decoration: none;
  cursor: pointer;
}

.bottom-nav-item i {
  width: 22px;
  height: 22px;
}

.bottom-nav-item.active {
  color: var(--accent-primary);
}

/* ============================================================
   Responsive: sidebar >=1024px, bottom-nav below.
   (DS: desktop sidebar >=1024, mobile bottom-nav <768. We show the
   bottom-nav across the whole <1024 range so tablets keep a nav rail
   instead of a dead zone.)
   ============================================================ */
@media (max-width: 1023.98px) {
  .sidebar {
    display: none;
  }

  .main-content {
    padding-bottom: var(--bottomnav-h);
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--bottomnav-h);
    display: flex;
    align-items: stretch;
    background: var(--header-bg);
    border-top: 1px solid var(--border-subtle);
    z-index: 20;
  }
}

/* ============================================================
   Home placeholder hero
   ============================================================ */
.hero {
  max-width: var(--content-max-w);
  margin: 0 auto;
  padding: var(--space-12) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  align-items: flex-start;
}

.hero-eyebrow {
  font-family: var(--font-body);
  font-size: var(--fs-label);
  font-weight: var(--fw-semibold);
  color: var(--accent-primary);
}

.hero-title {
  font-family: var(--font-display);
  font-size: var(--fs-display);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-display);
  color: var(--text-primary);
  margin: 0;
}

.hero-lead {
  font-family: var(--font-body);
  font-size: var(--fs-article-lead);
  line-height: var(--lh-snug);
  color: var(--text-muted);
  max-width: var(--reader-max-w);
  margin: 0;
}

/* ============================================================
   Offline fallback (DAPS-P2.8 PWA shell) — the chrome-less page
   the service worker serves on a failed navigation. Vertically
   centers the shared <daps-empty-state> pattern; tokens only.
   ============================================================ */
.offline-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}

/* ============================================================
   Reduced motion — kill all transitions/animations
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
