/* ==========================================================================
   Frost — frosted glass design system
   --------------------------------------------------------------------------
   Usage
     1. Put class "fg" on a root element (a wrapper div, not <body>).
     2. Pick a palette with one of: p-aurora (default), p-harbor, p-ember,
        p-orchid, p-meadow, p-glacier.
     3. Add "light" for light mode. Dark is the default.
        <div class="fg p-harbor light"> ... </div>
     4. Give the root a backdrop (.fg-backdrop with a few .fg-orb children)
        so the glass has color to blur.

   Everything is driven by the custom properties below. To add a palette,
   copy one .fg.p-* rule and change its six colors.
   ========================================================================== */

body { margin: 0; }

/* ---------- Tokens: dark mode (default) ---------- */
.fg {
  box-sizing: border-box;
  color-scheme: dark;

  /* Type */
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;

  /* Palette ramps (Aurora). bright = dark-mode accents, base = charts,
     deep = light-mode accents. */
  --a1-bright: #9D8FFF; --a1: #7C6CF0; --a1-deep: #5443D6;
  --a2-bright: #4FD6C8; --a2: #0F9D90; --a2-deep: #0B7A70;

  /* Page and text */
  --bg: #0A0C14;
  --text: #F3F4F8;
  --text-2: #D0D4E0;
  --text-3: #B4BACC;

  /* Surfaces */
  --glass: rgba(22, 25, 44, .38);          /* blurred panels */
  --glass-2: rgba(255, 255, 255, .08);     /* tiles, inputs, default buttons */
  --glass-3: rgba(255, 255, 255, .17);     /* hover and selected */
  --solid: rgba(16, 18, 32, .94);          /* tooltips, menus */
  --track: rgba(255, 255, 255, .12);       /* meter and switch tracks */

  /* Lines and light */
  --line: rgba(255, 255, 255, .2);
  --line-soft: rgba(255, 255, 255, .1);
  --rim: rgba(255, 255, 255, .16);
  --edge: linear-gradient(135deg, rgba(255, 255, 255, .6) 0%, rgba(255, 255, 255, .16) 28%, rgba(255, 255, 255, .05) 60%, rgba(255, 255, 255, .32) 100%);
  --sheen: linear-gradient(135deg, rgba(255, 255, 255, .1) 0%, rgba(255, 255, 255, .03) 28%, rgba(255, 255, 255, 0) 52%);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.4 -.45'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='.1'/%3E%3C/svg%3E");
  --glow: inset 0 0 28px rgba(255, 255, 255, .05);
  --well: inset 0 1px 2px rgba(0, 0, 0, .22);
  --shine: inset 0 1px 0 rgba(255, 255, 255, .22), inset 0 -1px 0 rgba(0, 0, 0, .2);
  --shadow: 0 28px 64px rgba(0, 0, 0, .42), 0 2px 8px rgba(0, 0, 0, .24);

  /* Roles */
  --accent: var(--a1-bright);
  --accent-2: var(--a2-bright);
  --on-accent: #0A0C14;
  --accent-soft: color-mix(in srgb, var(--a1-bright) 20%, transparent);
  --series-1: var(--a1);
  --series-2: var(--a2);
  --good: #62D6A0;
  --warn: #F0C26A;
  --bad: #FF9494;

  /* Backdrop */
  --orb-1: var(--a1);
  --orb-2: var(--a2);
  --orb-o: .62;
  --backdrop:
    radial-gradient(70% 55% at 0% 0%, color-mix(in srgb, var(--orb-1) 26%, transparent), transparent 72%),
    radial-gradient(55% 50% at 100% 35%, color-mix(in srgb, var(--orb-2) 22%, transparent), transparent 72%),
    radial-gradient(60% 50% at 45% 100%, color-mix(in srgb, var(--orb-1) 18%, transparent), transparent 72%),
    var(--bg);

  /* Shape */
  --blur: 28px;
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;

  font-family: var(--font);
  color: var(--text);
  background: var(--backdrop);
  -webkit-font-smoothing: antialiased;
}
.fg * { box-sizing: border-box; }
:where(.fg) a { color: inherit; }

