/* ==========================================================================
   THE APP SHELL
   Everything in this file is scoped to [data-app="1"], which pwa.js only sets
   when the site is running as an installed app. On the website none of it
   applies, so the site is untouched.

   Numbers are from the research, not taste:
     bar 64px + env(safe-area-inset-bottom)   between iOS 49pt and M3 80dp
     48px touch targets                       satisfies Apple 44 and Google 48
     3 slots                                  so the centre button dominates
     labels always visible                    icon-only navigation tests badly
     #A78BFA active                           7.7:1 on black; #7C5CFF is 4.8:1
   ========================================================================== */
/* Double-tap to zoom has no place in an installed app: it fires on any quick
   second tap, so tapping two stage buttons in a row zooms the screen instead.
   touch-action:manipulation switches off double-tap zoom AND the 300ms click
   delay, while leaving pinch-to-zoom alone — which user-scalable=no would not,
   and that would be an accessibility problem. */
[data-app="1"], [data-app="1"] *{
  touch-action:manipulation;
  /* the grey-blue flash the browser paints over anything you tap. Fine on a
     web page, wrong in an app. */
  -webkit-tap-highlight-color:rgba(0,0,0,0);
}
[data-app="1"]{
  -webkit-text-size-adjust:100%;
  --navh:64px;
  --safeb:env(safe-area-inset-bottom,0px);
  --fab:58px;
  --pop:24px;
  --app-dim:#8A8A8E;        /* 6.1:1 on black */
  --app-key:#A78BFA;        /* 7.7:1 — lifted so it doesn't vibrate on black */
}

/* the website's own header and footer are marketing; the app has its own */
[data-app="1"] .nav-wrap,
[data-app="1"] .site-foot,
[data-app="1"] .authbar,
[data-app="1"] .ticker{ display:none !important; }

