/* Gogen page styles. Colours come from the neon theme variables in static/neon.css. */

/* ── Grid ──────────────────────────────────────────────── */
.grid-wrap { position: relative; width: min(350px, 92vw); margin: 0 auto; }
#gogen-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  width: 100%;
  aspect-ratio: 1;
  user-select: none;
}
#path-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.g-cell {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 700; font-family: monospace;
  border-radius: 6px; border: 2px solid var(--border-dim);
  background: var(--bg-card); color: var(--text-main);
  transition: background .2s, border-color .2s, transform .15s, box-shadow .2s;
  position: relative; touch-action: manipulation; cursor: pointer;
}
.g-cell:focus-visible { outline: 2px solid var(--neon-cyan); outline-offset: 2px; }
.g-cell.given {
  background: rgba(191,90,255,.12); color: var(--neon-purple); border-color: var(--neon-purple);
  text-shadow: 0 0 8px var(--neon-purple); box-shadow: 0 0 8px rgba(191,90,255,.2); cursor: default;
}
.g-cell.placed { background: rgba(57,255,20,.07); border-color: var(--neon-green); color: var(--neon-green); text-shadow: 0 0 6px var(--neon-green); }
.g-cell.highlight { border-color: var(--neon-yellow); box-shadow: 0 0 0 3px rgba(255,230,0,.22); }
.g-cell.selected { border-color: var(--neon-cyan); box-shadow: 0 0 0 3px rgba(0,245,255,.3); background: rgba(0,245,255,.1); }
.g-cell.active-letter { box-shadow: 0 0 0 3px rgba(0,245,255,.55); }
.g-cell.candidate { border-color: var(--neon-cyan); background: rgba(0,245,255,.09); }
.g-cell.focus { border-color: var(--neon-yellow); background: rgba(255,230,0,.13); box-shadow: 0 0 0 3px rgba(255,230,0,.28); }
.g-cell.touch { border-color: var(--neon-cyan); background: rgba(0,245,255,.16); }
.g-cell.conflict { border-color: #ff4d6d; background: rgba(255,77,109,.14); color: #ff8fa3; text-shadow: none; }
.g-cell.mistake { border-color: #ff4d6d; background: rgba(255,77,109,.22); color: #fff; animation: shake .4s; }
.g-cell.flash { animation: cell-flash .6s ease; }
@keyframes cell-flash {
  0%   { background: rgba(255,230,0,.35); border-color: var(--neon-yellow); color: var(--neon-yellow); transform: scale(1.15); box-shadow: 0 0 22px rgba(255,230,0,.6); }
  100% { background: rgba(57,255,20,.07); border-color: var(--neon-green); color: var(--neon-green); transform: scale(1); }
}
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.g-cell .ncount {
  position: absolute; bottom: 2px; right: 4px; font-size: .55rem; font-weight: 400;
  font-family: sans-serif; color: var(--neon-yellow); display: none;
}
#gogen-grid.show-counts .ncount { display: block; }
.g-cell .marks {
  position: absolute; inset: 2px; display: grid; grid-template-columns: repeat(3, 1fr); align-items: center;
  justify-items: center; font-size: .5rem; font-weight: 400; line-height: 1; color: var(--text-dim);
  pointer-events: none;
}
.g-cell .marks.many { display: flex; align-items: flex-end; justify-content: flex-end; padding: 0 3px 2px 0; font-size: .6rem; }
.g-cell .marks .on { color: var(--neon-cyan); font-weight: 700; }

/* ── Letter bank (tap to place or inspect) ─────────────── */
#letter-bank { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin-top: 10px; }
.bank-letter {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  font-size: .9rem; font-weight: 700; font-family: monospace; border-radius: 5px;
  border: 1px solid var(--border-dim); background: var(--bg-surface); color: var(--text-main);
  transition: opacity .3s, background .15s; cursor: pointer; padding: 0; touch-action: manipulation;
}
.bank-letter:hover { background: #12122a; }
.bank-letter.placed { opacity: .35; text-decoration: line-through; }
.bank-letter.active { border-color: var(--neon-cyan); box-shadow: 0 0 0 2px rgba(0,245,255,.4); opacity: 1; }
.bank-letter.focus { border-color: var(--neon-yellow); box-shadow: 0 0 0 2px rgba(255,230,0,.4); opacity: 1; }

/* ── Controls under the grid ───────────────────────────── */
.grid-tools { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }
.grid-toggles { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 8px; font-size: .8rem; }

/* ── Status strip ──────────────────────────────────────── */
#status-strip {
  display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; font-family: monospace; font-size: .8rem;
  color: var(--text-dim); margin-bottom: 10px;
}
#status-strip b { color: var(--neon-cyan); font-weight: 600; }
#result-banner {
  border: 1px solid var(--neon-green); background: rgba(57,255,20,.08); color: var(--neon-green);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; font-family: monospace;
}

/* ── Section headings ──────────────────────────────────── */
.g-heading {
  font-family: monospace; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--neon-cyan); text-shadow: 0 0 6px rgba(0,245,255,.4); margin-bottom: 8px; font-weight: 600;
}

