/* ============================================================
   MizUp — Liquid Glass design system

   PURELY ADDITIVE. Every selector is new (`g-*`) or a custom
   property scoped to `.g-scope`, so nothing existing changes
   appearance unless it opts in.

   TWO RULES THIS FILE ENFORCES, because glass UI fails in
   exactly these two ways:

   1. CONTRAST. A frosted panel over a busy background routinely
      drops body text below readable contrast. Every surface here
      carries a solid tint UNDER the blur, not just blur. The
      tints were picked so #17171A text on light surfaces and
      #F2F2F5 text on dark surfaces both clear 4.5:1 against the
      worst-case backdrop, not the best case.

   2. BLUR BUDGET. backdrop-filter is expensive and compositing
      many blurred layers visibly drops frame rate on mid-range
      Android. Blur is therefore allowed on FOUR surface classes
      only — .g-topbar, .g-rail, .g-modal, .g-hero-panel — and
      explicitly NOT on .g-card, which is the one that would
      otherwise appear dozens of times per screen. Cards get the
      look from tint, border and shadow instead, which costs
      nothing.
   ============================================================ */

.g-scope {
  /* Per-product accent. ProductContext sets these inline. */
  --g-accent: #E63D2E;
  --g-accent-2: #FF7A5C;
  --g-bg-a: #0C0C14;
  --g-bg-b: #15152B;

  /* Surface tints. The alpha floor is what protects contrast. */
  --g-surface: rgba(255, 255, 255, .72);
  --g-surface-strong: rgba(255, 255, 255, .86);
  --g-line: rgba(17, 17, 26, .10);
  --g-line-bright: rgba(255, 255, 255, .55);

  --g-ink: #14141C;
  --g-ink-soft: #55566A;
  --g-radius: 16px;
  --g-blur: 18px;
}

/* Dark product surfaces (rails, topbars over the aurora) */
.g-scope {
  --g-dark-surface: rgba(20, 20, 34, .74);
  --g-dark-line: rgba(255, 255, 255, .12);
  --g-dark-ink: #F3F3F8;
  --g-dark-ink-soft: #A8A9C0;
}

/* ------------------------------------------------------------
   1. The backdrop the glass sits on
   ------------------------------------------------------------ */
.g-app {
  min-height: 100vh;
  position: relative;
  background:
    radial-gradient(980px 560px at 84% -10%, color-mix(in srgb, var(--g-accent) 26%, transparent) 0%, transparent 62%),
    radial-gradient(760px 480px at 6% 12%, rgba(53, 197, 240, .16) 0%, transparent 60%),
    linear-gradient(160deg, var(--g-bg-a) 0%, var(--g-bg-b) 55%, var(--g-bg-a) 100%);
  background-attachment: fixed;
}

/* Faint moving light. One element, one animation — cheap. */
.g-app::before {
  content: "";
  position: fixed;
  inset: -20%;
  background: conic-gradient(from 200deg,
    color-mix(in srgb, var(--g-accent) 16%, transparent),
    rgba(53, 197, 240, .12),
    color-mix(in srgb, var(--g-accent-2) 14%, transparent),
    color-mix(in srgb, var(--g-accent) 16%, transparent));
  filter: blur(90px);
  opacity: .55;
  pointer-events: none;
  z-index: 0;
}
html.motion .g-app::before { animation: g-drift 60s linear infinite; }
@keyframes g-drift { to { transform: rotate(360deg); } }

.g-app > * { position: relative; z-index: 1; }

/* ------------------------------------------------------------
   2. BLURRED SURFACES — the only four
   ------------------------------------------------------------ */
.g-topbar,
.g-rail,
.g-modal,
.g-hero-panel {
  -webkit-backdrop-filter: blur(var(--g-blur)) saturate(140%);
  backdrop-filter: blur(var(--g-blur)) saturate(140%);
}

.g-topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px;
  background: var(--g-dark-surface);
  border-bottom: 1px solid var(--g-dark-line);
  color: var(--g-dark-ink);
}
.g-topbar a { color: var(--g-dark-ink); }

.g-rail {
  background: var(--g-dark-surface);
  border-right: 1px solid var(--g-dark-line);
  color: var(--g-dark-ink);
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 3px;
}

/* ------------------------------------------------------------
   3. CARDS — glass LOOK, no blur. See the blur budget note.
   ------------------------------------------------------------ */
