/* ============================================================
   DUAL REALITY PORTAL
   新野兽派 × 赛博控制论终端
   左：极昼 · 精密机械　　右：极夜 · 神经矩阵
   ============================================================ */

:root {
  --ivory: #f4f4f0;
  --ink: #0a0a0a;
  --night: #08080a;
  --acid: #ccff00;
  --acid-dim: rgba(204, 255, 0, 0.55);
  --violet: #7b5cff;
  --red: #ff2e4d;
  --cyan: #00e5ff;
  --mono: ui-monospace, 'JetBrains Mono', Consolas, 'Courier New', monospace;
  --sans: 'Helvetica Neue', 'Arial Black', 'Arial Narrow', Arial, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--night);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

a {
  -webkit-tap-highlight-color: transparent;
}

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  transform-origin: 50% 50%;
  background: var(--night);
  isolation: isolate;
}

/* ============================================================
   两个世界
   ============================================================ */
.world {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
}

.world--day {
  background: var(--ivory);
  color: var(--ink);
  z-index: 1;
}

.world--night {
  background: var(--night);
  color: var(--acid);
  z-index: 2;
  /* JS 会每帧改写这个多边形；这是没脚本时的兜底 */
  clip-path: polygon(100% 0, 54% 0, 46% 100%, 100% 100%);
  will-change: clip-path;
}

/* 极昼：粗野主义网格 */
.day-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(10, 10, 10, 0.14) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(10, 10, 10, 0.14) 1px, transparent 1px),
    linear-gradient(to right, rgba(10, 10, 10, 0.26) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(10, 10, 10, 0.26) 1px, transparent 1px);
  background-size:
    48px 48px,
    48px 48px,
    240px 240px,
    240px 240px;
  pointer-events: none;
}

.gyro {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* 极夜：字符场 + 扫描线 */
.ascii {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 0 5px rgba(204, 255, 0, 0.22));
}

.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 3px,
    rgba(0, 0, 0, 0.42) 3px,
    rgba(0, 0, 0, 0.42) 4px
  );
  mix-blend-mode: multiply;
  opacity: 0.9;
}

/* ============================================================
   巨型字（被裂缝裁切）
   ============================================================ */
.type {
  position: absolute;
  margin: 0;
  font-family: var(--sans);
  font-weight: 900;
  font-size: clamp(64px, 14.2vw, 260px);
  line-height: 0.74;
  letter-spacing: -0.045em;
  white-space: nowrap;
  pointer-events: none;
  text-transform: uppercase;
}

.type--day {
  left: 1.2vw;
  bottom: 18vh;
  font-size: clamp(58px, 11.6vw, 210px);
  color: var(--ink);
}

/* 极夜的字抬到上面，和左边的字错开一层，不然两句话会在裂缝处连成一句 */
.type--night {
  left: 50%;
  top: 24vh;
  font-size: clamp(50px, 9.6vw, 176px);
  color: var(--acid);
  text-align: left;
  text-shadow: 0 0 34px rgba(204, 255, 0, 0.22);
}

/* ============================================================
   HUD
   ============================================================ */
.hud {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  pointer-events: none;
  white-space: nowrap;
}

.hud--day {
  top: 74px;
  left: 32px;
  color: var(--ink);
}

.hud--night {
  top: 74px;
  right: 32px;
  color: var(--acid);
  flex-direction: row-reverse;
}

.hud-index {
  padding: 3px 7px;
  background: var(--ink);
  color: var(--ivory);
  font-weight: 700;
  letter-spacing: 0.12em;
}

.hud--night .hud-index {
  background: var(--acid);
  color: var(--night);
}

.hud-name {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.hud-coord {
  opacity: 0.62;
  font-size: 9px;
}

.day-clock {
  position: absolute;
  top: 100px;
  left: 32px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  opacity: 0.72;
  pointer-events: none;
}

.night-readout {
  position: absolute;
  right: 32px;
  bottom: 128px;
  top: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--acid-dim);
  text-transform: uppercase;
  pointer-events: none;
}

/* ============================================================
   CTA
   ============================================================ */
.cta {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 16px;
  border: 2px solid currentColor;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  transition: background 0.18s steps(2), color 0.18s steps(2), transform 0.18s;
}

