/* ==========================================================================
   名字Gay指数计算器 — 极光玻璃主题
   计算与文案来自 Akanyi/Gaynum（MIT, Copyright (c) 2025 Akanyi）
   纯本地 CSS，无 CDN / 无外部字体。
   ========================================================================== */

:root {
  --bg: #070a14;
  --surface: rgba(20, 26, 45, 0.72);
  --surface-2: rgba(255, 255, 255, 0.045);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f6ff;
  --muted: #9aa4bd;
  --dim: #6b7690;
  --purple: #a855f7;
  --pink: #ec4899;
  --cyan: #22d3ee;
  --radius-xl: 1.6rem;
  --radius-lg: 1rem;
  --radius-md: 0.8rem;
  --shadow-card: 0 40px 90px -30px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(255, 255, 255, 0.02) inset;
}

* { box-sizing: border-box; }

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

body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 5.5rem 1rem 4.5rem;
  background:
    radial-gradient(1100px 720px at 8% -8%, rgba(124, 58, 237, 0.22), transparent 60%),
    radial-gradient(900px 620px at 108% 8%, rgba(34, 211, 238, 0.16), transparent 58%),
    radial-gradient(760px 620px at 50% 118%, rgba(236, 72, 153, 0.17), transparent 62%),
    var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* 细网格纹理 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(ellipse 75% 65% at 50% 38%, #000 15%, transparent 78%);
  mask-image: radial-gradient(ellipse 75% 65% at 50% 38%, #000 15%, transparent 78%);
}

button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.relative { position: relative; }

.noscript {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 1rem;
  text-align: center;
  background: #7f1d1d;
  color: #fff;
  font-size: 0.875rem;
  z-index: 20;
}

/* --------------------------------------------------------------------------
   背景光晕
   -------------------------------------------------------------------------- */
.bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }

.orb {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  will-change: transform;
}

.orb-1 {
  width: 460px; height: 460px;
  top: -160px; left: -120px;
  background: radial-gradient(circle at 35% 35%, rgba(168, 85, 247, 0.85), transparent 62%);
  animation: drift-a 22s ease-in-out infinite alternate;
}

.orb-2 {
  width: 420px; height: 420px;
  bottom: -170px; right: -110px;
  background: radial-gradient(circle at 60% 40%, rgba(34, 211, 238, 0.7), transparent 64%);
  animation: drift-b 26s ease-in-out infinite alternate;
}

.orb-3 {
  width: 340px; height: 340px;
  top: 42%; left: 58%;
  background: radial-gradient(circle at 50% 50%, rgba(236, 72, 153, 0.6), transparent 66%);
  animation: drift-c 30s ease-in-out infinite alternate;
}

@keyframes drift-a {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(60px, 40px, 0) scale(1.12); }
}
@keyframes drift-b {
  from { transform: translate3d(0, 0, 0) scale(1.05); }
  to { transform: translate3d(-50px, -30px, 0) scale(0.95); }
}
@keyframes drift-c {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-70px, 50px, 0); }
}

/* --------------------------------------------------------------------------
   顶部导航
   -------------------------------------------------------------------------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.055);
  color: #e8ebf7;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 24px -14px rgba(0, 0, 0, 0.9);
  transition: transform 0.22s ease, background-color 0.22s ease,
    border-color 0.22s ease, box-shadow 0.22s ease;
}

.pill:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.pill:active { transform: translateY(0) scale(0.97); }

.pill .icon { width: 15px; height: 15px; opacity: 0.9; }

.pill.share {
  border-color: transparent;
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 45%, #ec4899 100%);
  box-shadow: 0 12px 28px -10px rgba(168, 85, 247, 0.75);
}
.pill.share:hover { filter: brightness(1.08); }

/* 历史记录面板 */
.history-panel {
  position: absolute;
  left: 0;
  top: calc(100% + 0.55rem);
  width: 18rem;
  max-height: 22rem;
  overflow-y: auto;
  padding: 1rem;
  background: rgba(17, 22, 38, 0.94);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  animation: panel-in 0.22s ease-out;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.history-panel h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #e5e9f5;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.history-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.65rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.045);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.history-list li:hover {
  background: rgba(255, 255, 255, 0.075);
  border-color: rgba(168, 85, 247, 0.35);
}

