/* ════════════════════════════════════════════════════════════════════════
 * shop-shell.css — Shop navigation shell (Shop W1-A)
 * ════════════════════════════════════════════════════════════════════════
 * Two concerns:
 *   1. The persistent, collapsible Trace side panel docked on every shop tab
 *      (`.da-shop-shell` on the `.da-container` inside <main>, with a
 *      `.da-shop-shell__aside` sibling of the content).
 *   2. The /preferences sectioned layout (`.da-prefs`).
 * All colours/spacing use the design-system tokens so light/dark + brand stay
 * consistent. The panel reuses the copilot widget's `.da-copilot--inline`
 * variant unchanged; this file only lays out the dock + collapse chrome.
 */

/* ── Persistent copilot dock ─────────────────────────────────────────── */
.da-container.da-shop-shell {
  display: flex;
  align-items: flex-start;
  gap: var(--space-6, 1.5rem);
  max-width: 1536px;
}

.da-shop-shell__content {
  flex: 1 1 0;
  min-width: 0; /* let the content column shrink instead of overflowing */
}

.da-shop-shell__aside {
  flex: 0 0 22rem;
  position: sticky;
  top: var(--space-6, 1.5rem);
  align-self: flex-start;
}

.da-shop-shell__aside-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-2, 0.5rem);
  padding: var(--space-3, 0.75rem);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg, 12px);
}

.da-shop-shell__aside-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2, 0.5rem);
}

.da-shop-shell__aside-title {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2, 0.5rem);
  font-weight: 600;
  color: var(--text-brand);
}

/* ── Collapsed state ─────────────────────────────────────────────────── */
.da-shop-shell[data-collapsed] .da-shop-shell__aside {
  display: none;
}

.da-shop-shell__reopen {
  display: none;
}

.da-shop-shell[data-collapsed] .da-shop-shell__reopen {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2, 0.5rem);
  flex: 0 0 auto;
  position: sticky;
  top: var(--space-6, 1.5rem);
  align-self: flex-start;
  padding: var(--space-3, 0.75rem) var(--space-2, 0.5rem);
  background: var(--bg-secondary);
  color: var(--text-brand);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg, 12px);
  cursor: pointer;
  font-weight: 600;
}

.da-shop-shell__reopen-label {
  writing-mode: vertical-rl;
  font-size: var(--text-sm, 0.875rem);
}

.da-shop-shell__reopen:focus-visible,
.da-shop-shell__collapse:focus-visible {
  outline: 2px solid var(--border-focus, var(--text-brand));
  outline-offset: 2px;
}

/* ── Responsive: stack below the desktop breakpoint ──────────────────── */
@media (max-width: 1023px) {
  .da-container.da-shop-shell {
    flex-direction: column;
  }

  .da-shop-shell__aside {
    position: static;
    flex: 1 1 auto;
    width: 100%;
  }

  .da-shop-shell[data-collapsed] .da-shop-shell__reopen {
    position: static;
    flex-direction: row;
    width: 100%;
    justify-content: center;
  }

  .da-shop-shell__reopen-label {
    writing-mode: horizontal-tb;
  }
}

/* ════════════════════════════════════════════════════════════════════════
 * Preferences sectioned layout
 * ════════════════════════════════════════════════════════════════════════ */
.da-prefs {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: var(--space-6, 1.5rem);
  align-items: start;
}

.da-prefs__nav {
  position: sticky;
  top: var(--space-6, 1.5rem);
}

.da-prefs__nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1, 0.25rem);
}

.da-prefs__nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-2, 0.5rem);
  padding: var(--space-2, 0.5rem) var(--space-3, 0.75rem);
  border-radius: var(--radius-md, 8px);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
}

.da-prefs__nav-link:hover,
.da-prefs__nav-link:focus-visible {
  color: var(--text-brand);
  background: var(--bg-brand-subtle);
}

.da-prefs__sections {
  display: flex;
  flex-direction: column;
  gap: var(--space-6, 1.5rem);
}

/* Each preferences partial is a self-contained `.prefs-section` (SLOT CONTRACT).
 * The shell gives every section a uniform card frame so sections authored by
 * different feature agents (W1-B/C/D) read as one system, and offsets the
 * scroll target so the sticky navbar never hides a section heading. */
.da-prefs__sections .prefs-section {
  scroll-margin-top: var(--space-20, 5rem);
  padding: var(--space-5, 1.25rem);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg, 12px);
}

@media (max-width: 767px) {
  .da-prefs {
    grid-template-columns: 1fr;
  }

  .da-prefs__nav {
    position: static;
  }

  .da-prefs__nav-list {
    flex-direction: row;
    flex-wrap: wrap;
  }
}
