/* ============================================================
   UI Components — Figma-accurate redesign
   Font: Söhne (falls back to DM Sans / system-ui)
   Palette: light/pink theme matching Figma component specs
   ============================================================ */

@font-face {
  font-family: 'Söhne';
  font-weight: 300;
  font-style: normal;
  font-display: swap;
  src: url('../assets/fonts/soehne-web-leicht.woff2') format('woff2'),
       url('../assets/fonts/soehne-web-leicht.woff') format('woff');
}

@font-face {
  font-family: 'Söhne';
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url('../assets/fonts/soehne-web-buch.woff2') format('woff2'),
       url('../assets/fonts/soehne-web-buch.woff') format('woff');
}

@font-face {
  font-family: 'Söhne';
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  src: url('../assets/fonts/soehne-web-kraftig.woff2') format('woff2'),
       url('../assets/fonts/soehne-web-kraftig.woff') format('woff');
}

@font-face {
  font-family: 'Söhne';
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url('../assets/fonts/soehne-web-dreiviertelfett.woff2') format('woff2'),
       url('../assets/fonts/soehne-web-dreiviertelfett.woff') format('woff');
}

/* ── CSS custom properties ─────────────────────────────────── */
:root {
  --font-ui: 'Söhne', 'DM Sans', -apple-system, BlinkMacSystemFont,
             'Helvetica Neue', Arial, sans-serif;
  --color-ink:       #252525;
  --color-ink-faint: rgba(37, 37, 37, 0.8);
  --color-hud-open:  #FFD6FF;
  --color-hud-active: rgba(255, 255, 255, 0.1);
  --color-hud-idle:   rgba(255, 214, 255, 0.1);
  --color-border:    #FFFFFF;
  --color-pink-btn:  #FF98FF;
  --color-accent:    #FFCB5C;
}

/* ── Utility ───────────────────────────────────────────────── */
.hidden {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ── Logo ──────────────────────────────────────────────────── */
.logo {
  display: block;
  user-select: none;
  flex-shrink: 0;
}
.logo img {
  display: block;
  width: 100%;
  height: 100%;
}
.logo--large  { width: 80px; height: 60px; }
.logo--medium { width: 53px; height: 40px; }
.logo--small  { width: 27px; height: 20px; }

/* ── Button base ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  outline: none;
  cursor: pointer;
  pointer-events: auto;
  white-space: nowrap;
  transition: background 0.18s, color 0.18s, transform 0.14s, box-shadow 0.18s;
}
.btn:active { transform: scale(0.96); }

/* ── Button opaque — Figma spec ────────────────────────────────
   Idle:    #FFFFFF bg, #252525 text, pill 50px, no border
   Hover:   white bg, #FF98FF border + text, pink glow
   Clicked: #FF98FF bg, white text, pink glow
   Font:    Söhne 300 20px, padding 10px 30px, height 45px
─────────────────────────────────────────────────────────────── */
.btn--opaque {
  background: #FFFFFF;
  color: var(--color-ink);
  border: 1px solid transparent;
  border-radius: 50px;
  padding: 10px 30px;
  height: 45px;
  font-family: var(--font-ui);
  font-weight: 300;
  font-size: 20px;
}
.btn--opaque:hover {
  background: #FFFFFF;
  color: var(--color-pink-btn);
  border-color: var(--color-pink-btn);
  box-shadow: 0px 4px 16px rgba(255, 152, 255, 0.3);
}
.btn--opaque:active {
  background: var(--color-pink-btn);
  color: #FFFFFF;
  border-color: var(--color-pink-btn);
  box-shadow: 0px 4px 16px rgba(255, 152, 255, 0.3);
  transform: scale(0.97);
}

/* ── Button translucent — Figma spec ───────────────────────────
   Height 80px, padding 10px 10px 10px 30px, pill radius 50px
   Row layout: "Play to reveal" text + 60×60 arrow icon, gap 30px
   Idle:    rgba(255,255,255,0.1) bg, white 0.5px border, blur(5px)
   Hover:   rgba(255,152,255,0.1) bg, #FF98FF border, pink glow
   Clicked: #FF98FF bg (solid)
─────────────────────────────────────────────────────────────── */
.btn--translucent {
  height: 80px;
  padding: 10px 10px 10px 30px;
  background: rgba(255, 255, 255, 0.1);
  border: 0.5px solid #FFFFFF;
  border-radius: 50px;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 30px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.btn--translucent:hover {
  background: rgba(255, 152, 255, 0.1);
  border-color: #FF98FF;
  box-shadow: 0px 8px 32px rgba(255, 152, 255, 0.3);
}
.btn--translucent:active {
  background: #FF98FF;
  border-color: #FF98FF;
  transform: scale(0.98);
}
.btn__text {
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 24px;
  color: #FFFFFF;
  white-space: nowrap;
}
.btn__icon {
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  display: block;
}

/* ── ProgressBar ───────────────────────────────────────────────
   Figma: row, space-between, counter left, bar right.
   Counter: Söhne 500 20px #252525.
   Bar: 180×40 container, track at 8px height.
─────────────────────────────────────────────────────────────── */
.progress-row {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.progress-counter {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 20px;
  line-height: 1.5;
  color: var(--color-ink);
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: -0.01em;
}
.progress-sep {
  opacity: 0.55;
}

.progress-bar-wrap {
  flex: 1;
  margin-left: 16px;
  height: 40px;
  display: flex;
  align-items: center;
}

.progress-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(37, 37, 37, 0.12);
  border-radius: 4px;
  position: relative;
  overflow: visible;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #FFCB5C 0%, #FF98FF 100%);
  border-radius: 4px;
  width: 0%;
  transition: width 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 1;
}

.progress-star {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 0;
  width: 40px;
  height: 40px;
  overflow: visible;
  transition: left 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 3;
  user-select: none;
  pointer-events: none;
}

/* ── MilestoneStatus icons ─────────────────────────────────────
   Figma: 3 × 70×70px IMAGE-SVG nodes, row space-between, flex-end.
   No CSS container — icons use their own Figma SVG backgrounds.
   Locked:          opacity 0.3, locked SVG (has padlock overlay).
   Unlocked:        opacity 1, unlocked SVG (no padlock).
   Newly unlocked:  + purple glow drop-shadow (effect_238CUS).
─────────────────────────────────────────────────────────────── */
.milestone-status {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
}

.milestone-icon {
  width: 70px;
  height: 70px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.3;
  transition: opacity 0.4s ease;
}

.milestone-icon img {
  width: 70px;
  height: 70px;
  display: block;
  flex-shrink: 0;
}

.milestone-icon--unlocked {
  opacity: 1;
  filter: none;
}

/* Purple glow — only the most recently unlocked milestone (no transition so it snaps on/off) */
.milestone-icon--newly-unlocked {
  filter: drop-shadow(0px 4px 16px rgba(192, 115, 215, 0.5));
}

/* ── Milestone colour overlay ──────────────────────────────── */
.milestone-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 152, 255, 0.70);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 1;
}
.milestone-overlay--visible { opacity: 1; }

