/* ==========================================================================
   Fleet OS · 同源星圖 · 分頻脈動 P0  「點燈蓄勢」  (beacon-pulse-p0-20261106)
   --------------------------------------------------------------------------
   Scope: display layer only. 0 JS logic, 0 backend, 0 Auth, 0 Credits,
   0 question bank, 0 marking, 0 App Check, 0 CAFS change.

   HARD RULES — enforced by the shape of this file, not by trust:
     1. Only `opacity` and `transform` are animated. No width / height /
        margin / padding animation. No animated `filter`. No large-area
        `backdrop-filter` (the Fleet glass layer stays where it already is).
     2. Every `animation:` below is either (a) interaction-triggered and
        finite, or (b) gated behind `html.fleet-mode-edutainment` (墨陣).
        Standard mode therefore has **0 idle continuous animation**.
     3. Colour changes are allowed everywhere (色變); motion is not.
     4. 0 library, 0 web font, 0 audio, 0 particles, 0 fake countdown.
     5. Under `prefers-reduced-motion: reduce` this file allows a <=120ms
        cross-fade and instant colour changes only: 0 位移 / 0 縮放 /
        0 數字滾輪 / 0 背景呼吸.
     6. Footer DOM/text is untouched. This file never styles the operator
        sentence or adds a line break to it.

   Dose ladder (dose = how loud, deliberately small):
     微光   opacity 7% (墨陣 6%–8% breathing)
     髮絲邊 1px  rgba(248,250,252,.16) top edge on cards
     蓄光條 3px   amber #F59E0B, turns jade #10B981 at 100%
     三拍子 180ms opacity cross-fade per beat
     結果   280–400ms per stage, whole staged reveal <= 400ms
   ========================================================================== */

/* --------------------------------------------------------------------------
   0 · Tokens (namespaced; no site colour is redefined here)
   -------------------------------------------------------------------------- */

:root {
  --beacon-void: #0B0F17;
  --beacon-amber: #F59E0B;
  --beacon-amber-soft: #FBBF24;
  --beacon-amber-rgb: 245, 158, 11;
  --beacon-jade: #10B981;
  --beacon-jade-text: #34D399;
  --beacon-jade-soft: rgba(16, 185, 129, 0.4);
  --beacon-miss: #C2564B; /* 溫和暗珀紅 — not an alert red */
  --beacon-miss-text: #E2A79F;
  --beacon-miss-soft: rgba(194, 86, 75, 0.42);
  --beacon-hairline: rgba(248, 250, 252, 0.16);
  --beacon-glow-alpha: 0.07; /* inside the 4%–8% budget */
  --beacon-dur-press: 180ms; /* 150–220ms response window */
  --beacon-dur-result: 300ms; /* 280–400ms result window */
}

/* --------------------------------------------------------------------------
   1 · 全域微光材質 — base #0B0F17 + ONE radial glow + card top hairline
   The base surface stays whatever the station already paints (all Fleet
   stations resolve to --fleet-bg: #0B0F17 through the beacon tokens); this
   layer only adds the single light source on top of it.
   -------------------------------------------------------------------------- */

/* The light lives on the root element, not on <body>: every Fleet station
   paints its own body background (propagated to the canvas) and then stacks
   its cards above it. html::before is the one layer that sits above the page
   wash and below the station's own content, on every station. */
html::before {
  content: "";
  display: block;
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse 130% 95% at 50% -12%,
    rgba(var(--beacon-amber-rgb), var(--beacon-glow-alpha)) 0%,
    rgba(var(--beacon-amber-rgb), 0) 78%
  );
}

/* 1px top micro-highlight on the Fleet cards. Colour only: no border width,
   no radius, no layout change, and it degrades to nothing on a card that
   has no border to recolour. */
[data-beacon-plate],
#beacon-desk,
#beacon-pass,
#en-today,
#result-section,
.glass-sanctum,
.wl-slip {
  border-top-color: var(--beacon-hairline);
}