.history-empty {
  justify-content: flex-start !important;
  color: var(--dim) !important;
  cursor: default;
}
.history-empty:hover {
  background: rgba(255, 255, 255, 0.045) !important;
  border-color: transparent !important;
}

.history-item { flex: 1 1 auto; min-width: 0; }
.history-name { font-weight: 600; color: #d8b4fe; }
.history-percent { font-weight: 700; color: #fff; }
.history-msg {
  margin: 0.22rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recall-btn {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(192, 132, 252, 0.45);
  background: rgba(168, 85, 247, 0.08);
  color: #d8b4fe;
  font-size: 0.78rem;
  font-weight: 600;
  transition: background-color 0.2s ease, color 0.2s ease,
    border-color 0.2s ease, transform 0.2s ease;
}
.recall-btn:hover {
  background: linear-gradient(135deg, #7c3aed, #ec4899);
  border-color: transparent;
  color: #fff;
  transform: translateY(-1px);
}

.clear-btn {
  width: 100%;
  margin-top: 0.85rem;
  padding: 0.55rem 1rem;
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius-md);
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  font-weight: 600;
  font-size: 0.82rem;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.clear-btn:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(248, 113, 113, 0.5);
}

.history-note {
  margin: 0.85rem 0 0;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--dim);
}

/* --------------------------------------------------------------------------
   主卡片
   -------------------------------------------------------------------------- */
.card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 30rem;
  padding: 2.1rem 2rem 2.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.7rem;
  background: linear-gradient(180deg, rgba(26, 33, 55, 0.82), rgba(13, 17, 30, 0.9));
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(26px) saturate(130%);
  -webkit-backdrop-filter: blur(26px) saturate(130%);
}

/* 渐变描边 */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(140deg,
    rgba(168, 85, 247, 0.55),
    rgba(34, 211, 238, 0.18) 42%,
    rgba(236, 72, 153, 0.5));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

.header { text-align: center; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.7rem;
  padding: 0.32rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}

.eyebrow-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a855f7, #ec4899);
  box-shadow: 0 0 10px rgba(236, 72, 153, 0.9);
}

h1 {
  margin: 0;
  font-size: clamp(1.85rem, 6.2vw, 2.35rem);
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.rainbow-text {
  background: linear-gradient(100deg, #f472b6 0%, #c084fc 26%, #60a5fa 52%, #22d3ee 76%, #f472b6 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: title-flow 9s linear infinite;
}

@keyframes title-flow {
  to { background-position: 200% 50%; }
}

.subtitle {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* 输入区域 */
.form { display: flex; flex-direction: column; gap: 0.85rem; }

.input-wrap { position: relative; }

.input-icon {
  position: absolute;
  left: 1.05rem;
  top: 50%;
  width: 19px;
  height: 19px;
  transform: translateY(-50%);
  color: rgba(216, 180, 254, 0.75);
  pointer-events: none;
}

#nameInput {
  width: 100%;
  padding: 0.95rem 1.1rem 0.95rem 2.95rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  font-size: 1.02rem;
  outline: none;
  transition: border-color 0.22s ease, box-shadow 0.22s ease,
    background-color 0.22s ease;
}

#nameInput::placeholder { color: var(--dim); }

#nameInput:hover { background: rgba(255, 255, 255, 0.06); }

#nameInput:focus {
  border-color: rgba(168, 85, 247, 0.75);
  background: rgba(255, 255, 255, 0.065);
  box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.14),
    0 0 28px rgba(168, 85, 247, 0.22);
}

#calculateBtn {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.95rem 1.25rem;
  border: 0;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 45%, #ec4899 100%);
  background-size: 160% 160%;
  color: #fff;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 18px 34px -14px rgba(168, 85, 247, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transition: transform 0.2s ease, box-shadow 0.2s ease,
    background-position 0.4s ease, opacity 0.2s ease;
}

