/* Ayan Khan: playable journey. Game HUD over a scroll-driven 3D world. */
:root {
  --ink: #0f1c2e;
  --muted: #4a5c72;
  --paper: #ffffff;
  --accent: #1a95f3;
  --on-accent: #06121f;
  --gold: #ffd43b;
  --line: rgba(15, 28, 46, 0.12);
  --card: rgba(255, 255, 255, 0.9);
  --shadow: 0 18px 44px -20px rgba(15, 28, 46, 0.45);
  --radius: 16px;
  --font-display: 'Cabinet Grotesk', 'Satoshi', system-ui, sans-serif;
  --font-body: 'Satoshi', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --pad: clamp(14px, 3vw, 32px);
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { scrollbar-width: none; }
html::-webkit-scrollbar { display: none; }
body { margin: 0; background: #bfe3ff; color: var(--ink); font: 500 1rem/1.55 var(--font-body); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.025em; line-height: 1.04; margin: 0; text-wrap: balance; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
.skip { position: fixed; left: 12px; top: -60px; z-index: 60; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px; font-weight: 700; }
.skip:focus { top: 12px; }

#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; z-index: 0; }
#track { height: 2600vh; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; height: 50px; padding: 0 22px;
  border-radius: 999px; font: 700 1rem var(--font-body); text-decoration: none; cursor: pointer; border: 2px solid transparent;
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s;
}
.btn:active { transform: translateY(2px); }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: var(--ink); box-shadow: 0 4px 0 var(--ink); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); }
.btn-primary:active { box-shadow: 0 1px 0 var(--ink); }
.btn-ghost { background: var(--paper); color: var(--ink); border-color: var(--ink); box-shadow: 0 4px 0 var(--ink); }
.btn-ghost:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); }
.btn-ghost:active { box-shadow: 0 1px 0 var(--ink); }
.btn-sm { height: 40px; padding: 0 16px; font-size: 0.92rem; box-shadow: 0 3px 0 var(--ink); }

/* HUD: top */
.hud-top {
  position: fixed; z-index: 30; top: 12px; left: var(--pad); right: var(--pad);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.brand {
  display: inline-flex; align-items: center; gap: 10px; height: 46px; padding: 0 16px 0 8px; border-radius: 999px;
  background: var(--paper); border: 2px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
  text-decoration: none; font: 800 1.1rem var(--font-display);
}
.hud-actions { display: flex; gap: 10px; }

.levels {
  position: fixed; z-index: 30; top: 72px; left: 50%; transform: translateX(-50%); width: min(720px, calc(100% - 2 * var(--pad)));
  transition: opacity 0.4s var(--ease-out);
}
.bar { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.75); border: 2px solid var(--ink); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #25b7f9, #85e38b, #ffd43b, #ff6658); transition: width 0.25s linear; }
#levelTicks { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 8px; }
#levelTicks button {
  width: 100%; height: 30px; border-radius: 999px; border: 2px solid var(--ink); background: var(--paper); color: var(--ink);
  font: 800 0.8rem var(--font-display); cursor: pointer; box-shadow: 0 2px 0 var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 8px;
}
#levelTicks button.done { background: #dff3e0; }
#levelTicks button.current { background: var(--gold); }
#levelTicks button:hover { transform: translateY(-1px); }

