/* Guess the Celebrity — page-specific styles.
   Layout + Dify embed overrides. The page background comes from styles.css. */

:root {
  /* Tune these to taste: lower = more see-through */
  --chat-opacity: 0.82;
  /* The panel sits *behind* the faded iframe and acts as a scrim: without it
     the background image shows through the chat text and kills legibility. */
  --panel-alpha: 0.42;
}

/* --- Dify embed overrides --- */

#dify-chatbot-bubble-button {
  background-color: #1C64F2 !important;
}

#dify-chatbot-bubble-window {
  position: fixed !important;
  width: 24rem !important;
  height: 40rem !important;
  opacity: var(--chat-opacity);
}

/* Keep the floating chat window inside small screens */
@media (max-width: 480px) {
  #dify-chatbot-bubble-window {
    width: calc(100vw - 1rem) !important;
    height: calc(100dvh - 6rem) !important;
    max-height: 40rem !important;
    left: 0.5rem !important;
    right: 0.5rem !important;
  }
}

/* --- Page layout: fill the viewport on desktop, adapt on mobile --- */

html {
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100dvh;
  font-family: sans-serif;
  text-align: center;
  overflow: hidden;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

#gameContainer {
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: min(100%, 1400px);
  margin: 0 auto;
  height: 100%;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
  padding: clamp(0.4rem, 1.5vw, 1.25rem);
  border-radius: 0;
  /* Glassy panel so the page background reads through */
  background-color: rgba(255, 255, 255, var(--panel-alpha));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Small logo positioned on the top left of the game box */
#celebTitle {
  position: absolute;
  top: clamp(0.4rem, 1.5vw, 1rem);
  left: clamp(0.45rem, 1.5vw, 1.25rem);
  width: 46px;
  height: 46px;
  object-fit: cover;
  border-radius: 10px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.9);
  z-index: 10;
}

.game-header {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

#gameContainer h1 {
  margin: 0.15rem 0 0.35rem;
  padding: 0 48px;
  font-size: clamp(1.15rem, 3.5vw, 2.2rem);
  color: #1a1a1a;
  text-shadow: 0 1px 3px rgba(255, 255, 255, 0.85);
  line-height: 1.2;
}

/* Instructions details accordion */
.game-intro {
  flex: 0 0 auto;
  width: 100%;
  max-width: 680px;
  margin: 0 auto 0.4rem;
  font-size: 0.85rem;
  color: #1a1a1a;
  text-align: center;
}

.game-intro summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin: 0 auto;
  padding: 0.2rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #581c87;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(168, 85, 247, 0.4);
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  user-select: none;
  transition: background 0.2s, transform 0.15s;
}

.game-intro summary::-webkit-details-marker {
  display: none;
}

.game-intro summary:hover {
  background: #fff;
  border-color: #d946ef;
}

.game-intro[open] summary .intro-arrow {
  transform: rotate(180deg);
}

.game-intro .intro-arrow {
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 0.75rem;
}

.game-intro .intro-content {
  margin-top: 0.4rem;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(168, 85, 247, 0.25);
  font-size: 0.85rem;
  line-height: 1.4;
  color: #2e1065;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  max-height: 140px;
  overflow-y: auto;
}

.game-intro .intro-content div:not(:last-child) {
  margin-bottom: 0.35rem;
}

#gameContainer iframe {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  border: 0;
  border-radius: 20px;
  display: block;
  opacity: var(--chat-opacity);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

/* ============================================================
   Custom in-page chat (replaces the Dify iframe)
   ============================================================ */

#celebChat {
  flex: 1 1 0;
  min-height: 0;
  height: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-align: left;
  border-radius: 20px;
  background: rgba(255, 251, 240, var(--chat-opacity));
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#celebChat .celeb-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.9rem;
  color: #fff;
  background: linear-gradient(135deg, #8b5cf6 0%, #d946ef 55%, #ec4899 100%);
}

#celebChat .celeb-header img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: #fff;
}

#celebChat .celeb-header .celeb-name {
  font-weight: 700;
  font-size: 1.05rem;
}

