/* =====================================================================
   Grow Wings LMS — the glass surface
   ---------------------------------------------------------------------
   Loaded only when Settings → Branding → Surface is set to Glass, and
   scoped entirely to [data-surface="glass"]. With it off, not one byte
   of this file is fetched and the product is exactly as it was.

   ── The recipe is the platform's, not an invention ───────────────────
   Read out of the SMC client rather than designed here:

     components/layout/Sidebar.js
         radial-gradient(120% 40% at 0% 0%,  teal   .10, transparent 60%),
         radial-gradient(120% 30% at 100% 100%, violet .08, transparent 60%),
         rgba(9,13,26,.94);  backdrop-filter: blur(24px);
         border-right: 1px solid rgba(148,163,184,.12);

     components/layout/Header.js
         radial-gradient(… teal …), radial-gradient(40% 140% at 100% 0%,
         violet .07, transparent 60%), rgba(7,11,24,.9);
         backdrop-filter: blur(16px) saturate(140%);
         and a hairline across the top:
         linear-gradient(90deg, transparent, teal .35, violet .3, transparent)

     schoolTheme.js Panel
         background rgba(13,17,32,.78); border 1px solid rgba(3,218,198,.14);
         border-radius 18px;
         box-shadow 0 0 0 1px rgba(0,0,0,.2), 0 18px 40px -28px rgba(3,218,198,.35)
         — note the throw is TEAL-tinted, not grey. That glow under every
         panel is half of why the platform looks lit from inside.

   Two accents, not one: teal warms the top-left, violet the bottom-right.
   A single-hue wash was the thing that most made the earlier attempt look
   like a teal skin rather than like the platform.

   ── What stays readable ──────────────────────────────────────────────
   The platform's panels hold a few rows. This product holds attendance
   registers and mark tables, so the three-plane split stays:

     Atmosphere  the teal/violet field, fixed, well under everything.
     Chrome      sidebar, topbar, hero, stat tiles, sticky bars —
                 frosted, blurred, translucent. These frame the work.
     Content     cards holding tables, forms and prose. Near-opaque,
                 never blurred. A register that is hard to read at 4pm
                 on a Friday is a worse product however good it looks
                 in a screenshot.

   Nothing here is a fixed colour: every tint is mixed from --brand,
   --violet, --surface or --side-bg, so the file works unchanged on both
   themes and would survive another being added.
   ===================================================================== */