/* ---------- bottom bar ---------- */
.mm-bar{ display:none; }
[data-app="1"] .mm-bar{
  position:fixed; inset:auto 0 0 0; z-index:80;
  display:grid; grid-auto-flow:column; grid-auto-columns:1fr;
  height:calc(var(--navh) + var(--safeb));
  padding-bottom:var(--safeb);
  background:var(--ink1,#06060A);
  border-top:1px solid rgba(255,255,255,.09);
}
/* WebKit can report a stale safe-area on cold launch; bleed the colour down
   so the gap never flashes white underneath */
[data-app="1"] .mm-bar::after{
  content:''; position:absolute; top:100%; left:0; right:0; height:120px;
  background:var(--ink1,#06060A);
}
.mm-tab{
  display:flex; flex-direction:column; align-items:center; justify-content:flex-end;
  gap:6px; padding-bottom:11px; min-height:48px;
  background:none; border:0; text-decoration:none;
  color:var(--app-dim); transition:color .18s ease;
}
.mm-tab svg{ width:22px; height:22px; }
.mm-tab span{
  font-family:var(--m,monospace); font-size:.56rem; letter-spacing:.13em;
  text-transform:uppercase; line-height:1;
}
.mm-tab[aria-current]{ color:var(--app-key); }
/* state on two channels, never colour alone */
.mm-tab[aria-current] svg{ stroke-width:2.4; }

/* the centre button is an ACTION, so it never carries a selected state */
.mm-slot{ position:relative; }
.mm-go{
  position:absolute; left:50%; bottom:30px; transform:translateX(-50%);
  width:var(--fab); height:var(--fab); border-radius:50%;
  border:0; padding:0; cursor:pointer; display:grid; place-items:center;
  background:linear-gradient(165deg,var(--key,#7C5CFF) 0%,var(--key-lo,#5B41C4) 100%);
  /* a ring, not a shadow — shadows are invisible on pure black */
  box-shadow:0 0 0 6px var(--ink1,#06060A), 0 0 24px rgba(124,92,255,.32);
  transition:transform .16s ease, box-shadow .2s ease;
}
.mm-go:active{ transform:translateX(-50%) scale(.94); }
.mm-go.on{ box-shadow:0 0 0 6px var(--ink1,#06060A),
                     0 0 0 7.5px var(--app-key), 0 0 30px rgba(124,92,255,.32); }
.mm-go img{ width:32px; height:32px; border-radius:8px; }
.mm-golabel{
  position:absolute; left:50%; transform:translateX(-50%); bottom:11px;
  font-family:var(--m,monospace); font-size:.56rem; letter-spacing:.13em;
  text-transform:uppercase; color:var(--app-key); white-space:nowrap; line-height:1;
}

/* every scrolling page must clear the BUTTON, not just the bar, or the
   button sits on top of the last thing on the page */
[data-app="1"] body{
  padding-bottom:calc(var(--navh) + var(--pop) + 28px + var(--safeb));
}
/* EXCEPT the chat. It has no bar, and it is built on the page never
   scrolling: the messages scroll inside a fixed console. The padding above
   made the chat page taller than the screen, so a swipe dragged the whole
   page instead of the messages. */
[data-app="1"] body.mk-body{ padding-bottom:0; }

/* ---------- account, top right ---------- */
.mm-top{ display:none; }
[data-app="1"] .mm-top{
  position:sticky; top:0; z-index:60;
  display:flex; align-items:center; justify-content:space-between;
  gap:10px; padding:calc(13px + env(safe-area-inset-top,0px)) 18px 13px;
  background:var(--void,#000);
  border-bottom:1px solid rgba(255,255,255,.09);
}
.mm-top-t{
  font-family:var(--m,monospace); font-size:.68rem; letter-spacing:.2em;
  text-transform:uppercase; color:var(--app-dim); margin:0;
}
.mm-top-r{ display:flex; align-items:center; gap:2px; }
.mm-icon{
  width:38px; height:38px; display:grid; place-items:center; border-radius:50%;
  background:none; border:0; padding:0; cursor:pointer; color:var(--app-dim);
  text-decoration:none; transition:color .16s ease, background .16s ease;
}
.mm-icon:active{ background:rgba(255,255,255,.06); color:#EDEDED; }
.mm-icon svg{ width:22px; height:22px; }

/* On the website app.js never runs, so the header stays empty. An empty
   element can still take up space, so make sure it takes none. */
header[data-mm-top]:empty{ display:none; }

/* The clearance test lives on the website. Following it from inside the app
   drops people onto the site with no way back, because the test's own logo
   links to the marketing home page and that is outside anything the app knows
   about. Hidden in the app; untouched on the website. */
[data-app="1"] .cf-retake{ display:none !important; }

/* ==========================================================================
   THREE THEMES, FOLLOWING THE CYCLE
   Light cycle -> light. Dark cycle -> dark. The turn -> dusk, which is
   neither, so the app doesn't just describe the transition, it is one.

   Every value below was checked against its own background, not eyeballed.
   Worst ratio in the set is 5.69:1, which clears AA for body text.

   Light mode is warm paper rather than white: a pure white app would read as
   a different product, and #7C5CFF on white is only 4.35:1 — it FAILS for
   text — so light mode uses the deeper purple instead.
   ========================================================================== */
[data-app="1"]{
  --t-bg:#000; --t-surf:#06060A; --t-line:rgba(255,255,255,.09);
  --t-ink:#EDEDED; --t-dim:#8A8A8E; --t-key:#A78BFA;
  --t-fill:#7C5CFF; --t-on-fill:#000;
  transition:background-color .5s ease, color .5s ease;
}
[data-app="1"][data-theme="dark"]{
  --t-bg:#000; --t-surf:#06060A; --t-line:rgba(255,255,255,.09);
  --t-ink:#EDEDED; --t-dim:#8A8A8E; --t-key:#A78BFA;
  --t-fill:#7C5CFF; --t-on-fill:#000;
}
/* THE TURN. A true mid-tone, not another dark: 2.2:1 against the dark theme
   and 8.6:1 against the light one, so it reads as its own place rather than
   a slightly-off black. Purple-slate, pulled from the brand accent — there is
   no warmth in it anywhere, because dawn colours would belong to a different
   product. */
[data-app="1"][data-theme="dusk"]{
  --t-bg:#48405C; --t-surf:#544B6B; --t-line:rgba(255,255,255,.16);
  --t-ink:#F2F0F8; --t-dim:#C4C0D4; --t-key:#CBB8FF;
  --t-fill:#CBB8FF; --t-on-fill:#241E33;
}
[data-app="1"][data-theme="light"]{
  --t-bg:#F4F1EA; --t-surf:#FFFFFF; --t-line:rgba(0,0,0,.12);
  --t-ink:#16161A; --t-dim:#56565E; --t-key:#5B41C4;
  --t-fill:#5B41C4; --t-on-fill:#fff;
}
[data-app="1"] body{ background:var(--t-bg); color:var(--t-ink);
                     transition:background-color .5s ease, color .5s ease; }

/* the shell follows the theme rather than being hard-coded black */
[data-app="1"] .mm-bar{ background:var(--t-surf); border-top-color:var(--t-line); }
[data-app="1"] .mm-bar::after{ background:var(--t-surf); }
[data-app="1"] .mm-top{ background:var(--t-bg); border-bottom-color:var(--t-line); }
[data-app="1"] .mm-top-t, [data-app="1"] .mm-icon, [data-app="1"] .mm-tab{ color:var(--t-dim); }
[data-app="1"] .mm-tab[aria-current]{ color:var(--t-key); }
[data-app="1"] .mm-golabel{ color:var(--t-key); }
[data-app="1"] .mm-go{ box-shadow:0 0 0 6px var(--t-surf), 0 0 24px rgba(124,92,255,.32); }
/* the mark is black artwork on white, so it needs a light disc behind it in
   every theme, not just the dark ones */
[data-app="1"] .mm-go img{ background:#fff; }

/* ---------- the opening animation ----------
   Covers the gap between the phone's own splash (drawn from the manifest) and
   the app's first paint. Without it the screen flashes empty while the session
   and the cycle load. */
.mm-splash{ display:none; }
[data-app="1"] .mm-splash{
  position:fixed; inset:0; z-index:999;
  display:grid; place-items:center;
  background:var(--t-bg);
  opacity:1; transition:opacity .4s ease;
}
[data-app="1"] .mm-splash.out{ opacity:0; pointer-events:none; }
.mm-splash-mark{
  width:92px; height:92px; border-radius:22px; overflow:hidden;
  background:#fff;
  box-shadow:0 0 0 0 rgba(124,92,255,.55);
  animation:mm-breathe 1.6s ease-in-out infinite;
}
.mm-splash-mark img{ width:100%; height:100%; display:block; }
@keyframes mm-breathe{
  0%   { transform:scale(.96); box-shadow:0 0 0 0 rgba(124,92,255,.5); }
  55%  { transform:scale(1);   box-shadow:0 0 0 18px rgba(124,92,255,0); }
  100% { transform:scale(.96); box-shadow:0 0 0 0 rgba(124,92,255,0); }
}
/* anyone who has asked their phone for less movement gets a still mark */
@media (prefers-reduced-motion: reduce){
  .mm-splash-mark{ animation:none; }
  [data-app="1"] .mm-splash{ transition:none; }
}