/* --------------------------------------------------------------------------
   2 · Standard｜墨陣 視覺閘
   Standard  = the shared layer is completely still.
   墨陣      = the same layer unlocks one slow glow breath + one geometric
               hairline. This is the P0 switch difference; the full P2
               star-map is NOT in this file.
   The gate reads the classes that shared/bliss-mode-gate.js already writes:
   html.fleet-mode-standard / html.fleet-mode-edutainment / html.fleet-mode-pick
   -------------------------------------------------------------------------- */

/* A single geometric hairline (the "same-source" horizon). Standard: absent. */
html::after {
  content: "";
  display: block;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    90deg,
    rgba(var(--beacon-amber-rgb), 0) 0%,
    rgba(var(--beacon-amber-rgb), 0.22) 16%,
    rgba(var(--beacon-amber-rgb), 0.32) 50%,
    rgba(var(--beacon-amber-rgb), 0.22) 84%,
    rgba(var(--beacon-amber-rgb), 0) 100%
  );
}

/* Standard (explicit) and "no mode class yet" both stay still. */
html:not(.fleet-mode-edutainment)::before,
html:not(.fleet-mode-edutainment)::after {
  animation: none !important;
}

html.fleet-mode-edutainment::after {
  opacity: 1;
}

html.fleet-mode-edutainment::before {
  animation: beacon-breathe 12s ease-in-out infinite alternate;
}

@keyframes beacon-breathe {
  from {
    opacity: 0.86; /* 7% * .86 ≈ 6% */
  }
  to {
    opacity: 1; /* 7% */
  }
}

/* --------------------------------------------------------------------------
   2b · Standard 靜止清單
   The Fleet already ships decorative loops that run forever while the page
   sits still. In Standard they must not run: 同屏持續動畫＝0. Each selector
   below was taken from `document.getAnimations()` on the live local DOM
   (english / exam / game at 1440 and 390) and is frozen in Standard only —
   墨陣 gives every one of them back, so the mode switch stays visible.
   This is an override layer: no station file is edited by it.
   -------------------------------------------------------------------------- */

html:not(.fleet-mode-edutainment) :is(
    .god-rays,
    .animate-pulse,
    #listening-visualizer .bar,
    .reading-visualizer,
    .state-tag.active,
    .ex-type-btn.active,
    .diff-btn.active,
    .btn-infinite-inspo,
    .btn-infinite-inspo *,
    #bliss-fleet-coach-fab,
    #cc-palette-fab,
    .bsvg-pulse,
    #bliss-job-crystal-fab,
    #bliss-job-crystal-fab *,
    .bliss-skin-jingdu-light
  ) {
  animation: none !important;
}

html:not(.fleet-mode-edutainment) .reading-visualizer::after,
html:not(.fleet-mode-edutainment) #bliss-job-crystal-fab .lbl::after {
  animation: none !important;
}

/* --------------------------------------------------------------------------
   3 · Academic · 燈下試席 三拍子 + 蓄光燈芯
   Beat 1 選中提亮 · Beat 2 確認收束 · Beat 3 對／錯描邊
   Reading / timing state adds no ambient animation at all — every rule in
   this section is a static state style or an event-driven cross-fade.
   -------------------------------------------------------------------------- */

/* 3.1 蓄光燈芯 progress bar (2px–3px; amber march; jade at completion).
   The bar element itself is mounted by shared/bliss-beacon-pulse.js; this
   file owns its look only. */
body[data-realm] #beacon-desk::before {
  height: 3px;
  opacity: 1;
  background: rgba(var(--beacon-amber-rgb), 0.14);
}