.cta-cn {
  font-family: var(--sans);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.cta-en {
  font-size: 9px;
  opacity: 0.75;
}

.cta--day {
  left: 32px;
  bottom: 56px;
  color: var(--ink);
}

.cta--night {
  right: 32px;
  bottom: 56px;
  color: var(--acid);
  align-items: flex-end;
}

.world--day:hover .cta--day,
.cta--day:hover {
  background: var(--ink);
  color: var(--ivory);
}

.world--night:hover .cta--night,
.cta--night:hover {
  background: var(--acid);
  color: var(--night);
}

/* ============================================================
   裂缝
   ============================================================ */
.seam {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 22;
  pointer-events: none;
  overflow: visible;
}

.seam-group {
  mix-blend-mode: difference;
}

.seam-red,
.seam-cyan {
  fill: none;
  stroke-width: 1.4;
  opacity: 0.55;
}

.seam-red {
  stroke: var(--red);
}

.seam-cyan {
  stroke: var(--cyan);
}

.seam-glow {
  fill: none;
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 14;
  filter: blur(7px);
}

.seam-core {
  fill: none;
  stroke: #ffffff;
  stroke-width: 1.15;
}

/* ============================================================
   系统条
   ============================================================ */
.masthead,
.footerbar {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: #08080a;
  color: var(--acid);
  border: 0 solid rgba(204, 255, 0, 0.28);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  pointer-events: none;
  white-space: nowrap;
}

.masthead {
  top: 0;
  height: 38px;
  border-bottom-width: 1px;
}

.footerbar {
  bottom: 0;
  height: 30px;
  border-top-width: 1px;
  justify-content: space-between;
  font-size: 8px;
  color: rgba(204, 255, 0, 0.75);
}

.masthead-rule {
  flex: 1;
  height: 1px;
  background: currentColor;
  opacity: 0.35;
}

.masthead-title {
  font-weight: 700;
  letter-spacing: 0.28em;
}

.masthead-status {
  color: #ff5a6e;
}


/* ============================================================
   磁性准星光标
   ============================================================ */
.has-cursor,
.has-cursor a,
.has-cursor body {
  cursor: none;
}

.cursor {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  mix-blend-mode: difference;
  color: #ffffff;
  opacity: 0;
  transition: opacity 0.25s;
}

.cursor.is-ready {
  opacity: 1;
}

.cursor.is-hidden {
  display: none;
}

.hair {
  position: absolute;
  background: #ffffff;
  opacity: 0.65;
  will-change: transform;
}

.hair--x {
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
}

.hair--y {
  top: 0;
  bottom: 0;
  left: 0;
  width: 1px;
}

.ring {
  position: absolute;
  left: 0;
  top: 0;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 1px solid #ffffff;
  border-radius: 50%;
  will-change: transform;
  opacity: 0.92;
}

.ring::before,
.ring::after {
  content: '';
  position: absolute;
  left: 50%;
  width: 1px;
  height: 6px;
  background: #ffffff;
  transform: translateX(-50%);
}

.ring::before {
  top: -6px;
}

.ring::after {
  bottom: -6px;
}

.readout {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 61;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  background: rgba(8, 8, 10, 0.92);
  border: 1px solid rgba(204, 255, 0, 0.55);
  color: var(--acid);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  will-change: transform;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.2s;
}

.readout.is-on {
  opacity: 1;
}

.cursor-hash {
  opacity: 0.7;
}

.cursor-cue {
  color: #ffffff;
  opacity: 0.55;
}

/* ============================================================
   故障 / CRT
   ============================================================ */
.glitch {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
}

.glitch i {
  position: absolute;
  left: 0;
  right: 0;
  height: 5%;
  background: linear-gradient(
    90deg,
    rgba(255, 46, 77, 0.85),
    rgba(0, 229, 255, 0.7) 45%,
    rgba(204, 255, 0, 0.55)
  );
  transform: translate3d(0, 0, 0);
  opacity: 0;
}

.glitch i:nth-child(1) {
  top: 8%;
}
.glitch i:nth-child(2) {
  top: 23%;
}
.glitch i:nth-child(3) {
  top: 40%;
}
.glitch i:nth-child(4) {
  top: 57%;
}
.glitch i:nth-child(5) {
  top: 72%;
}
.glitch i:nth-child(6) {
  top: 88%;
}

.stage.is-glitching {
  animation: shake 0.09s steps(2, end) infinite;
  filter: drop-shadow(3px 0 0 rgba(255, 46, 77, 0.85)) drop-shadow(-3px 0 0 rgba(0, 229, 255, 0.85))
    contrast(1.08) saturate(1.15);
}

.stage.is-glitching .glitch {
  opacity: 1;
}

@keyframes shake {
  0% {
    transform: translate3d(0, 0, 0) skewX(0deg);
  }
  50% {
    transform: translate3d(var(--shake, 0px), 2px, 0) skewX(0.35deg);
  }
  100% {
    transform: translate3d(0, -1px, 0) skewX(-0.25deg);
  }
}

.stage.is-crashing {
  animation: crt-off 0.52s cubic-bezier(0.7, 0, 0.86, 0) forwards;
  transform-origin: 50% 50%;
}

@keyframes crt-off {
  0% {
    transform: scale(1, 1);
    filter: brightness(1);
  }
  35% {
    transform: scale(1.01, 0.52);
    filter: brightness(2.2) saturate(1.4);
  }
  55% {
    transform: scale(1.03, 0.06);
    filter: brightness(5);
  }
  72% {
    transform: scale(0.56, 0.008);
    filter: brightness(8);
  }
  100% {
    transform: scale(0.004, 0.004);
    filter: brightness(14);
  }
}

.crt-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  z-index: 70;
  height: 2px;
  background: #ffffff;
  opacity: 0;
  transform-origin: 50% 50%;
  box-shadow: 0 0 26px 8px rgba(255, 255, 255, 0.75);
  pointer-events: none;
}

