/* ========================================================================
   深夜情绪便利店 · 霓虹深夜美术（桌面橱窗 / 手机满屏 自适应）
   ===================================================================== */

/* 自托管字体子集（常用字，路演不依赖 Google CDN）。生僻字优雅回退到系统字体。 */
@font-face {
  font-family: "ZCOOL QingKe HuangYou";
  src: url("./fonts/ZCOOLQingKeHuangYou.subset.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Ma Shan Zheng";
  src: url("./fonts/MaShanZheng.subset.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --night-top: #05060f;
  --night-bottom: #161435;
  --neon-pink: #ff2e88;
  --neon-pink-soft: #ff6ec7;
  --neon-cyan: #00f0ff;
  --warm: #ffb65c;
  --warm-glow: rgba(255, 182, 92, 0.35);
  --paper: #f7f3e9;
  --ink: #2a2620;
  --z-bg: 0;
  --z-scene: 10;
  --z-ui: 20;
  --z-loading: 50;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background:
    radial-gradient(900px 520px at 50% 118%, rgba(255, 182, 92, 0.10), transparent 60%),
    radial-gradient(700px 420px at 82% -8%, rgba(0, 240, 255, 0.08), transparent 60%),
    radial-gradient(700px 420px at 12% 0%, rgba(255, 46, 136, 0.07), transparent 60%),
    linear-gradient(180deg, #03040a 0%, #0a0a1c 100%);
  color: #fff;
  font-family: "ZCOOL QingKe HuangYou", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

.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;
}

/* ===================== 舞台：手机满屏 / 桌面橱窗 ===================== */
#stage {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
}

@media (min-width: 768px) {
  body { display: grid; place-items: center; padding: 28px; }
  #stage {
    width: min(560px, 94vw);
    height: min(880px, 92dvh);
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow:
      0 50px 130px rgba(0, 0, 0, 0.65),
      0 0 0 1px rgba(255, 255, 255, 0.04),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
}

/* ===================== 沉浸背景层（限定在舞台内） ===================== */
.night-sky, .far-neon, .rain, .vignette {
  position: absolute; inset: 0; z-index: var(--z-bg); pointer-events: none;
}
.night-sky {
  background:
    radial-gradient(120% 60% at 50% 120%, rgba(255, 182, 92, 0.14), transparent 62%),
    radial-gradient(90% 50% at 80% -10%, rgba(0, 240, 255, 0.10), transparent 60%),
    linear-gradient(180deg, var(--night-top) 0%, var(--night-bottom) 100%);
}
.far-neon {
  background:
    radial-gradient(3px 3px at 18% 22%, rgba(255, 110, 199, 0.6), transparent 60%),
    radial-gradient(3px 3px at 76% 16%, rgba(0, 240, 255, 0.55), transparent 60%),
    radial-gradient(2px 2px at 60% 30%, rgba(255, 255, 255, 0.5), transparent 60%),
    radial-gradient(2px 2px at 36% 12%, rgba(255, 182, 92, 0.5), transparent 60%);
  filter: blur(0.5px);
  opacity: 0.7;
}
.rain {
  opacity: 0.08;
  background-image: repeating-linear-gradient(102deg, transparent 0 17px, rgba(255,255,255,0.45) 17px 18px);
  animation: rain 0.7s linear infinite;
}
@keyframes rain { to { background-position: 40px 120px; } }
.vignette {
  background: radial-gradient(120% 100% at 50% 45%, transparent 55%, rgba(0,0,0,0.55) 100%);
}

/* 推门走进店内：镜头朝门口推近 + 暖光涌入 */
.walk-flash {
  position: absolute; inset: 0; z-index: 40; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 60%, rgba(255,214,150,.96), rgba(255,180,95,.45) 42%, transparent 76%);
}
.walk-flash.is-on { animation: walkin .9s ease forwards; }
@keyframes walkin { 0% { opacity: 0; } 48% { opacity: .92; } 100% { opacity: 0; } }

/* ===================== 场景切换 ===================== */
.scene {
  position: absolute; inset: 0; z-index: var(--z-scene);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(18px, 3vh, 28px);
  padding: clamp(20px, 5vw, 40px);
  padding-top: max(env(safe-area-inset-top), 20px);
  padding-bottom: max(env(safe-area-inset-bottom), 20px);
  opacity: 0; visibility: hidden; transform: scale(1.04);
  transition: opacity .5s ease, transform .5s ease, visibility .5s;
}
.scene.is-active { opacity: 1; visibility: visible; transform: scale(1); }

/* ===================== 场景 1：店外 / 推门 ===================== */
.storefront {
  position: relative;
  width: min(420px, 86%);
  aspect-ratio: 4 / 5;
  max-height: 62vh;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  transform-origin: 50% 80%;
  transition: transform .8s cubic-bezier(.45,0,.7,.2), opacity .6s ease .15s;
}
.scene--street.walking-in .storefront { transform: scale(3.4); opacity: 0; }
.scene--street.walking-in .street-tagline { opacity: 0; transition: opacity .3s ease; }
.neon-sign {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; z-index: 3;
}
.neon-sign__cn {
  font-size: clamp(26px, 7vw, 40px); letter-spacing: 3px; color: #fff; white-space: nowrap;
  text-shadow: 0 0 6px var(--neon-pink), 0 0 14px var(--neon-pink), 0 0 30px var(--neon-pink-soft);
  animation: flicker 5s infinite;
}
.neon-sign__open {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: clamp(12px, 3vw, 14px); letter-spacing: 2px; color: var(--neon-cyan);
  text-shadow: 0 0 6px var(--neon-cyan), 0 0 12px var(--neon-cyan);
}
.neon-sign__open .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--neon-cyan);
  box-shadow: 0 0 8px var(--neon-cyan); animation: blink 2s steps(1) infinite;
}
@keyframes flicker {
  0%,18%,22%,25%,53%,57%,100% { opacity: 1; }
  20%,24%,55% { opacity: .58; }
}
@keyframes blink { 0%,49%{opacity:1} 50%,100%{opacity:.3} }