/* toast */
.toast {
  position: fixed; z-index: 40; top: 128px; left: 50%; transform: translate(-50%, -24px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 14px; padding: 12px 20px 12px 14px; border-radius: 18px;
  background: var(--ink); color: #fff; box-shadow: var(--shadow);
  transition: opacity 0.4s var(--ease-out), transform 0.5s var(--ease-out);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast > i { font-size: 2rem; color: var(--gold); }
.toast-k { font-size: 0.72rem; font-weight: 700; color: #9fb0c5; }
.toast-t { font: 800 1.2rem var(--font-display); }
.toast-s { font-size: 0.85rem; color: #cdd8e6; }

/* intro */
.intro {
  position: fixed; z-index: 20; left: var(--pad); top: 50%; transform: translateY(-46%); width: min(560px, calc(100% - 2 * var(--pad)));
  padding: 30px; border-radius: 24px; background: var(--card); border: 2px solid var(--ink); box-shadow: 0 6px 0 var(--ink);
  transition: opacity 0.5s var(--ease-out), transform 0.6s var(--ease-out);
}
.intro h1 { font-size: clamp(3rem, 7vw, 5.4rem); letter-spacing: -0.04em; line-height: 0.95; }
.intro .role { margin-top: 10px; font: 800 1.2rem var(--font-display); color: #0b6fc0; }
.intro .lede { margin-top: 12px; color: var(--muted); font-size: 1.08rem; max-width: 46ch; }
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }
.howto { margin-top: 18px; display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 0.92rem; }
.howto i { font-size: 1.3rem; }
body.playing .intro { opacity: 0; transform: translateY(-40%); pointer-events: none; }
body:not(.playing) .levels, body:not(.playing) .story, body:not(.playing) .inventory { opacity: 0; pointer-events: none; }

/* story card */
.story {
  position: fixed; z-index: 20; left: var(--pad); bottom: var(--pad); width: min(440px, calc(100% - 2 * var(--pad)));
  padding: 20px 22px; border-radius: var(--radius); background: var(--card); border: 2px solid var(--ink); box-shadow: 0 5px 0 var(--ink);
  transition: opacity 0.35s var(--ease-out), transform 0.35s var(--ease-out);
}
.story.swap { opacity: 0; transform: translateY(10px); }
.lvl { font: 800 0.8rem var(--font-display); color: #0b6fc0; }
.story h2 { font-size: clamp(1.4rem, 2.2vw, 1.85rem); margin-top: 2px; }
.story .when { margin-top: 4px; font-weight: 700; font-size: 0.88rem; color: var(--muted); }
.story .text { margin-top: 10px; color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chips:empty { display: none; }
.chips li {
  padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 700;
  border: 2px dashed rgba(15, 28, 46, 0.35); color: var(--muted);
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}
.chips li.got { border-style: solid; border-color: var(--ink); background: var(--gold); color: var(--ink); }

/* inventory */
.inventory {
  position: fixed; z-index: 20; right: var(--pad); bottom: var(--pad); width: min(300px, 40vw);
  padding: 16px; border-radius: var(--radius); background: var(--card); border: 2px solid var(--ink); box-shadow: 0 5px 0 var(--ink);
  transition: opacity 0.4s var(--ease-out);
}
.inv-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; font-size: 0.85rem; }
.inv-head b { font: 800 1.25rem var(--font-display); font-variant-numeric: tabular-nums; }
#invList { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; min-height: 30px; }
#invList li { padding: 2px 8px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 0.74rem; font-weight: 700; animation: pop 0.45s var(--ease-out); }
#invList:empty::after { content: 'Badges unlock in the Maple InfoSystems rooms.'; font-size: 0.85rem; color: var(--muted); }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: none; opacity: 1; } }

/* finish */
.finish {
  position: fixed; z-index: 25; inset: 0; display: grid; place-items: center end; padding: var(--pad) clamp(16px, 6vw, 96px);
  pointer-events: none; opacity: 0; transition: opacity 0.6s var(--ease-out);
}
.finish.on { opacity: 1; }
.finish.on .finish-card { pointer-events: auto; transform: none; }
.finish-card {
  width: min(520px, 100%); padding: 30px; border-radius: 24px; text-align: center; margin-top: 4vh;
  background: var(--card); border: 2px solid var(--ink); box-shadow: 0 6px 0 var(--ink);
  transform: translateY(24px) scale(0.97); transition: transform 0.6s var(--ease-out);
}
.finish-card > i { font-size: 2.6rem; }
.finish-card h2 { font-size: clamp(2.2rem, 4.4vw, 3.4rem); margin-top: 6px; }
.finish-card > p { margin-top: 12px; color: var(--muted); }
.finish-card .cta-row { justify-content: center; }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; margin-top: 20px; }
.links a { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; font-weight: 700; }
.links a:hover { color: #0b6fc0; }
.replay { margin-top: 18px; background: none; border: 0; font: 700 0.92rem var(--font-body); color: var(--muted); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.replay:hover { color: var(--ink); }
body.finished .story, body.finished .inventory { opacity: 0; pointer-events: none; }

/* written story: visible only without WebGL */
.story-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.no-webgl #game, .no-webgl #track, .no-webgl .levels, .no-webgl .story, .no-webgl .inventory, .no-webgl .toast { display: none; }
.no-webgl .intro, .no-webgl .finish { position: relative; transform: none; inset: auto; left: auto; top: auto; margin: 90px auto 24px; opacity: 1; }
.no-webgl .finish .finish-card { pointer-events: auto; transform: none; margin: 0 auto; }
.no-webgl .story-text { position: static; width: auto; height: auto; clip-path: none; white-space: normal; max-width: 640px; margin: 0 auto; padding: 0 var(--pad) 40px; }
.story-text ol { display: grid; gap: 18px; margin-top: 16px; }
.story-text h3 { font-size: 1.3rem; }

@media (max-width: 900px) {
  .brand span { display: none; }
  .levels { top: 68px; }
  #levelTicks button { font-size: 0; padding: 0; height: 14px; box-shadow: none; }
  .inventory { display: none; }
}
@media (max-width: 600px) {
  .hud-actions .btn-ghost { display: none; }
  .intro { top: auto; bottom: var(--pad); transform: none; padding: 22px; }
  body.playing .intro { transform: translateY(20px); }
  .intro h1 { font-size: 3rem; }
  .story { padding: 16px 18px; }
  .story .text { font-size: 0.95rem; }
  .finish { place-items: end center; }
  .finish-card { margin-top: 0; padding: 22px; }
  .toast { top: 100px; width: max-content; max-width: calc(100% - 24px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* badge inventory with real logos */
#invList li.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 3px; background: var(--ink); }
#invList li.badge img { width: 22px; height: 22px; border-radius: 50%; background: #fff; }
.story .task-logo { width: 34px; height: 34px; border-radius: 50%; float: right; margin-left: 10px; box-shadow: 0 0 0 2px var(--ink); background: #fff; }

.chips li img { width: 16px; height: 16px; border-radius: 50%; vertical-align: -3px; margin-right: 5px; background: #fff; }

/* phones: every card stays compact so the 3D scene stays visible */
@media (max-width: 600px) {
  .hud-top { top: 8px; left: 8px; right: 8px; }
  .brand { height: 40px; padding: 0 10px 0 6px; box-shadow: 0 2px 0 var(--ink); }
  .btn-sm { height: 36px; padding: 0 14px; font-size: 0.85rem; box-shadow: 0 2px 0 var(--ink); }
  .levels { top: 56px; width: calc(100% - 16px); }
  .bar { height: 7px; }
  #levelTicks { gap: 4px; margin-top: 5px; }
  #levelTicks button { height: 9px; }
  .toast { top: 84px; padding: 8px 12px 8px 10px; gap: 10px; border-radius: 14px; }
  .toast > i { font-size: 1.4rem; }
  .toast-t { font-size: 0.95rem; }
  .toast-s { font-size: 0.75rem; }
  .story { left: 8px; right: 8px; bottom: 8px; width: auto; padding: 10px 14px 12px; border-radius: 14px; box-shadow: 0 3px 0 var(--ink); }
  .lvl { font-size: 0.68rem; }
  .story h2 { font-size: 1.1rem; }
  .story .when { font-size: 0.74rem; margin-top: 2px; }
  .story .text { font-size: 0.82rem; line-height: 1.4; margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .chips { gap: 4px; margin-top: 8px; }
  .chips li { font-size: 0.66rem; padding: 2px 7px; border-width: 1.5px; }
  .chips li img { width: 11px; height: 11px; margin-right: 3px; }
  .intro { left: 8px; right: 8px; bottom: 8px; width: auto; padding: 16px; border-radius: 18px; box-shadow: 0 4px 0 var(--ink); }
  .intro h1 { font-size: 2.3rem; }
  .intro .role { font-size: 0.95rem; margin-top: 6px; }
  .intro .lede { font-size: 0.86rem; margin-top: 8px; }
  .intro .cta-row { margin-top: 14px; gap: 8px; }
  .intro .btn { height: 42px; padding: 0 16px; font-size: 0.9rem; }
  .howto { margin-top: 10px; font-size: 0.78rem; }
  .finish { padding: 8px; }
  .finish-card { padding: 16px 14px; border-radius: 18px; box-shadow: 0 4px 0 var(--ink); }
  .finish-card > i { font-size: 1.6rem; }
  .finish-card h2 { font-size: 1.7rem; margin-top: 2px; }
  .finish-card > p { font-size: 0.82rem; margin-top: 8px; }
  .finish-card .cta-row { margin-top: 12px; }
  .finish-card .btn { height: 42px; padding: 0 16px; font-size: 0.9rem; }
  .links { gap: 6px 14px; margin-top: 12px; font-size: 0.82rem; }
  .replay { margin-top: 8px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .story { width: min(360px, 46vw); padding: 10px 14px; }
  .story .text { font-size: 0.8rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .inventory { display: none; }
  .intro { top: 60px; bottom: auto; transform: none; padding: 14px; width: min(460px, 60vw); }
  .intro h1 { font-size: 2rem; }
  .finish-card { margin-top: 0; padding: 14px; }
  .finish-card > p { display: none; }
}