#beacon-charge {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  height: 3px;
  border-radius: var(--fleet-r-card, 12px) var(--fleet-r-card, 12px) 0 0;
  pointer-events: none;
  transform: scaleX(var(--beacon-charge, 0));
  transform-origin: left center;
  background: linear-gradient(
    90deg,
    var(--beacon-amber) 0%,
    var(--beacon-amber-soft) 76%,
    var(--beacon-amber) 100%
  );
  opacity: 0.94;
  transition: transform var(--beacon-dur-press) ease;
}

body[data-realm] [data-beacon-charge="complete"] #beacon-charge {
  background: var(--beacon-jade);
  opacity: 1;
}

/* Beat 2 → 1: while the desk holds a sealed beat the wick sits back. */
body[data-realm] [data-beacon-beat="sealed"] #beacon-charge {
  opacity: 0.8;
}

/* 3.2 Beat 1 · 選中提亮 — one 1px amber ring + a wick of light on the
   picked answer. Only opacity is animated; the ring is painted once. */
body[data-realm] #en-today-play .choice,
body[data-realm] .mcq-option,
body[data-realm] .esp-mc-btn {
  position: relative;
}

body[data-realm] #en-today-play .choice::after,
body[data-realm] .mcq-option::after,
body[data-realm] .esp-mc-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--beacon-dur-press) ease;
  box-shadow: inset 0 0 0 1px rgba(var(--beacon-amber-rgb), 0.58),
    inset 3px 0 0 0 rgba(var(--beacon-amber-rgb), 0.9);
  background: linear-gradient(
    90deg,
    rgba(var(--beacon-amber-rgb), 0.13) 0%,
    rgba(var(--beacon-amber-rgb), 0) 48%
  );
}

body[data-realm] #en-today-play .choice.is-pick::after,
body[data-realm] .mcq-option.is-picked::after,
body[data-realm] .mcq-option.active::after,
body[data-realm] .esp-mc-btn.is-on::after {
  opacity: 1;
}

/* 3.3 Beat 2 · 確認收束 — the options that were not chosen step back so the
   sealed answer is the only lit thing left. Opacity only. */
body[data-realm="exam"] .ff-answer-menu[data-locked="1"] .ff-menu-item:disabled {
  opacity: 0.68;
}

body[data-realm="exam"] .ff-answer-menu[data-locked="1"] .ff-menu-item.correct,
body[data-realm="exam"] .ff-answer-menu[data-locked="1"] .ff-menu-item.wrong {
  opacity: 1;
}

body[data-realm] .paper-q[data-lp-graded="1"] .mcq-option {
  opacity: 0.86;
}

body[data-realm] .paper-q[data-lp-graded="1"] .mcq-option.is-picked {
  opacity: 1;
}

/* 3.4 Beat 3 · 對／錯描邊 — the only two verdict colours in this wave. */
body[data-realm="exam"] .ff-answer-menu .ff-menu-item.correct {
  border-color: var(--beacon-jade) !important;
  color: var(--beacon-jade-text) !important;
  box-shadow: inset 0 0 0 1px var(--beacon-jade-soft);
}

body[data-realm="exam"] .ff-answer-menu .ff-menu-item.wrong {
  border-color: var(--beacon-miss) !important;
  color: var(--beacon-miss-text) !important;
  opacity: 0.92 !important;
  box-shadow: inset 0 0 0 1px var(--beacon-miss-soft);
}

body[data-realm] input.correct,
body[data-realm] textarea.correct {
  border-color: var(--beacon-jade) !important;
  box-shadow: inset 0 0 0 1px var(--beacon-jade-soft);
}

body[data-realm] input.incorrect,
body[data-realm] textarea.incorrect {
  border-color: var(--beacon-miss) !important;
  box-shadow: inset 0 0 0 1px var(--beacon-miss-soft);
}

/* Daily-ten progress cells carry the same verdict language. */
body[data-realm] #en-today-grid .cell.is-ok {
  box-shadow: inset 0 0 0 1px var(--beacon-jade-soft);
}

body[data-realm] #en-today-grid .cell.is-miss {
  box-shadow: inset 0 0 0 1px var(--beacon-miss-soft);
}

