/* ==========================================================================
   Mesori effects layer (v2): glass look + light neon for the static site.
   Loaded only by the two app pages (index.html and en/index.html), after
   site.css, so same-specificity rules here win by source order.
   Plain CSS on purpose: no Tailwind rebuild, and it can be copied as-is into
   the React app.

   Rules learned from measuring v1 (do not re-add):
   1. Animate transform and opacity only. Animating a custom property or a
      mask repaints the area on the main thread every frame (v1 ring: about
      190 ms per frame on a throttled phone profile). Keep the animated area
      small: two big drifting light pools alone cost 50-85 ms per frame.
   2. Nothing that animates sits behind a backdrop-filter element.
   3. On the smooth colours used here, backdrop-filter changes the picture by
      under 5/255. Phones skip it; desktops get it on static surfaces only.
   ========================================================================== */

/* 1. Tokens ----------------------------------------------------------------- */
:root {
  --gl-blur: 16px;
  --gl-sat: 170%;
  --gl-fill-a: rgba(255, 252, 244, .80);
  --gl-fill-b: rgba(255, 252, 244, .48);
  --gl-edge: rgba(200, 146, 42, .34);
  --gl-hi: rgba(255, 255, 255, .75);
  --gl-shadow: 0 14px 32px -16px rgba(61, 43, 31, .35);
  /* Set by effects.js on iPhone. The defaults give a static top-left sheen. */
  --tilt-x: 30%;
  --tilt-y: 0%;
}

/* 2. Ambient colour behind the page ------------------------------------------ */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(42vmax 42vmax at 92% 6%, rgba(240, 208, 128, .55), transparent 70%),
    radial-gradient(48vmax 48vmax at 4% 52%, rgba(26, 127, 142, .26), transparent 70%),
    radial-gradient(36vmax 36vmax at 70% 98%, rgba(27, 94, 46, .20), transparent 70%);
}

/* 3. iPhone safe areas ------------------------------------------------------- */
/* The page sets viewport-fit=cover, so in landscape the content ran under the
   notch, and the footer text sat under the home indicator. */
@supports (padding: max(1px, 2px)) {
  .wrap:not(.neon-panel) {
    padding-inline: max(1.25rem, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  }
  footer[class] {
    padding-bottom: max(2rem, calc(env(safe-area-inset-bottom, 0px) + .75rem));
  }
}

/* 4. Glass buttons and the header nav ---------------------------------------- */
.glass-gold,
.glass-ghost,
.seg {
  -webkit-tap-highlight-color: transparent;
}
.glass-gold {
  background: linear-gradient(180deg, rgba(240, 208, 128, .94), rgba(200, 146, 42, .84));
  border-color: rgba(255, 255, 255, .5);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .65),
    inset 0 -2px 0 rgba(128, 93, 27, .18),
    0 12px 28px -12px rgba(128, 93, 27, .6);
}
.glass-ghost {
  background: linear-gradient(180deg, rgba(255, 252, 244, .66), rgba(255, 252, 244, .36));
  border-color: rgba(61, 43, 31, .55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 10px 24px -14px rgba(61, 43, 31, .4);
}
.glass-ghost:disabled {
  opacity: .6;
  cursor: not-allowed;
}
.seg {
  background: rgba(255, 252, 244, .6);
  border-color: rgba(200, 146, 42, .5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), 0 10px 24px -14px rgba(61, 43, 31, .35);
}

/* 5. Glass cards ------------------------------------------------------------- */
.glass-card {
  position: relative;
  isolation: isolate;
  background: linear-gradient(160deg, var(--gl-fill-a), var(--gl-fill-b));
  border-color: var(--gl-edge);
  box-shadow: inset 0 1px 0 var(--gl-hi), var(--gl-shadow);
}
/* The light that follows the tilt on iPhone. z-index:-1 keeps it under the text. */
.glass-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(120% 90% at var(--tilt-x) var(--tilt-y),
              rgba(255, 255, 255, .6), rgba(255, 255, 255, 0) 55%);
}

/* Real backdrop blur: desktop-class devices only, on static surfaces only. */
@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
  .glass-gold,
  .glass-ghost,
  .seg,
  .glass-card {
    -webkit-backdrop-filter: blur(var(--gl-blur)) saturate(var(--gl-sat));
            backdrop-filter: blur(var(--gl-blur)) saturate(var(--gl-sat));
  }
  .glass-stage > li {
    -webkit-backdrop-filter: blur(10px) saturate(160%);
            backdrop-filter: blur(10px) saturate(160%);
  }
  .glass-card:hover {
    box-shadow: inset 0 1px 0 var(--gl-hi), 0 22px 40px -18px rgba(61, 43, 31, .45);
  }
}

/* Touch screens keep :hover after a tap, so the lift stayed on. Cancel the
   hover lift there, but keep the press feedback (:active) on the buttons. */