#calculateBtn::after {
  content: "";
  position: absolute;
  top: -40%;
  bottom: -40%;
  left: -30%;
  width: 45%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.38), transparent);
  transform: translateX(-180%) skewX(-16deg);
  animation: sheen 5.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes sheen {
  0%, 62% { transform: translateX(-180%) skewX(-16deg); }
  100% { transform: translateX(420%) skewX(-16deg); }
}

#calculateBtn:hover:not(:disabled) {
  transform: translateY(-2px);
  background-position: 100% 50%;
  box-shadow: 0 24px 44px -16px rgba(236, 72, 153, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.26);
}

#calculateBtn:active:not(:disabled) { transform: translateY(0) scale(0.99); }

#calculateBtn:disabled { opacity: 0.75; cursor: progress; }

.spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 结果区域 */
.result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.05rem;
  padding-top: 0.4rem;
  text-align: center;
}

.result-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--muted);
  word-break: break-word;
}
.result-name { font-weight: 700; color: #e9d5ff; }

.score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.2rem 0 0.1rem;
}

.percentage {
  display: block;
  font-size: clamp(3.3rem, 14vw, 4.6rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 0 44px rgba(168, 85, 247, 0.4);
}

.score-label {
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-indent: 0.32em;
  color: rgba(255, 255, 255, 0.38);
}

.progress-track {
  position: relative;
  width: 100%;
  height: 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0) 58%);
  box-shadow: 0 0 22px rgba(217, 70, 239, 0.45);
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.8s ease;
}

.result-message {
  width: 100%;
  min-height: 3.35rem;
  margin: 0;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.035);
  color: #e2e8f0;
  font-size: 1rem;
  line-height: 1.55;
}

.footer {
  position: fixed;
  bottom: 1.1rem;
  right: 1.25rem;
  z-index: 10;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.26);
}
.footer a { color: inherit; text-decoration: none; transition: color 0.25s ease; }
.footer a:hover { color: rgba(255, 255, 255, 0.55); }

/* --------------------------------------------------------------------------
   动画
   -------------------------------------------------------------------------- */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
  20%, 40%, 60%, 80% { transform: translateX(6px); }
}
.shake { animation: shake 0.5s ease-in-out; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fadeInUp 0.55s ease-out forwards; }

@keyframes initial-fade-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.container-fade-in {
  animation: initial-fade-in 0.7s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}

@keyframes pop-in {
  0% { transform: scale(0.82); opacity: 0; }
  70% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); }
}
.pop-in { animation: pop-in 0.5s cubic-bezier(0.25, 0.1, 0.25, 1) forwards; }

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 10px rgba(217, 70, 239, 0.35), 0 0 18px rgba(217, 70, 239, 0.2);
  }
  50% {
    box-shadow: 0 0 22px rgba(217, 70, 239, 0.8), 0 0 34px rgba(168, 85, 247, 0.5);
  }
}
.pulsing-glow { animation: pulse-glow 1.5s infinite ease-in-out; }

/* 100% 彩虹数字 */
@keyframes rainbow-flow {
  to { background-position: 300% 50%; }
}

.rainbow-100 {
  background: linear-gradient(90deg, #f472b6, #c084fc, #60a5fa, #22d3ee, #4ade80, #facc15, #fb923c, #f472b6);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 22px rgba(168, 85, 247, 0.45));
  animation: rainbow-flow 5s linear infinite;
}

/* pop-in 与彩虹动画同时存在 */
.rainbow-100.pop-in {
  animation: pop-in 0.5s cubic-bezier(0.25, 0.1, 0.25, 1) forwards,
    rainbow-flow 5s linear infinite;
}

/* --------------------------------------------------------------------------
   响应式
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  body { padding: 5rem 0.85rem 4rem; }
  .card { padding: 1.6rem 1.25rem 1.8rem; border-radius: 1.35rem; gap: 1.45rem; }
  .topbar { padding: 0.85rem; }
  .pill { font-size: 0.82rem; padding: 0.5rem 0.8rem; }
  .history-panel { width: min(18rem, calc(100vw - 1.7rem)); }
  h1 { font-size: 1.7rem; }
  .subtitle { font-size: 0.9rem; }
  .percentage { font-size: 3.4rem; }
  .result-message { font-size: 0.95rem; }
}

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