/* =====================================================================
   OASIS_OS — live WASM demo chrome. Loads after site.css. Used by
   site/demo/index.html (deployed) and www/index.html (local dev page).
   Contract with www/index.js: #container wraps canvas#oasis, and the
   container is the positioned parent the YouTube / browser iframe
   overlay attaches to.
   ===================================================================== */

.page-demo {
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; overflow: hidden;
  background: #050609;
}

/* ---------- Demo bar ---------- */
.demo-bar {
  flex: none; position: relative; z-index: 20;
  display: flex; align-items: center; gap: 0.75rem 1.25rem;
  min-height: 52px; padding: 0.5rem clamp(0.75rem, 2vw, 1.25rem);
  background: rgba(8, 9, 13, 0.92); border-bottom: 1px solid var(--line);
}
.demo-bar .brand__name { font-size: 0.88rem; }
.demo-bar__label {
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent); display: inline-flex; align-items: center; gap: 0.45rem;
}
.demo-bar__label::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--lime);
  box-shadow: 0 0 0 3px rgba(184, 228, 90, 0.18);
}
.demo-bar__spacer { flex: 1; }

.skin-picker { display: inline-flex; align-items: center; gap: 0.55rem; }
.skin-picker span { font-family: var(--mono); font-size: 0.72rem; color: var(--faint); }
.skin-picker select {
  appearance: none; -webkit-appearance: none;
  height: 36px; padding: 0 2.1rem 0 0.85rem; border-radius: var(--radius-pill);
  font: 500 0.85rem var(--sans); color: var(--text); cursor: pointer;
  border: 1px solid var(--line-2);
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) right 1.05rem center / 5px 5px no-repeat,
    linear-gradient(-45deg, transparent 50%, var(--muted) 50%) right 0.75rem center / 5px 5px no-repeat,
    var(--surface);
}
.skin-picker select:hover { border-color: var(--muted); }
.skin-picker select option, .skin-picker select optgroup { background: var(--surface); color: var(--text); }

.demo-bar__links { display: flex; align-items: center; gap: 0.35rem; }
.demo-bar__links a, .demo-bar__links button {
  height: 36px; display: inline-flex; align-items: center; padding: 0 0.8rem; border-radius: var(--radius-pill);
  font-size: 0.85rem; font-weight: 500; color: var(--muted);
  border: 1px solid transparent; background: transparent; cursor: pointer;
}
.demo-bar__links a:hover, .demo-bar__links button:hover { color: var(--text); text-decoration: none; background: rgba(255, 255, 255, 0.05); }
.demo-bar__links .is-boxed { border-color: var(--line-2); }
.demo-bar__links .demo-bar__icon { width: 36px; padding: 0; justify-content: center; }
.demo-bar__links .demo-bar__icon[hidden] { display: none; }
.demo-bar__icon.is-on { color: var(--accent); }
#help-btn[aria-expanded="true"] { color: var(--text); background: rgba(255, 255, 255, 0.06); }

/* Tablet widths: the "Live demo" label pushed GitHub past the edge. */
@media (max-width: 1000px) {
  .demo-bar__label { display: none; }
}

@media (max-width: 760px) {
  .demo-bar { flex-wrap: wrap; }
  .demo-bar__label { display: none; }
  .demo-bar__links .hide-sm { display: none; }
  .skin-picker { order: 3; width: 100%; }
  .skin-picker select { flex: 1; }
  .demo-bar__spacer { display: none; }
  .demo-bar__links { margin-left: auto; }
}

/* ---------- Stage ---------- */
#container {
  flex: 1; min-height: 0; position: relative; overflow: hidden;
  display: flex; justify-content: center; align-items: center;
  background:
    radial-gradient(60% 60% at 50% 45%, rgba(255, 138, 61, 0.07), transparent 70%),
    repeating-conic-gradient(#0a0c11 0% 25%, #08090d 0% 50%) 50% / 28px 28px;
}
/* www/index.js sizes the canvas to fit #container while keeping its aspect
   ratio (object-fit: contain is unreliable on <canvas> in Firefox). */
#oasis {
  display: block; background: #000; cursor: none; outline: none;
  image-rendering: pixelated; image-rendering: crisp-edges;
  box-shadow: 0 0 0 1px var(--line-2), 0 30px 90px -30px rgba(0, 0, 0, 0.95);
}
#oasis:focus-visible { box-shadow: 0 0 0 2px var(--sky), 0 30px 90px -30px rgba(0, 0, 0, 0.95); }

