/* =========================================================
   Maze Generator — tool-specific styles.
   Layered on /tools/_shared/tool.css.
   ========================================================= */

/* Allow the card to widen once a maze is rendered so big mazes
   (35×35) don't get squeezed. */
.widget-card {
  transition: max-width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.widget-card.is-result-shown {
  max-width: 760px;
}

/* ---------- Controls ---------- */
.mz-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}

.mz-field { display: flex; flex-direction: column; gap: var(--space-2); }
.mz-field-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}

/* Segmented size buttons */
.mz-size-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}
@media (min-width: 480px) {
  .mz-size-grid { grid-template-columns: repeat(4, 1fr); }
}

.mz-size-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--space-3) var(--space-2);
  min-height: 60px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition-colors), transform 0.06s ease;
}
.mz-size-btn:hover { border-color: var(--border-strong); }
.mz-size-btn:active { transform: translateY(1px); }
.mz-size-btn.is-active {
  background: var(--accent-soft-bg);
  border-color: var(--accent);
  color: var(--accent-soft-fg);
}
.mz-size-btn-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.mz-size-btn.is-active .mz-size-btn-sub {
  color: var(--accent-soft-fg);
  opacity: 0.85;
}

/* Custom width/height row */
.mz-custom-row {
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
  flex-wrap: wrap;
}
.mz-custom-field {
  flex: 1 1 120px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mz-custom-field label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}
.mz-custom-field input {
  width: 100%;
  padding: 10px 14px;
  font: inherit;
  font-size: 15px;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.mz-custom-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* Algorithm select */
.mz-select {
  width: 100%;
  padding: 10px 14px;
  font: inherit;
  font-size: 15px;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: var(--transition-colors);
}
.mz-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.mz-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Solution toggle (inline checkbox row) */
.mz-toggle-row {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}
.mz-toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.mz-actions { margin-top: var(--space-2); }
.mz-actions .btn { font-size: 16px; min-height: 52px; }

/* ---------- Result ---------- */
.mz-result {
  border-top: 1px solid var(--border);
  padding-top: var(--space-6);
  margin-top: var(--space-6);
}
.mz-result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.mz-result-meta {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}
.mz-result-actions {
  display: inline-flex;
  gap: var(--space-4);
  align-items: center;
  flex-wrap: wrap;
}
.mz-btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}
.mz-btn-link:hover { color: var(--accent-hover); text-decoration: underline; }

/* Play toggle — same row as the link-style actions, but bracketed so it
   reads as a distinct mode toggle instead of yet another action. */
.mz-btn-play {
  border: 1px solid var(--accent);
  background: var(--accent-soft-bg);
  color: var(--accent-soft-fg);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 13px;
}
.mz-btn-play:hover {
  background: var(--accent);
  color: var(--accent-fg);
  text-decoration: none;
}
.mz-btn-play[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.mz-legend {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
  font-size: 13px;
  color: var(--text-muted);
}
.mz-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mz-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.mz-legend-dot.is-start { background: #16A34A; }
.mz-legend-dot.is-end   { background: #DC2626; }

/* ---------- Maze paper ---------- */
.mz-svg-wrap {
  width: 100%;
  background: #FFFFFF;
  border-radius: var(--radius);
  padding: var(--space-3);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08),
              0 8px 24px rgba(15, 23, 42, 0.06);
  border: 1px solid var(--border);
  overflow: hidden;
}
.mz-svg-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

/* ---------- Play mode panel ---------- */
.mz-play-panel {
  margin-top: var(--space-5);
  padding: var(--space-5);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  align-items: center;
  text-align: center;
}

.mz-play-stats {
  display: flex;
  gap: var(--space-6);
  flex-wrap: wrap;
  justify-content: center;
}
.mz-play-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.mz-play-stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}
.mz-play-stat-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.mz-play-hint {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
  max-width: 360px;
}

.mz-play-message {
  margin: 0;
  min-height: 1.4em;
  font-size: 15px;
  font-weight: 600;
  color: var(--success);
}
.mz-play-message:empty { display: none; }

/* D-pad — three-by-three grid, four arrows in a cross. */
.mz-dpad {
  display: grid;
  grid-template-columns: 56px 56px 56px;
  grid-template-rows: 56px 56px 56px;
  gap: 6px;
}
.mz-dpad-up    { grid-column: 2; grid-row: 1; }
.mz-dpad-left  { grid-column: 1; grid-row: 2; }
.mz-dpad-right { grid-column: 3; grid-row: 2; }
.mz-dpad-down  { grid-column: 2; grid-row: 3; }

.mz-dpad-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  transition: var(--transition-colors), transform 0.06s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.mz-dpad-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.mz-dpad-btn:active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  transform: translateY(1px);
}

.mz-play-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  justify-content: center;
}
.mz-play-actions .btn {
  min-width: 120px;
}

/* ---------- Print ----------
   Goals:
   - One US Letter page, 0.5in margins.
   - Show only the maze itself (no chrome, no controls, no article).
   - Solution overlay stays visible if it's on. */
@media print {
  @page { margin: 0.5in; size: letter portrait; }

  body {
    background: #fff !important;
    color: #000 !important;
  }

  .tool-header,
  .tool-footer,
  .widget-eyebrow,
  .widget-lead,
  .widget-header h1,
  .mz-controls,
  .mz-result-actions,
  .mz-legend,
  .mz-result-meta,
  .mz-play-panel,
  .article,
  .attenda-cta,
  .skip-link {
    display: none !important;
  }

  .widget-wrap {
    padding: 0 !important;
  }
  .widget-card {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    background: #fff !important;
    max-width: none !important;
    width: 100% !important;
  }
  .widget-header {
    padding: 0 !important;
    margin: 0 !important;
  }

  .mz-result {
    border-top: none !important;
    padding: 0 !important;
    margin: 0 !important;
    page-break-inside: avoid !important;
  }
  .mz-result-header {
    margin: 0 !important;
  }

  .mz-svg-wrap {
    box-shadow: none !important;
    border: none !important;
    background: #fff !important;
    padding: 0 !important;
    page-break-inside: avoid !important;
  }
  .mz-svg-wrap svg {
    width: 100% !important;
    height: auto !important;
    max-height: 9.5in;
  }
}
