/* ============================================================
   FUZHOUNESE DISH QUIZ — Styles
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'DM Sans', sans-serif;
  background: #F5ECD7;
  color: #3B2F20;
  -webkit-font-smoothing: antialiased;
}

/* --- Quiz Container --- */
#quiz-container {
  width: 100%;
  height: 100%;
  max-width: 500px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: #FDF6E3;
  box-shadow: 0 0 60px rgba(59, 47, 32, 0.12);
}

/* On mobile, go full width */
@media (max-width: 520px) {
  #quiz-container {
    max-width: 100%;
    box-shadow: none;
  }
}

/* --- Screens --- */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
}

/* The result screen scrolls within its bounds */
#screen-result {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.screen-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* --- Scene Illustrations --- */
.scene-wrapper {
  position: relative;
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

/* Only cap the image height on question screens */
#screen-question .scene-wrapper {
  flex: 0 1 auto;
  max-height: 38vh;
}

.scene-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --- Character Cutout Overlays --- */
.character-overlay {
  position: absolute;
  pointer-events: none;
  transition: transform 0.3s ease;
  filter: drop-shadow(2px 3px 4px rgba(59, 47, 32, 0.25));
  z-index: 2;
}

.character-overlay img {
  width: 100%;
  height: auto;
  display: block;
}

/* Gentle bobbing animation */
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.character-overlay:nth-child(2) { animation: bob 3s ease-in-out infinite; }
.character-overlay:nth-child(3) { animation: bob 3.4s ease-in-out 0.5s infinite; }
.character-overlay:nth-child(4) { animation: bob 2.8s ease-in-out 1s infinite; }
.character-overlay:nth-child(5) { animation: bob 3.2s ease-in-out 1.5s infinite; }

/* --- Text Blocks --- */
.text-block {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex-shrink: 0;
}

/* --- Question Top Block (narrative above image) --- */
.question-top-block {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 24px 12px;
}

.question-top-block .narrative {
  margin-bottom: 0;
  font-size: 1.05rem;
  font-style: normal;
  font-family: 'DM Sans', sans-serif;
  line-height: 1.55;
}

.question-text-block {
  padding-top: 10px;
  padding-bottom: 16px;
}

/* --- Typography --- */
h1, h2 {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  line-height: 1.2;
}

h1 {
  font-size: 1.75rem;
  margin-bottom: 12px;
  color: #3B2F20;
}

h2 {
  font-size: 1.35rem;
  margin-bottom: 8px;
  color: #3B2F20;
}

.narrative {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #5A4A38;
  margin-bottom: 12px;
  max-width: 380px;
}

/* --- Buttons --- */
.btn {
  border: none;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #5A4A38;
  color: #FDF6E3;
  padding: 14px 40px;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 14px rgba(59, 47, 32, 0.2);
}

.btn-primary:hover {
  background: #4A3C2C;
  box-shadow: 0 6px 20px rgba(59, 47, 32, 0.3);
}

.btn-secondary {
  background: transparent;
  color: #8B7355;
  padding: 12px 32px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 500;
  border: 2px solid #D4C4A8;
}

.btn-secondary:hover {
  border-color: #8B7355;
  color: #5A4A38;
}

/* --- Choice Buttons --- */
.choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 400px;
}

.btn-choice {
  background: #FFFDF5;
  border: 2px solid #E8DCC8;
  border-radius: 14px;
  padding: 12px 16px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 2px 8px rgba(59, 47, 32, 0.06);
}

.btn-choice:hover {
  border-color: #C4A97D;
  background: #FFF9EB;
  box-shadow: 0 4px 16px rgba(59, 47, 32, 0.1);
  transform: translateY(-1px);
}

.choice-label {
  font-weight: 700;
  font-size: 1rem;
  color: #3B2F20;
}

.choice-desc {
  font-size: 0.85rem;
  color: #8B7355;
  line-height: 1.4;
}

/* --- Intro Specifics --- */
.intro-top-block {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 20px 10px;
}

.intro-top-block h1 {
  font-size: 1.75rem;
}

.intro-top-block .narrative {
  margin-bottom: 0;
}

.intro-bottom-block {
  padding: 12px 20px 24px;
}

/* --- Result Screen --- */
#screen-result .screen-inner {
  height: auto;
  min-height: 100%;
}

.result-character-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  background: #FDF6E3;
  padding: 24px 0 0;
}

.result-character-img {
  width: 200px;
  height: 200px;
  object-fit: contain;
  filter: drop-shadow(4px 6px 10px rgba(59, 47, 32, 0.2));
}

.result-text-block {
  padding-top: 16px;
}

.result-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: #A08B6E;
  margin-bottom: 4px;
}

.result-name {
  font-size: 2rem;
  margin-bottom: 4px;
}

.result-chinese {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 1rem;
  color: #8B7355;
  margin-bottom: 8px;
}

.result-archetype {
  display: inline-block;
  background: #5A4A38;
  color: #FDF6E3;
  padding: 4px 16px;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.result-tagline {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 1.15rem;
  color: #5A4A38;
  margin-bottom: 12px;
}

.result-profile {
  font-size: 0.95rem;
  line-height: 1.65;
  color: #5A4A38;
  max-width: 380px;
  margin-bottom: 24px;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  padding-bottom: 20px;
}

/* --- Share Link Display --- */
.share-link-container {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 380px;
  margin-top: 8px;
}

.share-link-container.visible {
  display: flex;
}

.share-link-row {
  display: flex;
  width: 100%;
  border: 2px solid #E8DCC8;
  border-radius: 12px;
  overflow: hidden;
  background: #FFFDF5;
}

.share-link-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  color: #5A4A38;
  outline: none;
  min-width: 0;
}

.btn-copy {
  border: none;
  background: #5A4A38;
  color: #FDF6E3;
  padding: 10px 18px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease;
  white-space: nowrap;
}

.btn-copy:hover {
  background: #4A3C2C;
}

.btn-copy.copied {
  background: #6B8F5E;
}

/* --- Screen Transition: Slide Up variant --- */
.screen.slide-in {
  opacity: 1;
  animation: slideUp 0.4s ease forwards;
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* --- Responsive Fine-tuning --- */
@media (max-width: 380px) {
  .text-block {
    padding: 12px 14px 16px;
  }

  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.05rem; }
  .narrative { font-size: 0.85rem; margin-bottom: 8px; }
  .intro-top-block h1 { font-size: 1.5rem; }
  .question-top-block .narrative { font-size: 0.9rem; }
  .result-name { font-size: 1.5rem; }
  .result-character-img { width: 150px; height: 150px; }
  .choice-desc { font-size: 0.8rem; }
}

@media (min-height: 800px) {
  .result-character-img {
    width: 240px;
    height: 240px;
  }
}

/* --- Desktop: center vertically too --- */
@media (min-width: 521px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #quiz-container {
    height: min(100vh, 850px);
    border-radius: 24px;
  }
}

/* Inside an iframe, fill the whole space */
body.in-iframe #quiz-container {
  max-width: 100%;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
}
