/* ==================================================
   RIDO MICRO-INTERACTIONS — hover polish + reveal states
   ==================================================
   Companion file: js/micro-interactions.js
   - Targets EXISTING classes only (the .mi-cursor-dot node is
     the single element created by JS).
   - Loads after every other stylesheet so its "extend, don't
     restructure" overrides win the cascade.
   - All motion lives behind @media (prefers-reduced-motion:
     no-preference) and html:not([data-motion="reduced"]) — the
     user toggle (js/motion-preferences.js) kills it instantly.
   - Transform / opacity / clip-path / background-size only.
   ================================================== */

/* ==================================================
   1. CUSTOM CURSOR (element appended to <body> by JS)
   Framer-style: on fine-pointer + hover devices with motion
   enabled, js/micro-interactions.js adds .has-custom-cursor to
   <html> and the .mi-cursor-dot node REPLACES the native
   cursor. States (JS toggles classes, position is JS-lerped):
   - default: 10px dot, white + mix-blend difference
   - .is-link: 40px ring over links / buttons
   - .is-label: 72px solid ink circle, blend off, with an
     uppercase label rendered from [data-label] via ::after
   FALLBACK SAFETY: cursor:none lives ONLY under the JS-added
   .has-custom-cursor class — if JS never runs, the native
   cursor is never hidden.
   ================================================== */
.mi-cursor-dot {
    position: fixed;
    top: -36px;
    left: -36px;
    width: 72px;
    height: 72px;
    pointer-events: none;
    z-index: 99999;
    opacity: 0;
    will-change: transform;
    mix-blend-mode: difference;
    transition: opacity 0.25s ease;
}

.mi-cursor-dot::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: #ffffff;
    border: 1.5px solid rgba(255, 255, 255, 0);
    transform: scale(0.139); /* 72px * 0.139 ~= 10px idle dot */
    transition:
        transform 0.25s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1)),
        background-color 0.15s ease,
        border-color 0.15s ease;
}

/* Label, rendered from the data-label attribute set by JS */
.mi-cursor-dot::after {
    content: attr(data-label);
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: var(--font-ui, "Rido Neue Haas Text", "Helvetica Neue", Helvetica, Arial, sans-serif);
    font-size: 11px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--paper, #ffffff);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.mi-cursor-dot.is-visible {
    opacity: 1;
}

/* Link / button hover: 40px ring */
.mi-cursor-dot.is-link::before {
    transform: scale(0.556); /* ~40px ring */
    background: rgba(255, 255, 255, 0);
    border-color: #ffffff;
}

/* Labeled state over big interactive cards: solid ink circle,
   blend OFF — solid reads cleaner, Framer-style. */
.mi-cursor-dot.is-label {
    mix-blend-mode: normal;
}

.mi-cursor-dot.is-label::before {
    transform: scale(1); /* full 72px */
    background: var(--ink, #0a0a0a);
    border-color: rgba(255, 255, 255, 0);
}

.mi-cursor-dot.is-label::after {
    opacity: 1;
}

/* Native cursor hiding — ONLY under the JS-added class, double
   gated by the motion toggle + fine-pointer media query. */
@media (hover: hover) and (pointer: fine) {
    html[data-motion="full"].has-custom-cursor,
    html[data-motion="full"].has-custom-cursor :where(*) {
        cursor: none;
    }

    /* Exceptions: native cursor returns where precision text /
       embedded UI lives (the JS hides the dot over the same
       zones). :where() keeps specificity flat so source order
       wins over the rule above. */
    html[data-motion="full"].has-custom-cursor :where(
        input, textarea, select,
        [contenteditable], [contenteditable] *,
        [data-native-cursor], [data-native-cursor] *,
        iframe,
        #design-consultation, #design-consultation *,
        #my-cal-inline-design-consultation, #my-cal-inline-design-consultation *,
        .senja-embed, .senja-embed *
    ) {
        cursor: auto;
    }
}

/* Touch / coarse pointers and reduced motion never see the dot */
@media (pointer: coarse), (hover: none) {
    .mi-cursor-dot { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
    .mi-cursor-dot { display: none !important; }
}

html[data-motion="reduced"] .mi-cursor-dot {
    display: none !important;
}

/* ==================================================
   3. HEADING LINE REVEALS — masked line states
   Applied only to headings js/micro-interactions.js splits
   itself ([data-mi-lines]); identical markup convention to
   js/motion.js (.motion-line-mask > .motion-line) so the two
   systems stay interchangeable. Per-line stagger (80ms) is set
   inline by JS via transition-delay.
   ================================================== */
[data-mi-lines] .motion-line-mask {
    display: block;
    overflow: hidden;
}

[data-mi-lines] .motion-line {
    display: block;
}

@media (prefers-reduced-motion: no-preference) {
    html:not([data-motion="reduced"]) [data-mi-lines] .motion-line {
        transform: translateY(112%);
        transition: transform 0.8s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1));
    }

    html:not([data-motion="reduced"]) [data-mi-lines].mi-lines-in .motion-line {
        transform: translateY(0);
    }
}