/* ============================================================
   HUD
   Figma: column, center, gap 20px, padding 20px, width 330px.
   Border-radius 20px, border 0.5px #FFFFFF, blur(10px).
   State backgrounds:
     idle       → rgba(255,214,255,0.1)
     active     → rgba(255,255,255,0.1)
     open       → #FFD6FF (solid)
   Sits at bottom-centre; slides to viewport centre on game-end.
   ============================================================ */
.hud {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: min(330px, 92vw);

  /* Layout */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 20px;

  /* Figma idle background */
  background: var(--color-hud-idle);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 0.5px solid var(--color-border);
  border-radius: 20px;

  /* Transitions for state changes and game-end animation */
  transition:
    background   0.45s ease,
    bottom       0.65s cubic-bezier(0.34, 1.56, 0.64, 1),
    transform    0.65s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity      0.4s  ease;

  z-index: 2;
  overflow: hidden;
}

/* Idle: invisible — first star not yet collected */
.hud--idle {
  opacity: 0;
  pointer-events: none;
}

/* Active collapsed/locked: translucent white */
.hud--active-milestones-locked,
.hud--active-milestone-1-unlocked-collapsed,
.hud--active-milestone-2-unlocked-collapsed {
  opacity: 1;
  background: var(--color-hud-active);
}

/* Open states: solid pink */
.hud--active-milestone-1-unlocked-open,
.hud--active-milestone-2-unlocked-open,
.hud--active-milestone-3-unlocked-open {
  opacity: 1;
  background: var(--color-hud-open);
}

/* Game-end: animate to vertical centre */
.hud--game-end {
  bottom: 50%;
  transform: translate(-50%, 50%);
}

/* ── Story panel ───────────────────────────────────────────── */
/* margin-top: -20px cancels the flex gap while height is 0,
   keeping bottom padding equal to side padding in all collapsed states. */
