/* CTRLGRID Material 3 Shared Design System (Google-style layout & tokens, 100% CTRLGRID-branded, zero external CDNs)
 * Build/copy step: Each app bundles this file into its own static/ folder (e.g. static/ctrlgrid-m3.css)
 * along with static/fonts/ (Roboto + Material Symbols Outlined woff2, Apache-2.0) during build or deploy.
 */

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("./fonts/roboto-latin-ext.woff2") format("woff2"),
       url("./fonts/roboto-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Material Symbols Outlined";
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url("./fonts/material-symbols-outlined.woff2") format("woff2");
}

:root {
  color-scheme: light dark;

  /* Core Light Palette (Material 3 / Google Workspace-inspired) */
  --cg-bg: #f8fafd;
  --cg-surface: #ffffff;
  --cg-surface-container: #f0f4f9;
  --cg-surface-container-low: #f6f8fc;
  --cg-surface-container-high: #e9eef6;
  --cg-surface-hover: #e1e8f2;
  --cg-primary: #0b57d0;
  --cg-primary-hover: #0842a0;
  --cg-on-primary: #ffffff;
  --cg-nav-pill-active: #d3e3fd;
  --cg-nav-pill-active-text: #041e49;
  --cg-selection: #c2e7ff;
  --cg-selection-text: #001d35;
  --cg-outline: #c4c7c5;
  --cg-outline-variant: #e0e3e7;
  --cg-text: #1f1f1f;
  --cg-text-secondary: #444746;
  --cg-text-muted: #5f6368;
  --cg-error: #b3261e;
  --cg-error-container: #fce8e6;
  --cg-success: #137333;
  --cg-success-container: #e6f4ea;
  --cg-warning: #b06000;
  --cg-warning-container: #fef7e0;

  /* Typography */
  --cg-font-sans: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --cg-font-mono: "JetBrains Mono", "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --cg-text-body: 14px;
  --cg-text-sm: 13px;
  --cg-text-xs: 12px;
  --cg-text-title: 18px;
  --cg-text-headline: 22px;

  /* Radii */
  --cg-radius-xs: 6px;
  --cg-radius-sm: 8px;
  --cg-radius-md: 12px;
  --cg-radius-card: 16px;
  --cg-radius-search: 28px;
  --cg-radius-fab: 28px;
  --cg-radius-pill: 100px;

  /* Elevation Shadows */
  --cg-shadow-1: 0 1px 2px rgba(0, 0, 0, 0.08), 0 1px 3px 1px rgba(0, 0, 0, 0.05);
  --cg-shadow-2: 0 2px 6px 2px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.12);
  --cg-shadow-3: 0 4px 12px 3px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.14);
  --cg-shadow-fab: 0 1px 3px rgba(0, 0, 0, 0.18), 0 4px 8px 3px rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --cg-bg: #1b1b1b;
    --cg-surface: #1f1f1f;
    --cg-surface-container: #282a2c;
    --cg-surface-container-low: #232426;
    --cg-surface-container-high: #303134;
    --cg-surface-hover: #383a3e;
    --cg-primary: #a8c7fa;
    --cg-primary-hover: #c2d9ff;
    --cg-on-primary: #062e6f;
    --cg-nav-pill-active: #004a77;
    --cg-nav-pill-active-text: #c2e7ff;
    --cg-selection: #004a77;
    --cg-selection-text: #c2e7ff;
    --cg-outline: #444746;
    --cg-outline-variant: #333537;
    --cg-text: #e3e3e3;
    --cg-text-secondary: #c4c7c5;
    --cg-text-muted: #9aa0a6;
    --cg-error: #f2b8b5;
    --cg-error-container: #5c1916;
    --cg-success: #81c995;
    --cg-success-container: #133a22;
    --cg-warning: #fdd663;
    --cg-warning-container: #4a3500;
    --cg-shadow-1: 0 1px 3px rgba(0, 0, 0, 0.4);
    --cg-shadow-2: 0 3px 10px rgba(0, 0, 0, 0.5);
    --cg-shadow-3: 0 8px 24px rgba(0, 0, 0, 0.6);
    --cg-shadow-fab: 0 3px 12px rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme="dark"] {
  --cg-bg: #1b1b1b;
  --cg-surface: #1f1f1f;
  --cg-surface-container: #282a2c;
  --cg-surface-container-low: #232426;
  --cg-surface-container-high: #303134;
  --cg-surface-hover: #383a3e;
  --cg-primary: #a8c7fa;
  --cg-primary-hover: #c2d9ff;
  --cg-on-primary: #062e6f;
  --cg-nav-pill-active: #004a77;
  --cg-nav-pill-active-text: #c2e7ff;
  --cg-selection: #004a77;
  --cg-selection-text: #c2e7ff;
  --cg-outline: #444746;
  --cg-outline-variant: #333537;
  --cg-text: #e3e3e3;
  --cg-text-secondary: #c4c7c5;
  --cg-text-muted: #9aa0a6;
  --cg-error: #f2b8b5;
  --cg-error-container: #5c1916;
  --cg-success: #81c995;
  --cg-success-container: #133a22;
  --cg-warning: #fdd663;
  --cg-warning-container: #4a3500;
  --cg-shadow-1: 0 1px 3px rgba(0, 0, 0, 0.4);
  --cg-shadow-2: 0 3px 10px rgba(0, 0, 0, 0.5);
  --cg-shadow-3: 0 8px 24px rgba(0, 0, 0, 0.6);
  --cg-shadow-fab: 0 3px 12px rgba(0, 0, 0, 0.55);
}