.awning {
  position: absolute; top: 22%; left: -5%; right: -5%; height: clamp(30px, 8%, 46px);
  background: repeating-linear-gradient(90deg, #c4264f 0 22px, #f7f3e9 22px 44px);
  border-radius: 7px 7px 0 0; box-shadow: 0 10px 22px rgba(0,0,0,.5);
  transform: perspective(320px) rotateX(30deg); z-index: 2;
}
.window-glow {
  position: absolute; bottom: 6%; width: 80%; height: 54%; overflow: hidden;
  background: linear-gradient(180deg, rgba(255,182,92,.20), rgba(255,182,92,.46));
  border: 2px solid rgba(255,255,255,.18); border-bottom: none; border-radius: 8px 8px 0 0;
  box-shadow: 0 0 70px var(--warm-glow), inset 0 0 50px var(--warm-glow);
  animation: interior 6s ease-in-out infinite;
}
/* 室内货架剪影（纵深） */
.window-glow::before {
  content: ""; position: absolute; inset: 16% 12% 14% 12%;
  background: repeating-linear-gradient(180deg, transparent 0 30%, rgba(90,58,26,.4) 30% 33%);
}
/* 货架上几件商品的剪影 */
.window-glow::after {
  content: ""; position: absolute; left: 14%; right: 14%; top: 30%; height: 9%;
  background:
    linear-gradient(rgba(214,118,42,.55) 0 0) 2% 0/10% 100% no-repeat,
    linear-gradient(rgba(80,150,180,.5) 0 0) 20% 20%/8% 80% no-repeat,
    linear-gradient(rgba(196,90,70,.55) 0 0) 36% 0/12% 100% no-repeat,
    linear-gradient(rgba(150,140,90,.5) 0 0) 56% 10%/9% 90% no-repeat,
    linear-gradient(rgba(120,90,160,.5) 0 0) 74% 0/11% 100% no-repeat,
    linear-gradient(rgba(214,160,80,.5) 0 0) 90% 25%/8% 75% no-repeat;
}
@keyframes interior {
  0%, 92%, 100% { filter: brightness(1); }
  93%, 95% { filter: brightness(0.82); }
  94% { filter: brightness(1.05); }
}
.door {
  position: relative; z-index: 3; width: 36%; height: 50%; margin-bottom: 6%;
  border: none; background: none; cursor: pointer; padding: 0;
  display: flex; align-items: flex-end; justify-content: center;
  transition: filter .3s;
}
.door__panel {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,236,200,.62), rgba(255,200,130,.88));
  border: 3px solid rgba(255,255,255,.22); border-radius: 6px 6px 0 0;
  box-shadow: 0 0 34px var(--warm-glow);
  transform-origin: left center;
  transition: transform .5s cubic-bezier(.34,1.56,.64,1);
}
.door:hover { filter: brightness(1.1); }
.door.is-open .door__panel { transform: perspective(620px) rotateY(-82deg); }
.door__hint {
  position: relative; z-index: 1; margin-bottom: clamp(12px, 4%, 20px);
  color: #5a3d12; font-size: clamp(13px, 3.4vw, 15px); font-weight: bold; letter-spacing: 1px;
  animation: bob 1.6s ease-in-out infinite;
}
@keyframes bob { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-5px)} }
.floor {
  position: absolute; bottom: -2%; left: -10%; right: -10%; height: 10%;
  background: linear-gradient(180deg, rgba(255,182,92,.18), transparent);
  filter: blur(6px);
}
.street-tagline {
  color: #cfd2ff; font-size: clamp(14px, 3.6vw, 16px); letter-spacing: 1px; opacity: .85;
  text-align: center; max-width: 30ch; line-height: 1.6;
}

