/* ═══════════════════════════════════════════════════
   Crucigrama — styles
   ═══════════════════════════════════════════════════ */

/* ── Outer wrapper ─────────────────────────────────── */
.cw-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: .5rem;
  container-type: size;
  overflow: hidden;
  padding: .4rem;
  box-sizing: border-box;
}

/* ── Header ────────────────────────────────────────── */
.cw-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-shrink: 0;
  padding: .4rem .75rem;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  border-radius: .6rem;
  color: #fff;
}
.cw-title {
  font-weight: 700;
  font-size: clamp(.8rem, 2.2cqw, 1.05rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}
.cw-progress-wrap {
  width: clamp(60px, 10cqw, 140px);
  height: 8px;
  background: rgba(255,255,255,.2);
  border-radius: 4px;
  flex-shrink: 0;
  overflow: hidden;
}
.cw-progress-bar {
  height: 100%;
  background: #4ade80;
  border-radius: 4px;
  transition: width .35s ease;
}
.cw-progress-txt {
  font-size: .78rem;
  color: #94a3b8;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* ── Body: clues + grid ────────────────────────────── */
.cw-body {
  display: flex;
  gap: .6rem;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

/* ── Clues sidebar ─────────────────────────────────── */
.cw-clues {
  width: clamp(130px, 24cqw, 240px);
  flex-shrink: 0;
  overflow-y: auto;
  font-size: clamp(.68rem, 1.7cqw, .9rem);
  padding-right: .25rem;
  background: var(--ww-bg-soft, #f8fafc);
  color: var(--ww-card-fg, var(--ww-fg, #1e293b));
  border-radius: .5rem;
  padding: .5rem .5rem .5rem .5rem;
  border: 1px solid var(--ww-card-border, #e2e8f0);
}
.cw-clue-section { margin-bottom: .6rem; }
.cw-clue-heading {
  font-weight: 800;
  font-size: clamp(.63rem, 1.5cqw, .78rem);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #475569;
  margin-bottom: .3rem;
  border-bottom: 2px solid #cbd5e1;
  padding-bottom: .2rem;
}
.cw-clue {
  padding: .22rem .35rem;
  border-radius: .3rem;
  cursor: pointer;
  line-height: 1.4;
  transition: background .1s;
  border-left: 3px solid transparent;
}
.cw-clue:hover       { background: #f1f5f9; }
.cw-clue-active      { background: #fef9c3 !important; border-left-color: #eab308; font-weight: 600; }
.cw-clue-solved      { color: #16a34a; text-decoration: line-through; opacity: .65; }
.cw-clue-wrong       { color: #dc2626; border-left-color: #dc2626; }

/* ── Grid wrapper ──────────────────────────────────── */
.cw-grid-wrap {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;        /* critical: lets flex child shrink */
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size; /* enables cqw/cqh on .cw-grid */
}

/* ── Grid ──────────────────────────────────────────── */
.cw-grid {
  display: grid;
  grid-template-columns: repeat(var(--cw-cols, 10), var(--cw-cell, 36px));
  grid-template-rows:    repeat(var(--cw-rows, 10), var(--cw-cell, 36px));
  gap: 2px;
  background: #1e293b;
  border: 3px solid #1e293b;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
}

/* ── Cell base ─────────────────────────────────────── */
.cw-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width:  var(--cw-cell, 36px);
  height: var(--cw-cell, 36px);
  user-select: none;
}
.cw-blocked {
  background: #1e293b;
}
.cw-white {
  background: var(--ww-card-bg, #ffffff);
  cursor: pointer;
  outline: none;
  transition: background .1s;
}
.cw-white:focus { outline: 2px solid #3b82f6; outline-offset: -2px; }

.cw-num {
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: max(6px, calc(var(--cw-cell, 36px) * 0.27));
  line-height: 1;
  color: var(--ww-card-fg, var(--ww-fg, #64748b));
  opacity: .6;
  font-weight: 700;
  pointer-events: none;
}

.cw-letter {
  font-size: max(10px, calc(var(--cw-cell, 36px) * 0.55));
  font-weight: 900;
  line-height: 1;
  color: var(--ww-card-fg, var(--ww-fg, #0f172a));
  text-transform: uppercase;
  pointer-events: none;
}

/* ── Cell states ───────────────────────────────────── */
.cw-active-word { background: #dbeafe; }
.cw-active-cell { background: #fde68a !important; }

.cw-correct-word              { background: #bbf7d0 !important; }
.cw-correct-word .cw-letter   { color: #15803d; }

.cw-wrong-word                { background: #fee2e2 !important; }

.cw-wrong-letter { color: #dc2626 !important; }
.cw-hint-letter  { color: #2563eb !important; }

/* ── Footer ────────────────────────────────────────── */
.cw-footer {
  display: flex;
  gap: .5rem;
  flex-shrink: 0;
}

/* ── Celebration overlay ───────────────────────────── */
.cw-celebration {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  border-radius: inherit;
  backdrop-filter: blur(3px);
}
.cw-celeb-box {
  background: var(--ww-card-bg, #fff);
  color: var(--ww-card-fg, var(--ww-fg, #0f172a));
  border-radius: 1.25rem;
  padding: 2rem 2.5rem;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
  animation: cw-pop .35s cubic-bezier(.34,1.56,.64,1);
}
@keyframes cw-pop {
  from { transform: scale(.6); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}

/* ── Editor preview mini-cells ─────────────────────── */
.cw-pre-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ww-card-bg, #fff);
  border: 1px solid var(--ww-card-border, #94a3b8);
}
.cw-pre-blk { background: #1e293b; }

/* ── Responsive: stack clues below grid on small cq ── */
@container (max-width: 480px) {
  .cw-body        { flex-direction: column-reverse; }
  .cw-clues       { width: 100%; max-height: 110px; overflow-y: auto; }
}
