/* Text tool styles. Every selector is scoped under .pocuvo-text; no global rules.
   Colours come only from the --pocuvo-text-* tokens below (light defaults), so a
   host page can theme the tool by redefining them on .pocuvo-text. */
.pocuvo-text {
  --pocuvo-text-accent: #1f4fd1;
  --pocuvo-text-accent-dark: #183ea6;
  --pocuvo-text-accent-soft: #eaf0fc;
  --pocuvo-text-accent-text: #ffffff;
  --pocuvo-text-primary: #1f4fd1;
  --pocuvo-text-primary-hover: #183ea6;
  --pocuvo-text-surface: #ffffff;
  --pocuvo-text-field-bg: #ffffff;
  --pocuvo-text-readonly-bg: #f4f5f7;
  --pocuvo-text-border: #5f6672;
  --pocuvo-text-muted: #3f4650;
  --pocuvo-text-focus: #1f4fd1;
  --pocuvo-text-error: #a40e26;
  --pocuvo-text-error-bg: #fdf0f1;
  --pocuvo-text-warning-bg: #fff6e0;
  --pocuvo-text-warning-border: #e0c27a;
  --pocuvo-text-info-bg: #eef3fc;
  --pocuvo-text-info-border: #c3d3f2;
  --pocuvo-text-disabled-bg: #e9edf2;
  --pocuvo-text-disabled-border: #c9d0d9;
  --pocuvo-text-disabled-text: #5b6472;
  box-sizing: border-box;
  max-width: 100%;
  font-size: 1rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.pocuvo-text *,
.pocuvo-text *::before,
.pocuvo-text *::after {
  box-sizing: inherit;
}

.pocuvo-text .pocuvo-text__heading {
  font-size: 1.5em;
  margin: 0 0 0.5em;
}

.pocuvo-text .pocuvo-text__intro,
.pocuvo-text .pocuvo-text__help,
.pocuvo-text .pocuvo-text__hint {
  margin: 0.25em 0 0.75em;
}

.pocuvo-text .pocuvo-text__help,
.pocuvo-text .pocuvo-text__hint {
  color: var(--pocuvo-text-muted);
  font-size: 0.9375em;
}

.pocuvo-text .pocuvo-text__notes {
  margin: 0 0 1em;
  padding-left: 1.25em;
}

.pocuvo-text .pocuvo-text__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25em;
}

.pocuvo-text .pocuvo-text__pane,
.pocuvo-text .pocuvo-text__controls {
  min-width: 0;
}

.pocuvo-text .pocuvo-text__label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.25em;
}

/* Current/max counters above the textarea: the current value is larger and bold, the limit muted.
   The two items wrap onto separate lines on narrow screens instead of overflowing. */
.pocuvo-text .pocuvo-text__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25em 1.25em;
  margin: 0 0 0.25em;
  padding: 0.375em 0.75em;
  background: var(--pocuvo-text-info-bg);
  border: 1px solid var(--pocuvo-text-info-border);
  border-radius: 0.5rem;
}

.pocuvo-text .pocuvo-text__stat {
  margin: 0;
  min-width: 0;
}

.pocuvo-text .pocuvo-text__stat-label {
  font-weight: 600;
}

.pocuvo-text .pocuvo-text__stat-current {
  font-size: 1.25em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.pocuvo-text .pocuvo-text__stat-limit {
  color: var(--pocuvo-text-muted);
  font-size: 0.9375em;
}

.pocuvo-text .pocuvo-text__stat[data-over="true"] .pocuvo-text__stat-current,
.pocuvo-text .pocuvo-text__stat-over {
  color: var(--pocuvo-text-error);
}

.pocuvo-text .pocuvo-text__stat-over {
  font-weight: 700;
}

/* Never below 16px so mobile browsers do not zoom on focus. */
.pocuvo-text .pocuvo-text__textarea {
  display: block;
  width: 100%;
  min-height: 12em;
  padding: 0.625em 0.75em;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: max(1em, 16px);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 4;
  color: inherit;
  background: var(--pocuvo-text-field-bg);
  border: 1px solid var(--pocuvo-text-border);
  border-radius: 0.5rem;
  resize: vertical;
}

.pocuvo-text .pocuvo-text__textarea[readonly],
.pocuvo-text .pocuvo-text__textarea:disabled {
  background: var(--pocuvo-text-readonly-bg);
}

.pocuvo-text .pocuvo-text__textarea[aria-invalid="true"] {
  border: 2px solid var(--pocuvo-text-error);
}

.pocuvo-text .pocuvo-text__options {
  margin: 0;
  padding: 0.75em 1em;
  border: 1px solid var(--pocuvo-text-border);
  border-radius: 0.5rem;
  min-width: 0;
}

.pocuvo-text .pocuvo-text__legend {
  font-weight: 700;
  padding: 0 0.25em;
}

.pocuvo-text .pocuvo-text__option {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  column-gap: 0.25em;
}

.pocuvo-text .pocuvo-text__option label {
  min-height: 44px;
  display: flex;
  align-items: center;
  font-weight: 600;
  cursor: pointer;
}

.pocuvo-text .pocuvo-text__checkbox {
  width: 1.25em;
  height: 1.25em;
  min-width: 24px;
  min-height: 24px;
  margin: 10px;
  justify-self: center;
  accent-color: var(--pocuvo-text-accent);
}

.pocuvo-text .pocuvo-text__option .pocuvo-text__hint {
  grid-column: 2;
  margin-top: 0;
}

/* Option hints in a native disclosure: the browser hides closed content and
   draws its own marker (summary keeps display: list-item). 44px hit height. */
.pocuvo-text .pocuvo-text__option-details {
  margin: 0.25em 0 0.5em;
  min-width: 0;
}

.pocuvo-text .pocuvo-text__option-details > summary {
  min-height: 44px;
  padding: 0.625em 0.25em;
  color: var(--pocuvo-text-accent);
  font-weight: 600;
  line-height: 1.5;
  cursor: pointer;
}

.pocuvo-text .pocuvo-text__option-details > summary:hover {
  color: var(--pocuvo-text-accent-dark);
  text-decoration: underline;
}

.pocuvo-text .pocuvo-text__option-details .pocuvo-text__hint {
  margin: 0 0 0.625em;
  padding-inline-start: 0.25em;
}

.pocuvo-text .pocuvo-text__warning {
  margin: 0.5em 0;
  padding: 0.5em 0.75em;
  background: var(--pocuvo-text-warning-bg);
  border: 1px solid var(--pocuvo-text-warning-border);
  border-radius: 0.5rem;
}

.pocuvo-text .pocuvo-text__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  align-items: center;
  margin: 0.75em 0;
}

