@import url('./css/stream-layers.css');
@import url('./css/download.css');

:root {
  --bg-start: #02040a;
  --bg-mid: #081120;
  --bg-end: #10294a;
  --flare-a: rgba(26, 72, 112, 0.26);
  --flare-b: rgba(77, 227, 255, 0.14);
  --text-main: #eaffff;
  --text-glow-a: rgba(77, 227, 255, 0.82);
  --text-glow-b: rgba(91, 192, 255, 0.52);
  --text-glow-c: rgba(16, 83, 214, 0.22);
  --text-blur: rgba(98, 255, 228, 0.45);
  --text-offset: rgba(123, 191, 255, 0.35);
  --text: #f4fbff;
  --card-bg: rgba(4, 10, 20, 0.82);
  --card-border: rgba(118, 180, 255, 0.18);
  --accent: #78dfff;
  --danger: #ff9f7d;

  /* === 自适应布局变量 - 仅关键元素优化 === */
  /* 触控区域最小尺寸 - Apple HIG标准 */
  --touch-target-min: 44px;

  /* 流体主标题 - 核心自适应 */
  --text-hero: clamp(3rem, 13vw, 12rem);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: clamp(14px, 1.5vw, 16px); /* 基础字体流体化 */
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh; /* 动态视口高度，支持移动端地址栏 */
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% 18%, var(--flare-a), transparent 34%),
    radial-gradient(circle at 80% 20%, var(--flare-b), transparent 28%),
    linear-gradient(180deg, var(--bg-start) 0%, var(--bg-mid) 48%, var(--bg-end) 100%);
  color: var(--text);
  font-family: "Inter", sans-serif;
  font-size: clamp(0.875rem, 2vw, 1rem); /* 基础字体流体化 */
  line-height: 1.6;
  transition:
    background 1.6s linear,
    color 1.6s linear;
}

body.network-busy .watcher-stage {
  cursor: progress;
}

body.connection-rush::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.08), transparent 30%),
    linear-gradient(180deg, rgba(160, 225, 255, 0.08), rgba(7, 14, 28, 0) 22%, rgba(7, 14, 28, 0.22) 100%);
  opacity: 1;
  z-index: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.04) 0,
      rgba(255, 255, 255, 0) 2px,
      rgba(255, 255, 255, 0) 6px
    );
  background-size: 100% 6px;
  opacity: 0.15;
  mix-blend-mode: screen;
}

body.connection-rush::after {
  content: none;
}

#particle-field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

#immersive-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s linear;
}

body.immersive-active #particle-field {
  opacity: 0;
  transition: opacity 1.2s ease;
}

body.immersive-active .page-shell {
  pointer-events: none;
}

body.immersive-active .mode-toggle {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

body.immersive-active .download-entry {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

body.immersive-active .camera-layer {
  background: transparent !important;
  z-index: 5;
}

body.immersive-active .camera-frame {
  opacity: 0 !important;
  pointer-events: none;
}

body.immersive-active .camera-hud,
body.immersive-active .camera-close {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 0.6s ease;
}

.page-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.mode-toggle {
  --liquid-x: 50%;
  --liquid-y: 50%;
  --liquid-core-size: 9%;
  --liquid-rim-size: 14%;
  --liquid-aura-size: 25%;
  --liquid-falloff-size: 50%;
  --liquid-gloss-width: 15%;
  --liquid-gloss-height: 19%;
  --liquid-ring-strength: 0.22;
  --liquid-presence: 0;
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 1rem);
  right: calc(env(safe-area-inset-right, 0px) + 1rem);
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.22rem;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: transparent;
  cursor: pointer;
  box-shadow:
    0 14px 34px rgba(3, 12, 24, 0.1),
    0 0 28px rgba(106, 214, 255, 0.05);
  transition:
    transform 0.28s ease,
    filter 0.28s ease,
    box-shadow 0.28s ease;
}

.mode-toggle-lens {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(
      circle at var(--liquid-x) var(--liquid-y),
      rgba(255, 255, 255, calc(0.22 * var(--liquid-presence))) 0 calc(var(--liquid-core-size) * 0.6),
      rgba(255, 255, 255, calc(0.12 * var(--liquid-presence))) calc(var(--liquid-core-size) * 0.96),
      rgba(255, 255, 255, calc(var(--liquid-ring-strength) * 0.95 * var(--liquid-presence))) calc(var(--liquid-rim-size) * 0.84),
      rgba(196, 237, 255, calc(var(--liquid-ring-strength) * 0.72 * var(--liquid-presence))) var(--liquid-aura-size),
      rgba(196, 237, 255, 0) var(--liquid-falloff-size)
    ),
    radial-gradient(
      circle at var(--liquid-x) var(--liquid-y),
      rgba(255, 255, 255, 0) 0 calc(var(--liquid-core-size) * 0.72),
      rgba(255, 255, 255, calc(var(--liquid-ring-strength) * 1.12 * var(--liquid-presence))) calc(var(--liquid-rim-size) * 0.74),
      rgba(255, 255, 255, 0) calc(var(--liquid-aura-size) * 0.82)
    ),
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.01)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(146, 222, 255, 0.05) 42%, rgba(18, 42, 68, 0.04) 100%);
  border: 1px solid rgba(235, 248, 255, 0.15);
  backdrop-filter: blur(30px) saturate(190%);
  -webkit-backdrop-filter: blur(30px) saturate(190%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 10px 28px rgba(8, 20, 34, 0.1),
    0 0 34px rgba(130, 218, 255, 0.08);
}

