/* ─────────────────────────────────────────────
   π 探索者 — editorial / ink & gold
   ───────────────────────────────────────────── */

:root {
  --ink: #08090C;
  --ink-2: #0E1015;
  --ink-3: #15181F;
  --line: rgba(255, 255, 255, .09);
  --line-2: rgba(255, 255, 255, .16);
  --fg: #EDEFF4;
  --fg-dim: #9BA1AE;
  --fg-faint: #5E6472;
  --gold: #E5B455;
  --gold-soft: rgba(229, 180, 85, .14);
  --warn: #E07A5F;
  --mono: "SF Mono", "JetBrains Mono", "IBM Plex Mono", ui-monospace, "Menlo", monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC", Georgia, serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", system-ui, sans-serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

html[data-theme="light"] {
  --ink: #F6F4EF;
  --ink-2: #FFFFFF;
  --ink-3: #FBFAF6;
  --line: rgba(20, 18, 14, .10);
  --line-2: rgba(20, 18, 14, .2);
  --fg: #14120E;
  --fg-dim: #5D574C;
  --fg-faint: #948C7D;
  --gold: #A9761B;
  --gold-soft: rgba(169, 118, 27, .12);
  --warn: #B4482C;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  overflow-x: hidden;
  transition: background .5s var(--ease), color .5s var(--ease);
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── atmosphere ─────────────────────────────── */

.field {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
  font-family: var(--mono);
  color: var(--fg);
  opacity: .045;
  overflow: hidden;
  line-height: 1.18;
  word-break: break-all;
  padding: 4.5rem 2rem 2rem;
  transition: opacity .6s var(--ease), color .5s var(--ease);
  mask-image: linear-gradient(180deg, #000 0%, rgba(0,0,0,.55) 38%, transparent 82%);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0,0,0,.55) 38%, transparent 82%);
}
html[data-theme="light"] .field { opacity: .055; }

.vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(90% 60% at 50% -10%, var(--gold-soft), transparent 60%),
    radial-gradient(70% 50% at 100% 100%, rgba(120, 160, 255, .05), transparent 60%);
}

/* ── topbar ─────────────────────────────────── */

.topbar {
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: 1.35rem clamp(1.1rem, 5vw, 3rem);
  max-width: 1180px; margin: 0 auto;
}

.brand {
  display: inline-flex; align-items: baseline; gap: .5rem;
  text-decoration: none; color: var(--fg);
}
.brand-mark {
  font-family: var(--serif);
  font-size: 1.6rem; line-height: 1;
  color: var(--gold);
}
.brand-name {
  font-family: var(--serif);
  font-size: 1.02rem; letter-spacing: .28em;
  color: var(--fg-dim);
}

.topnav { display: flex; align-items: center; gap: .35rem; }

.navbtn {
  font-family: var(--sans);
  font-size: .82rem; letter-spacing: .06em;
  color: var(--fg-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: .42rem .85rem;
  cursor: pointer;
  transition: color .25s, border-color .25s, background .25s;
}
.navbtn:hover { color: var(--fg); border-color: var(--line-2); }
.navbtn[aria-pressed="true"] {
  color: var(--gold); border-color: var(--gold); background: var(--gold-soft);
}
.iconbtn { padding: .42rem .5rem; display: grid; place-items: center; }
.iconbtn svg { width: 18px; height: 18px; }

html[data-theme="dark"] .ico-sun { display: none; }
html[data-theme="light"] .ico-moon { display: none; }

/* ── hero ───────────────────────────────────── */

main {
  position: relative; z-index: 2;
  max-width: 780px;
  margin: 0 auto;
  padding: clamp(1rem, 7vh, 4.5rem) clamp(1.1rem, 5vw, 2rem) 4rem;
}

.hero { text-align: center; }

.eyebrow {
  display: inline-flex; align-items: center; gap: .55rem;
  font-family: var(--mono);
  font-size: .7rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 1.5rem;
}
.eyebrow .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 0 var(--gold);
  animation: pulse 2.6s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(229,180,85,.5); }
  70%  { box-shadow: 0 0 0 7px rgba(229,180,85,0); }
  100% { box-shadow: 0 0 0 0 rgba(229,180,85,0); }
}

.title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.9rem, 11vw, 5.4rem);
  line-height: .95;
  letter-spacing: -.02em;
  margin: 0 0 1.1rem;
  color: var(--fg);
}
.title span {
  display: block;
  font-size: .46em;
  letter-spacing: .34em;
  margin-top: .5rem;
  color: var(--fg-dim);
  padding-left: .34em;
}

.lede {
  margin: 0 auto 2.4rem;
  max-width: 30ch;
  color: var(--fg-dim);
  font-size: 1.02rem;
  font-family: var(--serif);
}

/* ── search ─────────────────────────────────── */

.search {
  position: relative;
  display: flex; align-items: center;
  background: var(--ink-2);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  padding: .15rem .15rem .15rem 1.1rem;
  transition: border-color .3s var(--ease), box-shadow .3s var(--ease), transform .3s var(--ease);
}
.search:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px var(--gold-soft), 0 22px 60px -28px rgba(0,0,0,.7);
}