[data-surface="glass"]{
  /* Sidebar.js blur(24px); Header.js blur(16px) saturate(140%). */
  --g-blur:24px;
  --g-blur-head:16px;
  --g-blur-soft:10px;

  /* schoolTheme SURFACE.card is rgba(13,17,32,.78) — the solid panel at
     78%. Expressed as a mix so it follows whichever theme is on. */
  --g-plate:color-mix(in srgb, var(--surface) 78%, transparent);
  --g-plate-strong:color-mix(in srgb, var(--surface) 90%, transparent);

  /* The lit lip. A pane of glass catches light along its top edge; without
     it you have a semi-transparent box rather than glass. */
  --g-lip:inset 0 1px 0 color-mix(in srgb, #FFFFFF 55%, transparent);
  --g-foot:inset 0 -1px 0 color-mix(in srgb, var(--ink) 6%, transparent);

  /* SURFACE.line. Already teal in both themes — glass only firms it. */
  --g-edge:var(--line);

  /* The sidebar frosts from its OWN colour, never from --surface: it is a
     different material from the page and a white-based plate over a dark
     bar turns it pale and drops its text under 2:1. */
  --g-side:color-mix(in srgb, var(--side-bg) 92%, transparent);

  /* the two washes, as Sidebar.js mixes them */
  --g-w-teal:color-mix(in srgb, var(--brand) 10%, transparent);
  --g-w-violet:color-mix(in srgb, var(--violet) 8%, transparent);
}

/* A dark page keeps more of the panel — thinning near-black to 70% stops
   being a panel — and lights the lip with the accent, because white on
   near-black reads as a scratch rather than a highlight. */
[data-surface="glass"][data-tone="dark"]{
  --g-plate:color-mix(in srgb, var(--surface) 82%, transparent);
  --g-plate-strong:color-mix(in srgb, var(--surface) 93%, transparent);
  --g-lip:inset 0 1px 0 color-mix(in srgb, var(--brand) 22%, transparent);
  --g-foot:inset 0 -1px 0 rgba(0,0,0,.28);
  --g-side:color-mix(in srgb, var(--side-bg) 94%, transparent);
}

/* ── 1. atmosphere ──────────────────────────────────────────────────
   Glass is not a material you can see on its own — it is a material you
   see things THROUGH, so the ground has to be worth looking through at.
   The first attempt frosted the panels over a near-white page and the
   result was invisible: white thinned to 78% over #F4F7FB is #F4F7FB.

   Two hues, placed as the platform places them: teal warm in the
   top-left and along the left edge where the sidebar sits, violet in the
   bottom-right. Fixed, so it does not slide around under a scrolling
   register. Painted on <body> rather than on .bg-wash so it also covers
   the sign-in page, which has no .bg-wash in it. */
[data-surface="glass"] body{
  background-color:var(--bg);
  background-image:
    radial-gradient(78rem 48rem at 92% -14%,
      color-mix(in srgb,var(--violet) 20%,transparent), transparent 60%),
    radial-gradient(70rem 46rem at -10% -6%,
      color-mix(in srgb,var(--brand) 24%,transparent), transparent 62%),
    radial-gradient(60rem 44rem at 108% 104%,
      color-mix(in srgb,var(--brand) 16%,transparent), transparent 60%),
    radial-gradient(30rem 72rem at -6% 46%,
      color-mix(in srgb,var(--violet) 14%,transparent), transparent 64%);
  background-attachment:fixed;
  background-repeat:no-repeat;
}

/* On near-black the same pools barely register, so they come up. */
[data-surface="glass"][data-tone="dark"] body{
  background-image:
    radial-gradient(78rem 48rem at 92% -14%,
      color-mix(in srgb,var(--violet) 26%,transparent), transparent 58%),
    radial-gradient(70rem 46rem at -10% -6%,
      color-mix(in srgb,var(--brand) 30%,transparent), transparent 60%),
    radial-gradient(60rem 44rem at 108% 104%,
      color-mix(in srgb,var(--brand) 20%,transparent), transparent 58%),
    radial-gradient(30rem 72rem at -6% 46%,
      color-mix(in srgb,var(--violet) 18%,transparent), transparent 62%);
}

/* the original two-blob wash is now a third layer of the same idea, so it
   steps back and only supplies the slow movement */
[data-surface="glass"] .bg-wash .w1,
[data-surface="glass"] .bg-wash .w2{ opacity:.5; }

[data-surface="glass"] .bg-wash::after{
  content:'';position:absolute;display:block;border-radius:50%;
  width:min(740px,74vw);height:600px;left:30%;top:24%;
  background:radial-gradient(circle closest-side,
    color-mix(in srgb,var(--violet) 12%,transparent), transparent 70%);
  filter:blur(28px);
  animation:gDrift 54s ease-in-out infinite;
}
@keyframes gDrift{
  0%,100%{ transform:translate3d(0,0,0) scale(1); }
  50%    { transform:translate3d(-5%,4%,0) scale(1.08); }
}

/* ── 2. chrome ──────────────────────────────────────────────────────
   Everything here frames the work. All of it gets the plate, the blur
   and the lit lip; none of it holds text people read at length. */
@supports ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){
  [data-surface="glass"] .sidebar{
    -webkit-backdrop-filter:blur(var(--g-blur)) saturate(140%);
            backdrop-filter:blur(var(--g-blur)) saturate(140%);
  }
  [data-surface="glass"] .topbar,
  [data-surface="glass"] .learn__hero,
  [data-surface="glass"] .coursebar,
  [data-surface="glass"] .stat,
  [data-surface="glass"] .composer__actions,
  [data-surface="glass"] .play__foot,
  [data-surface="glass"] .sidebar-foot{
    -webkit-backdrop-filter:blur(var(--g-blur-head)) saturate(140%);
            backdrop-filter:blur(var(--g-blur-head)) saturate(140%);
  }
}

/* Sidebar.js, layer for layer. */
[data-surface="glass"] .sidebar{
  background:
    radial-gradient(120% 40% at 0% 0%, var(--g-w-teal), transparent 60%),
    radial-gradient(120% 30% at 100% 100%, var(--g-w-violet), transparent 60%),
    var(--g-side);
  border-right:1px solid var(--side-line);
  box-shadow:var(--g-lip), 12px 0 40px -28px rgba(0,0,0,.45);
}
[data-surface="glass"] .sidebar-foot{
  background:color-mix(in srgb,var(--side-foot) 80%,transparent);
  border-top:1px solid var(--side-line);
}

/* Header.js: the violet pulled to the top-right corner, and the teal →
   violet hairline across the very top. That thread is the detail people
   recognise the platform by. */
