/* ============================================================================
   como-a-ia-le-suas-palavras-tokenizador/app.css
   Styles for the in-browser tokenizer playground only. Scoped under .tok;
   inherits BPSO Lab 2026 tokens from blog.css. Loaded by the post page.
   Works in both dark (default) and [data-theme="light"].
   ========================================================================== */

.tok {
  /* Local fallbacks so the widget is robust even if blog.css tokens shift. */
  --tok-surface: var(--surface, #1e293b);
  --tok-surface-2: var(--surface-2, #243349);
  --tok-text: var(--text-main, #f8fafc);
  --tok-muted: var(--text-muted, #94a3b8);
  --tok-border: var(--border, rgba(255, 255, 255, .08));
  --tok-blue: var(--brand-blue, #2563eb);
  --tok-light: var(--brand-light, #60a5fa);
  --tok-glow: var(--brand-glow, rgba(37, 99, 235, .35));

  /* token chip palette — distinct hues, alternated; tuned for the dark panel */
  --tok-c0: #38bdf8; /* sky    */
  --tok-c1: #a78bfa; /* violet */
  --tok-c2: #34d399; /* green  */
  --tok-c3: #fbbf24; /* amber  */
  --tok-c4: #fb7185; /* rose   */
  --tok-c5: #f472b6; /* pink   */
  --tok-byte: #f97316; /* orange — multi-byte (accents/emoji) stand out */

  font-family: var(--font-body, 'Inter', system-ui, sans-serif);
  color: var(--tok-text);
  display: grid;
  gap: clamp(.9rem, 2.5vw, 1.2rem);
  width: 100%;
}

/* Light theme: panels turn light; the chip view stays on a dark stage so the
   bright token colors keep their punch and contrast. */
[data-theme="light"] .tok {
  --tok-surface: #ffffff;
  --tok-surface-2: #f1f5f9;
  --tok-text: #0f172a;
  --tok-muted: #475569;
  --tok-border: rgba(15, 23, 42, .12);
}

/* ---------------------------------------------------------------- Examples */
/* Just the label + example pills, wrapping naturally and left-aligned. "Limpar"
   used to share this row but got marooned top-right whenever the pills wrapped to a
   second line at reading-column width — it now lives on the textarea header instead. */
.tok__examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}
.tok__examples-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  flex: 1 1 auto;
  min-width: 0;
}
.tok__examples-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--tok-muted);
  margin-right: .1rem;
}
.tok__example {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 40px;
  min-width: 0;
  padding: .42rem .8rem;
  border: 1px dashed color-mix(in srgb, var(--tok-blue) 45%, var(--tok-border));
  background: color-mix(in srgb, var(--tok-blue) 8%, transparent);
  color: var(--tok-text);
  font-family: var(--font-body, system-ui);
  font-weight: 500;
  font-size: .82rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s;
}
.tok__example i { font-size: 1.05rem; line-height: 1; }
.tok__example:hover {
  background: color-mix(in srgb, var(--tok-blue) 18%, transparent);
  border-style: solid;
  transform: translateY(-1px);
}
.tok__example:active { transform: translateY(0); }

.tok__clear {
  appearance: none;
  margin-left: auto;
  flex: 0 0 auto;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 40px;
  padding: .42rem .8rem;
  border: 1px solid var(--tok-border);
  background: transparent;
  color: var(--tok-muted);
  font-family: var(--font-body, system-ui);
  font-weight: 600;
  font-size: .82rem;
  border-radius: 999px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.tok__clear i { font-size: 1.05rem; line-height: 1; }
.tok__clear:hover { color: var(--tok-text); border-color: var(--tok-blue); }

/* ---------------------------------------------------------------- Textarea */
.tok__field { display: grid; gap: .4rem; }
/* Header row above the textarea: field label on the left, "Limpar" pinned to the
   right via margin-left:auto on .tok__clear. Because the label is a single line, the
   clear button can never get marooned: it sits beside the label, or (on very narrow
   widths) wraps to its own line still flush-right. */
.tok__field-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .35rem .75rem;
}
.tok__field-label {
  font-family: var(--font-head, 'Poppins', sans-serif);
  font-weight: 700;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--tok-muted);
}
.tok__input {
  width: 100%;
  resize: vertical;
  min-height: 96px;
  max-height: 320px;
  padding: .9rem 1rem;
  border: 1px solid var(--tok-border);
  border-radius: var(--radius-sm, 10px);
  background: var(--tok-surface);
  color: var(--tok-text);
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: .95rem;
  line-height: 1.55;
  transition: border-color .15s, box-shadow .15s;
}
.tok__input::placeholder { color: var(--tok-muted); opacity: .8; }
.tok__input:focus-visible {
  outline: none;
  border-color: var(--tok-blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tok-blue) 35%, transparent);
}

/* ---------------------------------------------------------------- Chips */
.tok__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-content: flex-start;
  min-height: 64px;
  max-height: 240px;
  overflow-y: auto;
  padding: .85rem;
  border: 1px solid var(--tok-border);
  border-radius: var(--radius-sm, 10px);
  /* Always-dark stage so the bright token colors keep contrast in both themes. */
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .03), transparent 40%),
    #0b1220;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .02);
  line-height: 1.9;
}

.tok__empty {
  color: #64748b;
  font-style: italic;
  font-size: .92rem;
}

.tok__chip {
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: .92rem;
  line-height: 1.4;
  padding: .12em .35em;
  border-radius: 5px;
  white-space: pre;          /* preserve internal/leading spaces in a token */
  color: #0b1220;            /* dark glyph on a bright chip = high contrast */
  background: #cbd5e1;
}

