/* ==========================================================
   Agenții IT – mission game styles
   Cartoon "sticker" look: thick dark outlines, hard shadows,
   and one accent color that changes with every mission.
   ========================================================== */

:root {
  --ink: #1b1646;
  --night: #2b1a78;
  --night-deep: #120a3a;
  --paper: #f5f2ff;
  --sun: #ffd23f;
  --accent: #ffd23f;
  --accent-soft: color-mix(in srgb, var(--accent) 30%, white);

  --font-display: "Baloo 2", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --font-body: "Nunito", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, color-mix(in srgb, var(--accent) 38%, transparent), transparent 42%),
    radial-gradient(circle at 90% 85%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 40%),
    linear-gradient(160deg, var(--night) 0%, var(--night-deep) 100%);
  background-attachment: fixed;
}

button {
  font-family: inherit;
}

:focus-visible {
  outline: 4px solid #fff;
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

/* ---------- Floating background emojis ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.backdrop span {
  position: absolute;
  font-size: 3.4rem;
  opacity: 0.16;
  animation: drift 16s ease-in-out infinite alternate;
}

.backdrop span:nth-child(1) { left: 6%;  top: 20%; animation-delay: -2s; }
.backdrop span:nth-child(2) { left: 22%; top: 68%; animation-delay: -6s; }
.backdrop span:nth-child(3) { left: 40%; top: 12%; animation-delay: -9s; }
.backdrop span:nth-child(4) { left: 58%; top: 74%; animation-delay: -4s; }
.backdrop span:nth-child(5) { left: 72%; top: 18%; animation-delay: -11s; }
.backdrop span:nth-child(6) { left: 88%; top: 58%; animation-delay: -7s; }
.backdrop span:nth-child(7) { left: 12%; top: 46%; animation-delay: -13s; }
.backdrop span:nth-child(8) { left: 82%; top: 86%; animation-delay: -1s; }

@keyframes drift {
  from { transform: translate(0, 0) rotate(-8deg); }
  to   { transform: translate(40px, -50px) rotate(10deg); }
}

/* ---------- Top bar ---------- */

.top-bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 1.4rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.6rem;
  color: #fff;
}

.brand-icon {
  font-size: 2rem;
}

.mission-track {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.track-chip {
  width: 2.8rem;
  height: 2.8rem;
  display: grid;
  place-items: center;
  padding: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 3px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}

.track-chip:hover {
  transform: scale(1.12);
}

.track-chip.is-done {
  color: var(--ink);
  background: #fff;
  border-color: #fff;
}

.track-chip.is-active {
  color: var(--ink);
  background: var(--accent);
  border-color: #fff;
  transform: scale(1.3);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 45%, transparent);
}

