/* THE GOD TERMINAL — maze game window (js/maze.js).
 * The maze itself is canvas; this styles the HUD, the GO banner, the result card and the touch D-pad. */

.win.maze-win {
  /* The finish tile is gold in every palette; these match GOLD in maze.js. */
  --mz-gold: #ffcb2e;
  --mz-gold-hi: #fff7c9;
}
.win.maze-win .win-body.mz-body {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 0;
  padding: 0.6rem 0.7rem 0.7rem;
  overflow: hidden;
  /* Keep the playfield clean: nothing behind the window shows through the game. */
  border-radius: 0 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
}

/* ───────── HUD ───────── */
.mz-hud {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: none;
  min-width: 0;
}
.mz-stat, .mz-goose {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: color-mix(in srgb, var(--panel-strong) 70%, transparent);
  white-space: nowrap;
}
.mz-stat-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--dim);
}
.mz-val {
  display: inline-block;
  min-width: 2ch;
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--text-bright);
  text-shadow: var(--text-glow);
  font-variant-numeric: tabular-nums;
  transform-origin: 50% 60%;
}
.mz-time { min-width: 6ch; }

/* Desktop: the HUD rides in the title bar, between the title and the close button. */
.win-bar > .mz-hud {
  gap: 0.4rem;
  margin-right: 0.1rem;
}
.win-bar > .mz-hud .mz-stat,
.win-bar > .mz-hud .mz-goose { padding: 0.1rem 0.6rem; }
.win-bar > .mz-hud .mz-goose { margin-left: 0.3rem; }
@media (max-width: 780px) {
  .win-bar > .mz-hud .mz-goose .mz-stat-label { display: none; }
}

.mz-goose {
  margin-left: auto;
  align-items: center;
  transition: border-color 200ms, background-color 200ms;
}
.mz-goose-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 8px var(--good);
}
.mz-mood {
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-bright);
  transition: color 200ms;
}
.mz-goose.is-chasing {
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 20%, var(--panel-strong));
}
.mz-goose.is-chasing .mz-mood {
  color: color-mix(in srgb, var(--bad) 70%, #fff);
  text-shadow: 0 0 10px var(--bad);
}
.mz-goose.is-chasing .mz-goose-dot {
  background: var(--bad);
  box-shadow: 0 0 10px var(--bad);
  animation: mz-pulse 0.45s ease-in-out infinite alternate;
}
.mz-goose.is-baffled { border-color: var(--mz-gold); }
.mz-goose.is-baffled .mz-mood { color: var(--mz-gold-hi); }
.mz-goose.is-baffled .mz-goose-dot { background: var(--mz-gold); box-shadow: 0 0 10px var(--mz-gold); }
@keyframes mz-pulse { to { transform: scale(1.6); opacity: 0.75; } }

/* ───────── maze stage ───────── */
.mz-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  container-type: size;
  border: 1px solid var(--line);
  border-radius: 5px;
  background:
    radial-gradient(110% 90% at 50% 45%, color-mix(in srgb, var(--bg-2) 80%, transparent), color-mix(in srgb, var(--bg) 94%, transparent));
  box-shadow: inset 0 0 calc(44px * var(--glow-k)) calc(-12px * var(--glow-k)) var(--glow);
  overflow: hidden;
  touch-action: none;
}
.mz-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
/* Red edge glow while the goose is chasing you. */
.mz-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  box-shadow: inset 0 0 1.6rem 0 color-mix(in srgb, var(--bad) 80%, transparent), inset 0 0 0 2px var(--bad);
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease-out;
}
.mz-stage.is-danger::before { opacity: 0.55; animation: mz-danger 0.8s ease-in-out infinite alternate; }
html[data-reduced-motion="on"] .mz-stage.is-danger::before { animation: none; }
@keyframes mz-danger { from { opacity: 0.45; } to { opacity: 1; } }

/* White flash on the result moment. */
.mz-stage::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
.mz-stage.is-flash::after { animation: mz-flash 460ms ease-out; }
html[data-reduced-motion="on"] .mz-stage.is-flash::after { animation-name: mz-flash-soft; }
@keyframes mz-flash { from { opacity: 0.6; } to { opacity: 0; } }
@keyframes mz-flash-soft { from { opacity: 0.18; } to { opacity: 0; } }

