/* LocalMinesweeper: visual styles (HearthLoop implementation slot). */
/* Implementation pending. */

:root {
  --bg: #121212;
  --surface: #1e1e1e;
  --surface-hover: #2c2c2c;
  --border: #333;
  --text: #e0e0e0;
  --text-muted: #888;
  --accent: #bb86fc;
  --accent-active: #9965f4;
  --danger: #cf6679;
  --success: #03dac6;
  --warning: #ffb74d;
  --columns: 9;
  /* Ensure board fits in 320px viewport without horizontal overflow */
  --cell-size: min(32px, calc((100vw - 40px) / var(--columns)));
}

* { box-sizing: border-box; }

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

h1 { margin: 0.5rem 0; font-size: 1.5rem; }

nav {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
  flex-wrap: wrap;
  justify-content: center;
}

button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s, border-color 0.2s;
}

button:hover { background: var(--surface-hover); }

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Flag mode toggle active state */
#flag-mode[aria-pressed="true"] {
  background: var(--accent-active);
  border-color: var(--accent);
  color: #000;
  font-weight: bold;
}

#status {
  margin: 0.5rem 0;
  font-weight: bold;
  min-height: 1.2em;
}

.mines-timer {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  font-family: monospace;
  font-size: 1.1rem;
}

/* Board Grid Layout */
.board {
  display: grid;
  grid-template-columns: repeat(var(--columns), 1fr);
  gap: 2px;
  background: var(--border);
  padding: 2px;
  border-radius: 4px;
  width: fit-content;
  margin: 0 auto;
}

/* Scrollable board container for large boards */
main {
  display: block;
  width: 100%;
  min-width: 0;
  overflow-x: auto;
}

/* Cell Base Styles */
.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  min-width: 24px;
  min-height: 24px;
  background: var(--surface);
  border: none;
  color: var(--text);
  font-weight: bold;
  font-size: calc(var(--cell-size) * 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.cell:hover:not(:disabled):not(.revealed) {
  background: var(--surface-hover);
}

/* Visible keyboard focus */
.cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 1;
}

/* Revealed states */
.cell.revealed {
  background: #2a2a2a;
  cursor: default;
}

/* Number colors for revealed cells (data-adjacent) */
.cell[data-adjacent="1"] { color: #5c9aff; }
.cell[data-adjacent="2"] { color: #4caf50; }
.cell[data-adjacent="3"] { color: #ff5252; }
.cell[data-adjacent="4"] { color: #9c27b0; }
.cell[data-adjacent="5"] { color: #ff9800; }
.cell[data-adjacent="6"] { color: #00bcd4; }
.cell[data-adjacent="7"] { color: #795548; }
.cell[data-adjacent="8"] { color: #607d8b; }

/* Flagged state */
.cell.flagged::after {
  content: "🚩";
}

/* Mine states */
.cell.mine {
  background: var(--danger);
  color: #fff;
}

.cell.exploded {
  background: #ff1744;
  animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Disabled state for revealed cells */
.cell:disabled {
  cursor: default;
}

/* Help panel */
.help-panel {
  width: min(60ch, 100%);
  margin: 0.5rem 0;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.help-panel summary {
  cursor: pointer;
  font-weight: bold;
  color: var(--accent);
  user-select: none;
}

.help-panel summary:hover {
  text-decoration: underline;
}

.help-content {
  margin-top: 0.5rem;
  line-height: 1.5;
}

.help-image {
  width: 100%;
  height: auto;
  max-height: 180px;
  object-fit: contain;
  display: none;
  margin-bottom: 0.5rem;
}

.help-image.loaded {
  display: block;
}

.help-content ul {
  margin: 0.25rem 0;
  padding-left: 1.25rem;
}

.help-content li {
  margin-bottom: 0.25rem;
}

/* Responsive adjustments */
@media (max-width: 320px) {
  :root {
    --cell-size: calc((100vw - 40px) / var(--columns));
  }
  
  body { padding: 0.5rem; }
  
  h1 { font-size: 1.2rem; }
  
  button { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
}

@media (min-width: 768px) {
  :root {
    --cell-size: min(40px, calc((100vw - 200px) / var(--columns)));
  }
  
  body { padding: 2rem; }
}