#celebChat .celeb-header .celeb-tag {
  font-size: 0.8rem;
  opacity: 0.9;
}

#celebChat .celeb-reset {
  margin-left: auto;
  padding: 0.3rem 0.7rem;
  font: inherit;
  font-size: 0.78rem;
  color: #fff;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.16);
  white-space: nowrap;
}

#celebChat .celeb-reset:hover {
  background: rgba(255, 255, 255, 0.3);
}

#celebChat .celeb-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0.9rem;
  background: rgba(250, 232, 255, 0.55);
  -webkit-overflow-scrolling: touch;
}

#celebChat .celeb-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

#celebChat .celeb-row.user {
  flex-direction: row-reverse;
}

#celebChat .celeb-row img.celeb-avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fbcfe8;
  background: #fff;
}

#celebChat .celeb-bubble {
  max-width: min(78%, 60ch);
  padding: 0.55rem 0.8rem;
  border-radius: 14px;
  line-height: 1.45;
  font-size: 0.98rem;
  overflow-wrap: anywhere;
  color: #3b0764;
  background: #fff;
  border: 1px solid #f0abfc;
}

#celebChat .celeb-row.user .celeb-bubble {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #ec4899 0%, #a855f7 100%);
}

#celebChat .celeb-bubble strong {
  font-weight: 700;
}

#celebChat .celeb-quick {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0 0.9rem 0.6rem;
}

#celebChat .celeb-quick button {
  padding: 0.35rem 0.85rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  color: #7e22ce;
  background: #fff;
  border: 1px solid #d8b4fe;
  border-radius: 999px;
}

#celebChat .celeb-quick button:hover {
  background: #f5f3ff;
}

#celebChat .celeb-input {
  flex: 0 0 auto;
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem 0.8rem;
  border-top: 1px solid rgba(168, 85, 247, 0.25);
  background: rgba(255, 255, 255, 0.7);
}

#celebChat .celeb-input input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.6rem 0.85rem;
  font: inherit;
  border-radius: 999px;
  border: 1px solid #d8b4fe;
  background: #fff;
  color: #3b0764;
}

#celebChat .celeb-input input:focus {
  outline: none;
  border-color: #d946ef;
  box-shadow: 0 0 0 3px rgba(217, 70, 239, 0.2);
}

#celebChat .celeb-input button {
  padding: 0.6rem 1.15rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #ec4899 0%, #a855f7 100%);
  white-space: nowrap;
}

#celebChat .celeb-input button:disabled,
#celebChat .celeb-input input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Typing dots — also shown while a <thinking> block is streaming in */
#celebChat .celeb-typing {
  display: inline-flex;
  gap: 4px;
  padding: 2px 0;
}

#celebChat .celeb-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d946ef;
  animation: celebBlink 1.2s infinite ease-in-out;
}

#celebChat .celeb-typing span:nth-child(2) { animation-delay: 0.2s; }
#celebChat .celeb-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes celebBlink {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  #celebChat .celeb-typing span { animation: none; }
}

