/* ==========================================================================
   OrchidLLM — Material 3 Expressive foundation (shared by every surface)
   Load LAST, after page stylesheets. Colors below are the static fallback
   generated by M3E 2.13.2 <m3e-theme color="#8b5cf6" variant="vibrant">.
   js/orchid-theme.js regenerates them at runtime from the tier seed.
   ========================================================================== */

/* ---------- Color ----------
   Surfaces are NEUTRAL (near-black / near-white greys): light/dark mode decides them and
   nothing else tints them. Only the accent roles (primary / secondary / tertiary) carry
   colour; js/orchid-theme.js re-seeds those from the plan accent at runtime.
   m3e-theme wrappers (chat) are included so their generated purple surfaces are replaced:
   these outer declarations beat the component's own :host values. */
:root,
m3e-theme {
  color-scheme: dark;
  --md-sys-color-background: #0f0e13;
  --md-sys-color-on-background: #ececf1;
  --md-sys-color-surface: #0f0e13;
  --md-sys-color-surface-dim: #0f0e13;
  --md-sys-color-surface-bright: #2c2b31;
  --md-sys-color-surface-container-lowest: #0a090d;
  --md-sys-color-surface-container-low: #151419;
  --md-sys-color-surface-container: #1b1a20;
  --md-sys-color-surface-container-high: #232228;
  --md-sys-color-surface-container-highest: #2b2a31;
  --md-sys-color-surface-variant: #2b2a31;
  --md-sys-color-on-surface: #ececf1;
  --md-sys-color-on-surface-variant: #a9a7b3;
  --md-sys-color-outline: #77757f;
  --md-sys-color-outline-variant: #3a3941;
  --md-sys-color-inverse-surface: #e6e5ea;
  --md-sys-color-inverse-on-surface: #2f2e34;
}

:root {
  --md-sys-color-inverse-primary: #6e39db;
  --md-sys-color-primary: #ba9eff;
  --md-sys-color-on-primary: #39008c;
  --md-sys-color-primary-container: #ae8dff;
  --md-sys-color-on-primary-container: #2b006e;
  --md-sys-color-secondary: #c08cf7;
  --md-sys-color-on-secondary: #390068;
  --md-sys-color-secondary-container: #5e2c91;
  --md-sys-color-on-secondary-container: #e3c4ff;
  --md-sys-color-tertiary: #ff97b5;
  --md-sys-color-on-tertiary: #6a0934;
  --md-sys-color-tertiary-container: #fd81a8;
  --md-sys-color-on-tertiary-container: #59002a;
  --md-sys-color-error: #ff6e84;
  --md-sys-color-on-error: #490013;
  --md-sys-color-error-container: #a70138;
  --md-sys-color-on-error-container: #ffb2b9;
  --md-sys-color-success: #8fe0a8;
  --md-sys-color-on-success: #00391c;
  --md-sys-color-warning: #ffd08a;
  --md-sys-color-on-warning: #462a00;
  --md-sys-color-shadow: #000;
  --md-sys-color-scrim: #000;
}


:root[data-theme="light"],
:root[data-theme="light"] m3e-theme {
  color-scheme: light;
  --md-sys-color-background: #f7f7f9;
  --md-sys-color-on-background: #1b1b1f;
  --md-sys-color-surface: #f7f7f9;
  --md-sys-color-surface-dim: #dcdce0;
  --md-sys-color-surface-bright: #ffffff;
  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-low: #f1f1f4;
  --md-sys-color-surface-container: #ebebef;
  --md-sys-color-surface-container-high: #e5e5ea;
  --md-sys-color-surface-container-highest: #dfdfe5;
  --md-sys-color-surface-variant: #dfdfe5;
  --md-sys-color-on-surface: #1b1b1f;
  --md-sys-color-on-surface-variant: #5d5c66;
  --md-sys-color-outline: #8a8994;
  --md-sys-color-outline-variant: #d0ced7;
  --md-sys-color-inverse-surface: #2f2f33;
  --md-sys-color-inverse-on-surface: #f2f1f5;
}

:root[data-theme="light"] {
  --md-sys-color-inverse-primary: #a078ff;
  --md-sys-color-primary: #6b34d8;
  --md-sys-color-on-primary: #f8f0ff;
  --md-sys-color-primary-container: #ae8dff;
  --md-sys-color-on-primary-container: #2b006e;
  --md-sys-color-secondary: #7443a8;
  --md-sys-color-on-secondary: #fbefff;
  --md-sys-color-secondary-container: #e4c6ff;
  --md-sys-color-on-secondary-container: #5f2d92;
  --md-sys-color-tertiary: #9d365b;
  --md-sys-color-on-tertiary: #ffeff1;
  --md-sys-color-tertiary-container: #ff8eb0;
  --md-sys-color-on-tertiary-container: #640430;
  --md-sys-color-error: #b41340;
  --md-sys-color-on-error: #ffefef;
  --md-sys-color-error-container: #f74b6d;
  --md-sys-color-on-error-container: #510017;
  --md-sys-color-success: #1b6d3b;
  --md-sys-color-on-success: #ffffff;
  --md-sys-color-warning: #7a5000;
  --md-sys-color-on-warning: #ffffff;
}


