/**
 * @module water-sort/styles
 * @summary Water Sort 页面样式。实验室暗色主题：深色氛围衬高饱和液体，
 * 厚壁立体玻璃试管（对标同类头部产品的视觉公式）。
 */
:root {
  --ink: #eaf4ec;
  --paper: #0b1310;
  --surface: #121d17;
  --surface-2: #1a2a21;
  --moss: #7ddf6a;
  --moss-deep: #cdf65f;
  --lime: #cdf65f;
  --sand: #f2d985;
  --mist: #8ba596;
  --line: #24352c;
  --muted: #93ab9c;
  --radius: 14px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  --font: "Inter", "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(52% 34% at 18% -6%, rgba(56, 200, 240, 0.14), transparent 70%),
    radial-gradient(46% 30% at 84% -4%, rgba(163, 92, 245, 0.12), transparent 68%),
    radial-gradient(60% 42% at 50% 108%, rgba(125, 223, 106, 0.07), transparent 72%),
    radial-gradient(circle at 25% 30%, rgba(255, 255, 255, 0.025) 1px, transparent 1.6px),
    linear-gradient(180deg, #0d1712 0%, #0b1310 46%, #0a100d 100%);
  background-attachment: fixed;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding: 0 16px 64px;
  max-width: 760px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 4px;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink);
  text-decoration: none;
}

.lang-switcher {
  display: flex;
  gap: 6px;
}

.lang-switcher button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.lang-switcher button[aria-pressed="true"] {
  color: var(--moss-deep);
  border-color: var(--moss);
}

.hero {
  text-align: center;
  padding: 12px 0 24px;
}

/* 顶部装饰试管排：厚壁立体小试管 */
.hero-tubes {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 12px;
  height: 64px;
  margin-bottom: 16px;
}

.hero-tubes i {
  position: relative;
  width: 18px;
  border-radius: 9px;
  background:
    linear-gradient(180deg, var(--liquid) 0 64%, rgba(255, 255, 255, 0.06) 64% 100%);
  border: 2px solid rgba(234, 244, 236, 0.28);
  box-shadow:
    inset 3px 0 0 rgba(255, 255, 255, 0.3),
    inset -2px 0 0 rgba(255, 255, 255, 0.1),
    0 6px 14px rgba(0, 0, 0, 0.35);
}

/* 管口高光环 */
.hero-tubes i::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 50%;
  translate: -50% 0;
  width: 130%;
  height: 5px;
  border-radius: 999px;
  background: rgba(234, 244, 236, 0.22);
  border: 1px solid rgba(234, 244, 236, 0.3);
}

.hero-tubes i:nth-child(1) { --liquid: #38c8f0; height: 38px; }
.hero-tubes i:nth-child(2) { --liquid: #ffb648; height: 54px; }
.hero-tubes i:nth-child(3) { --liquid: #2ecc71; height: 44px; }
.hero-tubes i:nth-child(4) { --liquid: #a35cf5; height: 58px; }
.hero-tubes i:nth-child(5) { --liquid: #ff6fae; height: 34px; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  color: var(--moss);
  margin: 0 0 8px;
}

.hero h1 {
  font-size: clamp(28px, 7vw, 40px);
  margin: 0 0 10px;
  letter-spacing: -0.01em;
  background: linear-gradient(120deg, #8be8ff 15%, #cdf65f 60%, #f2d985 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.lede {
  color: var(--muted);
  max-width: 44ch;
  margin: 0 auto;
  font-size: 15px;
}

.play {
  margin-top: 8px;
}

/* 游戏舞台：深色实验台卡片 */
.stage {
  background: linear-gradient(180deg, rgba(26, 42, 33, 0.92) 0%, rgba(15, 25, 19, 0.96) 100%);
  border: 1px solid var(--line);
  border-top-color: rgba(125, 223, 106, 0.22);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: clamp(16px, 4vw, 28px);
}

.progress-track {
  height: 6px;
  max-width: 420px;
  margin: 4px auto 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #38c8f0, #2ecc71 55%, #cdf65f);
  box-shadow: 0 0 12px rgba(125, 223, 106, 0.5);
  transition: width 0.4s ease;
}

@media (prefers-reduced-motion: reduce) {
  .progress-track i { transition: none; }
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin-bottom: 22px;
}

.stat {
  font-size: 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
}

.stat strong {
  color: var(--ink);
}

.btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(125, 223, 106, 0.4);
}

.btn:active {
  transform: translateY(1px);
}

.btn--ghost {
  background: transparent;
}

.btn--primary {
  background: var(--moss);
  border-color: var(--moss);
  color: #0b1310;
  font-weight: 600;
}

.btn--primary:hover {
  background: var(--moss-deep);
  border-color: var(--moss-deep);
}

/* ---- 试管棋盘：厚壁立体玻璃 ---- */
.board {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(8px, 2.4vw, 16px);
  justify-content: center;
  align-items: flex-end;
  padding: 8px 0 24px;
  min-height: 220px;
}

.tube {
  --seg-h: clamp(22px, 6.2vw, 30px);
  position: relative;
  display: flex;
  flex-direction: column;
  width: clamp(38px, 9.5vw, 54px);
  padding: 6px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.05));
  border: 2px solid rgba(234, 244, 236, 0.3);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.07),
    inset 0 -8px 14px rgba(255, 255, 255, 0.06),
    0 8px 20px rgba(0, 0, 0, 0.4);
  border-radius: 12px 12px 16px 16px;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  font: inherit;
}

/* 左侧宽高光条（厚玻璃反光，压在液体上方） */
.tube::before {
  content: "";
  position: absolute;
  top: 7px;
  bottom: 7px;
  left: 4px;
  width: 6px;
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.18));
  pointer-events: none;
  z-index: 2;
}