.hud__story-panel {
  width: 100%;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  margin-top: -20px;
  transition:
    max-height 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    opacity    0.35s ease,
    margin-top 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.hud--active-milestone-1-unlocked-open .hud__story-panel,
.hud--active-milestone-2-unlocked-open .hud__story-panel,
.hud--active-milestone-3-unlocked-open .hud__story-panel {
  max-height: 360px;
  opacity: 1;
  margin-top: 0;
}

/* Story text — Figma: Söhne Kräftig 500 22px, lineHeight 28px, paragraphSpacing 8px.
   Each Figma paragraph is a separate <p> so margin-bottom gives exact paragraph spacing. */
.hud__story-text {
  width: 100%;
  margin: 0 0 14px;
}

.hud__story-text p {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 16px;
  line-height: 22px;   /* Figma 28px − 20% */
  color: var(--color-ink);
  margin: 0 0 8px;     /* Figma paragraphSpacing: 8px */
}

.hud__story-text p:last-child {
  margin-bottom: 0;
}

/* Dismiss hint — Figma: Söhne Buch 400 14px, lineHeight 18px, rgba(37,37,37,0.8), centered */
.hud__dismiss {
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 14px;
  line-height: 18px;
  color: var(--color-ink-faint);
  text-align: center;
  margin-bottom: 8px;
  width: 100%;
}

/* CTA button full-width */
.hud__cta-btn {
  width: 100%;
  margin-top: 4px;
}

/* WOW graphic — replaces ProgressBar in M3-open state */
.hud__wow {
  width: 100%;
  height: auto;
  display: block;
  flex-shrink: 0;
}

/* ============================================================
   SCREENS — full-viewport overlays
   ============================================================ */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  z-index: 10;
  opacity: 1;
  transition: opacity 0.4s ease;
}

/* ── Welcome screen ────────────────────────────────────────────
   Figma: full-screen background image, column space-between,
   40px padding (desktop), 40px 30px (mobile).
   Top: Logo (80×60). Bottom: button + tagline, 60px gap.
   Desktop: landscape BG. Mobile (≤768px): portrait BG.
─────────────────────────────────────────────────────────────── */
.welcome-screen {
  background-image: url('../assets/welcome/bg-desktop.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  justify-content: space-between;
  padding: 40px;
}

.welcome-screen__bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 60px;
}

.welcome-screen__tagline {
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 14px;
  line-height: 18px;
  color: #FFFFFF;
  text-align: center;
  text-transform: capitalize;
  margin: 0;
}

/* ── Start overlay — Figma: Start-screen-overlay component ────
   Full-screen transparent wrapper (no bg) centres the card.
   Card: 350px wide, rgba(255,214,255,0.1) bg, white 0.5px border,
   20px radius, blur(10px), box-shadow warm brown, 40px padding,
   36px column gap. Animates in with scale + fade.
─────────────────────────────────────────────────────────────── */
.start-overlay-wrapper {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 11;
}

.start-overlay-card {
  width: 350px;
  max-width: calc(100vw - 40px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 36px;
  padding: 40px;

  background: rgba(255, 214, 255, 0.1);
  border: 0.5px solid #FFFFFF;
  border-radius: 20px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0px 4px 30px 0px rgba(116, 67, 59, 0.2);
  overflow: hidden;

  /* Hidden state */
  opacity: 0;
  transform: scale(0.96) translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.start-overlay-wrapper--visible {
  pointer-events: auto;
}

.start-overlay-wrapper--visible .start-overlay-card {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.start-overlay__avatar {
  width: 100%;
  height: 270px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  display: block;
}

.start-overlay__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.start-overlay__instruction {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 20px;
  line-height: 30px;
  color: #FFFFFF;
  text-align: center;
  margin: 0;
}

.start-overlay__separator {
  width: 100%;
  border: none;
  border-top: 0.5px solid rgba(255, 255, 255, 0.6);
  margin: 0;
}

.start-overlay__collect-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.start-overlay__star {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: block;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .welcome-screen {
    background-image: url('../assets/welcome/bg-mobile.png');
    padding: 40px 30px;
  }
}

@media (max-width: 480px) {
  .hud {
    padding: 16px;
    gap: 14px;
    /* Move HUD to top on mobile */
    bottom: auto;
    top: 24px;
    transition:
      background  0.45s ease,
      top         0.65s cubic-bezier(0.34, 1.56, 0.64, 1),
      transform   0.65s cubic-bezier(0.34, 1.56, 0.64, 1),
      opacity     0.4s  ease;
  }
  /* Game-end: animate to vertical centre from top */
  .hud--game-end {
    top: 50%;
    transform: translate(-50%, -50%);
  }
  /* Match margin-top to mobile gap so top padding stays equal to side padding */
  .hud__story-panel { margin-top: -14px; }
  .hud--active-milestone-1-unlocked-open .hud__story-panel,
  .hud--active-milestone-2-unlocked-open .hud__story-panel,
  .hud--active-milestone-3-unlocked-open .hud__story-panel { margin-top: 0; }
  .progress-counter { font-size: 16px; }
  .hud__story-text  { font-size: 14px; }
  .milestone-icon     { width: 56px; height: 56px; }
  .milestone-icon img { width: 56px; height: 56px; }
}