/* Beat 3 at desk scale: the answered surface takes the verdict ring, and the
   desk edge takes a 1px tint so the verdict is readable at a glance. */
body[data-realm] #en-today-play[data-beacon-beat="right"] {
  border-radius: var(--fleet-r-control, 8px);
  box-shadow: inset 0 0 0 1px var(--beacon-jade-soft);
}

body[data-realm] #en-today-play[data-beacon-beat="wrong"] {
  border-radius: var(--fleet-r-control, 8px);
  box-shadow: inset 0 0 0 1px var(--beacon-miss-soft);
}

body[data-realm] #beacon-desk[data-beacon-beat="right"] {
  border-color: rgba(16, 185, 129, 0.34);
}

body[data-realm] #beacon-desk[data-beacon-beat="wrong"] {
  border-color: var(--beacon-miss-soft);
}

/* --------------------------------------------------------------------------
   4 · Game · 霧燈演局
   4.1 霧光底圖 — very slow (7.4s), opacity + transform only, 墨陣 only.
   4.2 凝神 — the decision surface brightens its own edge.
   4.3 結果分步淡入 — three stages, <= 400ms in total.
   -------------------------------------------------------------------------- */

/* 4.1 霧燈: two soft reservoirs of light. Standard shows the fog standing
   still (material, not motion); 墨陣 lets it breathe. */
body[data-realm="game"]::after {
  content: "";
  display: block;
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
  background: radial-gradient(
      ellipse 78% 62% at 18% 10%,
      rgba(248, 250, 252, 0.09) 0%,
      rgba(248, 250, 252, 0) 66%
    ),
    radial-gradient(
      ellipse 70% 62% at 82% 78%,
      rgba(var(--beacon-amber-rgb), 0.11) 0%,
      rgba(var(--beacon-amber-rgb), 0) 70%
    );
}

html.fleet-mode-edutainment body[data-realm="game"]::after {
  animation: beacon-fog 7.4s ease-in-out infinite alternate;
}

@keyframes beacon-fog {
  from {
    opacity: 0.4;
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    opacity: 0.78;
    transform: translate3d(0, -1.2%, 0) scale(1.02);
  }
}

/* 4.2 凝神: the decision edge lights up before the choice is made. */
body[data-realm="game"] #rpgChoices .rpg-choice,
body[data-realm="game"] #startScreen #wl-start,
body[data-realm="game"] .portal-btn {
  transition: border-color var(--beacon-dur-press) ease,
    opacity var(--beacon-dur-press) ease;
}

body[data-realm="game"] #rpgChoices .rpg-choice:hover,
body[data-realm="game"] #rpgChoices .rpg-choice:focus-visible {
  border-color: var(--beacon-amber-soft) !important;
  box-shadow: inset 0 0 0 1px rgba(var(--beacon-amber-rgb), 0.45),
    inset 0 0 0 4px rgba(var(--beacon-amber-rgb), 0.06);
}

body[data-realm="game"] #rpgChoices .rpg-choice.is-locked {
  opacity: 0.82;
}

body[data-realm="game"] #rpgChoices .rpg-choice.is-locked[aria-pressed="true"],
body[data-realm="game"] #rpgChoices .rpg-choice.is-locked:focus {
  opacity: 1;
  border-color: var(--beacon-amber) !important;
}

body[data-realm="game"] #startScreen #wl-start:hover,
body[data-realm="game"] #startScreen #wl-start:focus-visible,
body[data-realm="game"] .portal-btn:hover,
body[data-realm="game"] .portal-btn:focus-visible {
  border-color: var(--beacon-amber-soft) !important;
  box-shadow: inset 0 0 0 1px rgba(var(--beacon-amber-rgb), 0.5),
    0 0 0 1px rgba(var(--beacon-amber-rgb), 0.22);
}

