/*
 * DEV3 Motion Core - glass.css
 * Design tokens + the glass / form / toast primitives shared by every template.
 *
 * THEMING
 *   Set <html data-theme="dark|light|warm|cool">  (default: dark)
 *     dark  - near-black glass, neutral
 *     light - frosted white glass on a light page
 *     warm  - "room backdrop" glass: amber-tinted panels meant to sit over a blurred warm photo
 *     cool  - blue glass for cold light-streak scenes
 *   Override any token on :root (or on one element) to re-colour a template, for example:
 *     :root { --accent: #6ee7b7; }
 *   Colours are plain CSS variables, nothing is compiled.
 */

/* ---------- Tokens ---------- */
:root {
  /* brand */
  --accent: #ff6a3d;
  --accent-ink: #1a0d06;          /* text colour on top of --accent */
  --ok: #3ddc84;
  --warn: #ffb020;
  --danger: #ff5468;

  /* surface + text */
  --bg: #09090b;
  --text: #f5f3f0;
  --muted: #8f8c89;
  --line: rgba(255, 255, 255, .1);
  --field: rgba(255, 255, 255, .045);
  --field-focus: rgba(255, 255, 255, .07);

  /* glass */
  --glass-tint-a: rgba(58, 58, 64, .5);   /* top-left of the panel gradient */
  --glass-tint-b: rgba(22, 22, 26, .62);  /* bottom-right */
  --glass-blur: 22px;
  --glass-saturate: 150%;
  --glass-edge: rgba(255, 255, 255, .1);          /* 1px border */
  --glass-highlight: rgba(255, 255, 255, .09);    /* inner top edge light */
  --glass-shadow: 0 50px 100px -30px rgba(0, 0, 0, .85);
  --noise-opacity: .05;

  /* shape + type */
  --radius: 24px;
  --radius-sm: 12px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* motion */
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);

  /* chart palette (used by charts.js) */
  --chart-1: var(--accent);
  --chart-2: #5b7cff;
  --chart-3: #3ddc84;
  --chart-4: #ffb020;
  --chart-5: #c084fc;
  --chart-grid: rgba(255, 255, 255, .08);
  --chart-text: var(--muted);

  color-scheme: dark;
}

:root[data-theme="light"] {
  --accent: #4f46e5;
  --accent-ink: #fff;
  --bg: #eef0f5;
  --text: #14151a;
  --muted: #5d6270;
  --line: rgba(20, 21, 26, .12);
  --field: rgba(255, 255, 255, .6);
  --field-focus: rgba(255, 255, 255, .9);
  --glass-tint-a: rgba(255, 255, 255, .78);
  --glass-tint-b: rgba(255, 255, 255, .5);
  --glass-blur: 24px;
  --glass-saturate: 170%;
  --glass-edge: rgba(255, 255, 255, .85);
  --glass-highlight: rgba(255, 255, 255, 1);
  --glass-shadow: 0 40px 80px -30px rgba(40, 50, 90, .35);
  --noise-opacity: .035;
  --chart-grid: rgba(20, 21, 26, .09);
  color-scheme: light;
}

:root[data-theme="warm"] {          /* "room backdrop": amber glass over a blurred warm photo */
  --accent: #ffb36b;
  --accent-ink: #26140a;
  --bg: #1a1210;
  --text: #fff4e8;
  --muted: #c9ae98;
  --line: rgba(255, 226, 190, .16);
  --field: rgba(255, 236, 214, .08);
  --field-focus: rgba(255, 236, 214, .13);
  --glass-tint-a: rgba(120, 76, 44, .34);
  --glass-tint-b: rgba(60, 34, 20, .42);
  --glass-blur: 26px;
  --glass-saturate: 160%;
  --glass-edge: rgba(255, 226, 190, .22);
  --glass-highlight: rgba(255, 236, 214, .22);
  --glass-shadow: 0 40px 90px -30px rgba(20, 8, 0, .7);
  --chart-2: #ff7a59;
  --chart-3: #ffd27a;
  --chart-4: #8ad7c1;
  --chart-5: #f09bb8;
}

