/* ==============================
   kodomo-japan.org — styles.css
   モバイルファースト / 暗転演出 / アニメーション
   ============================== */

:root {
  --paper: #faf8f3;
  --ink: #1a1a1a;
  --darkness: 0;
  --bg-darkness: 0;
}

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

body {
  font-family: 'Noto Sans JP', system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  margin: 0;
  line-height: 1.7;
  letter-spacing: 0.02em;
  overflow-x: hidden;
  transition: background-color 1.2s ease, color 1.2s ease;
}

/* Tailwind extension via CSS variables */
.bg-paper { background-color: var(--paper); }
.text-ink { color: var(--ink); }

.font-serif {
  font-family: 'Noto Serif JP', 'Hiragino Mincho ProN', 'Yu Mincho', serif;
  letter-spacing: 0.04em;
}

/* ===== Scenes (each is full-height) ===== */
.scene {
  position: relative;
  transition: background-color 1.2s ease, color 1.2s ease;
}

/* Progressively darkening backgrounds */
.scene[data-bg="0"]    { background: #faf8f3; color: #1a1a1a; }
.scene[data-bg="0.05"] { background: #f5f2eb; color: #1a1a1a; }
.scene[data-bg="0.1"]  { background: #ece8df; color: #1a1a1a; }
.scene[data-bg="0.4"]  { background: #3a3835; color: #e8e6e0; }
.scene[data-bg="0.5"]  { background: #2a2926; color: #e8e6e0; }
.scene[data-bg="0.55"] { background: #232220; color: #e8e6e0; }
.scene[data-bg="0.6"]  { background: #1f1d1b; color: #e8e6e0; }
.scene[data-bg="0.7"]  { background: #1a1816; color: #e8e6e0; }
.scene[data-bg="0.78"] { background: #161412; color: #e0ddd5; }
.scene[data-bg="0.83"] { background: #121110; color: #d8d5cd; }
.scene[data-bg="0.88"] { background: #0e0d0c; color: #d0cdc5; }
.scene[data-bg="0.92"] { background: #0a0908; color: #c8c5bd; }
.scene[data-bg="0.95"] { background: #07060a; color: #c0bdb5; }
.scene[data-bg="0.96"] { background: #08070b; color: #c0bdb5; }
.scene[data-bg="0.97"] { background: #08070b; color: #c0bdb5; }
.scene[data-bg="1"]    { background: #000000; color: #ffffff; }
.scene[data-bg="action"] { background: #fafaf7; color: #1a1a1a; }

.scene.hero {
  background: linear-gradient(180deg, #fdfcf8 0%, #f5f2eb 100%);
}

/* ===== Scene reveal animations ===== */
.scene.in-view > div {
  animation: fadeUp 1s ease forwards;
  opacity: 0;
  transform: translateY(20px);
}

@keyframes fadeUp {
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Counter bar ===== */
#counter-bar {
  font-variant-numeric: tabular-nums;
}

#counter-bar.show {
  display: block;
  animation: slideDown 0.5s ease forwards;
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

/* ===== Buttons ===== */
.next-btn, .gender-btn, .path-btn, button {
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.next-btn:active, button:active {
  transform: scale(0.97);
}

.gender-btn.selected, .path-btn.selected {
  border-color: #c8302d !important;
  background: rgba(200, 48, 45, 0.06);
}


/* ===== Path sections (initially hidden, shown after decision) ===== */
.scene-path,
.scene-stage,
.scene-data,
.scene-2026,
.scene-intl,
.scene-final,
.scene-action {
  display: none !important;
}

.scene-path.revealed,
.scene-stage.revealed,
.scene-data.revealed,
.scene-2026.revealed,
.scene-intl.revealed,
.scene-final.revealed,
.scene-action.revealed {
  display: flex !important;
}

.scene-action.revealed {
  display: block !important;
}

/* Highlight the chosen path */
.scene-path.chosen-path::before {
  content: "あなたが選んだ道";
  position: absolute;
  top: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: #c8302d;
  color: #fff;
  padding: 0.25rem 0.9rem;
  border-radius: 999px;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  font-weight: 700;
}


/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== Mobile fine-tuning ===== */
@media (max-width: 480px) {
  .scene { padding-top: 4rem; padding-bottom: 4rem; }
  h1 { line-height: 1.4; }
  h2 { line-height: 1.5; }
  body { font-size: 15px; }
}

/* ===== Japanese typography (line-break improvements) ===== */
:lang(ja) h1,
:lang(ja) h2,
:lang(ja) h3 {
  text-wrap: balance;
  line-break: strict;
}

:lang(ja) p,
:lang(ja) li {
  text-wrap: pretty;
  line-break: strict;
}

/* Phrase-aware Japanese line breaking (Chrome 119+, Safari 17.5+) */
@supports (word-break: auto-phrase) {
  :lang(ja) h1,
  :lang(ja) h2,
  :lang(ja) h3,
  :lang(ja) p,
  :lang(ja) li {
    word-break: auto-phrase;
  }
}

/* On narrow mobile, hide manual <br class="md-only"> tags */
@media (max-width: 640px) {
  br.md-only { display: none; }
}

/* ===== Tap target safety ===== */
button, a {
  min-height: 44px;
}

/* ===== Smooth focus ring ===== */
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid #c8302d;
  outline-offset: 2px;
  border-radius: 4px;
}

/* ===== Selection color ===== */
::selection {
  background: #c8302d;
  color: #fff;
}

/* ===== Gender-specific content (hidden until selected) ===== */
.if-male, .if-female {
  display: none;
}

body.gender-male .if-male { display: inline; }
body.gender-female .if-female { display: inline; }

/* For block-level gender content */
.if-male.block, .if-female.block { display: none; }
body.gender-male .if-male.block { display: block; }
body.gender-female .if-female.block { display: block; }

/* ===== Illustration containers ===== */
.illustration svg,
.illustration img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 16px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.08);
}

/* P5 (empty house) gets a deeper, colder shadow for emotional weight */
.scene-p5 .illustration img,
.scene-p5 .illustration svg {
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}

/* Moment cards (4 happy memories) */
.moment-card {
  background: #fff;
  border: 1px solid rgb(254 243 199);
  border-radius: 12px;
  overflow: hidden;
  text-align: center;
  display: flex;
  flex-direction: column;
}
.moment-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}
.moment-card-text {
  padding: 0.75rem;
  font-size: 0.75rem;
  line-height: 1.3;
  color: rgb(68 64 60);
}

/* ===== Initial visibility for prologue scenes ===== */
.scene-hero { display: flex; }
.scene-p0, .scene-p1, .scene-p2, .scene-p3, .scene-p4, .scene-p5,
.scene-decision {
  display: flex;
}
