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

/* This tool keeps the shared widget-card default width (600px) until a
   puzzle is generated, then expands to fit the puzzle + padding. JS
   adds the `is-result-shown` class on the first successful generate. */
.widget-card {
  transition: max-width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.widget-card.is-result-shown {
  max-width: 720px;
}

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

.ws-field { display: flex; flex-direction: column; gap: var(--space-2); }
.ws-field label,
.ws-field-label-block {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}
.ws-field-hint {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--text-subtle);
  margin-left: 6px;
}
.ws-field-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}
.ws-status {
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}
.ws-status strong { color: var(--text); font-weight: 700; }

.ws-field input[type="text"],
.ws-field select,
.ws-field textarea {
  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);
}
.ws-field textarea {
  resize: vertical;
  min-height: 140px;
  line-height: 1.55;
  padding: var(--space-4);
  font-family: var(--font-mono);
  font-size: 14px;
}
.ws-field textarea::placeholder { color: var(--text-subtle); white-space: pre-line; }
.ws-field input:focus,
.ws-field select:focus,
.ws-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.ws-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

.ws-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-4);
}
.ws-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}
.ws-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.ws-hint {
  margin: var(--space-2) 0 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
.ws-hint.is-good { color: var(--success); }
.ws-hint.is-warn { color: var(--warning); }
.ws-hint.is-error { color: var(--danger); }

.ws-helper-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.ws-helper-actions .btn { flex: 0 0 auto; }

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

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

.ws-progress {
  margin: 0 0 var(--space-4);
  font-size: 14px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.ws-progress strong { color: var(--text); font-weight: 700; }

/* ---------- Grid ---------- */
.ws-grid-wrap {
  /* Cap puzzle width on the wider card so cells don't get visually
     enormous on small grids (10x10 on a 960px card would be 96px cells). */
  max-width: 640px;
  margin: 0 auto var(--space-5);
}
.ws-grid-stack {
  position: relative;
  width: 100%;
}
.ws-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}
.ws-overlay-line {
  fill: none;
  stroke-linecap: round;
}
.ws-overlay-line.is-found {
  stroke: var(--accent);
  opacity: 0.45;
}
.ws-overlay-line.is-revealed {
  stroke: var(--warning);
  opacity: 0.5;
}
.ws-grid {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-weight: 600;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.ws-cell {
  /* Square cells fluid to container; clamp font so letters stay legible
     across grid sizes from small (10) to large (20). border-box +
     padding keeps the cell square while giving the letter more
     breathing room inside it. */
  aspect-ratio: 1 / 1;
  box-sizing: border-box;
  padding: 4px;
  text-align: center;
  vertical-align: middle;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: clamp(10px, 1.9vw, 17px);
  cursor: crosshair;
  transition: background-color 0.08s ease, color 0.08s ease;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.ws-cell.is-selecting {
  background: var(--accent-soft-bg);
  color: var(--accent-soft-fg);
}

/* ---------- Word list ---------- */
.ws-wordlist-wrap .section-eyebrow { margin-bottom: var(--space-3); }
.ws-wordlist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-2) var(--space-4);
}
.ws-wordlist li {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  padding: 4px 0;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  transition: opacity 0.18s ease, color 0.18s ease;
}
.ws-wordlist li.is-found {
  text-decoration: line-through;
  color: var(--text-muted);
  opacity: 0.7;
}
.ws-wordlist li.is-skipped {
  color: var(--danger);
  font-style: normal;
}
.ws-wordlist li.is-skipped::after {
  content: " (didn't fit)";
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  text-transform: none;
}

/* ---------- Print ----------
   Goals:
   - One US Letter portrait page if at all possible.
   - Black & white only — no colors, no transitions, no chrome.
   - Show only: puzzle title, grid, word list. Nothing else.
   - Reset interactive state (found/revealed/skipped) so the printout
     looks like a fresh puzzle handed out, not the screen mid-play. */
@media print {
  @page { margin: 0.5in; size: letter portrait; }

  body {
    background: #fff !important;
    color: #000 !important;
    font-family: ui-sans-serif, system-ui, sans-serif !important;
  }

  /* Hide everything except the puzzle artifact. */
  .tool-header,
  .tool-footer,
  .widget-eyebrow,
  .widget-lead,
  .widget-header h1,
  .ws-controls,
  .ws-result-actions,
  .ws-progress,
  .article,
  .concept-block,
  .skip-link,
  .ws-overlay,
  .ws-wordlist li.is-skipped {
    display: none !important;
  }

  /* Card → no chrome, full width. */
  .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;
    border: none !important;
  }

  /* Result → no separator, snug to top. */
  .ws-result {
    border-top: none !important;
    padding: 0 !important;
    margin: 0 !important;
    page-break-inside: avoid !important;
  }
  .ws-result-header {
    text-align: center !important;
    margin: 0 0 14px !important;
    display: block !important;
  }
  .ws-result-title {
    color: #000 !important;
    font-size: 22px !important;
    font-weight: 700 !important;
    margin: 0 !important;
    line-height: 1.2 !important;
  }
  .ws-result-meta {
    color: #555 !important;
    font-size: 11px !important;
    margin: 4px 0 0 !important;
  }

  /* Grid → centered, fixed cell size, crisp black borders. */
  .ws-grid-wrap {
    overflow: visible !important;
    page-break-inside: avoid !important;
    text-align: center !important;
    max-width: none !important;
    margin: 0 auto 18px !important;
  }
  .ws-grid-stack {
    display: inline-block !important;
    width: auto !important;
  }
  .ws-grid {
    width: auto !important;
    table-layout: auto !important;
    border-collapse: collapse !important;
    margin: 0 auto !important;
    border: 1.5px solid #000 !important;
  }
  .ws-cell {
    width: 26px !important;
    height: 26px !important;
    aspect-ratio: auto !important;
    padding: 0 !important;
    font-size: 13px !important;
    background: #fff !important;
    color: #000 !important;
    border: 0.5px solid #999 !important;
    transition: none !important;
    font-weight: 500 !important;
  }
  /* Reset all interactive state in print — the printout is a fresh
     puzzle; we don't want strikethroughs or "found" marks. */
  .ws-cell.is-selecting {
    background: #fff !important;
    color: #000 !important;
    outline: none !important;
  }

  /* Word list → 4-column grid, monospace, plain. */
  .ws-wordlist-wrap {
    page-break-inside: avoid !important;
  }
  .ws-wordlist-wrap .section-eyebrow {
    text-align: center !important;
    color: #555 !important;
    font-size: 10px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.16em !important;
    margin: 0 0 8px !important;
    border: none !important;
    padding: 0 !important;
  }
  .ws-wordlist {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 3px 16px !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
  }
  .ws-wordlist li {
    color: #000 !important;
    opacity: 1 !important;
    text-decoration: none !important;
    font-size: 11px !important;
    padding: 1px 0 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    font-variant-numeric: tabular-nums !important;
  }
  .ws-wordlist li.is-found {
    color: #000 !important;
    opacity: 1 !important;
    text-decoration: none !important;
  }
  .ws-wordlist li.is-skipped::after {
    content: '' !important;
  }
}