/* ---------- Tokens: light mode ---------- */
.fg.light {
  color-scheme: light;
  --bg: #EDF0F7;
  --text: #12141C;
  --text-2: #3F4558;
  --text-3: #4C5266;

  --glass: rgba(255, 255, 255, .4);
  --glass-2: rgba(255, 255, 255, .42);
  --glass-3: rgba(255, 255, 255, .82);
  --solid: rgba(255, 255, 255, .96);
  --track: rgba(18, 20, 28, .1);

  --line: rgba(255, 255, 255, .9);
  --line-soft: rgba(18, 20, 28, .1);
  --rim: rgba(255, 255, 255, .9);
  --edge: linear-gradient(135deg, #fff 0%, rgba(255, 255, 255, .7) 30%, rgba(255, 255, 255, .35) 62%, rgba(255, 255, 255, .9) 100%);
  --sheen: linear-gradient(135deg, rgba(255, 255, 255, .5) 0%, rgba(255, 255, 255, .14) 30%, rgba(255, 255, 255, 0) 56%);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .1 0 0 0 0 .12 0 0 0 0 .22 0 0 0 1.4 -.45'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E");
  --glow: inset 0 0 28px rgba(255, 255, 255, .35);
  --well: inset 0 1px 2px rgba(40, 50, 90, .1);
  --shine: inset 0 1px 0 rgba(255, 255, 255, .95), inset 0 -1px 0 rgba(255, 255, 255, .35);
  --shadow: 0 0 0 1px rgba(18, 20, 28, .04), 0 24px 54px rgba(40, 50, 90, .18), 0 2px 6px rgba(40, 50, 90, .08);

  --accent: var(--a1-deep);
  --accent-2: var(--a2-deep);
  --on-accent: #FFFFFF;
  --accent-soft: color-mix(in srgb, var(--a1) 16%, transparent);
  --good: #0A6B3C;
  --warn: #7A4E00;
  --bad: #A51D29;

  --orb-1: var(--a1-bright);
  --orb-2: var(--a2-bright);
  --orb-o: .72;
}

/* ---------- Palettes ---------- */
.fg.p-harbor  { --a1-bright: #6FB0FF; --a1: #3B8DF0; --a1-deep: #1F63C4; --a2-bright: #FFB25C; --a2: #CF7A1C; --a2-deep: #9A5608; }
.fg.p-ember   { --a1-bright: #FF8A6B; --a1: #E8603F; --a1-deep: #B83F22; --a2-bright: #A995FF; --a2: #8767E8; --a2-deep: #5E3FCC; }
.fg.p-orchid  { --a1-bright: #F57FBF; --a1: #DB4F9E; --a1-deep: #B02A78; --a2-bright: #A396FF; --a2: #7F6DF2; --a2-deep: #5646D4; }
.fg.p-meadow  { --a1-bright: #4FD08A; --a1: #1F9D5C; --a1-deep: #13733F; --a2-bright: #8E9DFF; --a2: #5B6FE6; --a2-deep: #3B4FC4; }
.fg.p-glacier { --a1-bright: #4CC4E6; --a1: #1898BD; --a1-deep: #0D6E8C; --a2-bright: #F58BB2; --a2: #D95A8A; --a2-deep: #B03A68; }

/* ---------- Backdrop ---------- */
.fg-backdrop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.fg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(56px);
  opacity: var(--orb-o);
  pointer-events: none;
}

/* ---------- Surfaces ---------- */
/* Glass: the only surface that blurs what is behind it. */
.fg-glass {
  position: relative;
  background: var(--grain) 0 0 / 200px 200px, var(--sheen), var(--glass);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shine), var(--glow), var(--shadow);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
  backdrop-filter: blur(var(--blur)) saturate(180%);
}
/* Lit rim: a gradient ring drawn in the 1px border area. */
@supports ((-webkit-mask-composite: xor) or (mask-composite: exclude)) {
  .fg-glass { border-color: transparent; }
  .fg-glass::before {
    content: "";
    position: absolute;
    inset: -1px;
    padding: 1px;
    border-radius: inherit;
    background: var(--edge);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
  }
}
/* Tile: nested groups inside glass. No blur. */
.fg-tile {
  background: linear-gradient(160deg, var(--glass-3) -40%, var(--glass-2) 45%);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  box-shadow: inset 0 1px 0 var(--rim);
}
/* Popover: tooltips and menus that must stay readable over anything. */
.fg-popover {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--solid);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

/* ---------- Buttons ---------- */
.fg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass-2);
  color: var(--text);
  font: 600 14px/1 var(--font);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, transform .15s;
  box-shadow: inset 0 1px 0 var(--rim);
}
.fg-btn:hover { background: var(--glass-3); color: var(--text); }
.fg-btn:active { transform: translateY(1px); }
.fg-btn[disabled] { opacity: .45; cursor: not-allowed; }
.fg-btn-primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 90%, #fff), var(--accent));
  border-color: transparent;
  color: var(--on-accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 8px 22px color-mix(in srgb, var(--accent) 36%, transparent);
}
.fg-btn-primary:hover { background: color-mix(in srgb, var(--accent) 86%, var(--text)); color: var(--on-accent); }
.fg-btn-quiet { background: transparent; border-color: transparent; box-shadow: none; }
.fg-btn-icon { width: 44px; padding: 0; }

/* ---------- Navigation ---------- */
.fg-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  color: var(--text-2);
  font: 500 14px/1 var(--font);
  text-decoration: none;
}
.fg-nav:hover { background: var(--glass-2); color: var(--text); }
.fg-nav.is-active {
  background: var(--accent-soft);
  border-color: var(--line-soft);
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 0 1px 0 var(--rim);
}
.fg-nav.is-active .fg-ico { color: var(--accent); }

/* Segmented control */
.fg-segs {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  border-radius: 999px;
  background: var(--glass-2);
  border: 1px solid var(--line-soft);
  box-shadow: var(--well);
}
.fg-seg {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font: 600 13px/1 var(--font);
  cursor: pointer;
}
.fg-seg:hover { color: var(--text); }
.fg-seg.is-active { background: var(--glass-3); color: var(--text); box-shadow: var(--shine); }

/* Tabs */
.fg-tab {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-2);
  font: 600 14px/1 var(--font);
  cursor: pointer;
}
.fg-tab:hover { color: var(--text); }
.fg-tab.is-active { color: var(--text); border-bottom-color: var(--accent); }