/* 「3.1415926…[ 你的数字 ]…」——用固定前缀说明这是 π 里的一段，而非从开头续写 */
.search-prefix {
  font-family: var(--mono);
  font-size: clamp(.82rem, 2.9vw, 1.02rem);
  color: var(--fg-faint);
  letter-spacing: .06em;
  user-select: none;
  flex: none;
  white-space: nowrap;
}

.search-dots {
  font-family: var(--mono);
  font-size: clamp(.82rem, 2.9vw, 1.02rem);
  color: var(--gold);
  opacity: .75;
  user-select: none;
  flex: none;
  padding: 0 .1rem 0 .18rem;
}
.search-dots.tail { padding: 0 .35rem 0 .1rem; }

#q {
  flex: 1 1 0; min-width: 3.2em;
  background: var(--gold-soft);
  border: 0;
  border-bottom: 1px solid var(--gold);
  border-radius: 6px 6px 0 0;
  outline: 0;
  color: var(--fg);
  font-family: var(--mono);
  font-size: clamp(.95rem, 3.3vw, 1.2rem);
  letter-spacing: .12em;
  padding: .55rem .5rem .5rem;
  transition: background .25s var(--ease), box-shadow .25s var(--ease);
}
#q::placeholder {
  color: var(--fg-faint);
  letter-spacing: .04em;
  font-size: .86em;
}
.search:focus-within #q {
  background: var(--gold-soft);
  box-shadow: 0 2px 0 0 var(--gold);
}

.search-go {
  flex: none;
  display: grid; place-items: center;
  width: 52px; height: 52px;
  border: 0; border-radius: 11px;
  background: var(--gold);
  color: var(--ink);
  cursor: pointer;
  transition: transform .2s var(--ease), filter .2s;
}
.search-go svg { width: 21px; height: 21px; }
.search-go:hover { filter: brightness(1.1); transform: scale(1.03); }
.search-go:active { transform: scale(.96); }

.hintrow {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  margin: .9rem .2rem 0;
  font-size: .78rem;
  color: var(--fg-faint);
}
.hintrow p { margin: 0; }
.hintrow p.err { color: var(--warn); }
.kbdhint { font-family: var(--mono); white-space: nowrap; }
kbd {
  font-family: var(--mono);
  font-size: .72rem;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: .05rem .34rem;
  color: var(--fg-dim);
}

/* ── result ─────────────────────────────────── */

.result-slot { margin-top: 2.6rem; }
.result-slot:empty { margin-top: 0; }

.card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--ink-2);
  padding: clamp(1.3rem, 4vw, 2rem);
  animation: rise .55s var(--ease) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.card-label {
  font-family: var(--mono);
  font-size: .68rem; letter-spacing: .2em; text-transform: uppercase;
  color: var(--fg-faint);
  margin: 0 0 1rem;
}

.card-state {
  font-family: var(--serif);
  font-size: clamp(1.3rem, 4.4vw, 1.75rem);
  line-height: 1.4;
  margin: 0 0 .4rem;
  color: var(--fg);
}
.card-state .hl { color: var(--gold); }
.card-state.miss { color: var(--fg-dim); }

.pos {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.5rem, 7vw, 2.3rem);
  color: var(--gold);
  line-height: 1.15;
  margin: .9rem 0 .1rem;
  word-break: break-all;
}
.pos-sub { color: var(--fg-faint); font-size: .8rem; margin: 0; }

.ctx {
  margin-top: 1.6rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
}
.ctx-label {
  margin: 0 0 .7rem;
  font-size: .78rem;
  color: var(--fg-faint);
}
.ctx-digits {
  font-family: var(--mono);
  font-size: clamp(.78rem, 2.7vw, .95rem);
  line-height: 2;
  color: var(--fg-dim);
  word-break: break-all;
  letter-spacing: .08em;
}
.ctx-digits .pre, .ctx-digits .post { color: var(--fg-faint); }
.ctx-digits mark {
  background: var(--gold);
  color: var(--ink);
  border-radius: 3px;
  padding: .1em .12em;
  margin: 0 .05em;
}
.ctx-meta {
  margin: .9rem 0 0;
  font-family: var(--mono);
  font-size: .74rem;
  color: var(--fg-faint);
}

.card-actions {
  display: flex; flex-wrap: wrap; gap: .5rem;
  margin-top: 1.5rem;
  padding-top: 1.3rem;
  border-top: 1px solid var(--line);
}

.chip {
  font-family: var(--sans);
  font-size: .8rem;
  color: var(--fg-dim);
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: .38rem .9rem;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}
.chip:hover { color: var(--fg); border-color: var(--fg-faint); }
.chip[aria-pressed="true"] { color: var(--gold); border-color: var(--gold); background: var(--gold-soft); }

