/* ==========================================================================
   Win11 Shell — base styles: reset, type ramp, materials, scrollbars, focus
   Owned by ui-core.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg-solid-base);
}

body {
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: var(--fw-regular);
  color: var(--text-1);
  background: var(--bg-solid-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-optical-sizing: auto;
  /* Shell UI text is not selectable, like Windows. Inputs and .selectable opt in. */
  -webkit-user-select: none;
  user-select: none;
  cursor: default;
  overflow: hidden;
}

#root { height: 100%; }

input, textarea, [contenteditable="true"], .selectable, .selectable * {
  -webkit-user-select: text;
  user-select: text;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}
button { cursor: default; }
img, svg { display: block; }
img { -webkit-user-drag: none; }
a { color: var(--accent-fg); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: var(--fw-semibold); }
ul, ol { margin: 0; padding: 0; }
[hidden] { display: none !important; }

::selection { background: var(--selection-bg); color: var(--selection-text); }

/* ---- Surfaces ------------------------------------------------------------ */
html[data-surface="shell"],
html[data-surface="shell"] body,
html[data-surface="shell"] #root {
  background: transparent !important;
}
html[data-surface="desktop"],
html[data-surface="desktop"] body { background: #000; }
html[data-surface="preview"],
html[data-surface="preview"] body { background: #000; }
html[data-surface="app"],
html[data-surface="app"] body { background: transparent; }
html[data-surface="app"][data-blur="none"],
html[data-surface="app"][data-blur="none"] body { background: var(--bg-mica-solid); }
html[data-surface="gallery"] body { overflow: auto; }

/* Preview layout: desktop (z0) · window manager (z10) · shell (z100) */
#desktop-layer, #wm-layer, #shell-layer {
  position: fixed;
  inset: 0;
}
#desktop-layer { z-index: var(--z-desktop); }
#wm-layer { z-index: var(--z-windows); pointer-events: none; }
#wm-layer > * { pointer-events: auto; }
#shell-layer { z-index: var(--z-shell); pointer-events: none; }
#shell-layer [data-region] { pointer-events: auto; }
html[data-surface="shell"] body { pointer-events: none; }
html[data-surface="shell"] [data-region] { pointer-events: auto; }

/* ---- Type ramp -------------------------------------------------------- */
.caption      { font-size: var(--fs-caption); line-height: var(--lh-caption); font-weight: var(--fw-regular); }
.body         { font-size: var(--fs-body); line-height: var(--lh-body); font-weight: var(--fw-regular); }
.body-strong  { font-size: var(--fs-body); line-height: var(--lh-body); font-weight: var(--fw-semibold); }
.body-large   { font-size: var(--fs-body-large); line-height: var(--lh-body-large); font-weight: var(--fw-regular); }
.subtitle     { font-size: var(--fs-subtitle); line-height: var(--lh-subtitle); font-weight: var(--fw-semibold); font-family: var(--font-display); }
.title        { font-size: var(--fs-title); line-height: var(--lh-title); font-weight: var(--fw-semibold); font-family: var(--font-display); }
.title-large  { font-size: var(--fs-title-large); line-height: var(--lh-title-large); font-weight: var(--fw-semibold); font-family: var(--font-display); }
.display      { font-size: var(--fs-display); line-height: var(--lh-display); font-weight: var(--fw-semibold); font-family: var(--font-display); }

.text-1 { color: var(--text-1); }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.text-disabled { color: var(--text-disabled); }
.text-accent { color: var(--accent-fg); }
.text-success { color: var(--sys-success); }
.text-caution { color: var(--sys-caution); }
.text-critical { color: var(--sys-critical); }
.mono { font-family: var(--font-mono); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---- Materials (SPEC §8.1 frosted glass) --------------------------------
   Tokens: tokens.css (--acrylic-*, --mica-*, --taskbar-*; they already switch
   per html[data-blur] and per light/dark, so these recipes are mode-free):
     .acrylic           menus, popups, tooltips, dialogs, flyouts, toasts:
                        tint over luminosity + noise grain + 1px top-lit stroke,
                        blur 60 / saturate 180 % (in the page when data-blur=css,
                        and for in-app overlays on app surfaces)
     .mica / .mica-alt  window backgrounds / tab rows: tint, blur 80 / saturate 150 %
     .taskbar-material  taskbar: tint + noise + 1px top border, blur 50 / saturate 160 %
   data-blur="none" (transparency off) → the same rules paint solid colours.
   data-backdrop="none" (the host's WebKit cannot blur in the page) → data-blur
   "css" becomes "none"; on app surfaces .acrylic paints the solid colours.
   IMPORTANT for animations: Chrome/WebKit switch backdrop blur off while an
   element or one of its ANCESTORS has opacity < 1 (or a filter/mask/clip-path).
   Animate only transform (and clip-path on the frosted element itself); fade
   its content instead — see fadeContent()/fadeTargets() in js/core/dom.js.
   ------------------------------------------------------------------------ */
.acrylic {
  background-color: transparent;
  background-image:
    var(--acrylic-noise),
    linear-gradient(to bottom, var(--acrylic-stroke) 0, var(--acrylic-stroke) 1px, transparent 1px),
    linear-gradient(var(--acrylic-tint), var(--acrylic-tint)),
    linear-gradient(var(--acrylic-luminosity), var(--acrylic-luminosity));
}
.mica       { background-color: var(--mica-tint); }
.mica-alt   { background-color: var(--mica-alt-tint); }
.taskbar-material,
.acrylic-base {                                 /* .acrylic-base: older alias */
  background-color: transparent;
  background-image:
    var(--acrylic-noise),
    linear-gradient(to bottom, var(--taskbar-stroke) 0, var(--taskbar-stroke) 1px, transparent 1px),
    linear-gradient(var(--taskbar-tint), var(--taskbar-tint));
}
.smoke      { background-color: var(--bg-smoke); }
.card       { background-color: var(--bg-card); border: 1px solid var(--stroke-card); border-radius: var(--radius-card); }
.layer      { background-color: var(--bg-layer); }

:root[data-blur="css"] .acrylic,
:root[data-blur="compositor"][data-surface="app"]:not([data-backdrop="none"]) .acrylic {
  -webkit-backdrop-filter: blur(var(--acrylic-blur)) saturate(var(--acrylic-saturate));
  backdrop-filter: blur(var(--acrylic-blur)) saturate(var(--acrylic-saturate));
}
:root[data-blur="css"] .mica,
:root[data-blur="css"] .mica-alt {
  -webkit-backdrop-filter: blur(var(--mica-blur)) saturate(var(--mica-saturate));
  backdrop-filter: blur(var(--mica-blur)) saturate(var(--mica-saturate));
}
:root[data-blur="css"] .taskbar-material,
:root[data-blur="css"] .acrylic-base {
  -webkit-backdrop-filter: blur(var(--taskbar-blur)) saturate(var(--taskbar-saturate));
  backdrop-filter: blur(var(--taskbar-blur)) saturate(var(--taskbar-saturate));
}
/* An inactive window loses Mica (Windows falls back to the solid colour) */
.mica[data-active="false"], [data-active="false"] > .mica { background-color: var(--bg-mica-solid) !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }

/* Common elevated surface: flyouts, menus, popups */
.surface-flyout {
  border: 1px solid var(--stroke-flyout);
  border-radius: var(--radius-overlay);
  box-shadow: var(--shadow-flyout);
  background-clip: padding-box;
}

/* ---- Scrollbars (Win11: thin line, expands when hovered) --------------- */
::-webkit-scrollbar { width: 12px; height: 12px; background: transparent; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border: 5px solid transparent;
  border-radius: 6px;
  background-clip: padding-box;
  min-height: 40px;
}
*:hover::-webkit-scrollbar-thumb { border-width: 4px; }
::-webkit-scrollbar-thumb:hover { border-width: 3px; }
::-webkit-scrollbar-thumb:active { border-width: 3px; background-color: var(--text-2); }
*:hover::-webkit-scrollbar-track { background: transparent; }

/* ---- Focus visuals (2px outer + 1px inner) ------------------------------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus-outer);
  outline-offset: 1px;
  box-shadow: 0 0 0 1px var(--focus-inner);
}
.focus-inset:focus-visible { outline-offset: -2px; box-shadow: inset 0 0 0 3px var(--focus-inner); }

/* ---- Utilities ----------------------------------------------------------- */
.sr-only, .fl-sr {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1 1 auto; min-width: 0; }
.wrap { flex-wrap: wrap; }
.center { display: flex; align-items: center; justify-content: center; }
.divider { height: 1px; background: var(--stroke-divider); border: 0; margin: 0; }
.no-drag { -webkit-app-region: no-drag; }

/* Friendly error placeholder (main.js) */
.fl-placeholder {
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 32px; text-align: center; color: var(--text-1);
  background: var(--bg-solid-base);
}
.fl-placeholder__details { color: var(--text-3); font-size: var(--fs-caption); max-width: 520px; font-family: var(--font-mono); white-space: pre-wrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
:root[data-reduce-motion="true"] *:not(.fl-keep-motion, .fl-keep-motion *),
:root[data-reduce-motion="true"] *:not(.fl-keep-motion, .fl-keep-motion *)::before,
:root[data-reduce-motion="true"] *:not(.fl-keep-motion, .fl-keep-motion *)::after {
  animation-duration: 1ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 1ms !important;
  scroll-behavior: auto !important;
}
/* Indeterminate progress indicators carry .fl-keep-motion: they convey state. */