html[data-motion="reduced"] [data-mi-lines] .motion-line {
    transform: none !important;
    transition: none !important;
}

/* ==================================================
   4. IMAGE REVEALS — clip + settle states
   .mi-img-pre / .mi-img-in are added/removed by JS; once the
   reveal finishes both classes are stripped so the original
   hover transitions take back over. Opacity transition is kept
   so asset-loading.js' is-loading -> is-loaded fade survives.
   ================================================== */
@media (prefers-reduced-motion: no-preference) {
    html:not([data-motion="reduced"]) img.mi-img-pre {
        clip-path: inset(12% 0 0 0);
        transform: scale(1.06) translateZ(0);
        transition: opacity 260ms cubic-bezier(0.16, 1, 0.3, 1);
        will-change: clip-path, transform;
        backface-visibility: hidden;
    }

    html:not([data-motion="reduced"]) img.mi-img-pre.mi-img-in {
        clip-path: inset(0 0 0 0);
        transform: scale(1) translateZ(0);
        transition:
            clip-path 0.9s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1)),
            transform 0.9s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1)),
            opacity 260ms cubic-bezier(0.16, 1, 0.3, 1);
    }

    /* Framed cells (mosaic, vibe preview strip): the frame is drawn at once
       and the plate inside unveils top to bottom. The clip lives on the media
       child, never on the observed cell: a target clipped to nothing reports
       no intersection, so the IO fallback would never fire. */
    html:not([data-motion="reduced"]) .rido-topic-divider__cell.mi-img-pre > .rido-video,
    html:not([data-motion="reduced"]) .rido-topic-divider__cell.mi-img-pre > .rido-topic-divider__img,
    html:not([data-motion="reduced"]) .vibe-visual-frame.mi-img-pre > .vibe-visual-media {
        clip-path: inset(0 0 100% 0);
        will-change: clip-path;
    }

    html:not([data-motion="reduced"]) .rido-topic-divider__cell.mi-img-pre.mi-img-in > .rido-video,
    html:not([data-motion="reduced"]) .rido-topic-divider__cell.mi-img-pre.mi-img-in > .rido-topic-divider__img,
    html:not([data-motion="reduced"]) .vibe-visual-frame.mi-img-pre.mi-img-in > .vibe-visual-media {
        clip-path: inset(0 0 0 0);
        transition: clip-path 0.9s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1));
    }
}

/* ==================================================
   5. CARD HOVER POLISH — extends rido-card-hover.css /
   article.css / home-projects.css / vibe-coding.css hovers
   (existing border-color already darkens to #111 on hover).
   ================================================== */