.mode-toggle::before,
.mode-toggle::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.mode-toggle::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04) 42%, rgba(16, 34, 52, 0.02) 100%);
  opacity: 0.72;
}

.mode-toggle::after {
  left: var(--liquid-x);
  top: var(--liquid-y);
  width: var(--liquid-gloss-width);
  height: var(--liquid-gloss-height);
  background:
    radial-gradient(circle at 36% 34%, rgba(255, 255, 255, 0.42) 0 18%, rgba(255, 255, 255, 0.22) 34%, rgba(255, 255, 255, 0) 62%),
    radial-gradient(circle at 62% 66%, rgba(182, 232, 255, 0.16) 0 14%, rgba(182, 232, 255, 0) 42%);
  border-radius: 44% 56% 52% 48% / 46% 52% 48% 54%;
  mix-blend-mode: screen;
  filter: blur(10px);
  opacity: calc(0.9 * var(--liquid-presence));
  transform: translate(-50%, -50%);
  transition:
    left 0.16s ease,
    top 0.16s ease,
    width 0.18s ease,
    height 0.18s ease,
    transform 0.18s ease,
    opacity 0.35s ease;
}

.mode-toggle:hover {
  transform: translateY(-2px) scale(1.01);
  filter: brightness(1.04);
  box-shadow:
    0 18px 40px rgba(3, 12, 24, 0.12),
    0 0 32px rgba(106, 214, 255, 0.08);
}

.mode-toggle-segment {
  position: relative;
  z-index: 1;
  border-radius: 999px;
  transition:
    background 0.24s ease,
    box-shadow 0.24s ease,
    transform 0.24s ease;
}

.mode-toggle-segment.is-active {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(142, 220, 255, 0.09) 56%, rgba(245, 220, 175, 0.13));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 0 22px rgba(106, 214, 255, 0.09);
}

.mode-toggle-option {
  position: relative;
  min-width: 3.7rem;
  padding: 0.54rem 0.72rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(226, 241, 255, 0.76);
  font: inherit;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    color 0.24s ease,
    transform 0.24s ease,
    text-shadow 0.24s ease;
}

.mode-toggle-option-text {
  position: relative;
  z-index: 1;
  display: inline-block;
  white-space: nowrap;
  text-shadow:
    0 0 7px rgba(98, 255, 228, 0.36),
    0 0 16px rgba(98, 255, 228, 0.12);
}

.mode-toggle-segment.is-active .mode-toggle-option {
  color: rgba(248, 252, 255, 0.98);
}

.mode-toggle-option:hover {
  color: rgba(244, 251, 255, 0.94);
}

.mode-toggle-option:focus-visible {
  outline: 2px solid rgba(122, 223, 255, 0.72);
  outline-offset: 3px;
}

.mode-toggle:focus-visible {
  outline: 2px solid rgba(122, 223, 255, 0.72);
  outline-offset: 3px;
}

.corner-action {
  --liquid-x: 50%;
  --liquid-y: 50%;
  --liquid-core-size: 8%;
  --liquid-rim-size: 13%;
  --liquid-aura-size: 24%;
  --liquid-falloff-size: 48%;
  --liquid-gloss-width: 14%;
  --liquid-gloss-height: 18%;
  --liquid-ring-strength: 0.22;
  --liquid-presence: 0;
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 1rem);
  left: calc(env(safe-area-inset-left, 0px) + 1rem);
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: transparent;
  color: rgba(239, 249, 255, 0.92);
  text-decoration: none;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease;
  box-shadow: 0 10px 28px rgba(3, 12, 24, 0.08);
}