/* Mobile tab bar item */
.fg-tabitem {
  flex: 1;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 18px;
  text-decoration: none;
  color: var(--text-2);
  font: 600 11px/14px var(--font);
}
.fg-tabitem:hover { color: var(--text); }
.fg-tabitem.is-active { color: var(--text); background: var(--accent-soft); box-shadow: inset 0 1px 0 var(--rim); }
.fg-tabitem.is-active .fg-ico { color: var(--accent); }

/* ---------- Forms ---------- */
.fg-input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--line-soft);
  background: var(--glass-2);
  color: var(--text);
  font: 400 14px/1 var(--font);
  box-shadow: var(--well);
}
.fg-input::placeholder { color: var(--text-3); opacity: 1; }
/* Native option lists need an opaque fill to stay readable. */
.fg-input option { background-color: var(--bg); color: var(--text); }

.fg-switch {
  position: relative;
  flex: none;
  width: 52px;
  height: 32px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--track);
  cursor: pointer;
}
.fg-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--text);
  transition: transform .18s;
}
.fg-switch[aria-checked="true"] { background: var(--accent); border-color: transparent; }
.fg-switch[aria-checked="true"]::after { transform: translateX(20px); background: var(--on-accent); }

/* ---------- Data display ---------- */
.fg-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--glass-2);
  border: 1px solid var(--line-soft);
  color: var(--text-2);
  font: 600 12px/1 var(--font);
  white-space: nowrap;
  box-shadow: inset 0 1px 0 var(--rim);
}
.fg-chip.good { color: var(--good); }
.fg-chip.warn { color: var(--warn); }
.fg-chip.bad { color: var(--bad); }
.fg-chip .fg-ico { width: 14px; height: 14px; stroke-width: 2.2; }

.fg-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 0 10px;
  border-radius: 14px;
  text-decoration: none;
  color: var(--text);
}
.fg-row:hover { background: var(--glass-2); color: var(--text); }

.fg-meter { height: 8px; border-radius: 999px; background: var(--track); }
.fg-meter > * { height: 100%; border-radius: inherit; background: var(--series-1); }

/* ---------- Focus ---------- */
.fg :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Type and icon helpers ---------- */
.fg-ico {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.fg-label {
  font: 600 11px/16px var(--font);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.fg-num { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.fg-spec { font: 400 12px/18px var(--font); color: var(--text-2); }
.fg-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .fg *, .fg *::before, .fg *::after { transition: none !important; }
}