[data-surface="glass"] .topbar{
  position:relative;
  background:
    radial-gradient(40% 140% at 0% 0%, var(--g-w-teal), transparent 60%),
    radial-gradient(40% 140% at 100% 0%, var(--g-w-violet), transparent 60%),
    var(--topbar-bg);
  border-bottom:1px solid var(--side-line);
}
[data-surface="glass"] .topbar::before{
  content:'';position:absolute;inset:0 0 auto 0;height:1px;pointer-events:none;
  background:linear-gradient(90deg,
    transparent,
    color-mix(in srgb,var(--brand) 35%,transparent),
    color-mix(in srgb,var(--violet) 30%,transparent),
    transparent);
}

[data-surface="glass"] .learn__hero,
[data-surface="glass"] .coursebar{
  background:
    radial-gradient(120% 90% at 0% 0%,
      color-mix(in srgb,var(--brand) 10%,transparent), transparent 55%),
    var(--g-plate);
  border:1px solid var(--g-edge);
  box-shadow:var(--g-lip), var(--g-foot), var(--shadow-md);
}

/* schoolTheme's accented Panel: the tinted corner wash, and a 2px rule
   along the top that fades out at both ends. A stat tile is a number and
   a word — nothing to read closely, and the one place shine is welcome. */
[data-surface="glass"] .stat{
  position:relative;
  background:
    radial-gradient(120% 90% at 0% 0%,
      color-mix(in srgb,var(--brand) 10%,transparent), transparent 55%),
    var(--g-plate);
  border:1px solid var(--g-edge);
  box-shadow:var(--g-lip), var(--g-foot), var(--shadow-sm);
}
[data-surface="glass"] .stat::before{
  content:'';position:absolute;left:18px;right:18px;top:-1px;height:2px;
  border-radius:2px;pointer-events:none;opacity:.75;
  background:linear-gradient(90deg,transparent,var(--brand),transparent);
}
[data-surface="glass"] .stat.sky::before   { background:linear-gradient(90deg,transparent,var(--sky),transparent); }
[data-surface="glass"] .stat.violet::before{ background:linear-gradient(90deg,transparent,var(--violet),transparent); }
[data-surface="glass"] .stat.amber::before { background:linear-gradient(90deg,transparent,var(--amber),transparent); }

/* sticky action bars sit over scrolling content, which is exactly what
   frost is for: it says "this floats" without a hard shadow line */
[data-surface="glass"] .composer__actions,
[data-surface="glass"] .play__foot{
  background:var(--g-plate);
  border-top:1px solid var(--g-edge);
  box-shadow:var(--g-lip);
}

/* ── 3. content ─────────────────────────────────────────────────────
   Deliberately NOT blurred and barely translucent. A card keeps its own
   surface and gains the lit edge and the teal-tinted throw, so it belongs
   to the same world as the chrome without costing legibility. This is the
   restraint the look lives or dies on. */
[data-surface="glass"] .card,
[data-surface="glass"] .mod,
[data-surface="glass"] .mycourse,
[data-surface="glass"] .theme,
[data-surface="glass"] .lessonnav,
[data-surface="glass"] .handover{
  /* fully opaque, on purpose. Against the coloured field behind, solid
     paper reads as lifted rather than as flat — the contrast with the
     frosted chrome is what carries the depth. */
  background:var(--surface);
  border-color:var(--g-edge);
  box-shadow:var(--g-lip), var(--g-foot), var(--shadow-md);
}

/* a table inside a card must stay on a solid plate whatever happens
   above it — this is the rule that keeps the register readable */
[data-surface="glass"] .card table,
[data-surface="glass"] .card .reg,
[data-surface="glass"] table.tbl{
  background:var(--surface);
}

/* ── small surfaces that benefit from a lighter frost ─────────────── */
@supports ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){
  [data-surface="glass"] .cardmenu__btn,
  [data-surface="glass"] .burger,
  [data-surface="glass"] .badge{
    -webkit-backdrop-filter:blur(var(--g-blur-soft));
            backdrop-filter:blur(var(--g-blur-soft));
  }
}

/* schoolTheme's PrimaryButton is flat #03dac6 with #04121a on it, so the
   glass adds only a single highlight across the top and the teal throw
   the platform puts under everything. */