:root[data-theme="cool"] {          /* cold blue glass for light-streak scenes */
  --accent: #5b8cff;
  --accent-ink: #04112e;
  --bg: #050a18;
  --text: #eaf1ff;
  --muted: #8a9bbd;
  --line: rgba(150, 185, 255, .18);
  --field: rgba(140, 175, 255, .07);
  --field-focus: rgba(140, 175, 255, .12);
  --glass-tint-a: rgba(60, 100, 200, .26);
  --glass-tint-b: rgba(15, 30, 80, .46);
  --glass-blur: 24px;
  --glass-saturate: 180%;
  --glass-edge: rgba(150, 190, 255, .28);
  --glass-highlight: rgba(190, 215, 255, .28);
  --glass-shadow: 0 50px 100px -30px rgba(0, 10, 50, .8);
  --chart-2: #7ef0d0;
  --chart-3: #b9a2ff;
  --chart-4: #ffd27a;
  --chart-5: #ff8fb0;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html, body { min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg, canvas { max-width: 100%; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* Full-screen WebGL canvas. If WebGL is missing scene.js adds .no-webgl to <body>: hide the canvas and show your CSS fallback. */
.scene-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
body.no-webgl .scene-canvas { display: none; }
body.no-webgl { background: radial-gradient(circle at 25% 20%, color-mix(in srgb, var(--accent) 22%, var(--bg)), var(--bg) 62%); }

/* ---------- Focus (keyboard only) ---------- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px;
}
:where(input, textarea, select):focus-visible { outline-offset: 0; }

/* ---------- Glass surfaces ---------- */
.glass {
  position: relative; border-radius: var(--radius);
  background: linear-gradient(155deg, var(--glass-tint-a), var(--glass-tint-b));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-highlight), inset 0 -1px 0 rgba(0, 0, 0, .25);
}
/* Edge highlight: a 1px gradient ring that catches light on the top-left. Add .glass--edge, and set --glow (0..1) if you want it to react to a light. */
.glass--edge::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(120deg, color-mix(in srgb, var(--accent) calc(var(--glow, .35) * 70%), rgba(255, 255, 255, .35)), transparent 45%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
}
/* Film grain on top of a surface; adds the "frosted" feel and hides gradient banding. */
.glass--noise::after, .noise::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: var(--noise-opacity); mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
.noise { position: relative; }
.glass--sm { --radius: 16px; --glass-blur: 14px; }
.glass--pad { padding: 28px; }

/* ---------- Typography helpers ---------- */
.title { font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; }
.sub { color: var(--muted); font-size: 14px; line-height: 1.55; }
.eyebrow { font-size: 11px; letter-spacing: .3em; text-transform: uppercase; color: var(--muted); }
.link { color: var(--accent); text-decoration: none; border-radius: 4px; }
.link:hover { text-decoration: underline; }

/* ---------- Buttons ---------- */
.btn {
  position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 48px; padding: 0 22px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer;
  font-weight: 600; font-size: 15px; letter-spacing: .01em; transition: filter .2s, background .2s, opacity .2s, transform .2s var(--ease-out);
}
.btn:disabled { opacity: .45; cursor: default; }
.btn--block { width: 100%; }
.btn--primary {
  color: var(--accent-ink);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 100%, #fff 22%), var(--accent));
  box-shadow: 0 10px 30px -10px var(--accent), inset 0 1px 0 rgba(255, 255, 255, .45);
}
.btn--primary:not(:disabled):hover { filter: brightness(1.07); }
.btn--ghost { background: color-mix(in srgb, var(--text) 5%, transparent); color: var(--text); border-color: var(--line); }
.btn--ghost:not(:disabled):hover { background: color-mix(in srgb, var(--text) 10%, transparent); }
.btn--icon { width: 40px; height: 40px; padding: 0; border-radius: 12px; }
.btn .spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor; animation: dev3-spin .7s linear infinite; display: none; }
.btn.loading .spinner { display: block; }
.btn.loading .label { opacity: .7; }
@keyframes dev3-spin { to { transform: rotate(360deg); } }

/* ---------- Form fields ---------- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.control { position: relative; }
.input {
  width: 100%; height: 46px; padding: 0 44px 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--field); color: var(--text); font-size: 15px; outline: none; transition: border-color .2s, box-shadow .2s, background .2s;
}
.input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.input:focus { border-color: color-mix(in srgb, var(--accent) 70%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); background: var(--field-focus); }
.field.invalid .input { border-color: var(--danger); }
.error { display: none; color: var(--danger); font-size: 12px; margin-top: 6px; }
.field.invalid .error { display: block; }
.eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 8px; display: grid; place-items: center; }
.eye:hover { color: var(--text); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

/* ---------- Segmented tabs with a sliding indicator (ui.js tabs / motion.js slidingIndicator) ---------- */
.tabs { position: relative; display: inline-flex; gap: 2px; padding: 4px; border-radius: 14px; background: var(--field); border: 1px solid var(--line); }
.tab { position: relative; z-index: 1; background: none; border: 0; padding: 9px 16px; border-radius: 10px; cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 500; transition: color .2s; }
.tab[aria-selected="true"] { color: var(--text); }
.tab-indicator { position: absolute; z-index: 0; left: 0; top: 4px; bottom: 4px; width: 0; border-radius: 10px; background: color-mix(in srgb, var(--text) 12%, transparent); box-shadow: inset 0 1px 0 var(--glass-highlight); pointer-events: none; }

/* ---------- Toasts (motion.js toast) ---------- */
.toast-stack { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 10px; align-items: center; z-index: 1000; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
body[data-toast="top"] .toast-stack { bottom: auto; top: 24px; }
.toast {
  background: color-mix(in srgb, var(--bg) 88%, transparent); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  padding: 12px 18px; border-radius: 12px; font-size: 14px; color: var(--text); box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .6);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.toast[data-type="ok"] { border-left-color: var(--ok); }
.toast[data-type="error"] { border-left-color: var(--danger); }
.toast[data-type="warn"] { border-left-color: var(--warn); }

/* ---------- Success burst particles (motion.js successBurst) ---------- */
.burst-bit { position: fixed; left: 0; top: 0; width: 8px; height: 8px; border-radius: 50%; pointer-events: none; z-index: 999; will-change: transform; }

/* ---------- Reduced motion ---------- */
/* One rule that makes every CSS animation/transition effectively instant. GSAP helpers check reduceMotion themselves. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