.icon-button {
  width: 2.8rem;
  height: 2.8rem;
  font-size: 1.4rem;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 3px solid rgba(255, 255, 255, 0.45);
  border-radius: 14px;
  cursor: pointer;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ---------- Stage and slides ---------- */

.stage {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  padding: 0.4rem 1.2rem 1rem;
}

.slide-wrap {
  width: 100%;
  max-width: 1400px;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-origin: center center;
}

.slide-wrap.from-right {
  animation: enter-from-right 0.35s ease-out;
}

.slide-wrap.from-left {
  animation: enter-from-left 0.35s ease-out;
}

@keyframes enter-from-right {
  from { opacity: 0; transform: translateX(60px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes enter-from-left {
  from { opacity: 0; transform: translateX(-60px); }
  to   { opacity: 1; transform: translateX(0); }
}

.mission-banner {
  margin-bottom: 1.3rem;
  padding: 0.25em 1.2em;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.3rem, 2.8vw, 2.2rem);
  text-align: center;
  background: var(--accent);
  border: 4px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 6px 0 var(--ink);
}

.slide {
  position: relative;
  width: 100%;
  padding: clamp(1.2rem, 3vw, 2.4rem) clamp(1.2rem, 4vw, 3.4rem);
  background: var(--paper);
  border: 6px solid var(--ink);
  border-radius: 36px;
  box-shadow: 0 14px 0 var(--ink);
}

.slide-fit {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-origin: center center;
}

/* ---------- Welcome slide ---------- */

.slide--welcome {
  text-align: center;
}

.welcome-emoji {
  font-size: clamp(4rem, 9vw, 7rem);
  line-height: 1;
  display: inline-block;
  animation: wiggle 2.4s ease-in-out infinite;
}

.welcome-title {
  margin: 0.2em 0 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.4rem, 6vw, 4.8rem);
  line-height: 1.05;
  text-wrap: balance;
}

.welcome-subtitle {
  display: inline-block;
  margin: 0.6em 0 1em;
  padding: 0.1em 0.9em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.3rem, 2.6vw, 2rem);
  background: var(--accent);
  border: 4px solid var(--ink);
  border-radius: 999px;
}

.story-text {
  margin: 0 auto;
  max-width: 62ch;
  padding: 0.9rem 1.5rem;
  font-size: clamp(1.15rem, 2.2vw, 1.8rem);
  line-height: 1.45;
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 24px;
}

.start-button {
  margin-top: 1.6rem;
  padding: 0.3em 1.4em;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.5rem, 3vw, 2.4rem);
  color: var(--ink);
  background: var(--accent);
  border: 5px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 8px 0 var(--ink);
  cursor: pointer;
  animation: pulse 1.6s ease-in-out infinite;
}

.start-button:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 var(--ink);
}

/* ---------- Mission intro slide (the big title moment) ---------- */

.slide--intro {
  text-align: center;
  background: var(--accent);
}

.intro-icon {
  font-size: clamp(4.5rem, 11vw, 8.5rem);
  line-height: 1;
  display: inline-block;
  animation: bounce 1.1s ease-in-out infinite;
}

.intro-number {
  display: inline-block;
  margin-top: 0.2em;
  padding: 0.05em 0.9em;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 3.6vw, 3rem);
  color: #fff;
  background: var(--ink);
  border-radius: 999px;
}

.intro-title {
  margin: 0.15em 0 0.2em;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.5rem, 7.2vw, 6rem);
  line-height: 1.02;
  text-wrap: balance;
  text-shadow: 4px 4px 0 rgba(255, 255, 255, 0.65);
  animation: stamp 0.7s cubic-bezier(0.2, 1.2, 0.4, 1) both;
}

.intro-operation {
  display: inline-block;
  margin-bottom: 1.2rem;
  padding: 0.1em 1em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.2rem, 2.6vw, 2.1rem);
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 999px;
}

@keyframes stamp {
  0%   { opacity: 0; transform: scale(2.6) rotate(-6deg); }
  60%  { opacity: 1; transform: scale(0.94) rotate(1.5deg); }
  100% { opacity: 1; transform: scale(1) rotate(-1.5deg); }
}

/* ---------- Sound buttons (story slides) ---------- */

.sound-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.1rem;
}

.sound-button,
.sound-stop-button {
  padding: 0.25em 1.1em;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.4rem, 2.8vw, 2.2rem);
  border: 5px solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
}

.sound-button {
  color: #fff;
  background: var(--ink);
  box-shadow: 0 8px 0 rgba(27, 22, 70, 0.4);
}

.sound-button.is-playing {
  animation: pulse 1.2s ease-in-out infinite;
}

.sound-stop-button {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 8px 0 rgba(27, 22, 70, 0.4);
}

.sound-button:active:not(:disabled),
.sound-stop-button:active:not(:disabled) {
  transform: translateY(6px);
  box-shadow: 0 2px 0 rgba(27, 22, 70, 0.4);
}

.sound-stop-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.sound-status {
  margin: 0.6rem 0 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: #b00020;
}

/* ---------- Task slide ---------- */

.task-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.8rem;
}

.task-counter {
  padding: 0.05em 0.9em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  color: #fff;
  background: var(--ink);
  border-radius: 999px;
}