/* ───────── GO banner ───────── */
.mz-banner, .mz-result {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  text-align: center;
  pointer-events: none;
}
/* A soft pool of darkness so the walls never cut through the lettering. */
.mz-banner {
  background: radial-gradient(42% 38% at 50% 50%, color-mix(in srgb, var(--bg) 78%, transparent), transparent);
}
.mz-banner-big {
  font-family: var(--font-display);
  font-size: clamp(4rem, 34cqmin, 10rem);
  line-height: 0.75;
  color: var(--text-bright);
  text-shadow: 0 0 calc(18px * var(--glow-k) + 6px) var(--glow), 0 0 calc(60px * var(--glow-k)) var(--glow);
}
.mz-banner-sub, .mz-banner-hint {
  padding: 0.35rem 0.95rem;
  border-radius: 4px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
}
.mz-banner-sub {
  font-size: 1.125rem;
  color: var(--text-bright);
  border: 1px solid var(--line);
}
.mz-banner-hint {
  font-size: 0.875rem;
  color: var(--text);
}
.mz-gold {
  color: var(--mz-gold);
  text-shadow: 0 0 10px rgba(255, 190, 40, 0.75);
}
/* Narrow mazes: the two halves of the goal stack instead of wrapping mid-phrase. */
@container (max-width: 520px) {
  .mz-banner-sub .mz-sep { display: none; }
  .mz-banner-sub > span { display: block; }
}

/* ───────── result card ───────── */
.mz-banner, .mz-result { z-index: 2; }
.mz-result {
  background:
    radial-gradient(70% 60% at 50% 50%, color-mix(in srgb, var(--bg) 85%, transparent), transparent),
    color-mix(in srgb, var(--bg) 52%, transparent);
}
.mz-result-big {
  font-family: var(--font-display);
  line-height: 0.8;
  white-space: nowrap;
}
.mz-result-sub {
  padding: 0.3rem 1rem;
  border-radius: 4px;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.mz-result.is-win .mz-result-big {
  font-size: clamp(3rem, 12.5cqw, 7rem);
  color: var(--mz-gold-hi);
  text-shadow: 0 0 3px #fff, 0 0 16px var(--mz-gold), 0 0 48px rgba(255, 150, 20, 0.85);
}
.mz-result.is-win .mz-result-sub {
  color: #2a1a00;
  background: linear-gradient(180deg, var(--mz-gold-hi), var(--mz-gold));
  box-shadow: 0 0 22px rgba(255, 190, 40, 0.55);
}
.mz-result.is-lose .mz-result-big {
  font-size: clamp(4rem, 26cqmin, 10rem);
  color: color-mix(in srgb, var(--bad) 45%, #fff);
  text-shadow: 0 0 3px #fff, 0 0 18px var(--bad), 0 0 54px var(--bad);
}
.mz-result.is-lose .mz-result-sub {
  color: #fff;
  background: var(--bad);
  box-shadow: 0 0 24px color-mix(in srgb, var(--bad) 70%, transparent);
}

/* ───────── touch D-pad ───────── */
.mz-pad {
  display: grid;
  flex: none;
  grid-template-columns: repeat(3, 3.9rem);
  grid-template-rows: repeat(3, 3.9rem);
  grid-template-areas: ". up ." "left hub right" ". down .";
  gap: 0.3rem;
  justify-content: center;
}
.btn.mz-key {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  border-color: var(--line-bright);
  border-radius: 14px;
  background: color-mix(in srgb, var(--text) 9%, var(--panel-strong));
  box-shadow: 0 0 16px -6px var(--glow), inset 0 -3px 0 color-mix(in srgb, var(--bg) 55%, transparent);
}
.btn.mz-key.is-pressed {
  transform: scale(1.14);
  background: color-mix(in srgb, var(--text) 30%, var(--panel-strong));
  box-shadow: 0 0 26px -2px var(--glow), inset 0 0 14px -4px #fff;
}
.mz-key svg {
  width: 44%;
  height: 44%;
  fill: var(--text-bright);
  filter: drop-shadow(0 0 4px var(--glow));
  transform: rotate(var(--rot, 0deg));
}
.mz-key-up { grid-area: up; }
.mz-key-right { grid-area: right; --rot: 90deg; }
.mz-key-down { grid-area: down; --rot: 180deg; }
.mz-key-left { grid-area: left; --rot: 270deg; }
.mz-pad-hub {
  grid-area: hub;
  margin: 26%;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--text) 28%, transparent), transparent 70%);
}

@media (max-width: 599px) {
  .win.maze-win .win-body.mz-body { gap: 0.45rem; padding: 0.5rem; }
  .mz-hud { gap: 0.35rem; }
  .mz-stat, .mz-goose { gap: 0.35rem; padding: 0.2rem 0.5rem; }
  .mz-goose .mz-stat-label { display: none; }
  .mz-banner-sub { font-size: 1rem; }
}

/* Landscape phones: the HUD is in the title bar and the pad sits beside the maze. */
@media (orientation: landscape) and (max-height: 599px) {
  .win.maze-win.has-pad .win-body.mz-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: minmax(0, 1fr);
  }
  .maze-win.has-pad .mz-pad { align-self: center; }
}