.corner-action-lens {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(
      circle at var(--liquid-x) var(--liquid-y),
      rgba(255, 255, 255, calc(0.22 * var(--liquid-presence))) 0 calc(var(--liquid-core-size) * 0.6),
      rgba(255, 255, 255, calc(0.12 * var(--liquid-presence))) calc(var(--liquid-core-size) * 0.96),
      rgba(255, 255, 255, calc(var(--liquid-ring-strength) * 0.95 * var(--liquid-presence))) calc(var(--liquid-rim-size) * 0.84),
      rgba(196, 237, 255, calc(var(--liquid-ring-strength) * 0.72 * var(--liquid-presence))) var(--liquid-aura-size),
      rgba(196, 237, 255, 0) var(--liquid-falloff-size)
    ),
    radial-gradient(
      circle at var(--liquid-x) var(--liquid-y),
      rgba(255, 255, 255, 0) 0 calc(var(--liquid-core-size) * 0.72),
      rgba(255, 255, 255, calc(var(--liquid-ring-strength) * 1.12 * var(--liquid-presence))) calc(var(--liquid-rim-size) * 0.74),
      rgba(255, 255, 255, 0) calc(var(--liquid-aura-size) * 0.82)
    ),
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.01)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(146, 222, 255, 0.05) 42%, rgba(18, 42, 68, 0.04) 100%);
  border: 1px solid rgba(235, 248, 255, 0.15);
  backdrop-filter: blur(30px) saturate(190%);
  -webkit-backdrop-filter: blur(30px) saturate(190%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 10px 28px rgba(8, 20, 34, 0.1),
    0 0 34px rgba(130, 218, 255, 0.08);
  transition: border-color 0.18s ease;
}

.corner-action-content {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  padding: 0.78rem 1rem;
  border-radius: inherit;
}

.corner-action::before,
.corner-action::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.corner-action::before {
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04) 42%, rgba(16, 34, 52, 0.02) 100%);
  opacity: 0.72;
}

.corner-action::after {
  left: var(--liquid-x);
  top: var(--liquid-y);
  width: var(--liquid-gloss-width);
  height: var(--liquid-gloss-height);
  background:
    radial-gradient(circle at 36% 34%, rgba(255, 255, 255, 0.42) 0 18%, rgba(255, 255, 255, 0.22) 34%, rgba(255, 255, 255, 0) 62%),
    radial-gradient(circle at 62% 66%, rgba(182, 232, 255, 0.16) 0 14%, rgba(182, 232, 255, 0) 42%);
  border-radius: 44% 56% 52% 48% / 46% 52% 48% 54%;
  mix-blend-mode: screen;
  filter: blur(10px);
  opacity: calc(0.9 * var(--liquid-presence));
  transform: translate(-50%, -50%);
  transition:
    left 0.16s ease,
    top 0.16s ease,
    width 0.18s ease,
    height 0.18s ease,
    transform 0.18s ease,
    opacity 0.35s ease;
}

.corner-action:hover {
  transform: translateY(-2px) scale(1.01);
  filter: brightness(1.04);
  box-shadow:
    0 18px 40px rgba(3, 12, 24, 0.12),
    0 0 32px rgba(106, 214, 255, 0.08);
}

.corner-action:active {
  transform: translateY(0) scale(0.995);
}

.corner-action:focus-visible {
  outline: 2px solid rgba(122, 223, 255, 0.72);
  outline-offset: 3px;
}

.corner-action-icon {
  display: inline-flex;
  width: 1rem;
  height: 1rem;
  color: rgba(255, 255, 255, 0.65);
  filter: drop-shadow(0 0 8px rgba(98, 255, 228, 0.5));
}

.corner-action-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.corner-action-label {
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.8);
  text-shadow:
    0 0 8px rgba(98, 255, 228, 0.5),
    0 0 16px rgba(98, 255, 228, 0.3),
    0 0 24px rgba(98, 255, 228, 0.15),
    0 1px 0 rgba(255, 255, 255, 0.25);
  user-select: none;
  -webkit-user-select: none;
}

