/* ==========================================================================
   Unity WebGL player — embedded, click-to-load.
   Owns only the game area; nothing here affects the rest of the page.
   Uses the tokens defined in main.css.
   ========================================================================== */

.webgl-shell {
  max-width: 880px;
  margin: 0 auto;
}

/* The frame holds the canvas and every overlay state. */
.webgl-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  /* Matches the build's 960x600 canvas */
  aspect-ratio: 16 / 10;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0b0c0f;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
}

.webgl-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #0b0c0f;
  outline: none;
}

/* --------------------------------------------------------------------------
   Start state — the only thing loaded until the visitor chooses to play.
   -------------------------------------------------------------------------- */
.webgl-poster {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 28px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(11, 12, 15, .55) 0%, rgba(11, 12, 15, .88) 100%),
    url("../assets/images/projects/charles-on-chain/cover.jpg") center / cover no-repeat;
}

.webgl-poster[hidden] { display: none; }

.webgl-play {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 28px;
  color: var(--brand-ink);
  border: 1px solid var(--brand);
  border-radius: var(--radius-sm);
  background: var(--brand);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .34);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -.01em;
  transition: background .18s var(--ease), transform .18s var(--ease), box-shadow .18s var(--ease);
}
.webgl-play:hover {
  background: var(--brand-hover);
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, .42);
}
.webgl-play:active { transform: translateY(0); }
.webgl-play:disabled { cursor: wait; opacity: .7; transform: none; }
.webgl-play:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }

.webgl-note {
  margin: 0;
  color: #d6d7de;
  font-size: .875rem;
  line-height: 1.5;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .80);
}

/* --------------------------------------------------------------------------
   Loading state
   -------------------------------------------------------------------------- */
.webgl-loading {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: rgba(11, 12, 15, .93);
}
.webgl-loading[hidden] { display: none; }

.webgl-loading-label {
  margin: 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.webgl-bar {
  overflow: hidden;
  width: min(260px, 70%);
  height: 4px;
  border-radius: 999px;
  background: var(--surface-3);
}

.webgl-bar > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  transition: width .2s linear;
}

/* --------------------------------------------------------------------------
   Error state
   -------------------------------------------------------------------------- */
.webgl-error {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 26px;
  text-align: center;
  background: rgba(11, 12, 15, .95);
}
.webgl-error[hidden] { display: none; }

.webgl-error p {
  max-width: 460px;
  margin: 0;
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.65;
}
.webgl-error strong { display: block; margin-bottom: 6px; color: var(--text); font-size: 1rem; }
.webgl-error a {
  color: var(--accent);
  border-bottom: 1px solid currentColor;
  font-weight: 600;
  transition: color .16s var(--ease);
}
.webgl-error a:hover { color: var(--text); }

/* --------------------------------------------------------------------------
   Controls — website to Unity. Sits below the frame, outside it, so it never
   covers the canvas.
   -------------------------------------------------------------------------- */
.webgl-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.webgl-controls[hidden] { display: none; }

.webgl-toggle {
  min-height: 44px;
  padding: 0 20px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  font-family: var(--sans);
  font-size: .9rem;
  font-weight: 600;
  transition: background .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease);
}
.webgl-toggle:hover { background: var(--surface-3); border-color: var(--brand); }
.webgl-toggle:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* Paused: the button becomes the accented call to resume. */
.webgl-toggle.is-active {
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
}
.webgl-toggle.is-active:hover { background: var(--brand-hover); }

.webgl-controls-note {
  color: var(--faint);
  font-size: .855rem;
  line-height: 1.5;
}
.webgl-controls-note code {
  color: var(--muted);
  font-family: var(--mono);
  font-size: .95em;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 760px) {
  .webgl-shell { max-width: none; }
  /* Widescreen box: shorter than 16:10, so the game fits a phone screen. */
  .webgl-frame { aspect-ratio: 16 / 9; border-radius: var(--radius-sm); }
  .webgl-poster { padding: 20px; gap: 12px; }
  .webgl-play { min-height: 48px; padding: 0 20px; font-size: .92rem; }
  .webgl-note { font-size: .82rem; }

  /* Full-width control so it is an easy thumb target. */
  .webgl-controls { padding: 12px; }
  .webgl-toggle { width: 100%; min-height: 48px; }
  .webgl-controls-note { font-size: .82rem; }
}

@media (prefers-reduced-motion: reduce) {
  .webgl-play { transition: none; }
  .webgl-play:hover { transform: none; }
  .webgl-bar > span { transition: none; }
}
