/* ============================================================================
   geracao-de-labirintos/app.css — styles for the maze-generator playground only.
   Scoped under .maze; inherits BPSO Lab 2026 tokens from blog.css. Loaded by the
   post page. Works in both dark (default) and [data-theme="light"].
   ========================================================================== */

.maze {
  /* Local render tokens read by app.js via getComputedStyle. */
  --maze-bg: #0b1220;                       /* canvas backdrop */
  --maze-wall: #e2e8f0;                      /* maze walls */
  --maze-visited: rgba(37, 99, 235, .12);    /* carved/visited cells */
  --maze-stack: rgba(96, 165, 250, .34);     /* backtracking trail (cells on the stack) */
  --maze-current: #f59e0b;                   /* generation cursor */
  --maze-path: #22c55e;                      /* solution path */
  --maze-start: #22c55e;                     /* entrance marker */
  --maze-end: #ef4444;                       /* exit marker */

  display: grid;
  gap: 1.1rem;
  /* Cap the whole interactive by viewport height so on mobile the canvas AND the
     controls are visible together without scrolling the playground out of view. */
  max-height: 86vh;
}

[data-theme="light"] .maze {
  --maze-bg: #0f172a;                         /* keep the board dark for crisp contrast */
  --maze-wall: #e2e8f0;
  --maze-visited: rgba(96, 165, 250, .16);
  --maze-stack: rgba(96, 165, 250, .40);
}

/* ----------------------------------------------------------------- Stage */
.maze__stage {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  border-radius: var(--radius-sm, 10px);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--maze-bg);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .02);
  padding: clamp(.5rem, 2vw, 1rem);
}

.maze__canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  /* Cap by viewport so the board never pushes the controls off-screen on phones. */
  max-height: 62vh;
  touch-action: manipulation;
}
.maze__canvas:focus-visible {
  outline: 3px solid var(--brand-light);
  outline-offset: 3px;
}

/* Live status badge over the board. */
.maze__status {
  position: absolute;
  top: .6rem;
  left: .6rem;
  max-width: calc(100% - 1.2rem);
  font-family: var(--font-head, system-ui);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .01em;
  color: #e2e8f0;
  background: rgba(11, 18, 32, .74);
  border: 1px solid rgba(255, 255, 255, .12);
  padding: .24rem .6rem;
  border-radius: 999px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --------------------------------------------------------------- Controls */
.maze__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
}

.maze__btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 42px;
  min-width: 0;                 /* allow flex shrink so buttons never overflow */
  padding: 0 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 10px);
  background: var(--surface-2);
  color: var(--text-main);
  font-family: var(--font-head, system-ui);
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
  transition: transform .15s, border-color .15s, background .15s, color .15s;
}
.maze__btn i { font-size: 1.15rem; line-height: 1; }
.maze__btn:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--brand-blue) 60%, var(--border));
  transform: translateY(-1px);
}
.maze__btn:active:not(:disabled) { transform: translateY(0); }
.maze__btn:disabled { opacity: .55; cursor: progress; }

.maze__btn--primary {
  background: var(--brand-blue);
  border-color: var(--brand-blue);
  color: #fff;
  box-shadow: 0 8px 22px -10px var(--brand-glow);
}
.maze__btn--primary:hover:not(:disabled) {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}

/* Toggle button shows its pressed state with the brand accent. */
.maze__toggle[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--brand-blue) 60%, var(--border));
  color: var(--brand-light);
}
[data-theme="light"] .maze__toggle[aria-pressed="true"] { color: var(--brand-blue); }

/* Spinner for the generating state. */
.maze__spin { animation: maze-spin .8s linear infinite; }
@keyframes maze-spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- Sliders */
.maze__sliders {
  display: flex;
  flex-wrap: wrap;
  gap: .8rem 1.4rem;
}
.maze__slider {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  flex: 1 1 200px;
  min-width: 0;
}
.maze__slider-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .6rem;
}
.maze__slider-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
}
.maze__slider-val {
  font-size: .76rem;
  font-weight: 600;
  color: var(--brand-light);
  white-space: nowrap;
}
[data-theme="light"] .maze__slider-val { color: var(--brand-blue); }

.maze__range {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-blue), var(--brand-light));
  cursor: pointer;
  outline-offset: 4px;
}
.maze__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--brand-blue);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  cursor: pointer;
}
.maze__range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--brand-blue);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  cursor: pointer;
}
.maze__range::-moz-range-track { background: transparent; }

/* --------------------------------------------------------------- Responsive */
@media (max-width: 560px) {
  .maze { gap: .9rem; }
  .maze__btn { flex: 1 1 auto; padding: 0 .7rem; font-size: .86rem; }
  .maze__canvas { max-height: 52vh; }
  .maze__slider { flex-basis: 100%; }
  .maze__status { font-size: .66rem; }
}

@media (max-width: 360px) {
  .maze__btn span { display: inline; }
  .maze__btn { gap: .3rem; }
}

@media (prefers-reduced-motion: reduce) {
  .maze__btn, .maze__range { transition: none; }
  .maze__spin { animation: none; }
}
