/* =========================================================
   Sequence Memory — tool-specific styles.
   Layered on /tools/_shared/tool.css.
   ========================================================= */

/* ---------- Panel hues ----------
   Shared tokens only provide a single accent (teal), so the
   four panel colors are introduced here scoped to this tool.
   Hues chosen to be distinguishable in both light and dark
   themes; shape icons are the redundant channel for players
   who can't distinguish them by hue. Pairs that are easy to
   confuse for common colorblindness (green/red) are split by
   shape (circle vs triangle) and tone (low vs second-low).
*/
.sm-grid {
  /* Panel 0 — green (circle, 220 Hz) */
  --sm-p0:        #6FA15C;
  --sm-p0-bright: #A8DD8E;
  --sm-p0-glow:   rgba(168, 221, 142, 0.55);

  /* Panel 1 — coral (triangle, 277 Hz) */
  --sm-p1:        #C56A5B;
  --sm-p1-bright: #F4A797;
  --sm-p1-glow:   rgba(244, 167, 151, 0.55);

  /* Panel 2 — blue (square, 330 Hz) */
  --sm-p2:        #4A7FB8;
  --sm-p2-bright: #8FBDED;
  --sm-p2-glow:   rgba(143, 189, 237, 0.55);

  /* Panel 3 — amber (diamond, 415 Hz) */
  --sm-p3:        #C99A3F;
  --sm-p3-bright: #F2CB6A;
  --sm-p3-glow:   rgba(242, 203, 106, 0.6);
}

/* ---------- Stats row ---------- */
.sm-stats {
  display: flex;
  justify-content: center;
  gap: var(--space-8);
  margin-bottom: var(--space-4);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
}
.sm-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 80px;
}
.sm-stat-num {
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.1;
}
.sm-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---------- Status line ---------- */
.sm-status {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  min-height: 1.5em;
  margin-bottom: var(--space-5);
}
.sm-status.is-watch  { color: var(--accent); }
.sm-status.is-input  { color: var(--text); }
.sm-status.is-good   { color: var(--success); }
.sm-status.is-over   { color: var(--danger); }

/* ---------- Panel grid ---------- */
.sm-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  max-width: 440px;
  margin: 0 auto var(--space-6);
  aspect-ratio: 1 / 1;
}

/* ---------- Panel button ---------- */
.sm-panel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  background: var(--sm-panel-color, var(--surface-2));
  color: var(--accent-fg);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease,
              box-shadow 0.18s ease,
              transform 0.06s ease,
              border-color 0.18s ease,
              filter 0.18s ease;
}
.sm-grid .sm-panel[data-panel="0"] { --sm-panel-color: var(--sm-p0); --sm-panel-bright: var(--sm-p0-bright); --sm-panel-glow: var(--sm-p0-glow); }
.sm-grid .sm-panel[data-panel="1"] { --sm-panel-color: var(--sm-p1); --sm-panel-bright: var(--sm-p1-bright); --sm-panel-glow: var(--sm-p1-glow); }
.sm-grid .sm-panel[data-panel="2"] { --sm-panel-color: var(--sm-p2); --sm-panel-bright: var(--sm-p2-bright); --sm-panel-glow: var(--sm-p2-glow); }
.sm-grid .sm-panel[data-panel="3"] { --sm-panel-color: var(--sm-p3); --sm-panel-bright: var(--sm-p3-bright); --sm-panel-glow: var(--sm-p3-glow); }

/* Dim panels during idle / watch phases so the lit panel pops. */
.sm-grid[data-phase="idle"]  .sm-panel,
.sm-grid[data-phase="watch"] .sm-panel,
.sm-grid[data-phase="over"]  .sm-panel {
  filter: brightness(0.85) saturate(0.85);
}
.sm-grid[data-phase="input"] .sm-panel {
  filter: brightness(1) saturate(1);
}
.sm-grid[data-phase="input"] .sm-panel:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.sm-grid[data-phase="input"] .sm-panel:active {
  transform: translateY(1px);
}

/* The "lit" state — used both when the game flashes a panel
   during sequence playback AND when the player clicks one
   during input phase. */
.sm-panel.is-active {
  background: var(--sm-panel-bright);
  border-color: rgba(255, 255, 255, 0.85);
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.18),
    0 0 32px 6px var(--sm-panel-glow),
    inset 0 0 18px rgba(255, 255, 255, 0.25);
  filter: brightness(1.1) saturate(1.1) !important;
}

/* Wrong-input flash. */
.sm-panel.is-wrong {
  animation: sm-wrong 0.45s ease;
}
@keyframes sm-wrong {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* Disabled panels (watch phase) should not show pointer/focus
   affordances. */
.sm-panel:disabled {
  cursor: default;
}

/* ---------- Shape icon ---------- */
.sm-panel-shape {
  width: 56%;
  height: 56%;
  max-width: 110px;
  max-height: 110px;
  fill: var(--accent-fg);
  opacity: 0.92;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.sm-panel.is-active .sm-panel-shape {
  opacity: 1;
}

/* ---------- Keyboard hint ---------- */
.sm-panel-key {
  position: absolute;
  top: 8px;
  left: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-fg);
  opacity: 0.4;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  user-select: none;
}

/* ---------- Controls ---------- */
.sm-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.sm-controls-row {
  display: flex;
  gap: var(--space-3);
  justify-content: space-between;
}
.sm-controls-row .btn {
  flex: 1;
  min-height: 40px;
  font-size: 13px;
}

/* Mute button toggles its icon visibility based on aria-pressed. */
.sm-icon-muted { display: none; }
#sm-btn-mute[aria-pressed="true"] .sm-icon-sound { display: none; }
#sm-btn-mute[aria-pressed="true"] .sm-icon-muted { display: inline-block; }

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
  .sm-grid { gap: 10px; max-width: 100%; }
  .sm-stats { gap: var(--space-6); }
  .sm-stat-num { font-size: 24px; }
}