/* --- Mobile view adjustments (max-width: 767px) --- */
@media (max-width: 767px) {
  body {
    padding: 0 !important;
    background-attachment: scroll;
  }

  #gameContainer {
    padding: 0.35rem 0.45rem 0.45rem;
    border-radius: 0;
    width: 100%;
    /* Leave room at the bottom so the floating site-wide chatbot button (bottom: 20px, 56px height) does not cover the send button */
    height: calc(100dvh - 84px);
    max-height: calc(100dvh - 84px);
    margin-bottom: 84px;
  }

  #celebTitle {
    top: 0.35rem;
    left: 0.45rem;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border-width: 1.5px;
  }

  #gameContainer h1 {
    font-size: 1.15rem;
    padding: 0 36px;
    margin: 0.1rem 0 0.25rem;
  }

  #celebChat {
    border-radius: 14px;
  }

  #celebChat .celeb-header {
    padding: 0.4rem 0.65rem;
    gap: 0.5rem;
  }

  #celebChat .celeb-header img {
    width: 38px;
    height: 38px;
  }

  #celebChat .celeb-header .celeb-name {
    font-size: 0.95rem;
  }

  #celebChat .celeb-header .celeb-tag {
    font-size: 0.72rem;
  }

  #celebChat .celeb-reset {
    padding: 0.25rem 0.6rem;
    font-size: 0.72rem;
  }

  #celebChat .celeb-messages {
    padding: 0.55rem;
  }

  #celebChat .celeb-row {
    margin-bottom: 0.5rem;
    gap: 0.4rem;
  }

  #celebChat .celeb-row img.celeb-avatar {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
  }

  #celebChat .celeb-bubble {
    font-size: 0.88rem;
    padding: 0.45rem 0.65rem;
    max-width: 86%;
    border-radius: 12px;
  }

  #celebChat .celeb-quick {
    padding: 0.2rem 0.55rem 0.35rem;
    gap: 0.35rem;
  }

  #celebChat .celeb-quick button {
    padding: 0.25rem 0.6rem;
    font-size: 0.78rem;
    flex: 1 1 auto;
    text-align: center;
  }

  #celebChat .celeb-input {
    padding: 0.4rem 0.55rem 0.5rem;
    gap: 0.4rem;
  }

  #celebChat .celeb-input input {
    padding: 0.45rem 0.75rem;
    font-size: 16px; /* 16px prevents iOS Safari from zooming the viewport */
  }

  #celebChat .celeb-input button {
    padding: 0.45rem 0.95rem;
    font-size: 0.88rem;
  }
}

/* --- Short screen / Landscape view (max-height: 550px) --- */
@media (max-height: 550px) {
  #gameContainer {
    height: calc(100dvh - 76px);
    max-height: calc(100dvh - 76px);
    margin-bottom: 76px;
  }

  #celebTitle {
    top: 0.25rem;
    left: 0.35rem;
    width: 26px;
    height: 26px;
    border-radius: 6px;
  }

  #gameContainer h1 {
    font-size: 0.95rem;
    padding: 0 30px;
    margin: 0.05rem 0 0.15rem;
  }

  .game-intro {
    margin-bottom: 0.2rem;
  }

  .game-intro summary {
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
  }

  #celebChat .celeb-header {
    padding: 0.3rem 0.5rem;
  }

  #celebChat .celeb-header img {
    width: 30px;
    height: 30px;
  }
}

/* --- Desktop: give Jess more screen presence (min-width: 768px) --- */
@media (min-width: 768px) {
  body {
    padding: 12px;
    align-items: center;
    justify-content: center;
  }

  #gameContainer {
    border-radius: 28px;
    height: calc(100dvh - 24px);
    max-height: 940px;
    padding: 1rem 1.5rem 1.25rem;
  }

  #celebTitle {
    top: 1rem;
    left: 1.5rem;
    width: 52px;
    height: 52px;
    border-radius: 12px;
  }

  #gameContainer h1 {
    padding: 0 60px;
  }

  .game-intro summary {
    font-size: 0.85rem;
    padding: 0.25rem 0.85rem;
  }

  .game-intro .intro-content {
    font-size: 0.9rem;
  }

  #celebChat .celeb-header {
    padding: 0.7rem 1.1rem;
    gap: 0.85rem;
  }

  #celebChat .celeb-header img {
    width: 88px;
    height: 88px;
    border-width: 3px;
  }

  #celebChat .celeb-header .celeb-name {
    font-size: 1.35rem;
  }

  #celebChat .celeb-header .celeb-tag {
    font-size: 0.9rem;
  }

  /* flex-basis has to track the width or the row lets it squash */
  #celebChat .celeb-row img.celeb-avatar {
    width: 52px;
    height: 52px;
    flex-basis: 52px;
  }

  #celebChat .celeb-row.bot img.celeb-avatar {
    width: 68px;
    height: 68px;
    flex-basis: 68px;
    border-color: #f0abfc;
  }
}

@media (min-width: 1200px) {
  #celebChat .celeb-header img {
    width: 104px;
    height: 104px;
  }

  #celebChat .celeb-row.bot img.celeb-avatar {
    width: 80px;
    height: 80px;
    flex-basis: 80px;
  }
}