/* ===================== 店员气泡（通用） ===================== */
.clerk { display: flex; align-items: flex-start; gap: 12px; width: min(440px, 92%); }
.clerk__avatar {
  width: 50px; height: 50px; flex: 0 0 50px; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 40% 35%, #2b3a6b, #161a3a);
  box-shadow: 0 0 18px rgba(0,240,255,.35);
}
.clerk__avatar svg { width: 26px; height: 26px; fill: #ffe6a3; filter: drop-shadow(0 0 4px rgba(255,200,120,.6)); }
.clerk__bubble {
  position: relative; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.15);
  padding: 13px 17px; border-radius: 4px 16px 16px 16px; font-size: clamp(16px, 4vw, 18px); line-height: 1.6;
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
}
.scene.is-active .clerk__bubble { animation: bubblePop .4s ease both; }
@keyframes bubblePop { 0% { opacity: 0; transform: translateY(7px) scale(.96); } 100% { opacity: 1; transform: none; } }

/* ===================== 场景 2：柜台 ===================== */
.scene--counter { gap: clamp(16px, 3vh, 24px); }
.say { display: flex; flex-direction: column; gap: 12px; width: min(440px, 92%); }
#moodInput {
  resize: none; width: 100%; padding: 14px 16px; font-size: 16px; line-height: 1.6;
  color: #fff; background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.16); border-radius: 14px; font-family: inherit;
}
#moodInput:focus { outline: none; border-color: var(--neon-cyan); box-shadow: 0 0 14px rgba(0,240,255,.25); }
#moodInput::placeholder { color: #9aa0c4; }
#sayBtn {
  min-height: 48px; padding: 13px; font-size: 16px; letter-spacing: 2px; color: #11132a; font-family: inherit;
  background: linear-gradient(120deg, var(--neon-cyan), var(--neon-pink-soft));
  border: none; border-radius: 14px; cursor: pointer; font-weight: bold;
  box-shadow: 0 0 22px rgba(255,110,199,.42); transition: transform .15s, filter .2s;
}
#sayBtn:active { transform: scale(.97); }
#sayBtn:disabled { filter: grayscale(.6) brightness(.8); cursor: wait; }
.say__hint { text-align: center; color: #a6abce; font-size: clamp(12px, 3.2vw, 13px); }
.counter-ledge {
  position: absolute; bottom: 0; left: 0; right: 0; height: 14%;
  background: linear-gradient(180deg, rgba(120,90,50,.0), rgba(70,52,30,.55));
  border-top: 2px solid rgba(255,182,92,.25);
  box-shadow: 0 -6px 30px rgba(255,182,92,.12);
  z-index: -1;
}

/* ===================== 场景 3：取货 ===================== */
.shelf {
  position: relative; width: min(420px, 86%); padding: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.10); border-radius: 16px;
  box-shadow: inset 0 0 40px rgba(0,0,0,.35);
}
.shelf__row { height: 14px; margin: 18px 0; background: rgba(255,255,255,.06); border-radius: 4px; box-shadow: inset 0 2px 6px rgba(0,0,0,.4); }
.product {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.4);
  text-align: center; opacity: 0;
  background: linear-gradient(160deg, #fff, #ffe7c2); color: var(--ink);
  padding: 18px 22px; border-radius: 14px; min-width: min(220px, 70%);
  box-shadow: 0 16px 44px rgba(0,0,0,.5), 0 0 46px var(--warm-glow);
}
.product.is-out { animation: takeOut .8s cubic-bezier(.34,1.56,.64,1) forwards; }
@keyframes takeOut {
  0% { opacity: 0; transform: translate(-50%, -92%) scale(.4) rotate(-6deg); }
  60% { opacity: 1; transform: translate(-50%, -50%) scale(1.08) rotate(2deg); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); }
}
.product__name { font-size: clamp(19px, 5vw, 22px); font-weight: bold; line-height: 1.3; overflow-wrap: anywhere; }
.product__type { margin-top: 6px; font-size: clamp(11px, 3vw, 12px); letter-spacing: 2px; color: #b5762a; }
.product::after {
  content: ""; display: block; width: 72%; height: 13px; margin: 12px auto 0; opacity: .78;
  background: repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 4px, var(--ink) 4px 5px, transparent 5px 8px);
}