@media (prefers-reduced-motion: no-preference) and (hover: hover) {
    /* Article cards (hub, home featured, related) */
    html:not([data-motion="reduced"]) .article-card {
        transition:
            transform 260ms cubic-bezier(0.16, 1, 0.3, 1),
            border-color 260ms cubic-bezier(0.16, 1, 0.3, 1),
            background-color 260ms cubic-bezier(0.16, 1, 0.3, 1),
            box-shadow 0.5s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1));
    }

    html:not([data-motion="reduced"]) .article-card:hover,
    html:not([data-motion="reduced"]) .article-card:focus-within {
        transform: translateY(-4px);
        box-shadow: 0 24px 48px rgba(10, 10, 10, 0.08);
    }

    html:not([data-motion="reduced"]) .article-card__media img {
        transition:
            opacity 260ms cubic-bezier(0.16, 1, 0.3, 1),
            transform 0.6s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1));
    }

    html:not([data-motion="reduced"]) .article-card:hover .article-card__media img,
    html:not([data-motion="reduced"]) .article-card:focus-within .article-card__media img {
        transform: scale(1.04);
    }

    /* Home project cards */
    html:not([data-motion="reduced"]) .home-project-card,
    html:not([data-motion="reduced"]) .project-card.home-project-card.card.card--editorial-trace {
        transition:
            opacity 220ms cubic-bezier(0.16, 1, 0.3, 1),
            transform 240ms cubic-bezier(0.16, 1, 0.3, 1),
            border-color 240ms cubic-bezier(0.16, 1, 0.3, 1),
            box-shadow 0.5s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1));
    }

    html:not([data-motion="reduced"]) .home-project-card:hover,
    html:not([data-motion="reduced"]) .home-project-card:focus-visible,
    html:not([data-motion="reduced"]) .project-card.home-project-card.card.card--editorial-trace:hover,
    html:not([data-motion="reduced"]) .project-card.home-project-card.card.card--editorial-trace:focus-visible {
        transform: translateY(-4px);
        box-shadow: 0 24px 48px rgba(10, 10, 10, 0.08);
    }

    html:not([data-motion="reduced"]) .home-project-card .project-thumb-image {
        transition: transform 0.6s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1));
    }

    html:not([data-motion="reduced"]) .home-project-card:hover .project-thumb-image,
    html:not([data-motion="reduced"]) .home-project-card:focus-visible .project-thumb-image {
        transform: scale(1.04);
    }

    /* Vibe cards (home rail + catalogue) */
    html:not([data-motion="reduced"]) .vibe-card {
        transition:
            transform 260ms cubic-bezier(0.16, 1, 0.3, 1),
            border-color 240ms cubic-bezier(0.16, 1, 0.3, 1),
            box-shadow 0.5s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1));
    }

    html:not([data-motion="reduced"]) .vibe-card:hover,
    html:not([data-motion="reduced"]) .vibe-card:focus-visible {
        transform: translateY(-4px);
        box-shadow: 0 24px 48px rgba(10, 10, 10, 0.08);
    }

    html:not([data-motion="reduced"]) .vibe-card__image,
    html:not([data-motion="reduced"]) body[data-page="vibe-coding"] .vibe-catalog-grid .vibe-card__image,
    html:not([data-motion="reduced"]) body[data-page="home"] .vibe-home-grid .vibe-card__image {
        transition: transform 0.6s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1));
    }

    html:not([data-motion="reduced"]) .vibe-card:hover .vibe-card__image,
    html:not([data-motion="reduced"]) .vibe-card:focus-visible .vibe-card__image,
    html:not([data-motion="reduced"]) body[data-page="vibe-coding"] .vibe-catalog-grid .vibe-card:hover .vibe-card__image,
    html:not([data-motion="reduced"]) body[data-page="vibe-coding"] .vibe-catalog-grid .vibe-card:focus-visible .vibe-card__image,
    html:not([data-motion="reduced"]) body[data-page="home"] .vibe-home-grid .vibe-card:hover .vibe-card__image,
    html:not([data-motion="reduced"]) body[data-page="home"] .vibe-home-grid .vibe-card:focus-visible .vibe-card__image {
        transform: scale(1.04);
    }
}

/* Tag chips — invert on hover (color swap, fine under reduced motion) */
.article-chip {
    transition:
        background-color 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease;
}

