/* ============================================
   ai-puzzel.html — Page specific styles
   ============================================ */

body { min-height: 100vh; }

.header { text-align: center; padding: 3rem 1.5rem 2rem; position: relative; }
.header__back { position: absolute; top: 1.5rem; left: 1.5rem; font-size: 0.875rem; color: var(--color-muted); display: flex; align-items: center; gap: 0.4rem; text-decoration: none; transition: color 0.2s; }
.header__back:hover { color: var(--color-white); }
.header__eyebrow { font-family: var(--font-display); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--color-teal); margin-bottom: 0.75rem; }
.header__title { font-family: var(--font-display); font-size: clamp(1.8rem, 5vw, 3rem); font-weight: 700; line-height: 1.1; margin-bottom: 0.75rem; }
.header__title span { background: linear-gradient(135deg, var(--color-yellow), var(--color-purple)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.header__sub { font-size: 1rem; color: var(--color-muted); max-width: 480px; margin: 0 auto 2rem; line-height: 1.6; }

/* PROGRESS */
.progress-wrap { max-width: 600px; margin: 0 auto 0.5rem; padding: 0 1.5rem; }
.progress-label { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--color-muted); margin-bottom: 0.5rem; }
.progress-bar { height: 8px; background: var(--color-bg-card); border-radius: var(--radius-full); overflow: hidden; border: 1px solid var(--color-border); }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--color-accent), var(--color-purple)); border-radius: var(--radius-full); transition: width 0.5s ease; width: 0%; }

/* BOARD */
.board {
  max-width: 900px; margin: 2rem auto; padding: 0 1.5rem;
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 0;           /* pieces interlock — SVG tabs fill sockets */
  overflow: visible;
}

/* PUZZLE PIECES — background drawn by inline SVG (.piece__bg), CSS fallback below */
.piece {
  background: #111D35;
  border: 1.5px solid var(--color-border);
  border-radius: 0;
  padding: 1.75rem 1.5rem 1.75rem 1.5rem;
  cursor: pointer;
  transition: transform 0.25s, filter 0.25s;
  position: relative;
  overflow: visible;
  user-select: none;
  z-index: 0;
}
.piece:hover:not(.piece--done):not(.piece--locked) {
  transform: translateY(-5px);
  filter: brightness(1.12) drop-shadow(0 8px 20px rgba(0,0,0,0.4));
  z-index: 2;
}
.piece--done {
  filter: drop-shadow(0 0 14px var(--piece-glow));
  cursor: pointer;
  z-index: 1;
}
/* Done: dim the front, keep its height so the grid stays stable */
.piece--done .piece__front {
  opacity: 0.45;
  pointer-events: none;
}
/* Checkmark badge */
.piece--done::after {
  content: '✓';
  position: absolute; top: 8px; right: 10px;
  width: 20px; height: 20px;
  background: var(--piece-color);
  border-radius: 50%;
  font-size: 11px; font-weight: 700; color: #000;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
/* Back hidden by default */
.piece--done .piece__back { display: none; }

/* Open overlay: floats on top of adjacent pieces */
.piece--open { z-index: 30 !important; }
.piece--done.piece--open .piece__back {
  display: flex;
  position: absolute;
  top: 0; left: -10px; right: -10px;
  z-index: 1;
  background: #0d1929;
  border: 1.5px solid var(--piece-color);
  border-radius: 16px;
  padding: 1.25rem 1rem 1rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.75), 0 0 0 1px rgba(255,255,255,0.04);
  animation: flipIn 0.25s ease both;
}

