/* ============================================================
   至尊娱乐 - web/WebView boot overlay + shared login skin
   ------------------------------------------------------------
   This file is the single place for:
     1) colours (--kg369-* custom properties under :root, taken from
        the design package's layout.json "styleTokens"), used by both
        the pre-engine health-notice/loading DOM pages defined below
        (#kg808-boot-overlay) and the AuthUI.js login DOM (injected at
        runtime into the same document -> same cascade), and
     2) the composition pieces that are identical on both pages -
        the static background plate, the scene369.js canvas stack
        (background shader / skeletal actors / fountain), the shade
        overlay, logo and intro copy - see "shared landscape
        composition" below. AuthUI.js reuses these class
        names as-is; it only adds the button/popup/input rules that
        are specific to the login view in its own injected <style>.
   Both pages are authored at the package's 1334x750 landscape design
   resolution and centered+scaled(+rotated on a portrait viewport) via
   #kg808-frame here and .kg-auth-stage in AuthUI.js - same rotation
   formula in both, see the inline helper near the end of index.576b9.html
   and AuthUI.prototype.resize().
   Art lives in auth-ui/369/ (ui/ = the package's 2x PNGs shown at
   their 1x logical size, background/ = the character-free plate,
   rig/ = the Spine 3.8 actors plus the browser rig data, fx/ = the
   delivered effect sprites, scene369.js = the runtime adapter for the
   v2 web-preview reference implementation). The element ids
   starting with kg808- are historical and kept so index.576b9.html's boot
   driver and any external references keep working; the older 808
   placeholder art set is still in auth-ui/808/ but is only used for
   the password eye icon, which the 369 package does not ship.
   ============================================================ */

:root {
  /* text colours - layout.json styleTokens */
  --kg369-welcome: rgb(223, 222, 238);
  --kg369-agreement: rgb(174, 187, 212);
  --kg369-footer: rgb(165, 179, 205);
  --kg369-dialog-text: rgb(234, 241, 255);
  --kg369-dialog-dim: rgba(174, 187, 212, .78);
  --kg369-toast-text: rgb(234, 241, 255);
  --kg369-accent: #ffce7b;
  --kg369-danger: #ff9a9a;

  /* surfaces sampled from the delivered plates */
  --kg369-submit-text: #653309;          /* texts.json style.buttonTitle.colorGoldButton */
  --kg369-gold: #e8b666;                 /* btn_submit_normal.png */
  --kg369-gold-light: #fbdc9b;
  --kg369-input-bg: rgba(8, 16, 36, .5); /* input_normal.png */
  --kg369-input-border: rgba(174, 187, 212, .35);
  --kg369-panel: rgb(23, 38, 67);        /* dialog_panel.png */
  --kg369-backdrop: rgba(4, 7, 18, .66);
}

/* ---------- boot overlay: health notice + loading page ---------- */

#kg808-boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  overflow: hidden;
  background: #04060f;
  font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
  transition: opacity .32s ease;
}

#kg808-boot-overlay.kg808-fade-out {
  opacity: 0;
  pointer-events: none;
}

#kg808-boot-overlay * {
  box-sizing: border-box;
}

/* Same two layers as the login page (AuthUI.js .kg-auth-bg / .kg-auth-stage),
   so no side bars show on a tall phone and nothing is cropped:
   - #kg808-bg (plate, scene canvases, shade) is a 1334x750 box scaled to
     COVER the viewport (--kg808-bg-scale, a few px of bleed included);
   - #kg808-frame holds what has to be read. It is exactly the viewport
     (width/height/margins and the 90deg rotation of a portrait viewport come
     from the inline helper script near the end of index.576b9.html) and its groups
     (.kg808-grp, 1334x750 design boxes) are scaled to CONTAIN
     (--kg808-scale) and pinned to the edge they sit at in the design. */
#kg808-frame {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 100%;
  transform: rotate(var(--kg808-rotate, 0deg));
  transform-origin: 50% 50%;
}

#kg808-bg {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1334px;
  height: 750px;
  margin: -375px 0 0 -667px;
  transform: rotate(var(--kg808-rotate, 0deg)) scale(var(--kg808-bg-scale, 1));
  transform-origin: 50% 50%;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity .5s ease;
}

#kg808-boot-overlay.kg808-bg-on #kg808-bg {
  opacity: 1;
  visibility: visible;
}

.kg808-grp {
  position: absolute;
  width: 1334px;
  height: 750px;
  pointer-events: none;
  transform: scale(var(--kg808-scale, 1));
}

.kg808-grp--tl {
  left: 0;
  top: 0;
  transform-origin: 0 0;
}

.kg808-grp--bc {
  left: 50%;
  bottom: 0;
  margin-left: -667px;
  transform-origin: 50% 100%;
}

.kg808-stage {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity .5s ease;
}

.kg808-stage.kg808-visible {
  opacity: 1;
  visibility: visible;
}

/* -- stage 0: health notice (landscape, centered text block) -- */

#kg808-health {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* the notice itself is laid out at design size and scaled to contain, around its own centre */
.kg808-health-box {
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(var(--kg808-scale, 1));
}

.kg808-health-title {
  color: #3d9dff;
  font-weight: 700;
  font-size: 34px;
  text-shadow: 0 0 14px rgba(61, 157, 255, .65);
  margin-bottom: 22px;
  letter-spacing: 2px;
}

.kg808-health-lines p {
  color: #3d9dff;
  font-size: 18px;
  line-height: 1.8;
  margin: 0;
}

/* -- stage 1: loading page -- */