@media (hover: none) {
  .card:hover,
  .glass-card:hover,
  .stair:hover {
    transform: none;
  }
  .glass-card:hover {
    box-shadow: inset 0 1px 0 var(--gl-hi), var(--gl-shadow);
  }
  .btn-gold:hover:not(:active),
  .btn-ghost:hover:not(:active) {
    transform: none;
  }
  .btn-ghost:hover {
    background-color: transparent;
  }
}

/* 6. Glass chart columns: the "from easy to advanced" bars ------------------- */
.glass-stage {
  position: relative;
  z-index: 0;
}
/* A colourful backdrop behind the columns, feathered at the edges */
.glass-stage::before {
  content: "";
  position: absolute;
  inset: -10px -6px;
  z-index: -1;
  border-radius: 1.5rem;
  pointer-events: none;
  /* feather only a 16px band at each edge, so the full width stays covered */
  -webkit-mask-image:
    linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%),
    linear-gradient(to bottom, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
  -webkit-mask-composite: source-in;
          mask-image:
    linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%),
    linear-gradient(to bottom, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
          mask-composite: intersect;
  background:
    radial-gradient(70% 80% at 18% 18%, rgba(240, 208, 128, .6), transparent 70%),
    radial-gradient(60% 80% at 86% 84%, rgba(26, 127, 142, .42), transparent 70%),
    radial-gradient(55% 60% at 52% 48%, rgba(27, 94, 46, .26), transparent 72%);
}
/* Each column is tinted glass at the top and nearly the original solid colour
   at the body, so the five levels keep their colour (v1 lost about half of it). */
.glass-stage > li {
  --c: 27, 94, 46;
  background-color: transparent;
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, .34) 0%, rgba(255, 255, 255, 0) 38%),
    linear-gradient(180deg, rgba(var(--c), .72) 0%, rgba(var(--c), .96) 62%);
  border: 1px solid rgba(255, 255, 255, .38);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .55),
    inset 0 -16px 24px -16px rgba(0, 0, 0, .28),
    0 14px 26px -18px rgba(61, 43, 31, .65);
}
.glass-stage > .bg-lv-1 { --c: 27, 94, 46; }
.glass-stage > .bg-lv-2 { --c: 13, 126, 114; }
.glass-stage > .bg-lv-3 { --c: 26, 58, 107; }
.glass-stage > .bg-lv-4 { --c: 59, 26, 8; }
.glass-stage > .bg-lv-5 { --c: 122, 82, 0; }
/* Labels sit in dark pills: 7.9:1 or better on glyph pixels (the original was 4.5:1) */
.glass-stage > li > span {
  max-width: 100%;
  margin-top: .15rem;
  padding: .2rem .6rem;
  border-radius: 999px;
  background: rgba(26, 15, 2, .6);
  color: #FFF8E7;
  line-height: 1.4;
  overflow-wrap: normal;
  word-break: normal;
}
/* Columns grow from the baseline, one after another, when the section reveals */
.glass-stage > li:nth-child(1) { --i: 0; }
.glass-stage > li:nth-child(2) { --i: 1; }
.glass-stage > li:nth-child(3) { --i: 2; }
.glass-stage > li:nth-child(4) { --i: 3; }
.glass-stage > li:nth-child(5) { --i: 4; }
@keyframes glass-grow {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}
.reveal.in .glass-stage > li {
  animation: glass-grow .9s cubic-bezier(.2, .7, .2, 1) calc(var(--i, 0) * .11s) backwards;
}

/* 7. Neon: the Google Sign-In data section ----------------------------------- */
.neon-zone {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(60vmax 40vmax at 100% 0%, rgba(212, 170, 69, .16), transparent 60%),
    radial-gradient(55vmax 45vmax at 0% 100%, rgba(26, 127, 142, .22), transparent 60%),
    #1A0F02;
}
/* Two static light pools behind the content. They drifted in v1, but moving
   two big translucent layers cost about 50-85 ms per frame on the throttled
   phone profile, for a movement almost nobody could see (18-22 s per cycle). */
.neon-zone::before,
.neon-zone::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 70vmax;
  height: 70vmax;
  border-radius: 50%;
  pointer-events: none;
}
.neon-zone::before {
  inset-inline-start: -28vmax;
  top: -34vmax;
  background: radial-gradient(closest-side, rgba(240, 208, 128, .22), transparent);
}
.neon-zone::after {
  inset-inline-end: -30vmax;
  bottom: -38vmax;
  background: radial-gradient(closest-side, rgba(26, 127, 142, .3), transparent);
}
/* effects.js adds .is-live only while the element is on screen */
.neon-zone:not(.is-live) .neon-ring::before {
  animation-play-state: paused;
}