/* Close button inside overlay */
.piece__close {
  position: absolute; top: 8px; right: 8px;
  width: 24px; height: 24px;
  background: rgba(255,255,255,0.1);
  border: none; border-radius: 50%;
  color: #fff; font-size: 15px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.piece__close:hover { background: rgba(255,255,255,0.2); }
.piece--locked { opacity: 0.45; cursor: not-allowed; }
.piece--locked:hover { transform: none; filter: none; }

/* SVG background element (injected by JS) — z-index:-1 keeps it behind text content */
.piece__bg {
  position: absolute; top: 0; left: 0;
  overflow: visible; pointer-events: none; z-index: -1;
}
/* Stripe drawn inside SVG, so remove old ::before */
.piece__stripe { display: none; }
.piece__front { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 1rem; }
.piece__back  { position: relative; z-index: 1; display: none; flex-direction: column; gap: 1rem; animation: flipIn 0.4s ease both; }
@keyframes flipIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
.piece__icon { width: 52px; height: 52px; display: flex; align-items: center; }
.piece__number { font-family: var(--font-display); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--piece-color); }
.piece__question { font-size: 1.05rem; font-weight: 800; line-height: 1.3; color: var(--color-white); }
.piece__hint { font-size: 0.8rem; color: var(--color-muted); display: flex; align-items: center; gap: 0.4rem; }
.piece__tap { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; font-weight: 700; color: var(--piece-color); margin-top: 0.5rem; animation: bounce 1.5s infinite; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.piece__label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--piece-color); }
.piece__title { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; color: var(--color-white); line-height: 1.2; }
.piece__explain { font-size: 0.9rem; color: var(--color-muted); line-height: 1.7; }
.piece__example { background: rgba(255,255,255,0.04); border: 1px solid var(--color-border); border-left: 3px solid var(--piece-color); border-radius: 0 10px 10px 0; padding: 0.75rem 1rem; font-size: 0.85rem; color: var(--color-white); line-height: 1.6; }
.piece__example strong { color: var(--piece-color); }
.piece__tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.25rem; }

/* ROBOT INTRO — robot + tekst in de lege ruimte onder de header */
.robot-intro {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  max-width: 900px; margin: 0 auto 1.5rem;
  padding: 1rem 1.5rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 18px;
}
.robot-intro__img {
  width: 80px; height: 80px; flex-shrink: 0;
  object-fit: contain;
  animation: robotBob 3s ease-in-out infinite;
  filter: drop-shadow(0 4px 16px rgba(16,185,129,0.35));
}
@keyframes robotBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.robot-intro__text {
  flex: 1;
}
.robot-intro__typed {
  display: inline;
  font-size: 0.9rem; color: var(--color-muted); line-height: 1.7;
}

/* Ballon verschijnt als alle stukjes klaar zijn */
.robot-intro__bubble { display: none; flex: 1; }
.robot-intro__bubble.show { display: block; animation: fadeUp 0.4s ease both; }

.robot-bubble {
  background: rgba(17, 29, 53, 0.95);
  border: 1.5px solid rgba(16,185,129,0.4);
  border-radius: 20px;
  padding: 1.5rem 2rem;
  position: relative;
  margin-bottom: 2rem;
  box-shadow: 0 0 60px rgba(16,185,129,0.15);
  text-align: left;
}
.robot-bubble::before {
  content: '';
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  border: 10px solid transparent;
  border-bottom-color: rgba(16,185,129,0.4);
}
.robot-bubble::after {
  content: '';
  position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  border: 9px solid transparent;
  border-bottom-color: rgba(17, 29, 53, 0.95);
}
.robot-bubble__label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #10B981; margin-bottom: 0.75rem; }
.robot-bubble__text { font-size: 1rem; line-height: 1.8; color: var(--color-white); min-height: 3em; }
.robot-bubble__cursor { display: inline-block; width: 2px; height: 1.1em; background: #10B981; vertical-align: text-bottom; margin-left: 2px; animation: blink 0.7s step-end infinite; }
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0; } }

