/* ==================================================
   TEXT FX — React Bits-style text animation, rebuilt vanilla
   ==================================================
   Self-contained. Driven by js/text-fx.js via selectors —
   no markup/content changes. GSAP-optional (home has it,
   subpages fall back to CSS/IO). Fully reduced-motion gated.

   Effects: char/word split reveal, cursor proximity, scramble,
   shiny/gradient sweep, typewriter.
   ================================================== */

/* Split atoms — inline-block so they can transform individually */
.tfx-char,
.tfx-word {
    display: inline-block;
    will-change: transform, opacity;
    backface-visibility: hidden;
}

/* A word's letters travel together: lines break only between words */
.tfx-wordbox {
    display: inline-block;
    white-space: nowrap;
}

/* Preserve spaces between split words/chars */
.tfx-space {
    display: inline-block;
    white-space: pre;
}

/* Container hides overflow during line-style reveals; keep it simple */
.tfx-split {
    /* nothing structural — atoms carry the motion */
}

/* ---------- Reveal initial state (JS removes on enter) ---------- */
.tfx-reveal .tfx-char,
.tfx-reveal .tfx-word {
    opacity: 0;
    transform: translateY(0.45em);
}

.tfx-reveal.is-tfx-in .tfx-char,
.tfx-reveal.is-tfx-in .tfx-word {
    opacity: 1;
    transform: none;
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
    transition-delay: var(--tfx-delay, 0s);
}

/* ---------- Proximity (JS sets per-char transform) ---------- */
.tfx-proximity .tfx-char {
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.tfx-proximity.is-tfx-tracking .tfx-char {
    transition: none; /* JS rAF drives it while the pointer is active */
}

/* ---------- Scramble ---------- */
.tfx-scramble {
    /* tabular figures steady the width while glyphs cycle */
    font-variant-numeric: tabular-nums;
}

.tfx-scramble__glyph {
    display: inline-block;
}

.tfx-scramble__glyph.is-scrambling {
    opacity: 0.72;
}

/* ==================================================
   EDITORIAL READING INTERACTIONS
   (replaces the glossy shine — typographic, not flashy)
   ================================================== */

/* Reading focus — hover a paragraph and its siblings soften back, so the
   line you're reading holds the ink. Close-reading feel for long-form. */
@media (hover: hover) and (pointer: fine) {
    .tfx-read-focus:hover p {
        color: color-mix(in srgb, var(--ink, #111) 48%, var(--paper, #fff));
        transition: color 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .tfx-read-focus p:hover {
        color: var(--ink, #111);
    }
}

/* Marginal accent tick — a small rule grows in the gutter of the hovered
   paragraph (and list item), like an editor's margin mark. */
.tfx-mark p,
.tfx-mark li {
    position: relative;
}

.tfx-mark p::before,
.tfx-mark li::before {
    content: "";
    position: absolute;
    left: -0.85em;
    top: 0.5em;
    width: 2px;
    height: 0;
    background: var(--accent, currentColor);
    transition: height 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
    .tfx-mark p:hover::before,
    .tfx-mark li:hover::before {
        height: 1.05em;
    }
}

/* Blockquotes get a quiet emphasis on hover — accent rule thickens */
.article-post-body blockquote,
#article-content blockquote {
    transition: border-color 0.35s ease, padding-left 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (hover: hover) and (pointer: fine) {
    .article-post-body blockquote:hover,
    #article-content blockquote:hover {
        border-color: var(--accent, currentColor);
    }
}

/* Reduced motion: keep the focus legible but drop the transitions */
@media (prefers-reduced-motion: reduce) {
    .tfx-read-focus:hover p,
    .tfx-read-focus p:hover,
    .tfx-mark p::before,
    .tfx-mark li::before { transition: none; }
}

html[data-motion="reduced"] .tfx-read-focus:hover p {
    color: var(--ink, #111); /* don't dim under reduced motion */
}

/* ---------- Typewriter (hero kicker) ---------- */
.tfx-type {
    /* caret */
}

.tfx-type__caret {
    display: inline-block;
    width: 0.06em;
    margin-left: 0.12em;
    align-self: stretch;
    background: currentColor;
    animation: tfx-caret 1s steps(1) infinite;
    vertical-align: -0.06em;
}

.tfx-type.is-tfx-done .tfx-type__caret {
    animation: none;
    opacity: 0;
    transition: opacity 0.4s ease 0.3s;
}

@keyframes tfx-caret {
    0%, 50% { opacity: 1; }
    50.01%, 100% { opacity: 0; }
}

/* ---------- Rotating words (optional slot) ---------- */
.tfx-rotate {
    display: inline-grid;
    vertical-align: bottom;
}

.tfx-rotate__word {
    grid-area: 1 / 1;
    opacity: 0;
    transform: translateY(0.5em);
    transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.tfx-rotate__word.is-current {
    opacity: 1;
    transform: none;
}

.tfx-rotate__word.is-leaving {
    opacity: 0;
    transform: translateY(-0.5em);
}

/* ==================================================
   REDUCED MOTION — everything resolves to final state
   ================================================== */
@media (prefers-reduced-motion: reduce) {
    .tfx-reveal .tfx-char,
    .tfx-reveal .tfx-word {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }

    .tfx-proximity .tfx-char {
        transition: none !important;
        transform: none !important;
    }

    .tfx-shine:hover {
        animation: none !important;
    }

    .tfx-type__caret {
        display: none !important;
    }

    .tfx-rotate__word {
        transition: none !important;
    }
}

/* Honor the site-level motion toggle too, if present */
html[data-motion="reduced"] .tfx-reveal .tfx-char,
html[data-motion="reduced"] .tfx-reveal .tfx-word {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
}

html[data-motion="reduced"] .tfx-shine:hover {
    animation: none !important;
}

html[data-motion="reduced"] .tfx-type__caret {
    display: none !important;
}

/* ==================================================
   EDITORIAL FLATTENING — no drop shadows on content.
   Style is editorial/Swiss: flat planes + hairline rules, never
   drop shadows. Focus stays indicated by the :focus-visible
   outline (design-system.css). Preloader glows + form-input
   focus rings (coloring.css) are intentionally untouched.
   ================================================== */
.article-card, .article-card:hover, .article-card:focus-within, .article-card:focus-visible,
.home-project-card, .home-project-card:hover, .home-project-card:focus-visible,
.project-card, .project-card:hover, .project-card:focus-visible,
.card, .card:hover, .card:focus-within,
.vibe-card, .vibe-card:hover, .vibe-card:focus-visible,
.rido-case-card, .rido-case-card:hover,
.ui-marquee-card, .ui-marquee-card:hover, .ui-marquee-row:hover .ui-marquee-card:hover,
.rido-recommendation-card, .rido-recommendation-card:hover,
.rido-recommendation-card__avatar,
.rido-recommendation-card:hover .rido-recommendation-card__avatar,
#my-cal-inline-design-consultation,
#design-consultation #my-cal-inline-design-consultation,
.btn-main, .btn-main:hover,
.senja-embed, .senja-embed *,
.site-nav__mobile, .site-nav__mobile-panel, [class*="mobile-panel"],
.de_count, .de_count:hover {
    box-shadow: none !important;
}
