/* Yipeisheng interactive prototype — mobile first, WeChat-friendly.
   Color tokens: --brand-orange is a common Hermès-orange approximation,
   not an official brand specification. Calibrate later. */

:root {
  --brand-orange: #f37021;
  --brand-orange-deep: #c44710;
  --brand-orange-ink: #8a2e08;
  --cream: #fff6ee;
  --cream-deep: #f3e3d4;
  --ink: #2a1a12;
  --ink-soft: #5c4336;
  --line: rgba(42, 26, 18, 0.12);
  --white: #fffdf9;
  --banner-h: 2.4rem;
  --banner-offset: calc(0.9rem + 1.05rem + env(safe-area-inset-top, 0px));
  --radius: 1.15rem;
  --shadow: 0 18px 40px rgba(80, 30, 8, 0.18);
  --font: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Source Han Sans SC",
    "Microsoft YaHei", "Helvetica Neue", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: #1a100c;
  color: var(--ink);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 0;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
  border: 0;
}

button {
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: none;
  color: inherit;
}

button:focus-visible,
[data-action]:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 3px;
}

.stage {
  height: 100%;
  max-height: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(1200px 600px at 50% -10%, #4a2416 0%, #1a100c 55%);
}

/* Phone frame is a height-constrained flex column. The legal banner stays in
   normal flow (not sticky/fixed) so overflow/transform on descendants cannot
   retarget it, and body scroll is locked on mobile so the real viewport
   cannot carry it away. */
.device {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100%;
  min-height: 0;
  background: var(--cream);
  overflow: hidden;
  overscroll-behavior: none;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (min-width: 640px) {
  .stage {
    height: 100%;
    max-height: 100%;
    padding: 2.5rem 1.25rem;
    overflow: hidden;
  }
  .device {
    max-width: 390px;
    min-height: 0;
    height: min(844px, calc(100vh - 5rem));
    height: min(844px, calc(100dvh - 5rem));
    border-radius: 28px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.08);
  }
}

.proto-chrome {
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
  flex-shrink: 0;
  width: 100%;
}

.proto-banner {
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
  flex-shrink: 0;
  box-sizing: border-box;
  min-height: var(--banner-offset);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(0.45rem + env(safe-area-inset-top, 0px))
    calc(0.75rem + env(safe-area-inset-right, 0px))
    0.45rem
    calc(0.75rem + env(safe-area-inset-left, 0px));
  background-color: #2a1a12;
  color: #f6d7c4;
  overflow: visible;
}

.proto-banner-text {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  max-width: 100%;
  color: #f6d7c4;
  background: transparent;
  font-size: 0.75rem;
  line-height: 1.4;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-align: center;
  text-indent: 0;
  white-space: nowrap;
  overflow: visible;
  opacity: 1;
  visibility: visible;
  -webkit-text-fill-color: #f6d7c4;
}

.screens {
  position: relative;
  z-index: 0;
  overflow: hidden;
  overscroll-behavior: none;
  flex: 1 1 0%;
  min-height: 0;
}

/* Opacity-only show/hide: a transform on the screen layer would create a
   containing block and can also promote a layer that paints over chrome
   during transitions. Scrolling happens only here, never on html/body. */
[data-screen] {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  overflow: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* Hide outgoing controls immediately, including from keyboard navigation. */
  transition: opacity 0.35s ease;
}

[data-screen].is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 1;
}