.tube:hover {
  border-color: rgba(125, 223, 106, 0.5);
}

.tube:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 2px;
}

.tube--selected {
  border-color: var(--moss);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.1),
    0 0 0 3px rgba(125, 223, 106, 0.25),
    0 12px 26px rgba(0, 0, 0, 0.5);
  transform: translateY(-8px);
}

.tube--done {
  border-color: rgba(125, 223, 106, 0.75);
}

/* 完成管：右上角 ✓ 徽标 + 光晕 */
.tube--done::after {
  content: "✓";
  position: absolute;
  top: -9px;
  right: -8px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  background: var(--moss);
  color: #0b1310;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 0 12px rgba(125, 223, 106, 0.65);
}

/* 液体段：上亮下深渐变 + 液面高光 */
.seg {
  position: relative;
  height: var(--seg-h);
  border-radius: 5px;
  margin-top: 3px;
  background-color: var(--liquid, #333);
  background-image: linear-gradient(
    180deg,
    color-mix(in srgb, var(--liquid) 72%, white) 0%,
    var(--liquid) 34%,
    color-mix(in srgb, var(--liquid) 74%, black) 100%
  );
  box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.22);
}

/* 液面张力高光 */
.seg::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 2px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.4);
}

.seg:first-child {
  margin-top: 0;
  border-bottom-left-radius: 9px;
  border-bottom-right-radius: 9px;
}

.seg--empty {
  background: rgba(255, 255, 255, 0.045);
  box-shadow: none;
}

.seg--empty::after {
  display: none;
}

/* ---- SEO 指南卡片 ---- */
.seo-guide {
  margin-top: 40px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 6px 22px 22px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.3);
}

.seo-guide summary {
  cursor: pointer;
  padding: 14px 0;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
}

.seo-guide summary::marker {
  color: var(--moss);
}

.seo-guide h2 {
  font-size: 22px;
  margin: 18px 0 10px;
}

.seo-guide h3 {
  font-size: 16px;
  margin: 22px 0 8px;
  color: var(--moss-deep);
}

.seo-guide p,
.seo-guide li {
  color: var(--muted);
  font-size: 14.5px;
}

/* ---- Field notes / footer ---- */
.field-notes {
  margin: 36px 0 0;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.field-notes ul {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.field-notes a {
  color: var(--ink);
  text-decoration: none;
}

.field-notes a:hover {
  color: var(--moss);
}

.site-foot {
  margin-top: 28px;
  text-align: center;
}

.footer-links {
  font-size: 13px;
  color: var(--muted);
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--ink);
}

/* ---- 对话框 ---- */
.dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: 420px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow);
  color: var(--ink);
  background: linear-gradient(180deg, #16241c, #101a14);
  border: 1px solid var(--line);
}

.dialog::backdrop {
  background: rgba(4, 8, 6, 0.62);
  backdrop-filter: blur(3px);
}

.dialog__body {
  padding: 24px;
}

.dialog__body h2 {
  margin: 0 0 12px;
}

.dialog__body p {
  margin: 0 0 12px;
  color: var(--muted);
}

.dialog__body .hint {
  font-size: 13px;
}

.dialog__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 18px;
}

.chip {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}

.chip--done {
  border-color: var(--moss);
  background: rgba(125, 223, 106, 0.14);
  color: var(--moss-deep);
}

.win-moves {
  font-size: 13px;
  color: var(--muted);
}

/* ---- 胜利庆祝 ---- */
.celebrate {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}

.confetti {
  position: absolute;
  top: -12px;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  animation: fall 1.5s ease-in forwards;
}

@keyframes fall {
  to {
    transform: translate(var(--drift, 0), 105vh) rotate(360deg);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .confetti {
    display: none;
  }
}

@media (max-width: 420px) {
  .controls .stat {
    order: 3;
  }

  .stage {
    padding: 12px 10px 16px;
    border-radius: 18px;
  }

  .hero-tubes {
    gap: 8px;
    height: 50px;
    margin-bottom: 10px;
  }

  .hero-tubes i {
    width: 14px;
  }

  .seo-guide {
    padding: 4px 16px 16px;
  }
}