/* ---------- Shape, type, motion, elevation ---------- */
:root {
  /* M3 Expressive corner scale (spec names) */
  --m3x-corner-xs: 4px;
  --m3x-corner-s: 8px;
  --m3x-corner-m: 12px;
  --m3x-corner-l: 16px;
  --m3x-corner-l-plus: 20px;
  --m3x-corner-xl: 28px;
  --m3x-corner-xl-plus: 32px;
  --m3x-corner-xxl: 48px;
  --m3x-corner-full: 9999px;

  /* Typography: one variable family, rounded for display */
  --m3x-font-brand: "Google Sans Flex", "Google Sans", system-ui, sans-serif;
  --m3x-font-plain: "Google Sans Flex", "Google Sans Text", system-ui, sans-serif;
  --m3x-font-mono: "Roboto Mono", ui-monospace, monospace;
  --md-sys-typescale-display-font: var(--m3x-font-brand);
  --md-sys-typescale-body-font: var(--m3x-font-plain);

  /* Springs (from M3E motion="expressive") */
  --md-sys-motion-spring-fast-spatial: 350ms linear(0, 0.0017 0.6%, 0.0079 1.3%, 0.0164 1.9%, 0.0298 2.6%, 0.0665 4%, 0.1178 5.5%, 0.1742 6.9%, 0.2412 8.4%, 0.5471 14.7%, 0.6213 16.3%, 0.6871 17.8%, 0.7523 19.4%, 0.8119 21%, 0.8655 22.6%, 0.9129 24.2%, 0.9564 25.9%, 0.995 27.7%, 1.0264 29.5%, 1.0521 31.4%, 1.071 33.3%, 1.0843 35.3%, 1.0922 37.4%, 1.0948 39.7%, 1.0919 42.3%, 1.0835 45.2%, 1.0299 57.4%, 1.0082 63.9%, 0.9951 71%, 0.991 79.3%, 0.9982 99.9%, 1);
  --md-sys-motion-spring-default-spatial: 500ms linear(0, 0.0012 0.5%, 0.0054 1.1%, 0.0112 1.6%, 0.0205 2.2%, 0.046 3.4%, 0.0644 4.1%, 0.0851 4.8%, 0.1248 6%, 0.1762 7.4%, 0.2394 9%, 0.3995 12.9%, 0.4754 14.8%, 0.551 16.8%, 0.6176 18.7%, 0.6874 20.9%, 0.7492 23.1%, 0.8027 25.3%, 0.8502 27.6%, 0.8717 28.8%, 0.8928 30.1%, 0.9115 31.4%, 0.928 32.7%, 0.9571 35.5%, 0.9792 38.4%, 0.9953 41.5%, 1.0066 45%, 1.0131 49%, 1.0152 53.7%, 1.0029 79.4%, 0.9999 99.9%, 1);
  --md-sys-motion-spring-fast-effects: 150ms linear(0, 0.0048 1.1%, 0.0197 2.3%, 0.0445 3.6%, 0.0817 5.1%, 0.1162 6.3%, 0.16 7.7%, 0.3647 13.8%, 0.4629 16.9%, 0.5129 18.6%, 0.557 20.2%, 0.5982 21.8%, 0.6365 23.4%, 0.6718 25%, 0.7062 26.7%, 0.7376 28.4%, 0.7661 30.1%, 0.7932 31.9%, 0.8175 33.7%, 0.8404 35.6%, 0.8606 37.5%, 0.8811 39.7%, 0.8988 41.9%, 0.9152 44.3%, 0.9297 46.8%, 0.9426 49.5%, 0.9537 52.3%, 0.9713 58.5%, 0.9833 65.4%, 0.9914 73.7%, 0.996 83.1%, 1);
  --m3x-spring-fast: var(--md-sys-motion-spring-fast-spatial);
  --m3x-spring: var(--md-sys-motion-spring-default-spatial);
  --m3x-fade: var(--md-sys-motion-spring-fast-effects);
  --m3x-shape-morph: 200ms cubic-bezier(0.2, 0, 0, 1); /* no overshoot: springs on border-radius flash square corners */
  --md-sys-motion-easing-emphasized: cubic-bezier(0.2, 0, 0, 1);
  --md-sys-motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);

  --md-sys-elevation-1: 0 1px 2px rgb(0 0 0 / .3), 0 1px 3px 1px rgb(0 0 0 / .15);
  --md-sys-elevation-2: 0 1px 2px rgb(0 0 0 / .3), 0 2px 6px 2px rgb(0 0 0 / .15);
  --md-sys-elevation-3: 0 4px 8px 3px rgb(0 0 0 / .15), 0 1px 3px rgb(0 0 0 / .3);

  /* ---- Alias layer: legacy page tokens now read the shared scheme ---- */
  --font: var(--m3x-font-plain);
  --font-display: var(--m3x-font-brand);
  --font-body: var(--m3x-font-plain);
  --font-mono: var(--m3x-font-mono);
  --ease-emph: var(--md-sys-motion-easing-emphasized);
  --spring: cubic-bezier(0.34, 1.36, 0.64, 1);
}

