/* ===========================================================================
 * Kismat PWA shell — the chrome that lives OUTSIDE Unity.
 *
 * Loaded by index.html (for the Add-to-Home-Screen sheet, the update nudge and
 * the session strip) and by offline.html (which loads nothing else, because it
 * has to render with the network dead).
 *
 * Values mirror unity/Assets/UI/Theme/tokens.uss (Midnight Volt, ADR-061) and
 * web/css/tokens.css. Like the WebGL template's own <style>, this is one of the
 * few places outside the theme allowed to name them: a stylesheet served to a
 * browser cannot read USS, and offline.html must paint with zero dependencies.
 * The names are prefixed --k- so nothing here collides with the template's own
 * :root block.
 * =========================================================================== */

:root {
  --k-ground:  #0a0a0a;                  /* --surface-base    */
  --k-raised:  #1a1a1a;                  /* --surface-raised  */
  --k-ink:     #ffffff;                  /* --text-primary    */
  --k-muted:   #a0a0a0;                  /* --text-secondary  */
  --k-accent:  #edff00;                  /* --accent (volt)   */
  --k-on-accent: #0a0a0a;                /* --text-on-accent  */
  --k-line:    rgba(255, 255, 255, .12); /* --border-default  */

  --k-safe-b:  env(safe-area-inset-bottom, 0px);
  --k-safe-l:  env(safe-area-inset-left, 0px);
  --k-safe-r:  env(safe-area-inset-right, 0px);
}

/* ------------------------------------------------------------- offline.html
 * A whole document, not a fragment: it is served by the service worker when
 * the network is gone, so it must stand up on its own.
 *
 * It says one thing and shows nothing else. No lobby, no last-known balance,
 * no "recent wins" — MOBILE-TRACKER M-18 and the PRD both make that a trust
 * rule rather than a layout preference, because a stale number on this screen
 * is indistinguishable from a lie. */
.k-offline {
  margin: 0;
  min-height: 100dvh;
  background: var(--k-ground);
  color: var(--k-ink);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px calc(24px + var(--k-safe-l)) calc(32px + var(--k-safe-b)) calc(24px + var(--k-safe-r));
  -webkit-tap-highlight-color: transparent;
}

.k-offline__inner {
  max-width: 360px;
  text-align: center;
}

.k-offline__mark {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  display: block;
  margin: 0 auto 24px;
}

.k-offline__title {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .01em;
  line-height: 1.25;
}

.k-offline__body {
  margin: 0 0 28px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--k-muted);
}

.k-offline__retry {
  display: inline-block;
  min-height: 48px;
  line-height: 48px;
  padding: 0 28px;
  border-radius: 12px;
  background: var(--k-accent);
  color: var(--k-on-accent);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}

/* ============================================================ shared sheet
 * One bottom-sheet component, three uses: the Add-to-Home-Screen teach (M-13),
 * the new-build nudge (M-12) and the session strip (M-16). Hidden with the
 * [hidden] attribute so nothing can tab into it or swallow a canvas touch. */
.k-sheet[hidden] { display: none; }

.k-sheet {
  position: fixed;
  left: calc(12px + var(--k-safe-l));
  right: calc(12px + var(--k-safe-r));
  bottom: calc(12px + var(--k-safe-b));
  z-index: 9;
  box-sizing: border-box;
  padding: 16px 16px 14px;
  border-radius: 16px;
  border: 1px solid var(--k-line);
  background: var(--k-raised);
  color: var(--k-ink);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .6);
  animation: k-rise .28s ease both;
}

/* THE ANIMATION MAY NOT TOUCH OPACITY.
 *
 * It did, and the sheet shipped invisible: caught in headless Chrome over the
 * live client at 390x844, computed opacity 0.041 twenty-five seconds after the
 * element was inserted. Unity's WebGL loop starves the frames this animation is
 * driven by, so `from { opacity: 0 }` is not a fade-in — it is a sheet the
 * player never sees, with no error anywhere to say so.
 *
 * A transform is safe because its worst case is legible: the sheet sits 18px
 * lower than intended and is still entirely on screen and fully opaque. Nothing
 * that decides whether this element can be READ may live in a keyframe. */
@keyframes k-rise {
  from { transform: translateY(18px); }
  to   { transform: none; }
}

/* The project honours a reduced-motion preference everywhere else; this is
 * shell chrome and must honour it too. */
@media (prefers-reduced-motion: reduce) {
  .k-sheet { animation: none; }
}

@media (min-width: 700px) {
  .k-sheet { left: auto; right: 20px; max-width: 380px; }
}

.k-sheet__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.k-sheet__icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex: 0 0 auto;
}

.k-sheet__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .01em;
}

.k-sheet__body {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--k-muted);
}

.k-sheet__body b {
  color: var(--k-ink);
  font-weight: 600;
}

/* The Share glyph, drawn inline so the steps name the icon the player is
 * actually looking for rather than describing it in words. */
.k-share {
  width: 15px;
  height: 15px;
  vertical-align: -2px;
  fill: none;
  stroke: var(--k-accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.k-sheet__actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.k-btn {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1px solid var(--k-line);
  background: transparent;
  color: var(--k-muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.k-btn--primary {
  background: var(--k-accent);
  border-color: var(--k-accent);
  color: var(--k-on-accent);
}

.k-btn:focus-visible {
  outline: 2px solid var(--k-accent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------- session strip
 * A single honest line, not a dialog. It never claims anything was lost,
 * because nothing was: the ledger is the server's. */
.k-sheet--strip .k-sheet__head { margin-bottom: 6px; }
