@import url("/colors/stuff-theme.css");

/* ================================================================
   Stuff Window Component — CSS Tokens and Lab Chrome
   Design doc §10.4 (z-order) and §15.2 (surfaces)
   ================================================================ */

/* ================================================================
   Z-order tokens
   ================================================================ */

:root {
  --stuff-z-environment: 0;
  --stuff-z-main: 100;
  --stuff-z-window-header: 300;
  --stuff-z-window-footer: 300;
  --stuff-z-drawer-base: 500;
  --stuff-z-drawer-active: 600;
  --stuff-z-drawer-modal: 700;
  --stuff-z-dialog: 800;
}

/* ================================================================
   Surface and elevation tokens (light mode fallbacks)
   These are overridden by stuff-theme.css when available.
   ================================================================ */

:root {
  --stuff-primary: #008153;
  --stuff-on-primary: #fffcfc;
  --stuff-surface: #fffcfc;
  --stuff-surface-container-low: #fffaf5;
  --stuff-surface-container: #fdf5e8;
  --stuff-surface-container-high: #f9edda;
  --stuff-on-surface: #050100;
  --stuff-on-surface-variant: #6b5d4e;
  --stuff-outline: rgba(5, 1, 0, 0.15);
  --stuff-outline-variant: rgba(5, 1, 0, 0.08);
  --stuff-elevation-0: none;
  --stuff-elevation-1: 0 1px 2px rgba(0, 0, 0, 0.18);
  --stuff-elevation-2: 0 2px 6px rgba(0, 0, 0, 0.20);
  --stuff-elevation-3: 0 4px 12px rgba(0, 0, 0, 0.22);
  --stuff-elevation-4: 0 8px 20px rgba(0, 0, 0, 0.24);
  --stuff-elevation-5: 0 12px 28px rgba(0, 0, 0, 0.28);
  --stuff-shape-small: 8px;
  --stuff-shape-medium: 12px;
  --stuff-shape-large: 16px;
  --stuff-shape-extra-large: 28px;
  --stuff-font-family: "Nunito Sans", system-ui, sans-serif;
}

/* ================================================================
   Dark mode token overrides — warm brand-aligned dark surfaces
   (replaces the generic Material purple-grey defaults above)
   ================================================================ */

[data-theme="dark"] {
  /* Surface hierarchy: elevated surfaces are lighter in dark mode */
  --stuff-surface:                #1b1713;
  --stuff-surface-container-low:  #231f1a;
  --stuff-surface-container:      #2c2821;
  --stuff-surface-container-high: #38302a;
  --stuff-on-surface:             #e9ddd2;
  --stuff-on-surface-variant:     #b5a68f;
  --stuff-primary:                #5fc491;
  --stuff-on-primary:             #002d18;
  --stuff-outline:           rgba(181, 166, 143, 0.35);
  --stuff-outline-variant:   rgba(233, 221, 210, 0.10);
  --stuff-elevation-1: 0 1px  2px  rgba(0, 0, 0, 0.50);
  --stuff-elevation-2: 0 2px  6px  rgba(0, 0, 0, 0.55);
  --stuff-elevation-3: 0 4px  12px rgba(0, 0, 0, 0.60);
  --stuff-elevation-4: 0 8px  20px rgba(0, 0, 0, 0.65);
  --stuff-elevation-5: 0 12px 28px rgba(0, 0, 0, 0.70);
}

/* ================================================================
   Base page styles for the window lab
   ================================================================ */

html,
body {
  min-height: 100%;
}

body.window-lab-page {
  margin: 0;
  min-height: 100dvh;
  background: var(--stuff-surface);
  color: var(--stuff-on-surface);
  font-family: var(--stuff-font-family, "Nunito Sans", system-ui, sans-serif);
  display: flex;
  flex-direction: column;
}

/* ================================================================
   Lab chrome — fixture switcher
   ================================================================ */

.fixture-switcher {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--stuff-surface-container, #f3edf7);
  border-bottom: 1px solid var(--stuff-outline-variant, rgba(0, 0, 0, 0.12));
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: var(--stuff-z-dialog, 800);
  flex-wrap: wrap;
}

.fixture-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--stuff-on-surface, #1d1b20);
  margin: 0;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.fixture-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.fixture-btn {
  padding: 4px 14px;
  border: 1px solid var(--stuff-outline, rgba(73, 69, 79, 0.5));
  background: transparent;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--stuff-on-surface, #1d1b20);
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}