[data-surface="glass"] .btn-primary{
  background:
    linear-gradient(180deg,
      color-mix(in srgb,#FFFFFF 18%,transparent) 0%,
      transparent 52%),
    var(--teal-btn);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb,#FFFFFF 30%,transparent),
    0 10px 22px -11px color-mix(in srgb,var(--brand) 88%,transparent);
}
/* GhostButton: transparent with a teal edge, filling faintly on hover. */
[data-surface="glass"] .btn-ghost{
  background:color-mix(in srgb,var(--surface) 70%,transparent);
  border-color:var(--line-hard);
}

/* Inputs read as recessed rather than raised: the lip is inverted. */
[data-surface="glass"] input[type=text],
[data-surface="glass"] input[type=email],
[data-surface="glass"] input[type=password],
[data-surface="glass"] input[type=number],
[data-surface="glass"] input[type=date],
[data-surface="glass"] input[type=time],
[data-surface="glass"] input[type=search],
[data-surface="glass"] select,
[data-surface="glass"] textarea{
  background:color-mix(in srgb,var(--surface) 76%,transparent);
  border-color:var(--g-edge);
  box-shadow:inset 0 1px 2px color-mix(in srgb,var(--ink) 7%,transparent);
}

/* ── the sign-in page ───────────────────────────────────────────────
   This screen was built deliberately card-less — "white, no cards, no
   shadows" — so there is nothing here to frost. Rather than rebuild the
   layout the week of UAT, the form itself becomes the pane: it lifts off
   the field behind it and gains the same lit lip as the chrome. One
   change, reversible, and it is the first thing the client sees.

   The tokens here are login.css's own --gw-* set, NOT the app's. The
   signed-out layout is self-contained and never emits the app palette,
   so --surface and --line simply do not exist on this page; a rule
   written against them resolves to nothing and the pane loses its
   background entirely. login.css defines --gw-white and --gw-line in
   both tones, which is what makes this follow the theme.
   login.css carries the dark-tone override for this same selector. */
[data-surface="glass"] .gw-form{
  background:color-mix(in srgb, var(--gw-white,#FFFFFF) 88%, transparent);
  border:1px solid var(--gw-line, rgba(2,164,149,.22));
  border-radius:20px;
  padding:26px clamp(20px,3.2vw,30px) 28px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.72),
    var(--gw-shadow-lg, 0 40px 80px -36px rgba(2,164,149,.45));
}
@supports ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){
  [data-surface="glass"] .gw-form{
    -webkit-backdrop-filter:blur(20px) saturate(150%);
            backdrop-filter:blur(20px) saturate(150%);
  }
}
/* the mists behind it come up, so the pane has something to sit on */
[data-surface="glass"] .gw-pane::before{ opacity:1; transform:scale(1.25); }
[data-surface="glass"] .gw-pane::after { transform:scale(1.3); }

/* ── when the browser cannot frost ──────────────────────────────────
   Safari before 9, Firefox with the flag off, and every browser with GPU
   compositing disabled. Translucency without blur shows the text
   underneath, so those surfaces go solid instead — plainer than the
   glass, and still correct.

   These resolve through tokens rather than to #FFFFFF, which is what the
   earlier version did: on the dark theme it handed those browsers a white
   topbar and white stat tiles over a near-black page. */
@supports not ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){
  [data-surface="glass"] .topbar,
  [data-surface="glass"] .learn__hero,
  [data-surface="glass"] .coursebar,
  [data-surface="glass"] .stat,
  [data-surface="glass"] .composer__actions,
  [data-surface="glass"] .play__foot{
    background:var(--surface);
  }
  [data-surface="glass"] .sidebar{ background:var(--side-bg); }
  /* again the signed-out page's own token, not the app's */
  [data-surface="glass"] .gw-form{ background:var(--gw-white,#FFFFFF); }
}

/* ── motion, and the people who do not want it ─────────────────────── */
@media (prefers-reduced-motion:reduce){
  [data-surface="glass"] .bg-wash::after{ animation:none; }
}

/* ── phones ─────────────────────────────────────────────────────────
   A full-height blurred sidebar over a blurred topbar is the most
   expensive thing on the page, and on a mid-range Android it drops frames
   while scrolling a register. The frost is eased off where the screen is
   small and the hardware usually is too. */
@media (max-width:860px){
  [data-surface="glass"]{ --g-blur:14px; --g-blur-head:12px; --g-blur-soft:8px; }
  [data-surface="glass"] .bg-wash::after{ animation:none; }
}

/* Printing: none of this should reach paper. */
@media print{
  [data-surface="glass"] *{
    -webkit-backdrop-filter:none !important; backdrop-filter:none !important;
    box-shadow:none !important;
  }
  [data-surface="glass"] .bg-wash{ display:none !important; }
  [data-surface="glass"] .topbar::before,
  [data-surface="glass"] .stat::before{ display:none !important; }
}