.g-card {
  background: var(--g-surface);
  border: 1px solid var(--g-line);
  border-radius: var(--g-radius);
  box-shadow:
    0 1px 0 var(--g-line-bright) inset,
    0 10px 30px rgba(8, 8, 20, .16);
  padding: 18px;
  color: var(--g-ink);
}
.g-card--dark {
  background: var(--g-dark-surface);
  border-color: var(--g-dark-line);
  color: var(--g-dark-ink);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .10) inset,
    0 10px 30px rgba(0, 0, 0, .3);
}

.g-card h3 { margin: 0 0 6px; font-size: 15px; letter-spacing: -.01em; }
.g-card p { margin: 0; font-size: 13.5px; color: var(--g-ink-soft); line-height: 1.6; }
.g-card--dark p { color: var(--g-dark-ink-soft); }

/* ------------------------------------------------------------
   4. Rail navigation
   ------------------------------------------------------------ */
.g-rail-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 16px;
  border-bottom: 1px solid var(--g-dark-line);
  margin-bottom: 12px;
}
.g-rail-brand strong { font-size: 15px; letter-spacing: -.01em; }
.g-rail-brand span { display: block; font-size: 10.5px; color: var(--g-dark-ink-soft); }
.g-rail-dot { width: 26px; height: 26px; border-radius: 8px; background: var(--g-accent); flex-shrink: 0; }

