/* =============================================
   LuxTool — /text/word-counter/word-counter.css
   Tool-specific styles for the Word Counter Pro tool.
   Site chrome and shared building blocks come from
   /style.css (see other tool style.css files for the full
   list). Note: .stat-box / .stat-num / .stat-label are
   deliberately NOT included here — they're shared between
   this tool and Typing Master (not yet extracted), so they
   remain in the main /style.css until that tool is split
   out too.
   ============================================= */

/* ── WRITING ASSISTANT / WORD COUNTER PRO ── */
.wa-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .wa-layout {
    grid-template-columns: 1fr;
  }
}

.wa-editor-panel {
  position: sticky;
  top: calc(var(--app-nav-h) + 1rem);
}

.wa-editor-container {
  position: relative;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  height: 520px;
}

.wa-backdrop,
.wa-textarea {
  width: 100%;
  height: 100%;
  padding: 1.5rem;
  font-family: 'Inter', sans-serif;
  font-size: 1.05rem;
  line-height: 1.7;
  box-sizing: border-box;
  margin: 0;
}

.wa-textarea {
  position: relative;
  background: transparent;
  color: var(--text);
  border: none;
  resize: none;
  outline: none;
  z-index: 2;
  display: block;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.wa-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  color: transparent;
  white-space: pre-wrap;
  word-wrap: break-word;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.wa-textarea::-webkit-scrollbar {
  width: 8px;
}

.wa-textarea::-webkit-scrollbar-track {
  background: transparent;
}

.wa-textarea::-webkit-scrollbar-thumb {
  background: var(--gold-dim);
  border-radius: 10px;
}

.wa-textarea::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
}

/* Highlighting Styles */
.wa-hl-filler {
  background: rgba(248, 113, 113, 0.25);
  border-bottom: 2px dashed #fca5a5;
}

.wa-hl-long {
  background: rgba(96, 165, 250, 0.15);
  border-bottom: 2px solid rgba(96, 165, 250, 0.3);
}

.wa-hl-repeat {
  background: rgba(251, 191, 36, 0.15);
  border-bottom: 2px solid var(--gold);
}

.wa-side-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.wa-goal-card {
  padding: 1rem;
  background: color-mix(in srgb, var(--text) 5%, var(--surface));
  border: 1px solid var(--border);
  border-radius: 0.8rem;
}

.wa-goal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.wa-goal-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.wa-goal-stats {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold);
}

.wa-progress-track {
  height: 6px;
  background: color-mix(in srgb, var(--text) 12%, var(--surface));
  border-radius: 10px;
  overflow: hidden;
}

.wa-progress-fill {
  height: 100%;
  background: var(--gold);
  width: 0%;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.wa-goal-card.reached .wa-progress-fill {
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

.wa-goal-card.reached .wa-goal-stats {
  color: #4ade80;
}

.wa-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.wa-stat-card {
  padding: 0.8rem;
  background: color-mix(in srgb, var(--text) 7%, var(--surface));
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  text-align: center;
}

.wa-stat-val {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  display: block;
}

.wa-stat-label {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 0.2rem;
  display: block;
}

.wa-keyword-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.wa-keyword-item {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0.6rem;
  background: color-mix(in srgb, var(--text) 4%, var(--surface));
  border-radius: 4px;
  font-size: 0.8rem;
}

.wa-clean-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.75rem;
  background: color-mix(in srgb, var(--text) 4%, var(--surface));
  border-top: 1px solid var(--border);
}

.wa-clean-btn {
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  border-radius: 0.4rem;
  cursor: pointer;
  transition: 0.2s;
}

.wa-clean-btn:hover {
  background: var(--gold-dim);
  transform: translateY(-1px);
}

.wa-toggle-group {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.8rem;
}

.wa-toggle-btn {
  flex: 1;
  padding: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  background: color-mix(in srgb, var(--text) 8%, var(--surface));
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: 0.2s;
}

.wa-toggle-btn.active {
  background: var(--gold-dim);
  color: var(--gold);
  border-color: var(--gold);
}

.wa-counter-animate {
  animation: wa-pop 0.3s ease-out;
}

@keyframes wa-pop {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.08);
    color: var(--gold);
  }

  100% {
    transform: scale(1);
  }
}

@media (max-width: 600px) {
  .wa-editor-container {
    height: 380px;
  }

  .wa-textarea,
  .wa-backdrop {
    font-size: 0.95rem;
  }
}

/* ============================================================
   ADDITIONS — v2 improvements
   Always-on stat bar, presets, readability, keyword controls,
   quality summary, export actions. Reuses existing tokens
   (--gold, --surface, --border, --muted, --text, --radius).
   ============================================================ */

/* ── Always-on stat bar (sits directly against the editor) ── */
.wa-count-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

@media (max-width: 520px) {
  .wa-count-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}

.wa-count-cell {
  padding: 0.6rem 0.5rem;
  background: color-mix(in srgb, var(--text) 7%, var(--surface));
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  text-align: center;
}