/* Heading: the neon sign switches on once, when the section reveals */
.neon-title {
  text-shadow:
    0 0 2px rgba(255, 231, 166, .75),
    0 0 14px rgba(240, 208, 128, .55),
    0 0 34px rgba(212, 170, 69, .35);
}
.reveal.in .neon-title {
  animation: neon-ignite 1.8s linear .25s 1 both;
}
@keyframes neon-ignite {
  0%, 100% { opacity: 1; }
  4%  { opacity: .25; }
  7%  { opacity: 1; }
  11% { opacity: .4; }
  14% { opacity: 1; }
}

/* The panel behind the existing text. Narrower gutter and padding on phones,
   so the text column stays close to the original width. */
.neon-panel {
  position: relative;
  isolation: isolate;
  width: min(46rem, calc(100% - 1.75rem));
  max-width: 46rem;
  margin-inline: auto;
  padding: clamp(1.125rem, 3.2vw, 2.25rem);
  border-radius: 1.5rem;
  background: linear-gradient(160deg, rgba(255, 255, 255, .10), rgba(255, 255, 255, .035));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), 0 30px 60px -30px rgba(0, 0, 0, .6);
}
@supports (padding: max(1px, 2px)) {
  .neon-panel {
    width: min(46rem, calc(100% - 2 * max(.875rem, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px))));
  }
}
/* The neon ring. The ring shape is a static mask; only a big conic box
   rotates inside it (transform), so no repaint happens per frame.
   Coverage: a box of (1+2k) times the panel size contains the panel at every
   angle when (1+2k) >= sqrt(1 + (H/W)^2) and (1+2k) >= sqrt(1 + (W/H)^2).
   Desktop panels (H/W about 0.7) need k = 0.4; phones at 390px (H/W about 2)
   need 0.6; at 320px (H/W up to 3) they need 1.1. The box is only as big as
   each size needs, because a bigger rotating layer costs more per frame. */
.neon-ring {
  position: absolute;
  inset: 0;
  z-index: -1;
  padding: 1.5px;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask-composite: exclude;
}
.neon-ring::before {
  content: "";
  position: absolute;
  inset: -60%;
  background: conic-gradient(from 0deg,
              transparent 0deg, transparent 220deg,
              rgba(240, 208, 128, .95) 300deg,
              rgba(26, 127, 142, .9) 332deg,
              transparent 360deg);
  animation: neon-spin 8s linear infinite;
  will-change: transform;
}
@keyframes neon-spin {
  to { transform: rotate(360deg); }
}
@media (max-width: 480px) {
  .neon-ring::before { inset: -80%; }
}
@media (max-width: 350px) {
  .neon-ring::before { inset: -110%; }
}

/* Hero call to action: a soft neon halo that breathes. The glow is a
   box-shadow on a box the exact size of the button: an outer shadow is never
   painted inside its own box, so it cannot tint the button face (the first
   version used a gradient and left a muddy patch on the gold). Only opacity
   animates, and only while the button is on screen. */
.neon-cta {
  position: relative;
  isolation: isolate;
}
.neon-cta::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    0 0 14px 2px rgba(240, 208, 128, .95),
    0 0 34px 8px rgba(212, 170, 69, .38);
  opacity: .5;
  animation: neon-breathe 3.4s ease-in-out infinite alternate;
  will-change: opacity;
}
.neon-cta:not(.is-live)::after {
  animation-play-state: paused;
}
@keyframes neon-breathe {
  from { opacity: .3; }
  to   { opacity: .9; }
}

/* 8. Accessibility: reduced motion and reduced transparency ------------------ */
/* input.css already stops most animations. The ::before elements sit outside
   its selectors, so they are listed here. */
@media (prefers-reduced-motion: reduce) {
  .neon-ring::before,
  .neon-cta::after,
  .reveal.in .neon-title,
  .reveal.in .glass-stage > li {
    animation: none !important;
  }
}
@media (prefers-reduced-transparency: reduce) {
  .glass-gold,
  .glass-ghost,
  .glass-card,
  .seg,
  .glass-stage > li {
    -webkit-backdrop-filter: none;
            backdrop-filter: none;
  }
  .glass-gold { background: #D4AA45; }
  .glass-ghost,
  .glass-card,
  .seg { background: #FEFBF4; }
  .neon-panel { background: #2C1A0A; }
}

/* 9. Touch targets: at least 44px (Apple HIG and WCAG 2.5.5) ----------------- */
@media (pointer: coarse) {
  .seg a,
  #lg {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}
/* Phones: five narrow columns. A little less gap and a smaller label keep each
   word whole inside its column (checked from 320px to 430px). */
@media (max-width: 480px) {
  .glass-stage {
    gap: .3rem;
  }
  .glass-stage > li > span {
    font-size: .75rem;
    padding: .2rem .25rem;
  }
}