/* alternating hues */
.tok__chip--c0 { background: var(--tok-c0); }
.tok__chip--c1 { background: var(--tok-c1); }
.tok__chip--c2 { background: var(--tok-c2); }
.tok__chip--c3 { background: var(--tok-c3); }
.tok__chip--c4 { background: var(--tok-c4); color: #fff; }
.tok__chip--c5 { background: var(--tok-c5); color: #2a0a1c; }

/* whitespace tokens: faint, show the glyph (· or ↵) */
.tok__chip--space {
  background: rgba(255, 255, 255, .06);
  color: #64748b;
  border: 1px dashed rgba(255, 255, 255, .14);
}

/* multi-byte tokens (accents / emoji) get a hot accent so the cost is obvious */
.tok__chip--byte {
  background: var(--tok-byte);
  color: #1a0d00;
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
}

/* staggered chip reveal (suppressed under reduced motion) */
.tok__chip.is-in {
  animation: tok-pop .22s ease both;
}
@keyframes tok-pop {
  from { opacity: 0; transform: translateY(4px) scale(.92); }
  to   { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------------- Stats */
.tok__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .7rem;
}
.tok__stat {
  display: grid;
  gap: .2rem;
  padding: .7rem .85rem;
  background: var(--tok-surface);
  border: 1px solid var(--tok-border);
  border-radius: var(--radius-sm, 10px);
  text-align: center;
}
.tok__stat-value {
  font-family: var(--font-head, 'Poppins', sans-serif);
  font-weight: 800;
  font-size: clamp(1.2rem, 4vw, 1.5rem);
  line-height: 1;
  color: var(--tok-text);
  font-variant-numeric: tabular-nums;
}
.tok__stat-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--tok-muted);
}
.tok__stat--accent {
  background: color-mix(in srgb, var(--tok-blue) 14%, var(--tok-surface));
  border-color: color-mix(in srgb, var(--tok-blue) 45%, var(--tok-border));
}
.tok__stat--accent .tok__stat-value { color: var(--tok-light); }
[data-theme="light"] .tok__stat--accent .tok__stat-value { color: var(--tok-blue); }

.tok__stat.is-pop .tok__stat-value { animation: tok-bump .4s ease; }
@keyframes tok-bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.16); }
  100% { transform: scale(1); }
}

/* ---------------------------------------------------------------- Cost card */
.tok__cost {
  display: grid;
  gap: .9rem;
  padding: clamp(.9rem, 3vw, 1.2rem);
  background: var(--tok-surface);
  border: 1px solid var(--tok-border);
  border-radius: var(--radius-sm, 10px);
}
.tok__cost-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.tok__cost-title {
  font-family: var(--font-head, 'Poppins', sans-serif);
  font-weight: 700;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--tok-muted);
}
.tok__cost-value {
  font-family: var(--font-head, 'Poppins', sans-serif);
  font-weight: 800;
  font-size: clamp(1.4rem, 5vw, 1.9rem);
  line-height: 1;
  color: var(--tok-light);
  font-variant-numeric: tabular-nums;
}
[data-theme="light"] .tok__cost-value { color: var(--tok-blue); }

/* price slider */
.tok__price { display: grid; gap: .5rem; }
.tok__price-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .8rem;
  flex-wrap: wrap;
}
.tok__price-label { font-size: .82rem; font-weight: 600; color: var(--tok-muted); }
.tok__price-val {
  font-size: .82rem;
  font-weight: 700;
  color: var(--tok-text);
  font-variant-numeric: tabular-nums;
}
.tok__range {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--tok-blue), var(--tok-light));
  cursor: pointer;
  outline-offset: 4px;
}
.tok__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--tok-blue);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  cursor: pointer;
}
.tok__range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--tok-blue);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  cursor: pointer;
}
.tok__range::-moz-range-track { background: transparent; }

/* input / output toggle */
.tok__mode {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  flex-wrap: wrap;
}
.tok__mode-label { font-size: .82rem; font-weight: 600; color: var(--tok-muted); }
.tok__mode-group {
  display: inline-flex;
  border: 1px solid var(--tok-border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--tok-surface-2);
}
.tok__mode-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 38px;
  min-width: 0;
  padding: .4rem .9rem;
  border: 0;
  background: transparent;
  color: var(--tok-muted);
  font-family: var(--font-body, system-ui);
  font-weight: 600;
  font-size: .82rem;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.tok__mode-btn i { font-size: 1.05rem; line-height: 1; }
.tok__mode-btn:hover { color: var(--tok-text); }
.tok__mode-btn.is-active { background: var(--tok-blue); color: #fff; }

/* ---------------------------------------------------------------- Responsive */
/* On narrow screens, keep everything readable and stacked; the textarea +
   chips + stats + cost all stay visible and reachable together. */
@media (max-width: 560px) {
  /* Examples stack as a tidy column: label heads its own line, pills below.
     "Limpar" now lives on the textarea header row (label left, clear flush-right). */
  .tok__examples-group { flex: 1 1 100%; }
  .tok__examples-label { width: 100%; }
  .tok__stats { grid-template-columns: 1fr 1fr; }
  .tok__stat--accent { grid-column: 1 / -1; }
  .tok__chips { max-height: 200px; }
  .tok__mode { flex-direction: column; align-items: stretch; }
  .tok__mode-group { justify-content: stretch; }
  .tok__mode-btn { flex: 1 1 0; justify-content: center; }
}

@media (max-width: 360px) {
  .tok__example .tok-hide-360 { display: none; }
  .tok__chip { font-size: .86rem; }
}

/* ---------------------------------------------------------------- Motion */
@media (prefers-reduced-motion: reduce) {
  .tok__chip.is-in { animation: none; }
  .tok__stat.is-pop .tok__stat-value { animation: none; }
  .tok__example,
  .tok__clear,
  .tok__mode-btn { transition: none; }
}