/* Chat's shorthand palette — same specificity as reference.css [data-theme] */
:root,
:root[data-theme="dark"],
:root[data-theme="light"] {
  --p: var(--md-sys-color-primary);
  --on-p: var(--md-sys-color-on-primary);
  --pc: var(--md-sys-color-primary-container);
  --on-pc: var(--md-sys-color-on-primary-container);
  --s: var(--md-sys-color-secondary);
  --on-s: var(--md-sys-color-on-secondary);
  --sc: var(--md-sys-color-secondary-container);
  --on-sc: var(--md-sys-color-on-secondary-container);
  --t: var(--md-sys-color-tertiary);
  --on-t: var(--md-sys-color-on-tertiary);
  --tc: var(--md-sys-color-tertiary-container);
  --on-tc: var(--md-sys-color-on-tertiary-container);
  --bg: var(--md-sys-color-surface);
  --on-bg: var(--md-sys-color-on-surface);
  --surf: var(--md-sys-color-surface-container-low);
  --on-surf: var(--md-sys-color-on-surface);
  --surf-v: var(--md-sys-color-surface-variant);
  --on-surf-v: var(--md-sys-color-on-surface-variant);
  --on-surf-variant: var(--md-sys-color-on-surface-variant);
  --surf-lo: var(--md-sys-color-surface-container-low);
  --surf-mid: var(--md-sys-color-surface-container);
  --surf-hi: var(--md-sys-color-surface-container-high);
  --surf-hst: var(--md-sys-color-surface-container-highest);
  --out: var(--md-sys-color-outline);
  --out-v: var(--md-sys-color-outline-variant);
  --err: var(--md-sys-color-error);
  --err-c: var(--md-sys-color-error-container);
  --r-pill: var(--m3x-corner-full);
  --r-full: var(--m3x-corner-full);
  --r-xl: var(--m3x-corner-xl);
  --r-lg: var(--m3x-corner-l-plus);
  --r-md: var(--m3x-corner-l);
  --r-sm: var(--m3x-corner-m);
  --r-xs: var(--m3x-corner-s);
}

/* ==========================================================================
   Base
   ========================================================================== */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--m3x-font-plain);
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  -webkit-font-smoothing: antialiased;
  font-optical-sizing: auto;
}
h1, h2, h3,
.view-title, .page-title, .section-title, .sec-title {
  font-family: var(--m3x-font-brand);
  font-variation-settings: "ROND" 100;
  letter-spacing: -0.01em;
}
h1 { font-weight: 600; }
code, kbd, pre, samp { font-family: var(--m3x-font-mono); }

/* Rounded symbols everywhere: softer, matches expressive shapes */
.material-symbols-outlined,
.material-symbols-rounded,
.ms {
  font-family: "Material Symbols Rounded" !important;
  font-variation-settings: "FILL" 0, "wght" 450, "GRAD" 0, "opsz" 24;
  transition: font-variation-settings var(--m3x-fade);
}

::selection { background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); }

:focus-visible {
  outline: 3px solid var(--md-sys-color-secondary);
  outline-offset: 2px;
}

/* Thin tonal scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--md-sys-color-outline-variant) transparent; }

/* Shared press feedback: corners tighten and the target squishes slightly
   (M3 Expressive "shape morph" on press). Opt-in via .m3x-press or the
   common button classes below. */
.m3x-press,
.btn, .live-button, .oauth-btn, .subcard-action-btn, .view-more-usage-btn,
.booster-show-more-btn, .new-chat-btn, .temp-btn, .icon-btn, .filter-chip,
.f-chip, .quick-link-item, .nav-rail-item, .bottom-nav-item, .tool-nav-item {
  /* border-radius must NOT use the spring: its overshoot dips the radius below
     zero for a frame and pill buttons flash square on hover/press. */
  transition:
    border-radius var(--m3x-shape-morph),
    transform var(--m3x-spring-fast),
    background-color var(--m3x-fade),
    color var(--m3x-fade),
    box-shadow var(--m3x-fade);
}
.m3x-press:active,
.btn:active, .live-button:active, .oauth-btn:active:not(:disabled),
.subcard-action-btn:active, .view-more-usage-btn:active, .booster-show-more-btn:active,
.new-chat-btn:active, .temp-btn:active, .filter-chip:active, .f-chip:active {
  border-radius: var(--m3x-corner-m) !important;
  transform: scale(0.97);
}
.icon-btn:active { transform: scale(0.9); }

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