.wa-count-cell.primary {
  background: rgba(251, 191, 36, 0.08);
  border-color: var(--gold-dim);
}

.wa-count-num {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  display: block;
  line-height: 1.1;
}

.wa-count-cell.primary .wa-count-num {
  color: var(--gold);
}

.wa-count-lbl {
  font-size: 0.6rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.25rem;
  display: block;
}

/* ── Export action row ── */
.wa-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.wa-action-btn {
  flex: 1;
  min-width: 120px;
  padding: 0.55rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  background: color-mix(in srgb, var(--text) 8%, var(--surface));
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: 0.2s;
}

.wa-action-btn:hover {
  border-color: var(--gold);
  transform: translateY(-1px);
}

.wa-action-btn.done {
  border-color: #22c55e;
  color: #4ade80;
}

/* ── Preset target chips ── */
.wa-preset-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.wa-preset {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.65rem;
  background: color-mix(in srgb, var(--text) 7%, var(--surface));
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold-dim);
  border-radius: 0.45rem;
  font-size: 0.8rem;
}

.wa-preset-name {
  color: var(--text);
  font-weight: 500;
}

.wa-preset-count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
}

.wa-preset.near {
  border-left-color: var(--gold);
}

.wa-preset.near .wa-preset-count {
  color: var(--gold);
}

.wa-preset.over {
  border-left-color: #f87171;
  background: rgba(248, 113, 113, 0.08);
}

.wa-preset.over .wa-preset-count {
  color: #fca5a5;
  font-weight: 600;
}

/* ── Readability block ── */
.wa-read-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.wa-read-main {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.7rem 0.8rem;
  background: color-mix(in srgb, var(--text) 7%, var(--surface));
  border: 1px solid var(--border);
  border-radius: 0.55rem;
}

.wa-read-score {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--gold);
  line-height: 1;
}

.wa-read-desc {
  font-size: 0.75rem;
  color: var(--muted);
}

.wa-read-desc strong {
  color: var(--text);
  display: block;
  font-size: 0.8rem;
  margin-bottom: 0.1rem;
}

.wa-read-sub {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.wa-read-sub .wa-stat-card {
  text-align: left;
  padding: 0.6rem 0.7rem;
}

/* ── Keyword controls ── */
.wa-kw-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.6rem 0 0.2rem;
}

.wa-kw-phrase {
  display: flex;
  gap: 0.25rem;
}

.wa-kw-phrase-btn {
  padding: 0.25rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  background: color-mix(in srgb, var(--text) 8%, var(--surface));
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 0.4rem;
  cursor: pointer;
  transition: 0.2s;
}

.wa-kw-phrase-btn.active {
  background: var(--gold-dim);
  color: var(--gold);
  border-color: var(--gold);
}

.wa-kw-toggle {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: auto;
  cursor: pointer;
  user-select: none;
}

.wa-kw-term {
  color: var(--text);
}

.wa-kw-meta {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
}

.wa-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 1rem;
}

/* ── Writing-quality summary ── */
.wa-quality-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.wa-quality-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.35rem 0.1rem;
}

.wa-quality-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #22c55e;
}

.wa-quality-row.filler .wa-quality-dot { background: #22c55e; }
.wa-quality-row.long .wa-quality-dot { background: #22c55e; }
.wa-quality-row.repeat .wa-quality-dot { background: #22c55e; }

.wa-quality-val.flagged { color: var(--text); font-weight: 500; }
.wa-quality-row.filler .wa-quality-val.flagged ~ .wa-quality-dot,
.wa-quality-row .wa-quality-val.flagged { }

/* Recolour dot when the row is flagged */
.wa-quality-row.filler:has(.flagged) .wa-quality-dot { background: #f87171; }
.wa-quality-row.long:has(.flagged) .wa-quality-dot { background: #60a5fa; }
.wa-quality-row.repeat:has(.flagged) .wa-quality-dot { background: var(--gold); }

/* ── WPM inline inputs ── */
.wa-wpm-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.wa-wpm-field {
  flex: 1;
}

.wa-wpm-field label {
  font-size: 0.62rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 0.2rem;
}

.wa-wpm-field input {
  width: 100%;
  padding: 0.3rem 0.5rem;
  height: 30px;
  font-size: 0.8rem;
  box-sizing: border-box;
}

/* ── SEO reference tables ── */
.wa-ref-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.6rem 0 0.2rem;
  font-size: 0.85rem;
}

.wa-ref-table th,
.wa-ref-table td {
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--border);
}

.wa-ref-table th {
  color: var(--gold);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.wa-ref-table td {
  color: var(--muted);
}

.wa-ref-table td:first-child {
  color: var(--text);
}

/* ── Editor: on phones, keep the count bar above the editor (already
   in source order), and ensure the sticky panel doesn't hide it. ── */
@media (max-width: 900px) {
  .wa-editor-panel {
    position: static;
  }
}
