/* ==========================================================================
   yyolk.com 单屏首页
   一屏之内只有域名和备案号，深色极客风，零依赖零构建
   主视觉：曲速星河（Canvas 2D，见 main.js）
   文字动效：解码 / 高光横扫 / 偶发故障闪烁
   ========================================================================== */

/* ---------- 自托管字体 ---------- */
/* 只用于域名，latin 子集 14.6KB。DM Mono 许可：见 fonts/dm-mono-OFL.txt */
/* 注意：DM Mono 最粗只有 500，页面里必须把 font-weight 也设成 500，
   否则浏览器会做伪粗体合成，字形会发糊且各系统不一致 */
@font-face {
  font-family: "DMMono";
  src: url("./fonts/dm-mono-latin-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;

  --bg: #0a0c10;
  --text: #e8edf4;
  --text-mute: #7c8a9b;
  --accent: #56c8e6;
  --glitch: #ff7ab6;

  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --gutter: clamp(16px, 4vw, 32px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* 移动端浏览器地址栏收起/展开时不会露出空白 */
  margin: 0;
  overflow: hidden; /* 只有一屏，不出现滚动条 */
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  -webkit-font-smoothing: antialiased;
}

/* ---------- 舞台 ---------- */
.stage {
  position: relative;
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
}

/* 底层点阵：没有 Canvas 时当静态背景，有 Canvas 时提供质感底纹 */
.stage__grid {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at center, rgba(232, 237, 244, .12) 1px, transparent 1.4px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 0%, rgba(0, 0, 0, .3) 58%, transparent 84%);
  mask-image: radial-gradient(circle at 50% 50%, #000 0%, rgba(0, 0, 0, .3) 58%, transparent 84%);
}

/* 曲速星河画布 */
.stage__warp {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* 中央净区：让星河在文字周围自然淡出，既保可读性又出景深 */
.stage__void {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(960px, 84vw);
  height: min(430px, 48vh);
  transform: translate(-50%, -50%);
  pointer-events: none;
  background: radial-gradient(closest-side, rgba(10, 12, 16, .95), rgba(10, 12, 16, .6) 52%, rgba(10, 12, 16, 0));
}

/* ---------- 域名 ---------- */
.wordmark {
  font-family: "DMMono", var(--font-mono);
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: .1em;
  margin: 0;
  /* 等宽字体每字符 0.6em，域名 9 个字符，按 12vw 走、上限 8rem，320px 小屏也放得下 */
  font-size: clamp(2.6rem, 12vw, 8rem);
  font-weight: 500; /* 与 DM Mono 唯一的粗度一致，避免伪粗体合成 */
  line-height: 1;
  letter-spacing: .02em;
}

.wordmark__text {
  position: relative;
  display: inline-block;
  /* 高光横扫：底色是近白，青色亮带缓慢掠过 */
  background-image: linear-gradient(
    100deg,
    var(--text) 0 40%,
    #cdefff 50%,
    var(--text) 60% 100%
  );
  background-size: 320% 100%;
  background-position: 130% 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: sheen 9s ease-in-out infinite;
}

@keyframes sheen {
  0%,
  62%,
  100% {
    background-position: 130% 0;
  }
  82% {
    background-position: -40% 0;
  }
}

/* 故障闪烁：两层错位副本，每 7 秒闪一下 */
.wordmark__text::before,
.wordmark__text::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  background: none;
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: screen;
}

.wordmark__text::before {
  color: var(--accent);
  animation: glitch-a 7s steps(1, end) infinite;
}

.wordmark__text::after {
  color: var(--glitch);
  animation: glitch-b 7s steps(1, end) infinite;
}

@keyframes glitch-a {
  0%, 90%, 100% { opacity: 0; transform: translate3d(0, 0, 0); }
  91% { opacity: .5; transform: translate3d(-3px, -1px, 0); }
  94% { opacity: .35; transform: translate3d(2px, 1px, 0); }
  97% { opacity: 0; transform: translate3d(0, 0, 0); }
}

@keyframes glitch-b {
  0%, 90%, 100% { opacity: 0; transform: translate3d(0, 0, 0); }
  92% { opacity: .45; transform: translate3d(3px, 1px, 0); }
  95% { opacity: .3; transform: translate3d(-2px, -1px, 0); }
  97% { opacity: 0; transform: translate3d(0, 0, 0); }
}

/* 光标 */
.wordmark__caret {
  width: .075em;
  height: .82em;
  background: var(--accent);
  animation: blink 1.15s steps(1, end) infinite;
}

@keyframes blink {
  0%, 55% { opacity: 1; }
  56%, 100% { opacity: 0; }
}

/* ---------- 备案号 ---------- */
.beian {
  flex: none;
  z-index: 1;
  padding: 0 var(--gutter) calc(18px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: .78rem;
  letter-spacing: .02em;
  color: var(--text-mute);
}

.beian a {
  color: inherit;
  text-decoration: none;
  transition: color .2s ease;
}

.beian a:hover {
  color: var(--accent);
}

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

::selection {
  background: var(--accent);
  color: var(--bg);
}

/* ---------- 小屏 ---------- */
@media (max-width: 480px) {
  .stage__grid {
    background-size: 16px 16px;
  }

  .wordmark {
    gap: .08em;
  }
}

/* ---------- 动效降级 ---------- */
/* 减少动效时：不画星河（JS 不启动 Canvas），文字与光标全部静止 */
@media (prefers-reduced-motion: reduce) {
  .wordmark__text,
  .wordmark__text::before,
  .wordmark__text::after,
  .wordmark__caret {
    animation: none;
  }

  .wordmark__text {
    background: none;
    color: var(--text);
    -webkit-text-fill-color: currentColor;
  }

  .stage__void {
    opacity: .55;
  }
}