.stage.is-crashing .crt-line {
  animation: crt-line 0.52s ease-out forwards;
}

@keyframes crt-line {
  0%,
  38% {
    opacity: 0;
    transform: scaleX(1);
  }
  48% {
    opacity: 1;
    transform: scaleX(1);
  }
  72% {
    opacity: 1;
    transform: scaleX(0.4);
  }
  100% {
    opacity: 0.5;
    transform: scaleX(0.002);
  }
}

/* ============================================================
   无脚本
   ============================================================ */
.noscript {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 8vw;
  background: var(--ivory);
  color: var(--ink);
  font-family: var(--mono);
  text-align: center;
}

.noscript a {
  color: var(--ink);
  border-bottom: 2px solid var(--ink);
  font-size: 18px;
  text-decoration: none;
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 900px) {
  .type {
    font-size: clamp(56px, 19vw, 150px);
    bottom: 20vh;
  }

  .hud {
    font-size: 9px;
    gap: 8px;
  }

  .hud--day {
    left: 18px;
    top: 66px;
  }

  .hud--night {
    right: 18px;
    top: 66px;
  }

  .hud-coord {
    display: none;
  }

  .day-clock {
    left: 18px;
    top: 92px;
    font-size: 10px;
  }

  .night-readout {
    right: 18px;
    top: 92px;
  }

  .cta--day {
    left: 18px;
    bottom: 52px;
  }

  .cta--night {
    right: 18px;
    bottom: 52px;
  }

  .masthead-title {
    display: none;
  }
}

@media (max-width: 560px) {
  .type {
    font-size: 26vw;
    bottom: 26vh;
  }

  .type--day {
    left: -2vw;
  }

  /* 手机上不继承 .type 的 bottom，否则上下都钉住，盒子会被拉得老高 */
  .type--night {
    left: 52%;
    right: auto;
    top: 20vh;
    bottom: auto;
  }

  .masthead-title,
  .masthead-rule {
    display: none;
  }

  .masthead {
    justify-content: space-between;
  }

  .hud-name {
    display: none;
  }

  .hud--day,
  .hud--night {
    top: 58px;
  }

  .day-clock {
    top: 84px;
    font-size: 9px;
    letter-spacing: 0.02em;
  }

  .night-readout {
    display: none;
  }

  .cta {
    padding: 9px 11px;
  }

  .cta--night {
    right: 12px;
  }

  .cta-cn {
    font-size: 12px;
  }

  .cta-en {
    font-size: 8px;
  }

  .footerbar {
    font-size: 7px;
    letter-spacing: 0.1em;
  }

  .footerbar span:nth-child(2),
  .footerbar span:last-child {
    display: none;
  }
}

/* ============================================================
   减少动效
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .stage.is-glitching,
  .stage.is-crashing {
    animation: none !important;
    filter: none !important;
  }

  .stage.is-crashing .crt-line {
    animation: none !important;
  }

  .glitch {
    display: none;
  }

  .cursor {
    display: none;
  }

  .cta,
  .cursor {
    transition: none;
  }
}

/* 极夜：暗角 + HUD 底片，让字符墙退后、字读得清 */
.night-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to right, rgba(8, 8, 10, 0.92) 0%, rgba(8, 8, 10, 0) 16%),
    radial-gradient(
      105% 85% at 78% 42%,
      rgba(8, 8, 10, 0) 0%,
      rgba(8, 8, 10, 0.35) 60%,
      rgba(8, 8, 10, 0.88) 100%
    );
}

.hud--night,
.night-readout {
  padding: 6px 9px;
  background: rgba(8, 8, 10, 0.72);
  border: 1px solid rgba(204, 255, 0, 0.18);
}

.hud--day,
.day-clock {
  padding: 6px 9px;
  background: rgba(244, 244, 240, 0.82);
  border: 1px solid rgba(10, 10, 10, 0.14);
}

.day-clock {
  display: inline-block;
}

/* 触屏设备不装自定义光标 */
@media (pointer: coarse) {
  .cursor,
  .readout {
    display: none;
  }
}