.task-operation {
  padding: 0.05em 0.9em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  background: var(--accent);
  border: 3px solid var(--ink);
  border-radius: 999px;
}

.task-heading {
  margin: 0 0 0.3em;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.7rem, 3.6vw, 3rem);
  line-height: 1.1;
}

.task-text {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.7rem, 3.4vw, 3.1rem);
  line-height: 1.35;
}

.chip {
  display: inline-block;
  margin-block: 0.05em;
  padding: 0 0.35em;
  font-weight: 800;
  background: var(--accent-soft);
  border: 3px solid var(--ink);
  border-radius: 0.5em;
  overflow-wrap: anywhere;
}

kbd {
  display: inline-block;
  min-width: 1.7em;
  padding: 0 0.5em;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.9em;
  text-align: center;
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--ink);
  border-bottom-width: 7px;
  border-radius: 0.4em;
}

.key-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem 1.2rem;
  margin-top: 1.2rem;
  font-size: clamp(2rem, 4.8vw, 4rem);
}

.key-combo {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  font-family: var(--font-display);
  font-weight: 800;
}

.key-arrow {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--ink);
}

.hint-button {
  margin-top: 1.4rem;
  padding: 0.2em 1.1em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  color: var(--ink);
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 5px 0 var(--ink);
  cursor: pointer;
}

.hint-button:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--ink);
}

.hint-panel {
  margin-top: 1rem;
  padding: 0.9rem 1.6rem;
  font-size: clamp(1.1rem, 2vw, 1.6rem);
  line-height: 1.45;
  background: var(--accent-soft);
  border: 4px dashed var(--ink);
  border-radius: 24px;
  animation: pop-in 0.25s ease-out;
}

.hint-panel ol {
  margin: 0;
  padding-left: 1.4em;
}

.hint-panel li {
  margin: 0.3em 0;
}

.hint-note {
  margin: 0.6em 0 0;
  font-weight: 800;
}

/* ---------- Checkpoint slide (folder tree) ---------- */

.fake-window {
  margin-top: 1rem;
  overflow: hidden;
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 20px;
}

.window-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.1rem, 2.2vw, 1.7rem);
  background: var(--accent);
  border-bottom: 4px solid var(--ink);
}

.window-dot {
  width: 0.8rem;
  height: 0.8rem;
  background: var(--ink);
  border-radius: 50%;
}

.window-title {
  margin-left: 0.4rem;
}

.window-body {
  padding: 1rem 1.4rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.3rem, 2.7vw, 2.2rem);
}

.tree,
.tree ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tree .tree {
  margin-left: 1.1rem;
  padding-left: 1.4rem;
  border-left: 3px dashed color-mix(in srgb, var(--ink) 35%, transparent);
}

.tree-item {
  margin: 0.2em 0;
}

.tree-label {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4em;
}

.tree-badge {
  padding: 0 0.7em;
  font-size: 0.55em;
  font-weight: 800;
  background: var(--sun);
  border: 3px solid var(--ink);
  border-radius: 999px;
  animation: wiggle 1.8s ease-in-out infinite;
}

.empty-folder {
  margin: 0;
  opacity: 0.65;
}

.checkpoint-note {
  margin: 1.2rem 0 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.2rem, 2.4vw, 1.9rem);
  line-height: 1.35;
}

/* ---------- Final shortcuts quiz ---------- */

.slide--shortcuts {
  text-align: center;
}

.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1.1rem;
  margin-top: 1.4rem;
}

.flip-card {
  height: 200px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  perspective: 900px;
}

.flip-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.flip-card.is-revealed .flip-inner {
  transform: rotateY(180deg);
}

.flip-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.6rem;
  font-family: var(--font-display);
  font-weight: 800;
  border: 5px solid var(--ink);
  border-radius: 24px;
  box-shadow: 0 8px 0 var(--ink);
  backface-visibility: hidden;
}

.flip-front {
  background: var(--accent-soft);
}

.flip-back {
  color: #fff;
  background: var(--ink);
  transform: rotateY(180deg);
}