/* Material Symbols Helper */
.material-symbols-outlined {
  font-family: "Material Symbols Outlined", sans-serif;
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* Reusable M3 Primitives */
.cg-m3-card {
  background: var(--cg-surface);
  border: 1px solid var(--cg-outline-variant);
  border-radius: var(--cg-radius-card);
  box-shadow: var(--cg-shadow-1);
}

.cg-m3-search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--cg-surface-container);
  border: 1px solid transparent;
  border-radius: var(--cg-radius-search);
  padding: 0 16px;
  height: 46px;
  transition: background 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.cg-m3-search:focus-within {
  background: var(--cg-surface);
  border-color: var(--cg-outline-variant);
  box-shadow: var(--cg-shadow-2);
}

.cg-m3-nav-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--cg-radius-pill);
  color: var(--cg-text-secondary);
  font-size: var(--cg-text-body);
  font-weight: 500;
  text-decoration: none;
  border: none;
  background: transparent;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 120ms ease, color 120ms ease;
}

.cg-m3-nav-pill:hover {
  background: var(--cg-surface-hover);
  color: var(--cg-text);
}

.cg-m3-nav-pill.active,
.cg-m3-nav-pill[aria-current="page"] {
  background: var(--cg-nav-pill-active);
  color: var(--cg-nav-pill-active-text);
  font-weight: 600;
}

.cg-m3-fab {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 22px 0 16px;
  border-radius: var(--cg-radius-fab);
  border: none;
  background: var(--cg-nav-pill-active);
  color: var(--cg-nav-pill-active-text);
  font-family: var(--cg-font-sans);
  font-size: var(--cg-text-body);
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--cg-shadow-fab);
  transition: box-shadow 140ms ease, filter 140ms ease, transform 120ms ease;
}

.cg-m3-fab:hover {
  box-shadow: var(--cg-shadow-3);
  filter: brightness(0.98);
}

.cg-m3-btn-filled {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 20px;
  border-radius: var(--cg-radius-pill);
  border: none;
  background: var(--cg-primary);
  color: var(--cg-on-primary);
  font-family: var(--cg-font-sans);
  font-size: var(--cg-text-body);
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, box-shadow 120ms ease;
}

.cg-m3-btn-filled:hover {
  background: var(--cg-primary-hover);
  box-shadow: var(--cg-shadow-1);
}

.cg-m3-btn-tonal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 18px;
  border-radius: var(--cg-radius-pill);
  border: none;
  background: var(--cg-nav-pill-active);
  color: var(--cg-nav-pill-active-text);
  font-family: var(--cg-font-sans);
  font-size: var(--cg-text-body);
  font-weight: 500;
  cursor: pointer;
}

.cg-m3-btn-outlined {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 18px;
  border-radius: var(--cg-radius-pill);
  border: 1px solid var(--cg-outline);
  background: transparent;
  color: var(--cg-primary);
  font-family: var(--cg-font-sans);
  font-size: var(--cg-text-body);
  font-weight: 500;
  cursor: pointer;
}

.cg-m3-btn-outlined:hover {
  background: var(--cg-surface-container);
}

.cg-m3-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--cg-radius-sm);
  border: 1px solid var(--cg-outline);
  background: var(--cg-surface);
  color: var(--cg-text-secondary);
  font-size: var(--cg-text-sm);
  font-weight: 500;
  cursor: pointer;
}

.cg-m3-chip.active {
  background: var(--cg-nav-pill-active);
  border-color: transparent;
  color: var(--cg-nav-pill-active-text);
}