/* ----- Intro ----- */
.screen-intro {
  background:
    radial-gradient(120% 80% at 80% -10%, #ffb067 0%, transparent 42%),
    linear-gradient(165deg, #ff8a3d 0%, var(--brand-orange) 38%, var(--brand-orange-deep) 100%);
  color: var(--white);
  justify-content: space-between;
  padding: 1.75rem 1.5rem 1.4rem;
}

.intro-mark {
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  opacity: 0.85;
  font-weight: 500;
}

.intro-hero {
  margin: auto 0 2.5rem;
}

.intro-kicker {
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  opacity: 0.9;
  margin: 0 0 0.85rem;
}

.intro-title {
  font-size: clamp(3.2rem, 16vw, 4.4rem);
  line-height: 0.95;
  font-weight: 600;
  letter-spacing: 0.08em;
  margin: 0;
  text-shadow: 0 8px 30px rgba(80, 20, 0, 0.25);
}

.intro-rule {
  width: 3.2rem;
  height: 2px;
  background: rgba(255, 255, 255, 0.7);
  margin: 1.15rem 0 0.9rem;
}

.intro-sub {
  margin: 0;
  font-size: 1.02rem;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  font-weight: 500;
}

.intro-meta {
  margin: 0.55rem 0 0;
  font-size: 0.82rem;
  opacity: 0.86;
}

.intro-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.intro-hint {
  font-size: 0.78rem;
  opacity: 0.88;
}

.btn-ghost {
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  background: rgba(255, 255, 255, 0.08);
}

.btn-ghost:active {
  background: rgba(255, 255, 255, 0.18);
}

.screen-intro.is-active .intro-title,
.screen-intro.is-active .intro-rule,
.screen-intro.is-active .intro-sub,
.screen-intro.is-active .intro-meta,
.screen-intro.is-active .intro-kicker {
  animation: rise 0.9s ease both;
}
.intro-kicker { animation-delay: 0.05s; }
.intro-title { animation-delay: 0.15s; }
.intro-rule { animation-delay: 0.32s; }
.intro-sub { animation-delay: 0.42s; }
.intro-meta { animation-delay: 0.52s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ----- Shared content screens ----- */
.screen-panel {
  background: var(--cream);
  padding: 1.25rem 1.2rem 1.6rem;
}

.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  color: var(--brand-orange-deep);
  font-weight: 600;
}

.panel-title {
  margin: 0.45rem 0 0.75rem;
  font-size: 1.55rem;
  letter-spacing: 0.04em;
  line-height: 1.25;
}

.lede,
.body-copy {
  margin: 0 0 0.85rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.7;
}

.note {
  margin: 0 0 1.15rem;
  padding: 0.75rem 0.85rem;
  background: rgba(243, 112, 33, 0.08);
  border-left: 3px solid var(--brand-orange);
  color: var(--ink);
  font-size: 0.8rem;
  line-height: 1.65;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-top: auto;
  padding-top: 1rem;
}

.btn-primary,
.btn-secondary,
.btn-text {
  width: 100%;
  border-radius: 999px;
  padding: 0.9rem 1.1rem;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.btn-primary {
  background: var(--brand-orange);
  color: var(--white);
  box-shadow: 0 10px 20px rgba(196, 71, 16, 0.25);
}

.btn-primary:active {
  background: var(--brand-orange-deep);
}

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-secondary:active {
  background: var(--cream-deep);
}

.btn-text {
  background: transparent;
  color: var(--ink-soft);
  font-weight: 500;
  padding: 0.55rem;
}

/* ----- Leave ----- */
.screen-leave {
  background:
    linear-gradient(180deg, #fff6ee 0%, #efe0d4 100%);
}

/* ----- Narrative doorway and complete composition mounts ----- */
.hub-head { padding-bottom: .6rem; }
.hub-brand { margin: .5rem 0 .8rem; font-size: 1.8rem; line-height: 1.3; }
.scene-art { position: relative; background: transparent; flex: 0 0 auto; }
.scene-art img { width: 100%; height: 100%; object-fit: contain; object-position: center; }
.scene-placeholder { display: none; padding: 2rem 1rem; font-size: .85rem; }
.scene-art.no-photo .scene-placeholder { display: block; }
.doorway-art { height: 13rem; margin: 0 0 1rem; }
.chapter-index { margin: 1.2rem 0 .8rem; border-top: 1px solid var(--line); }
.chapter-index button { width: 100%; min-height: 60px; display: flex; align-items: center; gap: .6rem; text-align: left; border-bottom: 1px solid var(--line); padding: .7rem .2rem; font-size: .92rem; }
.chapter-index button span:first-child { color: var(--brand-orange-ink); font-size: .75rem; }
.chapter-index button span:last-child { margin-left: auto; font-size: .72rem; color: var(--ink-soft); }
.hub-foot { margin-top: auto; }

/* ----- Scene chapter ----- */
.screen-scene {
  padding: 0;
  background: var(--cream);
}

.scene-panels {
  position: relative;
  flex: 1;
  min-height: min-content;
}

[data-scene-panel] {
  display: none;
  flex-direction: column;
  min-height: 100%;
}

[data-scene-panel].is-active {
  display: flex;
}

.chapter-hero {
  position: relative;
  height: 16.5rem;
  flex: 0 0 auto;
  overflow: visible;
  margin: 0 1rem;
  background: radial-gradient(ellipse at center, #ffdfb5 0%, #fff6ee 72%);
}

.chapter-hero .scene-art { height: 100%; }
[data-scene-panel].is-active .chapter-hero .scene-art { animation: scene-reveal .65s ease-out both; }
@keyframes scene-reveal {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.chapter-body {
  padding: 1.15rem 1.2rem 1.5rem;
}

.review-box {
  margin: 0.9rem 0 1rem;
  padding: 0.95rem 1rem;
  border: 1px dashed rgba(196, 71, 16, 0.45);
  background: rgba(243, 112, 33, 0.06);
  border-radius: 0.7rem;
}

.review-box strong {
  display: block;
  color: var(--brand-orange-ink);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}

.review-box p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--ink-soft);
}

.caption-note {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
  line-height: 1.65;
}

.chapter-nav {
  display: flex;
  gap: 0.5rem;
}

.chapter-nav .btn-secondary,
.chapter-nav .btn-text {
  width: auto;
  flex: 1;
}

/* ----- Reduced motion ----- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  [data-screen] {
    transform: none;
  }
}

body.reduced-motion,
body.reduced-motion::before,
body.reduced-motion::after,
body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  transition: none !important;
  scroll-behavior: auto !important;
  animation: none !important;
}

/* Narrative rhythm: no text or click targets sit over the supplied art. */
.experience-tools { display: flex; align-items: center; justify-content: space-between; gap: .4rem; padding: .3rem .8rem; background: #fff6ee; border-bottom: 1px solid var(--line); font-size: .7rem; }
.experience-tools button { min-height: 36px; padding: .4rem; text-decoration: underline; text-underline-offset: 3px; }
[data-screen] > * { flex-shrink: 0; min-width: 0; }
.screen-intro { justify-content: flex-start; gap: .8rem; padding: 1.2rem; }
.intro-mark { margin: 0; }
.intro-hero { margin: 1rem 0 0; }
.intro-title { font-size: 3.5rem; }
.intro-rule { margin: .7rem 0; }
.opening-art { height: clamp(180px, 30vh, 260px); margin: auto -.4rem 0; }
.intro-foot { flex-wrap: wrap; margin-top: .3rem; }
.intro-foot button { min-height: 44px; }
.chapter-heading { padding: 1.25rem 1.2rem .4rem; }
.chapter-heading .panel-title { font-size: 1.9rem; }
.chapter-body { padding-top: .8rem; }
.narrative-copy { font-size: 1rem; }
.click-cue { font-size: .76rem; line-height: 1.6; color: var(--ink-soft); margin: .6rem 0; }
.chapter-nav { flex-wrap: wrap; }
.chapter-nav button { flex: 1 1 130px; min-height: 48px; }
.chapter-utilities { display: flex; flex-wrap: wrap; justify-content: space-between; margin-top: .5rem; }
.chapter-utilities button { width: auto; flex: 1 1 auto; min-height: 44px; font-size: .8rem; }
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus { outline: none; }
h1[tabindex="-1"]:focus-visible, h2[tabindex="-1"]:focus-visible { text-decoration: underline; text-decoration-color: currentColor; text-decoration-thickness: 2px; text-underline-offset: .2em; }
button:focus-visible, [data-action]:focus-visible { outline: 3px solid #71310f; outline-offset: 2px; box-shadow: 0 0 0 4px #fff6ee; }
.screen-intro button:focus-visible { outline-color: #fffdf9; box-shadow: 0 0 0 4px #71310f; }
@media (max-height: 650px) { .intro-hero { margin-top: .3rem; } .opening-art { height: 180px; } .intro-title { font-size: 3rem; } }

.screen-intro.is-active .opening-art { animation: scene-reveal .65s ease-out both; }