.flip-emoji {
  font-size: 3.2rem;
  line-height: 1;
}

.flip-meaning {
  font-size: 1.5rem;
  line-height: 1.1;
}

.flip-question {
  font-size: 1.1rem;
  opacity: 0.7;
}

.flip-keys {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.2em;
  font-size: 1.7rem;
}

.flip-keys kbd {
  border-color: #fff;
}

.reveal-all-button {
  margin-top: 1.8rem;
  padding: 0.2em 1.2em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 5px 0 var(--ink);
  cursor: pointer;
}

/* ---------- Finish slide ---------- */

.slide--finish {
  overflow: hidden;
  text-align: center;
}

.finish-trophy {
  font-size: clamp(4.5rem, 11vw, 8rem);
  line-height: 1;
  display: inline-block;
  animation: bounce 1s ease-in-out infinite;
}

.finish-title {
  margin: 0.1em 0 0.3em;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.4rem, 6.5vw, 5.4rem);
  line-height: 1.05;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.7rem;
  margin-top: 1.4rem;
}

.badge {
  padding: 0.1em 0.9em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.1rem, 2.2vw, 1.7rem);
  background: var(--accent-soft);
  border: 4px solid var(--ink);
  border-radius: 999px;
}

.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 18px;
  border-radius: 3px;
  animation: confetti-fall linear infinite;
}

@keyframes confetti-fall {
  from { transform: translateY(0) rotate(0deg); }
  to   { transform: translateY(110vh) rotate(720deg); }
}

/* ---------- Shared animations ---------- */

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-16px); }
}

@keyframes wiggle {
  0%, 100% { transform: rotate(-6deg); }
  50%      { transform: rotate(6deg); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

/* ---------- Navigation controls ---------- */

.controls {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.2rem;
  padding: 0.2rem 1.2rem 0.9rem;
}

.nav-button {
  padding: 0.25em 1.2em;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.2rem, 2.4vw, 1.9rem);
  color: var(--ink);
  background: var(--accent);
  border: 5px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 8px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}

.nav-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 0 var(--ink);
}

.nav-button:active:not(:disabled) {
  transform: translateY(6px);
  box-shadow: 0 2px 0 var(--ink);
}

.nav-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: 0 4px 0 var(--ink);
}

.progress {
  text-align: center;
  color: #fff;
}

.progress-text {
  margin-bottom: 0.3rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
}

.progress-bar {
  height: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* ---------- Mascot in the top bar ---------- */

.mascot {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
  flex: 1 1 0;
}

.mascot-emoji {
  font-size: 2.8rem;
  line-height: 1;
  animation: hop 0.55s ease-in-out infinite alternate;
}

@keyframes hop {
  from { transform: translateY(0) rotate(-6deg); }
  to   { transform: translateY(-6px) rotate(6deg); }
}

.mascot-pop.is-popping {
  animation: mascot-pop 0.5s ease-out;
}

@keyframes mascot-pop {
  0%   { transform: scale(0.4) rotate(-20deg); }
  70%  { transform: scale(1.25) rotate(8deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.mascot-bubble {
  position: relative;
  max-width: 260px;
  padding: 0.2em 0.8em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.2;
  color: var(--ink);
  background: #fff;
  border-radius: 18px;
}

.mascot-bubble::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 50%;
  margin-top: -8px;
  border: 8px solid transparent;
  border-right-color: #fff;
}

.mascot-bubble.is-popping {
  animation: pop-in 0.3s ease-out;
}

.top-bar .icon-button {
  flex: none;
}

/* ---------- Small screens ---------- */

@media (max-width: 900px) {
  .mascot-bubble {
    display: none;
  }

  .track-chip {
    width: 2.2rem;
    height: 2.2rem;
    font-size: 1rem;
  }

  .mission-track {
    gap: 0.4rem;
  }

  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .progress {
    grid-column: 1 / -1;
    grid-row: 1;
  }
}

/* ---------- Respect reduced-motion settings ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