.boot {
  position: absolute; inset: 0; z-index: 4; pointer-events: none;
  display: flex; align-items: center; justify-content: center; padding: var(--space-s);
  transition: opacity 0.4s;
}
.boot.is-done { opacity: 0; visibility: hidden; transition: opacity 0.4s, visibility 0s 0.4s; }
.boot__panel {
  display: grid; justify-items: center; gap: 0.6rem; text-align: center;
  padding: var(--space-m) var(--space-l); border-radius: var(--radius);
  background: rgba(10, 12, 17, 0.82); border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
}
.boot__mark { width: 30px; height: 19px; margin-bottom: 0.35rem; animation: boot-pulse 1.6s var(--ease-in-out) infinite; }
@keyframes boot-pulse { 50% { opacity: 0.45; transform: scale(0.94); } }
.boot__msg {
  font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text);
}
.boot__sub { font-size: 0.85rem; color: var(--muted); max-width: 34ch; }
.boot__bar {
  width: 180px; height: 3px; margin-top: 0.4rem; border-radius: 3px;
  background: var(--line); overflow: hidden;
}
.boot__bar::after {
  content: ""; display: block; width: 40%; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--lime));
  animation: boot-slide 1.1s var(--ease) infinite alternate;
}
@keyframes boot-slide { from { transform: translateX(-10%); } to { transform: translateX(160%); } }
@media (prefers-reduced-motion: reduce) {
  /* a static, half-filled bar instead of a shuttle */
  .boot__bar::after { animation: none; width: 50%; }
}

/* Phones held upright: the 480x272 screen is short and wide, so pin it
   (and the boot panel) to the top and leave the space below for the
   controls card instead of covering the screen with it. */
@media (orientation: portrait) and (max-width: 600px) {
  #container { align-items: flex-start; padding-top: 0.75rem; }
  .boot:not(.is-failed) { align-items: flex-start; padding-top: 2rem; }
  .boot__panel { padding: var(--space-s) var(--space-m); }
}

/* Fallback card (js/demo.js): WASM build missing, no WebAssembly, or a
   boot that never finished. Replaces the indicator's contents. */
.boot.is-failed {
  pointer-events: auto; padding: var(--space-s);
  background: rgba(5, 6, 9, 0.72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  font-family: var(--sans); font-size: var(--step-0); letter-spacing: 0; text-transform: none;
}
.boot__card {
  width: min(460px, 100%); padding: var(--space-m) var(--space-m) var(--space-m);
  border-radius: var(--radius); border: 1px solid var(--line-2);
  background: var(--surface); box-shadow: var(--shadow-3); text-align: left;
}
.boot__code {
  font-family: var(--mono); font-size: var(--step--2); letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--accent);
}
.boot__why { margin-top: var(--space-2xs); color: var(--muted); font-size: 0.92rem; line-height: 1.6; }
.boot__actions { margin-top: var(--space-m); display: flex; flex-wrap: wrap; gap: var(--space-2xs); }

/* ---------- Controls card ---------- */
.instructions {
  position: absolute; z-index: 5; left: 50%; bottom: clamp(0.75rem, 3vh, 1.5rem);
  transform: translateX(-50%); width: min(560px, calc(100% - 1.5rem));
  max-height: calc(100% - 1.5rem); overflow-y: auto;
  padding: 1.1rem 1.25rem 1.1rem; border-radius: var(--radius);
  background: rgba(17, 20, 28, 0.95); border: 1px solid var(--line-2);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.9);
  font-size: 0.86rem; line-height: 1.55; color: var(--muted);
  transition: opacity 0.3s, transform 0.3s var(--ease);
}
.instructions[hidden] { display: none; }
.instructions.is-leaving { opacity: 0; transform: translate(-50%, 8px); }
.instructions h2 {
  font-size: 0.72rem; font-family: var(--mono); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 0.75rem;
}
.instructions__grid {
  display: grid; gap: 0.9rem 1.5rem; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
}
.instructions h3 { font-size: 0.8rem; font-weight: 650; color: var(--text); margin-bottom: 0.4rem; }
.instructions ul { display: grid; gap: 0.3rem; }
.instructions li { display: flex; align-items: center; gap: 0.6rem; }
.instructions .keys { display: inline-flex; gap: 0.2rem; min-width: 6.6rem; }
.instructions kbd {
  display: inline-block; min-width: 1.6em; text-align: center;
  font-family: var(--mono); font-size: 0.74rem; padding: 0.05rem 0.4rem; border-radius: 5px;
  background: var(--surface-2); border: 1px solid var(--line-2); border-bottom-width: 2px; color: var(--text);
}
.instructions__note {
  margin-top: 0.85rem; padding-top: 0.75rem; border-top: 1px solid var(--line);
  font-size: 0.8rem; color: var(--faint);
}
.instructions__rotate { display: none; }
@media (orientation: portrait) and (max-width: 600px) {
  .instructions__rotate {
    display: block; margin-top: 0.6rem; font-size: 0.8rem; color: var(--accent-2);
  }
}
.instructions__foot { margin-top: 0.85rem; display: flex; gap: 0.75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.instructions__foot a { font-size: 0.82rem; }
.instructions .dismiss {
  height: 34px; padding: 0 1rem; border-radius: var(--radius-pill); cursor: pointer;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text); font-size: 0.82rem; font-weight: 600;
}
.instructions .dismiss:hover { border-color: var(--muted); }

.page-demo noscript { padding: 2rem; text-align: center; color: var(--muted); }