body.watcher-roll-active .corner-action,
body.watcher-live-active .corner-action,
body.watcher-roll-active .mode-toggle,
body.watcher-live-active .mode-toggle {
  opacity: 0;
  pointer-events: none;
}

.panel {
  position: relative;
  min-height: 100vh;
  padding: 0 5vw;
}

.hero-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.watcher-stage {
  position: relative;
  z-index: 3;
  display: inline-block;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  padding: 1.5rem 0 2.5rem;
  filter: drop-shadow(0 2px 10px rgba(9, 34, 58, 0.14));
  transform-origin: var(--watcher-focus-x, 50%) var(--watcher-focus-y, 50%);
  transition:
    transform 3s linear,
    opacity 2.4s linear,
    filter 2.4s linear;
  will-change: transform, opacity, filter;
}

body:not(.watcher-transition-active):not(.watcher-expanding-active):not(.watcher-roll-active):not(.watcher-live-active) .watcher-stage {
  transition:
    transform 1.75s cubic-bezier(0.16, 0.84, 0.2, 1),
    opacity 1.05s ease-out,
    filter 1.1s ease-out;
}

body.watcher-transition-active .watcher-stage {
  z-index: 6;
  transform: scale(1);
  opacity: 1;
  filter: drop-shadow(0 2px 10px rgba(9, 34, 58, 0.14));
}

body.watcher-expanding-active .watcher-stage {
  z-index: 6;
  transform: scale(18.4);
  opacity: 0.05;
  filter: drop-shadow(0 10px 18px rgba(6, 20, 36, 0.04));
}

body.watcher-roll-active .watcher-stage,
body.watcher-live-active .watcher-stage {
  z-index: 2;
  opacity: 0;
  transform: scale(18.8);
  filter: drop-shadow(0 26px 60px rgba(4, 14, 26, 0));
}

.watcher-measure {
  display: block;
  font-family: "Orbitron", sans-serif;
  font-weight: 800;
  font-size: clamp(4rem, 13vw, 12rem);
  line-height: 0.92;
  letter-spacing: 0.18em;
  color: transparent;
  text-transform: uppercase;
  user-select: none;
  -webkit-user-select: none;
}

.watcher-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hold-meter {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(520px, 68vw);
  height: 4px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.hold-meter.is-visible {
  opacity: 1;
}

body.watcher-transition-active .hold-meter,
body.watcher-expanding-active .hold-meter,
body.watcher-roll-active .hold-meter,
body.watcher-live-active .hold-meter,
body.watcher-transition-active .stage-status,
body.watcher-expanding-active .stage-status,
body.watcher-roll-active .stage-status,
body.watcher-live-active .stage-status {
  opacity: 0;
}

.hold-meter-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(130, 255, 234, 0.2), rgba(255, 255, 255, 0.95), rgba(255, 213, 168, 0.7));
  box-shadow: 0 0 18px rgba(125, 229, 255, 0.45);
}

.stage-status {
  position: absolute;
  left: 50%;
  top: calc(100% + 1rem);
  min-height: 1.2rem;
  transform: translateX(-50%);
  color: rgba(236, 248, 255, 0.88);
  font-size: 0.78rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  white-space: nowrap;
  text-shadow: 0 1px 8px rgba(16, 56, 92, 0.18);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.stage-status.is-visible {
  opacity: 1;
}

@media (max-width: 900px) {
  .watcher-stage {
    text-align: center;
  }
}

@media (max-width: 640px) {
  .panel {
    padding: 0 1rem;
  }

  .corner-action {
    top: calc(env(safe-area-inset-top, 0px) + 0.75rem);
    left: calc(env(safe-area-inset-left, 0px) + 0.75rem);
    padding: 0.7rem 0.9rem;
    gap: 0.55rem;
  }

  .mode-toggle {
    top: calc(env(safe-area-inset-top, 0px) + 0.75rem);
    right: calc(env(safe-area-inset-right, 0px) + 0.75rem);
    gap: 0.16rem;
    padding: 0.18rem;
  }

  .mode-toggle-option {
    min-width: 3.35rem;
    padding: 0.5rem 0.6rem;
    font-size: 0.58rem;
    letter-spacing: 0.1em;
  }

  .watcher-stage {
    max-width: 100%;
  }

  .hold-meter {
    width: 84vw;
  }

  .stage-status {
    font-size: 0.68rem;
    letter-spacing: 0.2em;
  }
}
