/* ===== Typewriter plugin =====
   All selectors scoped under [data-cb-type="typewriter"] so nothing leaks.
   Colors run through CSS variables so dark mode is a variable override. */
[data-cb-type="typewriter"] {
    display: block;
    font-size: clamp(28px, 5vw, 48px);
    font-weight: 700;
    line-height: 1.2;
    color: var(--tw-text, #111827);
    --tw-accent: #3b82f6;
}

/* ── Dark mode (opt-in — commented out) ───────────────────────────────────
   Dark mode for a rendered block is the SITE's responsibility, not the plugin's.
   The static text uses --tw-text; the rotating word keeps the accent color you
   configured. Uncomment and point the selector at your site's theme trigger.
   NOTE: `.dark` is also the ContentBuilder editor's own UI theme, so on a page
   that runs the editor, prefer a different class here.

.dark [data-cb-type="typewriter"] {
    --tw-text: #f3f4f6;
}
*/

/* Optional heading wrapper (h1 / h2 / h3 / p, class .tw-line). Reset the UA
   margin and font so whichever tag is chosen matches the block's headline look —
   the heading is only there to give search engines the right semantics. */
[data-cb-type="typewriter"] .tw-line {
    margin: 0;
    font: inherit;
    color: inherit;
}

[data-cb-type="typewriter"] .tw-rotate {
    color: var(--tw-accent);
    white-space: pre;
}

/* Blinking caret (typewriter effect, when enabled) */
[data-cb-type="typewriter"][data-cb-cursor="true"][data-cb-effect="type"] .tw-rotate::after {
    content: "";
    display: inline-block;
    width: 0.08em;
    height: 1em;
    margin-left: 0.04em;
    vertical-align: text-bottom;
    background: var(--tw-accent);
    animation: tw-blink 1s steps(1) infinite;
}

@keyframes tw-blink {
    0%, 50% { opacity: 1; }
    50.01%, 100% { opacity: 0; }
}

/* Fade effect */
[data-cb-type="typewriter"][data-cb-effect="fade"] .tw-rotate {
    display: inline-block;
    transition: opacity 0.4s ease, transform 0.4s ease;
}
[data-cb-type="typewriter"][data-cb-effect="fade"] .tw-rotate.is-out {
    opacity: 0;
    transform: translateY(-0.2em);
}
[data-cb-type="typewriter"][data-cb-effect="fade"] .tw-rotate.is-in {
    opacity: 1;
    transform: translateY(0);
}

/* Data list is the accessible source of truth; hidden but readable by
   assistive tech (not display:none). */
[data-cb-type="typewriter"] .tw-words {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

@media (prefers-reduced-motion: reduce) {
    [data-cb-type="typewriter"] .tw-rotate::after { animation: none; }
}