/* ── Word list ─────────────────────────────────────────── */
.word-row {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 4px; cursor: pointer;
  transition: background .15s; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.word-row:hover, .word-row.active { background: #0e0e22; }
.word-row.active { border-left: 2px solid var(--neon-cyan); }
.word-row.focus { background: rgba(255,230,0,.1); }
.word-row .wlabel { font-family: monospace; font-weight: 600; font-size: .95rem; letter-spacing: 1px; }
.word-row .wstate { margin-left: auto; font-size: .8rem; }
.word-row.broken .wstate { color: #ff4d6d; }
.word-row.complete .wstate { color: var(--neon-green); }
.wl { display: inline-block; width: 1.1em; text-align: center; }
.wl.placed { color: var(--neon-green); text-shadow: 0 0 5px rgba(57,255,20,.4); }
.wl.unplaced { color: var(--text-dim); }

/* ── Coach (current hint / message) ────────────────────── */
#coach {
  border-left: 3px solid var(--neon-cyan); background: var(--bg-surface); border-radius: 0 6px 6px 0;
  padding: 10px 12px; font-size: .92rem; min-height: 3.2rem; margin-bottom: 10px; color: var(--text-main);
}
#coach.warn { border-color: var(--neon-orange); }
#coach.error { border-color: #ff4d6d; }
#coach.success { border-color: var(--neon-green); }
#coach .coach-title { font-family: monospace; font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-dim); margin-bottom: 2px; }
.coach-actions { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Inspector + neighbour web ─────────────────────────── */
#inspector { font-size: .85rem; background: var(--bg-surface); border-radius: 6px; padding: 8px 10px; margin-bottom: 10px; }
#inspector .insp-letter { font-family: monospace; font-weight: 700; font-size: 1.1rem; color: var(--neon-cyan); }
.chip { display: inline-block; font-family: monospace; border: 1px solid var(--border-dim); border-radius: 4px; padding: 0 5px; margin: 0 2px; }
.chip.on { border-color: var(--neon-green); color: var(--neon-green); }
#web-table { font-family: monospace; font-size: .8rem; width: 100%; }
#web-table td { padding: 2px 6px; vertical-align: top; }
#web-table tr { cursor: pointer; }
#web-table tr:hover { background: #0e0e22; }
#web-table .need { color: var(--text-dim); font-size: .7rem; }

/* ── Hint log ──────────────────────────────────────────── */
#hint-log { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.hint-card { border-left: 3px solid var(--neon-cyan); padding: 6px 10px; background: var(--bg-surface); border-radius: 0 4px 4px 0; font-size: .85rem; color: var(--text-main); }
.hint-card .letter-badge {
  display: inline-block; width: 24px; height: 24px; line-height: 24px; text-align: center; border-radius: 4px;
  font-weight: 700; font-family: monospace; background: var(--neon-cyan); color: #000; margin-right: 6px; font-size: .9rem;
}
.hint-card .tech { float: right; font-size: .65rem; font-family: monospace; text-transform: uppercase; letter-spacing: .06em; color: var(--neon-orange); }
.hint-card.given-card { border-color: var(--neon-purple); }
.hint-card.given-card .letter-badge { background: var(--neon-purple); color: #fff; }

/* ── Tutorial ──────────────────────────────────────────── */
#tutorial {
  border: 1px solid var(--neon-cyan); background: rgba(0,245,255,.06); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 14px; box-shadow: 0 0 20px rgba(0,245,255,.08);
}
#tutorial h5 { font-family: monospace; color: var(--neon-cyan); margin-bottom: 6px; }
#tutorial .tut-dots { display: flex; gap: 6px; margin-bottom: 8px; }
#tutorial .tut-dots span { width: 22px; height: 4px; border-radius: 2px; background: var(--border-dim); }
#tutorial .tut-dots span.done { background: var(--neon-cyan); }

/* ── Custom puzzle panel ───────────────────────────────── */
#custom-grid-input { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; width: min(220px, 80vw); }
.custom-cell-input {
  width: 100%; aspect-ratio: 1; text-align: center; font-size: 1rem; font-weight: 700; font-family: monospace;
  text-transform: uppercase; border: 1px solid var(--border-dim); border-radius: 4px; background: var(--bg-base);
  color: var(--text-main); padding: 0;
}
.custom-cell-input:focus { outline: 2px solid var(--neon-cyan); border-color: transparent; box-shadow: none; }

button, .btn, .puzzle-btn { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

@media (max-width: 576px) {
  .bank-letter { width: 38px; height: 38px; }
  #letter-bank { gap: 6px; }
  #custom-grid-input { width: min(290px, 90vw); }
  .custom-cell-input { font-size: 1.1rem; }
  #hint-log { max-height: 200px; }
}
@media (prefers-reduced-motion: reduce) {
  .g-cell, .g-cell.flash, .g-cell.mistake { animation: none; transition: none; }
}