#kg808-loading {
  background: transparent; /* #kg808-bg is behind the frame */
}

/* ---------- 369 loading bar (design/delivery/369-login-skeletal-v2)
   ------------------------------------------------------------
   Ported from that package's web-preview/loading.css (class names
   simple-load-* there) to fixed px for our 1334x750 design stage - no
   cqw/vw units. Per docs/简单进度条接入.md: gold bar ~747x20, centred
   on Cocos (0,-262) -> top-left stage coords x 293.5..1040.5,
   y 627..647; the status label sits left and the percent right,
   directly above the bar, and nothing else is drawn above it. Shared
   by #kg808-loading below (ids kg808-progress-fill/-pct, driven by
   index.576b9.html's boot driver) and AuthUI.js's own login-stage loading
   panel (ids kg-auth-load-*), which also toggles this class's
   [hidden] and its own "unknown" modifier - see AuthUI.prototype.
   openLoading/updateLoading/closeLoading. */
.kg369-load {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.kg369-load[hidden] {
  display: none;
}

.kg369-load-label {
  position: absolute;
  left: 293.5px;
  top: 597px;
  width: 747px;
  height: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--kg369-welcome);
  font-size: 16px;
  letter-spacing: 1px;
  text-shadow: 0 1px 5px #000;
}

.kg369-load-percent {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  color: var(--kg369-gold-light);
  font-weight: 700;
}

.kg369-load-track {
  position: absolute;
  left: 293.5px;
  top: 627px;
  width: 747px;
  height: 20px;
  border-radius: 10px;
  border: 1px solid var(--kg369-input-border);
  background: var(--kg369-input-bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
  overflow: hidden;
}

.kg369-load-fill {
  height: 100%;
  width: 0;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--kg369-gold) 0%, var(--kg369-gold-light) 100%);
  box-shadow: 0 0 10px rgba(251, 220, 155, .4);
  transition: width .12s linear;
}

/* unknown-total mode: a fixed-width segment sweeps the track instead
   of showing a (fake) percentage - doc 简单进度条接入.md "总量未知时
   不显示伪百分比". */
.kg369-load.unknown .kg369-load-fill {
  width: 28% !important;
  animation: kg369-load-search 2s ease-in-out infinite;
}

@keyframes kg369-load-search {
  50% {
    transform: translateX(250%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .kg369-load-fill {
    transition: none;
  }

  .kg369-load.unknown .kg369-load-fill {
    animation: none;
  }
}

/* footer row - same composition/position as AuthUI.js's .kg369-footer
   (layout.json "footer": 40.02/720.25, 1253.97x11; footer_copy.png is
   deliberately not used, see 接入说明 7) */
.kg808-footer {
  position: absolute;
  z-index: 5;
  left: 40px;
  top: 716px;
  width: 1254px;
  height: 20px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: var(--kg369-footer);
  font-size: 10px;
  line-height: 20px;
  white-space: nowrap;
}

.kg808-health-line {
  flex: 1 1 auto;
  text-align: center;
}

.kg808-connection,
.kg808-version {
  flex: 0 0 auto;
  opacity: .9;
}

/* ---------- shared landscape composition ----------
   static plate (z 0) -> scene background shader (1) -> skeletal
   actors (2) -> shade (3) -> fountain (4) -> art and controls (5).
   This is web-preview/style.css's own order (.scene = #living-background
   + the rig canvas, then .shade, then #particles, then the UI): the
   shade dims the characters, the water sparkle sits on top of it.
   The three canvases are created by auth-ui/369/scene369.js inside
   .kg369-scene; everything here only has to reserve the z bands.
   Used as-is by both #kg808-loading above and AuthUI.js's login stage. */

.kg369-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 1334px;
  height: 750px;
  display: block;
  pointer-events: none;
}

/* The generic "a piece of art" band. It has to be declared BEFORE the
   plate/shade rules below: both pages write class="kg369-art kg369-bg"
   / "kg369-art kg369-shade", the selectors have the same specificity,
   so whichever comes last wins the z-index - and the plate has to stay
   behind the scene canvases, not in front of them. */
.kg369-art {
  position: absolute;
  display: block;
  pointer-events: none;
  z-index: 5;
}

.kg369-bg {
  position: absolute;
  left: 0;
  top: 0;
  width: 1334px;
  height: 750px;
  object-fit: cover;
  display: block;
  pointer-events: none;
  z-index: 0;
}

/* scene369.js mounts its canvases here and gives them their own
   z-index (1 background, 2 actors, 4 fountain), so this wrapper must
   NOT create a stacking context - no z-index, no transform, no filter.
   Without WebGL/2d nothing is mounted and .kg369-bg stays visible. */
.kg369-scene {
  overflow: hidden;
}

/* The shader canvas fades in once its texture is uploaded and it has
   drawn one frame; until then (or forever, when WebGL is missing)
   bg_static_cover.png shows through unchanged. */
.kg369-scene-bg {
  opacity: 0;
  transition: opacity .6s ease;
}

.kg369-scene-bg.kg369-scene-ready {
  opacity: 1;
}

.kg369-shade {
  position: absolute;
  left: 0;
  top: 0;
  width: 1334px;
  height: 750px;
  display: block;
  pointer-events: none;
  z-index: 3;
}

/* layout.json drawRects (1x) for the two pieces both pages share */
.kg369-logo {
  left: 21.92px;
  top: 9.25px;
  width: 576px;
  height: 207px;
}

.kg369-intro {
  left: 49.36px;
  top: 216px;
  width: 353px;
  height: 178px;
}