.pocuvo-text .pocuvo-text__actions .pocuvo-text__help {
  flex-basis: 100%;
  margin: 0;
}

/* Same shape as the site's .button: filled primary, outlined secondary. */
.pocuvo-text .pocuvo-text__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0.5em 1.125em;
  font: inherit;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  border: 2px solid var(--pocuvo-text-accent);
  border-radius: 0.5rem;
  background: var(--pocuvo-text-surface);
  color: var(--pocuvo-text-accent);
  cursor: pointer;
  touch-action: manipulation;
}

.pocuvo-text .pocuvo-text__button:hover {
  border-color: var(--pocuvo-text-accent-dark);
  background: var(--pocuvo-text-accent-soft);
  color: var(--pocuvo-text-accent-dark);
}

.pocuvo-text .pocuvo-text__button--primary {
  background: var(--pocuvo-text-primary);
  border-color: var(--pocuvo-text-primary);
  color: var(--pocuvo-text-accent-text);
}

.pocuvo-text .pocuvo-text__button--primary:hover {
  border-color: var(--pocuvo-text-primary-hover);
  background: var(--pocuvo-text-primary-hover);
  color: var(--pocuvo-text-accent-text);
}

/* Unavailable (aria-disabled live, disabled in the static snapshot): readable grey, unchanged on hover. */
.pocuvo-text .pocuvo-text__button[aria-disabled="true"],
.pocuvo-text .pocuvo-text__button:disabled {
  border-color: var(--pocuvo-text-disabled-border);
  background: var(--pocuvo-text-disabled-bg);
  color: var(--pocuvo-text-disabled-text);
  cursor: not-allowed;
}

.pocuvo-text :focus-visible {
  outline: 3px solid var(--pocuvo-text-focus);
  outline-offset: 2px;
}

.pocuvo-text .pocuvo-text__status:empty,
.pocuvo-text .pocuvo-text__alert:empty {
  display: none;
}

.pocuvo-text .pocuvo-text__status {
  margin: 0.5em 0;
  padding: 0.5em 0.75em;
  font-weight: 700;
  background: var(--pocuvo-text-info-bg);
  border: 1px solid var(--pocuvo-text-info-border);
  border-radius: 0.5rem;
}

.pocuvo-text .pocuvo-text__alert {
  margin: 0.5em 0;
  padding: 0.5em 0.75em;
  border: 2px solid var(--pocuvo-text-error);
  border-radius: 0.5rem;
  background: var(--pocuvo-text-error-bg);
  color: var(--pocuvo-text-error);
}

.pocuvo-text .pocuvo-text__alert p {
  margin: 0.25em 0;
}

/* Wide screens: source and result side by side; DOM/reading order stays source → controls → result.
   The second row is flexible so a tall result never opens a gap between source and controls. */
@media (min-width: 60em) {
  .pocuvo-text .pocuvo-text__layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "source result"
      "controls result";
    align-items: start;
  }

  .pocuvo-text .pocuvo-text__pane--source {
    grid-area: source;
  }

  .pocuvo-text .pocuvo-text__controls {
    grid-area: controls;
  }

  .pocuvo-text .pocuvo-text__pane--result {
    grid-area: result;
  }
}