/* 4.3 結果分步: beats → slip → signature, 300ms each with a 40ms stagger. */
body[data-realm="game"] #resultScreen.active .wl-slip > * {
  animation: beacon-result-step var(--beacon-dur-result) ease both;
}

body[data-realm="game"] #resultScreen.active .wl-slip > :nth-child(1) {
  animation-delay: 0ms;
}

body[data-realm="game"] #resultScreen.active .wl-slip > :nth-child(2) {
  animation-delay: 40ms;
}

body[data-realm="game"] #resultScreen.active .wl-slip > :nth-child(3) {
  animation-delay: 80ms;
}

body[data-realm="game"] #resultScreen.active .wl-slip > :nth-child(n + 4) {
  animation-delay: 100ms;
}

/* The reflection itself arrives late (async). It gets the same step-in when
   it does, so the result still reads as three beats, not one dump. */
body[data-realm="game"] #oracleContent:not(.hidden),
body[data-realm="game"] #game-breath-box:not(.hidden),
body[data-realm="game"] #game-practice-box:not(.hidden) {
  animation: beacon-result-step var(--beacon-dur-result) ease both;
}

@keyframes beacon-result-step {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   5 · 預備級 (P1) hooks — defined, deliberately NOT activated in P0.
   These exist so P1 does not have to re-invent names. Nothing here renders
   a shape yet; no particle field, no star-map, no 換陣 flow.
   -------------------------------------------------------------------------- */

[data-beacon-hook="credits-step"] {
  /* P1: 數字單步翻頁 + 琥珀刻度槽 (front-end only) */
}

[data-beacon-hook="map-hall-ring"] {
  /* P1: 地圖抽屜當前站琥珀呼吸環 */
}

[data-beacon-hook="star-link"] {
  /* P2: 星圖連珠 */
}

/* --------------------------------------------------------------------------
   6 · prefers-reduced-motion 總閘
   Allowed: <=120ms cross-fade, instant colour change.
   Forbidden: transform, scale, breathing, number roll, marquee.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html::before,
  html::after,
  body[data-realm="game"]::after {
    animation: none !important;
    transform: none !important;
  }

  #beacon-charge {
    transition: none !important;
    transform: scaleX(var(--beacon-charge, 0)) !important;
  }

  body[data-realm] #en-today-play .choice::after,
  body[data-realm] .mcq-option::after,
  body[data-realm] .esp-mc-btn::after {
    transition: none !important;
  }

  body[data-realm="game"] #rpgChoices .rpg-choice,
  body[data-realm="game"] #startScreen #wl-start,
  body[data-realm="game"] .portal-btn {
    transition: none !important;
    transform: none !important;
  }

  body[data-realm="game"] #resultScreen.active .wl-slip > *,
  body[data-realm="game"] #oracleContent:not(.hidden),
  body[data-realm="game"] #game-breath-box:not(.hidden),
  body[data-realm="game"] #game-practice-box:not(.hidden) {
    animation: beacon-fade-only 120ms linear both !important;
    transform: none !important;
  }

  /* Pre-existing decorative idle loops must also stand still under reduce —
     same evidence-derived list as the Standard gate above. */
  :is(
      .animate-pulse,
      .animate-soul-pulse,
      .animate-gate-glow,
      .animate-spin-slow,
      .god-rays,
      #listening-visualizer .bar,
      .reading-visualizer,
      .state-tag.active,
      .ex-type-btn.active,
      .diff-btn.active,
      .btn-infinite-inspo,
      .btn-infinite-inspo *,
      #bliss-fleet-coach-fab,
      #cc-palette-fab,
      .bsvg-pulse,
      #bliss-job-crystal-fab,
      #bliss-job-crystal-fab *,
      .bliss-skin-jingdu-light
    ) {
    animation: none !important;
  }

  .reading-visualizer::after,
  #bliss-job-crystal-fab .lbl::after {
    animation: none !important;
  }
}

@keyframes beacon-fade-only {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
