/* ==========================================================================
   TUTORIAL / HELP OVERLAY  —— 按 ESC 打开的动态操作指南
   ========================================================================== */

.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 6, 6, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 1;
  transition: opacity 0.25s ease;
}

.tutorial-overlay.hidden {
  display: none;
}

.tutorial-overlay.is-closing {
  opacity: 0;
}

.tutorial-card {
  width: min(760px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #17150f 0%, #100f0c 100%);
  border: 1px solid var(--accent-gold-dim);
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.7), inset 0 0 60px rgba(200, 169, 110, 0.04);
  padding: 30px 34px 26px;
  animation: tut-rise 0.35s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

@keyframes tut-rise {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.tutorial-title {
  font-family: var(--font-heading);
  color: var(--accent-gold);
  font-size: 1.9rem;
  text-align: center;
  letter-spacing: 2px;
  margin: 0;
}

.tutorial-sub {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  letter-spacing: 1px;
  margin: 4px 0 20px;
}

.tutorial-section {
  margin-bottom: 22px;
}

.tutorial-section h3 {
  color: var(--accent-gold);
  font-family: var(--font-heading);
  font-size: 1.05rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin: 0 0 14px;
  letter-spacing: 1px;
}

/* ---- Controls grid ---- */
.tutorial-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 22px;
}

.ctrl {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 46px;
}

.ctrl-label {
  color: var(--text-primary);
  font-size: 0.92rem;
  line-height: 1.35;
}

/* keycap */
.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 9px;
  background: linear-gradient(180deg, #2a2721 0%, #1b1915 100%);
  border: 1px solid var(--accent-gold-dim);
  border-bottom-width: 3px;
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
}

.key-wide { min-width: 78px; padding: 0 12px; font-size: 0.82rem; white-space: nowrap; }
.key-esc { min-width: 48px; letter-spacing: 1px; }

/* WASD cross layout */
.keys.wasd {
  display: grid;
  grid-template-columns: repeat(3, 30px);
  grid-template-rows: 30px 30px;
  gap: 4px;
  justify-content: center;
}
.keys.wasd .key { min-width: 30px; height: 30px; padding: 0; font-size: 0.82rem; }
.keys.wasd .k-w { grid-column: 2; grid-row: 1; }
.keys.wasd .k-a { grid-column: 1; grid-row: 2; }
.keys.wasd .k-s { grid-column: 2; grid-row: 2; }
.keys.wasd .k-d { grid-column: 3; grid-row: 2; }

/* the pulse "demo": each WASD key lights up in sequence */
.keys.wasd .key { animation: key-press 3.2s infinite; }
.keys.wasd .k-w { animation-delay: 0s; }
.keys.wasd .k-a { animation-delay: 0.8s; }
.keys.wasd .k-s { animation-delay: 1.6s; }
.keys.wasd .k-d { animation-delay: 2.4s; }

@keyframes key-press {
  0%, 12%, 100% {
    background: linear-gradient(180deg, #2a2721 0%, #1b1915 100%);
    color: var(--text-primary);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
    transform: translateY(0);
  }
  4%, 8% {
    background: linear-gradient(180deg, var(--accent-gold) 0%, var(--accent-gold-dim) 100%);
    color: #14120d;
    box-shadow: 0 0 14px rgba(200, 169, 110, 0.7);
    transform: translateY(1px);
  }
}

/* animated mouse */
.mouse {
  position: relative;
  width: 30px;
  height: 44px;
  border: 2px solid var(--accent-gold-dim);
  border-radius: 16px;
  flex: 0 0 auto;
}
.mouse-dot {
  position: absolute;
  top: 6px;
  left: 50%;
  width: 4px;
  height: 8px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--accent-gold);
  animation: mouse-scroll 1.6s infinite;
}
@keyframes mouse-scroll {
  0%, 100% { transform: translateY(0); opacity: 1; }
  50% { transform: translateY(6px); opacity: 0.3; }
}

/* ---- Steps ---- */
.tutorial-steps {
  margin: 0;
  padding-left: 22px;
  color: var(--text-primary);
}
.tutorial-steps li {
  margin-bottom: 10px;
  line-height: 1.5;
  font-size: 0.94rem;
  animation: step-in 0.5s ease both;
}
.tutorial-steps li:nth-child(1) { animation-delay: 0.15s; }
.tutorial-steps li:nth-child(2) { animation-delay: 0.28s; }
.tutorial-steps li:nth-child(3) { animation-delay: 0.41s; }
.tutorial-steps li:nth-child(4) { animation-delay: 0.54s; }
.tutorial-steps b { color: var(--accent-gold); }

@keyframes step-in {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.tutorial-close {
  display: block;
  margin: 8px auto 6px;
}

.tutorial-hint {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin: 6px 0 0;
}
.key-esc-inline {
  min-width: 0;
  height: auto;
  padding: 1px 6px;
  border-bottom-width: 2px;
  font-size: 0.72rem;
}

@media (max-width: 600px) {
  .tutorial-controls { grid-template-columns: 1fr; }
  .tutorial-card { padding: 22px 18px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .tutorial-card,
  .tutorial-steps li,
  .keys.wasd .key,
  .mouse-dot { animation: none !important; }
}