/* ===================== 场景 4：小票 ===================== */
.receipt-wrap { display: grid; place-items: center; }
.receipt {
  width: min(330px, 82%); background: var(--paper); color: var(--ink);
  padding: 26px 24px 20px; position: relative;
  font-family: "Courier New", ui-monospace, "Noto Sans Mono", monospace;
  box-shadow: 0 20px 54px rgba(0,0,0,.55);
  transform: rotate(-1.2deg);
  -webkit-mask:
    radial-gradient(6px at 6px 50%, transparent 98%, #000) -6px 0/12px 100%,
    linear-gradient(#000 0 0);
}
.receipt__head { text-align: center; }
.receipt.is-printing { animation: printout .85s cubic-bezier(.2,.7,.2,1) both; }
@keyframes printout {
  0% { clip-path: inset(0 0 100% 0); opacity: .65; }
  100% { clip-path: inset(0 0 0 0); opacity: 1; }
}
.receipt__store { font-family: "Ma Shan Zheng", serif; font-size: clamp(22px, 6vw, 25px); letter-spacing: 2px; }
.receipt__sub { font-size: 9px; letter-spacing: 2px; color: #8a8273; margin-top: 2px; }
.receipt__meta { font-size: 11px; color: #6b6457; margin-top: 8px; }
.receipt__divider { border-top: 1px dashed #b3aa97; margin: 12px 0; }
.receipt__divider--dash { border-top-style: dotted; }
.receipt__line { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; font-weight: bold; gap: 8px; }
.receipt__item { line-height: 1.4; overflow-wrap: anywhere; }
.receipt__price { white-space: nowrap; }
.receipt__type { font-size: 11px; color: #8a8273; margin-top: 4px; letter-spacing: 1px; }
.receipt__greeting { font-size: 13px; line-height: 1.7; margin: 4px 0; }
.receipt__note {
  font-family: "Ma Shan Zheng", serif; font-size: clamp(16px, 4.5vw, 18px); line-height: 1.6;
  color: #c4264f; margin-top: 6px;
}
.receipt__foot { text-align: center; font-size: 11px; color: #6b6457; margin-top: 6px; line-height: 1.8; }
.receipt__thanks { color: var(--ink); }
.receipt__barcode {
  height: 34px; margin-top: 10px;
  background: repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 4px, var(--ink) 4px 5px, transparent 5px 9px);
}
/* 分享钩子：QR + 品牌一句话，转发出去也看得懂 */
.receipt__share {
  display: flex; align-items: center; gap: 12px;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px dashed #b3aa97; text-align: left;
}
.receipt__qr {
  width: 64px; height: 64px; flex: none;
  image-rendering: pixelated; border-radius: 3px;
}
.receipt__share-copy { min-width: 0; }
.receipt__brand { font-family: "Ma Shan Zheng", serif; font-size: 16px; color: var(--ink); letter-spacing: 1px; }
.receipt__slogan { font-size: 10px; color: #8a8273; line-height: 1.5; margin-top: 2px; }
.receipt__cta { font-size: 10px; color: #c4264f; margin-top: 4px; letter-spacing: 1px; }

/* ===================== 按钮 / 加载 ===================== */
.ghost-btn {
  min-height: 48px; padding: 12px 26px; font-size: clamp(14px, 3.6vw, 15px); letter-spacing: 1px;
  color: #fff; font-family: inherit;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px; cursor: pointer; transition: transform .15s, background .2s, border-color .2s;
}
.ghost-btn:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.35); }
.ghost-btn:active { transform: scale(.96); }
.ghost-btn--primary {
  background: linear-gradient(120deg, var(--neon-cyan), var(--neon-pink-soft)); color: #11132a; border: none; font-weight: bold;
}
.ghost-btn--primary:hover { filter: brightness(1.06); }
.checkout-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

.loading {
  position: absolute; inset: 0; z-index: var(--z-loading); display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: rgba(5,6,15,.8); backdrop-filter: blur(3px); color: #cfd2ff; font-size: 15px;
}
.loading.is-on { display: flex; }
.loading__dots { display: flex; gap: 8px; }
.loading__dots span {
  width: 12px; height: 12px; border-radius: 50%; background: var(--neon-cyan);
  animation: pulse 1.2s ease-in-out infinite;
}
.loading__dots span:nth-child(2) { animation-delay: .2s; }
.loading__dots span:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 0%,100%{opacity:.3;transform:scale(.8)} 50%{opacity:1;transform:scale(1.2)} }

/* ===================== 无障碍：焦点环 ===================== */
:focus-visible { outline: 2px solid var(--neon-cyan); outline-offset: 3px; border-radius: 4px; }

/* ===================== 减少动效偏好 ===================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .rain { display: none; }
}

/* ===================== 矮屏 / 横屏微调 ===================== */
@media (max-height: 620px) {
  .storefront { max-height: 54vh; }
  .scene { gap: 14px; }
}