.article-card .article-chip:hover {
    background: var(--ink, #0a0a0a);
    color: var(--paper, #ffffff);
    border-color: var(--ink, #0a0a0a);
}

/* ==================================================
   6. LINK UNDERLINE SWEEPS — .ds-link pattern from
   design-system.css applied to nav labels, footer links and
   card CTA labels. (.article-card__cta already ships its own
   scaleX underline in article.css — left untouched.)
   ================================================== */
@media (prefers-reduced-motion: no-preference) and (hover: hover) {
    html:not([data-motion="reduced"]) .site-nav__primary .site-nav__link .nav-label,
    html:not([data-motion="reduced"]) .site-footer__nav a,
    html:not([data-motion="reduced"]) .home-project-card .project-btn__label,
    html:not([data-motion="reduced"]) .vibe-card__cta-label {
        background-image: linear-gradient(currentColor, currentColor);
        background-size: 0% 1px;
        background-position: 0 100%;
        background-repeat: no-repeat;
        transition: background-size 0.4s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1));
    }

    html:not([data-motion="reduced"]) .site-nav__primary .site-nav__link:hover .nav-label,
    html:not([data-motion="reduced"]) .site-nav__primary .site-nav__link:focus-visible .nav-label,
    html:not([data-motion="reduced"]) .site-footer__nav a:hover,
    html:not([data-motion="reduced"]) .site-footer__nav a:focus-visible,
    html:not([data-motion="reduced"]) .home-project-card:hover .project-btn__label,
    html:not([data-motion="reduced"]) .home-project-card:focus-visible .project-btn__label,
    html:not([data-motion="reduced"]) .vibe-card:hover .vibe-card__cta-label,
    html:not([data-motion="reduced"]) .vibe-card:focus-visible .vibe-card__cta-label {
        background-size: 100% 1px;
    }

    /* Arrow glyphs nudge along their pointing direction (existing
       2px nudge deepened to 4px; transitions already in place). */
    html:not([data-motion="reduced"]) .home-project-card:hover .project-btn__icon,
    html:not([data-motion="reduced"]) .home-project-card:hover .project-btn .lucide,
    html:not([data-motion="reduced"]) .home-project-card:focus-visible .project-btn__icon,
    html:not([data-motion="reduced"]) .home-project-card:focus-visible .project-btn .lucide,
    html:not([data-motion="reduced"]) .vibe-card:hover .vibe-card__cta-arrow,
    html:not([data-motion="reduced"]) .vibe-card:focus-visible .vibe-card__cta-arrow {
        transform: translate(4px, -4px);
    }

    /* Nav external-link arrows (↗ pseudo-glyphs in navbar.css) */
    html:not([data-motion="reduced"]) .site-nav__primary .site-nav__link .nav-icon[data-lucide="arrow-up-right"] {
        transition: transform 0.3s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1));
    }

    html:not([data-motion="reduced"]) .site-nav__primary .site-nav__link:hover .nav-icon[data-lucide="arrow-up-right"],
    html:not([data-motion="reduced"]) .site-nav__primary .site-nav__link:focus-visible .nav-icon[data-lucide="arrow-up-right"] {
        transform: translate(3px, -3px);
    }
}

/* ==================================================
   7. LOGO WALL HOVER
   style.css already does grayscale(1)->0 + opacity lift, but
   only transitions opacity — add the filter so color fades in
   instead of snapping.
   ================================================== */
.logo-wall-item {
    transition: opacity 0.3s ease, filter 0.3s ease;
}

html[data-motion="reduced"] .logo-wall-item {
    transition: none;
}

/* ==================================================
   10. NAV SCROLL-SPY STYLE
   The spy logic already lives in js/navbar.js (.is-active on
   [data-nav-link]); this only adds the 1px / 6px-offset
   underline. Static style — fine under reduced motion.
   ================================================== */
.site-nav__primary .site-nav__link.is-active .nav-label {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 6px;
}

/* ==================================================
   12. FOOTER CTA: "LET'S TALK"
   Its hover is the letter decrypt (js/text-fx.js), like every
   other footer link. The ink panel that used to rise behind it
   filled the whole link box, far wider than the words, so it
   is gone (2026-10-31).
   ================================================== */

/* Reduced motion: no decrypt, so the call dims instead */
@media (prefers-reduced-motion: reduce) {
    .site-footer__cta-link:hover .site-footer__cta,
    .site-footer__cta-link:focus-visible .site-footer__cta {
        color: rgba(10, 10, 10, 0.55);
    }
}

html[data-motion="reduced"] .site-footer__cta-link:hover .site-footer__cta,
html[data-motion="reduced"] .site-footer__cta-link:focus-visible .site-footer__cta {
    color: rgba(10, 10, 10, 0.55);
}

/* Touch screens: small links get a tap area at least 24 px tall, without moving anything. */
@media (pointer: coarse) {
    .site-nav__brand,
    .vibe-nav-back,
    .rido-recommendation-card__read,
    .site-footer__social a,
    .article-toc__item a {
        padding-block: 6px;
        margin-block: -6px;
    }

    .site-footer__social a {
        padding-inline: 8px;
        margin-inline: -8px;
    }

    .founder-banner__social-link {
        position: relative;
    }

    .founder-banner__social-link::after {
        content: "";
        position: absolute;
        inset: -6px;
    }
}