/* FLOATERS */
.floaters { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.floater { position: absolute; opacity: 0.07; animation: float linear infinite; }
@keyframes float { from { transform: translateY(110vh) rotate(0deg); } to { transform: translateY(-20vh) rotate(360deg); } }

main { position: relative; z-index: 1; }

/* ── MOBILE CARD QUIZ ── */
.mobile-quiz { display: none; }

@media (max-width: 640px) {
  /* Verberg desktop puzzelbord, toon card quiz */
  .board        { display: none !important; }
  .mobile-quiz  { display: block; padding: 0 1rem 2rem; }

  /* Header compact */
  .header { padding: 1.25rem 1rem 0.5rem; }
  .header__title { font-size: clamp(1.4rem, 7vw, 2rem); }
  .header__sub { font-size: 0.85rem; }
  .progress-wrap { padding: 0 1rem; margin-bottom: 0.75rem; }

  /* Robot intro compact */
  .robot-intro { gap: 0.75rem; padding: 0.875rem 1rem; margin: 0.5rem 0 0.75rem; }
  .robot-intro__img { width: 52px; height: 52px; }
  .robot-intro__typed { font-size: 0.82rem; }
  .robot-bubble { padding: 1rem 1.25rem; }
  .robot-bubble__text { font-size: 0.875rem; }

  /* ── Quiz header ── */
  .mq-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 0.875rem;
  }
  .mq-step { font-size: 0.78rem; font-weight: 700; color: var(--color-muted); letter-spacing: 0.05em; text-transform: uppercase; }
  .mq-dots { display: flex; gap: 5px; align-items: center; }
  .mq-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,0.12); transition: all 0.3s; }
  .mq-dot--active { width: 18px; border-radius: 4px; background: var(--color-white); }
  .mq-dot--done { background: #10B981; }

  /* ── Flip scene — geen preserve-3d (werkt niet op iOS Safari) ── */
  .mq-scene { height: auto; min-height: 340px; margin-bottom: 0; }
  .mq-card  { width: 100%; position: relative; }

  .mq-front, .mq-back {
    border-radius: 20px;
    padding: 1.4rem 1.25rem 1.25rem;
    display: flex; flex-direction: column; gap: 0.6rem;
    background: #111D35;
    border: 1.5px solid rgba(255,255,255,0.08);
  }
  /* Gekleurde bovenrand */
  .mq-front::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
    background: var(--piece-color); border-radius: 20px 20px 0 0;
  }
  /* Back verborgen totdat kaart geflippt is */
  .mq-back { display: none; border-color: var(--piece-color); }
  .mq-card.flipped .mq-front { display: none; }
  .mq-card.flipped .mq-back  {
    display: flex;
    animation: mqFlipIn 0.35s ease both;
  }
  @keyframes mqFlipIn {
    from { opacity: 0; transform: rotateY(-12deg) scale(0.97); }
    to   { opacity: 1; transform: rotateY(0)  scale(1); }
  }

  /* Front content */
  .mq-icon { width: 40px; height: 40px; }
  .mq-num  { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--piece-color); }
  .mq-q    { font-size: 1.15rem; font-weight: 800; line-height: 1.3; color: #fff; flex: 1; }
  .mq-hint { font-size: 0.8rem; color: var(--color-muted); }
  .mq-lock { font-size: 0.8rem; color: var(--color-muted); background: rgba(255,255,255,0.05); border-radius: 10px; padding: 0.75rem; }

  .mq-flip-btn {
    margin-top: auto;
    background: var(--piece-color); color: #000;
    font-weight: 800; font-size: 0.95rem;
    border: none; border-radius: 12px;
    padding: 0.9rem 1rem; width: 100%;
    cursor: pointer; transition: opacity 0.15s;
  }
  .mq-flip-btn:active { opacity: 0.75; }

  /* Back content */
  .mq-back-meta  { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--piece-color); }
  .mq-back-title { font-size: 1.05rem; font-weight: 800; color: #fff; }
  .mq-back-text  { font-size: 0.83rem; color: var(--color-muted); line-height: 1.65; }
  .mq-back-example {
    background: rgba(255,255,255,0.04);
    border-left: 3px solid var(--piece-color);
    border-radius: 0 8px 8px 0;
    padding: 0.6rem 0.75rem;
    font-size: 0.78rem; color: #fff; line-height: 1.6;
  }
  .mq-back-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; }

  .mq-next-btn {
    margin-top: auto;
    background: transparent; color: var(--piece-color);
    font-weight: 700; font-size: 0.9rem;
    border: 1.5px solid var(--piece-color); border-radius: 12px;
    padding: 0.8rem 1rem; width: 100%;
    cursor: pointer; transition: background 0.15s;
  }
  .mq-next-btn:active { background: rgba(255,255,255,0.07); }
}