.g-nav {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 10px;
  font-size: 13.5px; color: var(--g-dark-ink-soft);
  border: 1px solid transparent;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.g-nav:hover { text-decoration: none; color: var(--g-dark-ink); background: rgba(255, 255, 255, .07); }
.g-nav.is-on {
  color: var(--g-dark-ink);
  background: color-mix(in srgb, var(--g-accent) 22%, transparent);
  border-color: color-mix(in srgb, var(--g-accent) 45%, transparent);
}
.g-nav-group {
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: rgba(255, 255, 255, .38); padding: 16px 11px 6px;
}

/* ------------------------------------------------------------
   5. Status strip — a product states its own health first
   ------------------------------------------------------------ */
.g-status { display: flex; gap: 10px; flex-wrap: wrap; }
.g-stat {
  flex: 1 1 150px;
  background: var(--g-dark-surface);
  border: 1px solid var(--g-dark-line);
  border-radius: 12px; padding: 12px 14px;
  color: var(--g-dark-ink);
}
.g-stat span { display: block; font-size: 11px; color: var(--g-dark-ink-soft); }
.g-stat strong { display: block; font-size: 21px; letter-spacing: -.02em; margin-top: 3px; }
.g-pill {
  display: inline-block; font-size: 10.5px; font-weight: 650;
  padding: 3px 9px; border-radius: 14px; margin-top: 5px;
}
.g-pill--ok { background: rgba(46, 212, 122, .18); color: #6BE3A4; }
.g-pill--warn { background: rgba(245, 166, 35, .18); color: #F5C06A; }
.g-pill--bad { background: rgba(230, 83, 61, .18); color: #FF9A86; }

/* ------------------------------------------------------------
   6. Buttons
   ------------------------------------------------------------ */
.g-btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  font: inherit; font-size: 14px; font-weight: 550;
  padding: 11px 20px; border-radius: 11px; cursor: pointer;
  border: 1px solid transparent; transition: transform .15s ease, box-shadow .15s ease;
}
.g-btn:hover { text-decoration: none; transform: translateY(-1px); }
.g-btn--primary {
  background: linear-gradient(180deg, var(--g-accent-2), var(--g-accent));
  color: #fff;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--g-accent) 42%, transparent);
}
.g-btn--primary:hover { color: #fff; }
.g-btn--ghost {
  background: rgba(255, 255, 255, .08);
  border-color: var(--g-dark-line);
  color: var(--g-dark-ink);
}
.g-btn--ghost:hover { color: var(--g-dark-ink); background: rgba(255, 255, 255, .14); }

/* ------------------------------------------------------------
   7. Product switcher
   ------------------------------------------------------------ */
.g-switch { position: relative; }
.g-switch-menu {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 250px;
  background: var(--g-dark-surface);
  -webkit-backdrop-filter: blur(var(--g-blur)); backdrop-filter: blur(var(--g-blur));
  border: 1px solid var(--g-dark-line); border-radius: 14px;
  padding: 8px; z-index: 60;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .45);
}
.g-switch-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 11px; border-radius: 10px;
  color: var(--g-dark-ink); font-size: 13.5px;
}
.g-switch-item:hover { text-decoration: none; background: rgba(255, 255, 255, .08); color: var(--g-dark-ink); }
.g-switch-item i { width: 22px; height: 22px; border-radius: 7px; display: block; flex-shrink: 0; }
.g-switch-item small { display: block; font-size: 11px; color: var(--g-dark-ink-soft); }
.g-switch-item.is-locked { opacity: .5; }

/* ------------------------------------------------------------
   8. Login shell
   ------------------------------------------------------------ */
.g-login {
  min-height: 100vh; display: grid; place-items: center; padding: 32px 20px;
}
.g-hero-panel {
  width: 100%; max-width: 420px;
  background: var(--g-dark-surface);
  border: 1px solid var(--g-dark-line);
  border-radius: 20px; padding: 32px;
  color: var(--g-dark-ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .12) inset, 0 26px 70px rgba(0, 0, 0, .45);
}
.g-hero-panel h1 { font-size: 24px; margin: 14px 0 6px; letter-spacing: -.02em; color: #fff; }
.g-hero-panel p { font-size: 14px; color: var(--g-dark-ink-soft); margin: 0 0 22px; line-height: 1.6; }
.g-hero-panel label { display: block; font-size: 12.5px; color: var(--g-dark-ink-soft); margin-bottom: 6px; }
.g-hero-panel input {
  width: 100%; font-size: 16px; padding: 12px 14px; margin-bottom: 16px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--g-dark-line); border-radius: 10px; color: #fff;
}
.g-hero-panel input:focus { outline: 2px solid var(--g-accent); outline-offset: 1px; }
.g-hero-panel input::placeholder { color: rgba(255, 255, 255, .34); }

/* ------------------------------------------------------------
   9. Layout
   ------------------------------------------------------------ */
.g-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.g-main { padding: 22px 24px 60px; }
@media (max-width: 900px) {
  .g-shell { grid-template-columns: 1fr; }
  .g-rail { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .22s ease; z-index: 50; }
  .g-rail.is-open { transform: none; }
  .g-main { padding: 16px 16px 70px; }
  /* Fewer blurred layers on small screens — see the blur budget note. */
  .g-topbar { -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
}

/* ------------------------------------------------------------
   10. Fallbacks and accessibility
   ------------------------------------------------------------ */

/* No backdrop-filter support: fall back to solid surfaces rather
   than transparent ones, or the text becomes unreadable. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .g-topbar, .g-rail, .g-modal, .g-hero-panel, .g-switch-menu { background: #171728; }
  .g-card { background: #FFFFFF; }
}

@media (prefers-reduced-motion: reduce) {
  html.motion .g-app::before { animation: none; }
  .g-btn:hover { transform: none; }
}

/* Reduced transparency (iOS/macOS accessibility setting) — honour it. */
@media (prefers-reduced-transparency: reduce) {
  .g-topbar, .g-rail, .g-modal, .g-hero-panel, .g-switch-menu {
    -webkit-backdrop-filter: none; backdrop-filter: none; background: #171728;
  }
  .g-card { background: #FFFFFF; }
}

@media print {
  .g-app::before, .g-rail, .g-topbar { display: none !important; }
  .g-card { background: #fff; box-shadow: none; }
}

/* ------------------------------------------------------------
   12. PROFILE MENU
   The top right of the product shell used to be a name and
   nothing else - no profile, no settings, no sign out without
   walking back to the rail.
   ------------------------------------------------------------ */
.g-user { position: relative; }

.g-user-btn {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 10px 5px 5px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: none;
  color: var(--g-dark-ink);
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease;
}
.g-user-btn:hover { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .14); }
.g-user-btn[aria-expanded="true"] { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .20); }

.g-user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(180deg, var(--g-accent-2) 0%, var(--g-accent) 100%);
  color: #fff; font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.g-user-name { font-size: 13px; color: var(--g-dark-ink-soft); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.g-user-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  min-width: 230px;
  background: rgba(18, 18, 32, .96);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--g-dark-line);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  padding: 6px;
}
.g-user-head { padding: 10px 11px 12px; border-bottom: 1px solid var(--g-dark-line); margin-bottom: 6px; }
.g-user-head strong { display: block; font-size: 13.5px; color: #fff; }
.g-user-head span { display: block; font-size: 11.5px; color: var(--g-dark-ink-soft); margin-top: 2px; }

.g-user-menu a {
  display: block;
  padding: 9px 11px;
  border-radius: 9px;
  font-size: 13.5px;
  color: var(--g-dark-ink);
  transition: background .12s ease;
}
.g-user-menu a:hover { background: rgba(255, 255, 255, .09); text-decoration: none; color: #fff; }
.g-user-sep { height: 1px; background: var(--g-dark-line); margin: 6px 4px; }
.g-user-out { color: #FF9A86 !important; }
.g-user-out:hover { background: rgba(230, 83, 61, .18) !important; }

@media (max-width: 720px) {
  .g-user-name { display: none; }
}