/* skeleton while loading */
.skel { display: grid; gap: .8rem; }
.skel div {
  height: 14px; border-radius: 6px;
  background: linear-gradient(90deg, var(--ink-3), var(--line-2), var(--ink-3));
  background-size: 200% 100%;
  animation: sweep 1.1s linear infinite;
}
.skel div:nth-child(1) { width: 42%; height: 26px; }
.skel div:nth-child(2) { width: 66%; }
.skel div:nth-child(3) { width: 88%; }
@keyframes sweep { to { background-position: -200% 0; } }

/* ── sections ───────────────────────────────── */

.sec-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.1rem;
}
.sec-head h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.1rem;
  letter-spacing: .04em;
  margin: 0;
  color: var(--fg);
}
.sec-note { font-family: var(--mono); font-size: .72rem; color: var(--fg-faint); }

.textbtn {
  background: none; border: 0;
  font-family: var(--sans); font-size: .78rem;
  color: var(--fg-faint);
  cursor: pointer; padding: 0;
  transition: color .2s;
}
.textbtn:hover { color: var(--warn); }

.recent { margin-top: 2.6rem; }

.recent-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: .5rem;
}
.recent-list button {
  font-family: var(--mono);
  font-size: .82rem;
  letter-spacing: .08em;
  color: var(--fg-dim);
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .42rem .8rem;
  cursor: pointer;
  transition: color .2s, border-color .2s, transform .2s var(--ease);
}
.recent-list button:hover { color: var(--gold); border-color: var(--gold); transform: translateY(-1px); }

/* ── distribution ───────────────────────────── */

.panel {
  margin-top: 2.6rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--ink-2);
  padding: clamp(1.2rem, 4vw, 1.8rem);
  animation: rise .4s var(--ease) both;
}

.dist {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: clamp(.3rem, 1.6vw, .7rem);
  padding-top: .5rem;
}
.dist-col {
  display: flex; flex-direction: column; align-items: center;
  gap: .4rem;
  cursor: default;
}
.dist-track {
  position: relative;
  width: 100%;
  height: 132px;
}
.dist-axis {
  position: absolute; left: -2px; right: -2px; top: 50%;
  border-top: 1px dashed var(--line-2);
}
.dist-bar {
  position: absolute;
  left: 0; right: 0;
  border-radius: 3px;
  transition: filter .2s, transform .25s var(--ease);
  min-height: 2px;
}
.dist-bar.pos {
  bottom: 50%;
  background: linear-gradient(180deg, var(--gold), rgba(229,180,85,.5));
  border-radius: 3px 3px 1px 1px;
}
.dist-bar.neg {
  top: 50%;
  background: linear-gradient(0deg, var(--fg-faint), rgba(155,161,174,.4));
  border-radius: 1px 1px 3px 3px;
}
.dist-col:hover .dist-bar { filter: brightness(1.3); }
.dist-num {
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}
.dist-dev {
  font-family: var(--mono);
  font-size: .62rem;
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}

.dist-legend {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  margin-top: 1.2rem;
  padding-top: .9rem;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--fg-faint);
  flex-wrap: wrap;
}
.dist-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.dist-legend i {
  width: 9px; height: 9px; border-radius: 2px; display: inline-block;
}
.dist-legend .sw-pos { background: var(--gold); }
.dist-legend .sw-neg { background: var(--fg-faint); }

/* ── explore ────────────────────────────────── */

.explore {
  margin-top: 3.4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.5rem; flex-wrap: wrap;
}
.explore-copy h2 {
  font-family: var(--serif); font-weight: 400;
  font-size: 1.16rem; margin: 0 0 .35rem; color: var(--fg);
}
.explore-copy p { margin: 0; color: var(--fg-dim); font-size: .9rem; max-width: 38ch; }

.ghostbtn {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--sans); font-size: .86rem;
  color: var(--gold);
  background: transparent;
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: .6rem 1.15rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background .25s, transform .2s var(--ease);
}
.ghostbtn svg { width: 16px; height: 16px; transition: transform .25s var(--ease); }
.ghostbtn:hover { background: var(--gold-soft); }
.ghostbtn:hover svg { transform: translateX(3px); }
.ghostbtn:active { transform: scale(.97); }

footer {
  position: relative; z-index: 2;
  max-width: 780px; margin: 0 auto;
  padding: 1rem clamp(1.1rem, 5vw, 2rem) 3rem;
  color: var(--fg-faint);
  font-size: .76rem;
  line-height: 1.7;
}
footer code {
  font-family: var(--mono);
  background: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: .05rem .35rem;
}

/* ── responsive ─────────────────────────────── */

@media (max-width: 560px) {
  .topnav .navbtn:not(.iconbtn) { padding: .38rem .6rem; font-size: .76rem; }
  .kbdhint { display: none; }
  .hintrow { justify-content: center; }
  .dist { height: 138px; gap: .28rem; }
  .dist-num { font-size: .62rem; }
  .explore { flex-direction: column; align-items: flex-start; }
  .card-actions { gap: .4rem; }
  .chip { font-size: .76rem; padding: .34rem .75rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