.fixture-btn:hover {
  background: var(--stuff-surface-container-high, #ece6f0);
}

.fixture-btn.active {
  background: var(--stuff-primary, #6750a4);
  color: #fff;
  border-color: var(--stuff-primary, #6750a4);
}

#theme-toggle {
  margin-left: auto;
  white-space: nowrap;
  padding: 4px 14px;
  border: 1px solid var(--stuff-outline, rgba(73, 69, 79, 0.5));
  background: transparent;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--stuff-on-surface, #1d1b20);
  font-family: inherit;
  transition: background 0.15s;
}

#theme-toggle:hover {
  background: var(--stuff-surface-container-high, #ece6f0);
}

/* ================================================================
   Fixture root — fills the remaining viewport
   ================================================================ */

.fixture-root {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ================================================================
   stuff-window host layout (light DOM selectors)
   Used when CSS cannot pierce the shadow root via ::slotted
   ================================================================ */

stuff-window {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  position: relative;
}

/* Window header in light DOM */
stuff-window > .window-header,
stuff-window > header {
  position: sticky;
  top: 0;
  z-index: var(--stuff-z-window-header, 300);
  background: var(--stuff-surface-container, #f3edf7);
  box-shadow: var(--stuff-elevation-1, 0 1px 2px rgba(0, 0, 0, 0.18));
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding-block: 0;
  padding-inline-start: 16px;
  padding-inline-end: calc(16px + var(--stuff-window-chrome-end, 0px));
  min-height: 56px;
  margin-inline-start: var(--stuff-window-outer-left-offset, 0px);
  margin-inline-end: var(--stuff-window-outer-right-offset, 0px);
}

/* hide-toolbar attribute: hides the header/toolbar */
stuff-window[hide-toolbar] > .window-header,
stuff-window[hide-toolbar] > header {
  display: none;
}

/* Window body in light DOM */
stuff-window > .window-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
  box-sizing: border-box;
  margin-inline-start: var(--stuff-window-outer-left-offset, 0px);
  margin-inline-end: var(--stuff-window-outer-right-offset, 0px);
  padding-inline-start: var(--stuff-window-inner-left-offset, 0px);
  padding-inline-end: var(--stuff-window-inner-right-offset, 0px);
}

/* Window footer in light DOM */
stuff-window > .window-footer,
stuff-window > footer {
  z-index: var(--stuff-z-window-footer, 300);
  background: var(--stuff-surface-container-low, #f7f2fa);
  border-top: 1px solid var(--stuff-outline-variant, rgba(0, 0, 0, 0.08));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  flex-shrink: 0;
  margin-inline-start: var(--stuff-window-outer-left-offset, 0px);
  margin-inline-end: var(--stuff-window-outer-right-offset, 0px);
}

/* Main in light DOM */
stuff-window main {
  flex: 1;
  min-width: 0;
  background: var(--stuff-surface, #fffbfe);
  padding: 24px;
  box-sizing: border-box;
}

stuff-window main.window-panel-main {
  display: flex;
  padding: 0;
  min-height: 0;
  overflow: hidden;
}

/* stuff-drawer in light DOM — position: absolute removes it from flex flow */
stuff-drawer {
  display: block;
}

/* ================================================================
   Window header inner elements
   ================================================================ */

.window-identity {
  display: flex;
  align-items: center;
  gap: 8px;
}

.window-identity strong {
  font-size: 1rem;
  font-weight: 700;
}

/* ================================================================
   Toolbar button resets used in fixtures
   ================================================================ */

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  color: var(--stuff-on-surface, #1d1b20);
  font-size: 1.1rem;
  padding: 0;
  transition: background 0.15s;
}

.toolbar-btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

.toolbar-btn:focus-visible {
  outline: 2px solid var(--stuff-primary, #6750a4);
  outline-offset: 2px;
}

/* ================================================================
   Status badge used in header fixtures
   ================================================================ */

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  background: var(--stuff-surface-container-high, #ece6f0);
  color: var(--stuff-on-surface, #1d1b20);
}

/* ================================================================
   Full-screen rich cards inside window panels
   ================================================================ */

[data-window-panel] {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.window-panel-card {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 0;
  max-width: none;
  height: 100%;
}

.window-panel-card.is-fullscreen,
.window-panel-card[data-presentation="full-screen"] {
  min-height: 0;
  height: 100%;
}

.window-panel-card[data-presentation="full-screen"] [data-card="container"] {
  min-height: 100%;
  height: 100%;
}

.window-panel-card[data-presentation="full-screen"] [data-card="collapse"] {
  height: 100%;
  min-height: 0;
}

.window-panel-card[data-presentation="full-screen"] [data-card="content"] {
  overflow: auto;
}

.window-panel-nav {
  display: grid;
  gap: 0.75rem;
}

.window-panel-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.window-panel-nav a {
  display: block;
  padding: 0.75rem 0.9rem;
  border-radius: 0.85rem;
  color: inherit;
  text-decoration: none;
  background: color-mix(in srgb, var(--stuff-surface-container) 88%, transparent);
}

.window-panel-nav a[aria-current] {
  background: color-mix(in srgb, var(--stuff-primary) 20%, var(--stuff-surface-container-high));
  font-weight: 700;
}

.window-panel-grid {
  display: grid;
  gap: 0.75rem;
}

.window-panel-toolbox {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 0.75rem;
}

.window-panel-toolbox button {
  padding: 0.9rem;
  border: 1px solid var(--stuff-outline-variant, rgba(0, 0, 0, 0.12));
  border-radius: 0.85rem;
  cursor: pointer;
  background: var(--stuff-surface-container, #f3edf7);
  color: inherit;
  font: inherit;
}
