/* ==========================================================================
   ENHANCEMENT LAYER (loaded after styles.css)
   Typography refresh, calmer accent treatment and the motion system.
   Applied following the Higgsfield design-taste redesign protocol:
   preserve brand + IA, then type -> spacing -> color -> motion.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300..800&family=Geist+Mono:wght@400..600&display=swap');

:root {
    --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'Geist Mono', 'JetBrains Mono', ui-monospace, monospace;

    /* Same brand red, slightly less neon so it reads as an accent, not a glow */
    --primary: #f2433b;
    --primary-hover: #d93530;
    --primary-glow: rgba(242, 67, 59, 0.12);
    --primary-glow-strong: rgba(242, 67, 59, 0.32);
    --border-hover: #f2433b;

    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --reveal-distance: 28px;
}

/* --- Ambient backdrop: soft light pool + film grain instead of a grid --- */
body {
    background-image: none;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(60vw 50vh at 85% 0%, rgba(242, 67, 59, 0.08), transparent 70%),
        radial-gradient(50vw 40vh at 0% 100%, rgba(255, 255, 255, 0.025), transparent 70%);
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 3000;
    pointer-events: none;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection {
    background: var(--primary);
    color: #fff;
}

/* --- Typography refresh --- */
.hero-title {
    font-size: clamp(2rem, 6vw + 0.5rem, 3.9rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.08;
}

/* Underline as real text decoration so it follows the name when it wraps */
.hero-title .highlight {
    display: inline;
    font-weight: 700;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.14em;
    text-decoration-color: rgba(242, 67, 59, 0.45);
}

.hero-title .highlight::after {
    display: none;
}

.section-title,
.section-title-large,
.showcase-modal-title {
    font-weight: 700;
    letter-spacing: -0.035em;
}

.section-subtitle,
.about-card-tag,
.tech-stack-title,
.badge-text {
    font-weight: 500;
    letter-spacing: 0.16em;
}

.hero-subtitle,
.contact-lead {
    text-wrap: pretty;
}

.section-title,
.section-title-large,
.hero-title {
    text-wrap: balance;
}

/* --- Header condenses once the hero scrolls away --- */
.site-header .header-container {
    transition: height var(--transition-normal);
}

.site-header.is-condensed {
    background-color: rgba(5, 5, 7, 0.88);
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.site-header.is-condensed .header-container {
    height: 64px;
}

.site-header.is-condensed .logo-img {
    height: 40px;
}

.nav-links li a.is-active {
    color: var(--text-main);
}

.nav-links li a.is-active::after {
    width: 100%;
}

/* --- Buttons: tinted shadows, tactile press --- */
.btn-primary {
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 8px 24px -10px var(--primary-glow-strong);
}

.btn-primary:hover {
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 12px 28px -10px var(--primary-glow-strong);
}

.btn:active,
.social-btn:active,
.showcase-tile:active {
    transform: translateY(0) scale(0.98);
    transition-duration: 0.08s;
}

.btn i.bi-arrow-right,
.showcase-cta i {
    transition: transform var(--transition-normal);
}

.btn:hover i.bi-arrow-right {
    transform: translateX(4px);
}

:where(a, button, .showcase-tile):focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
}

/* --- Hero portrait: pointer-reactive depth --- */
.hero-image-wrapper {
    perspective: 900px;
}

.image-glow {
    --rx: 0deg;
    --ry: 0deg;
    --mx: 50%;
    --my: 50%;
    transform: rotateX(var(--rx)) rotateY(var(--ry));
    transform-style: preserve-3d;
    /* transform is smoothed in JS, so only colors transition here */
    transition: border-color var(--transition-slow), box-shadow var(--transition-slow);
}

.image-glow::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: radial-gradient(420px circle at var(--mx) var(--my), rgba(255, 255, 255, 0.07), transparent 45%);
    opacity: 0;
    transition: opacity var(--transition-slow);
}

.image-glow:hover::after {
    opacity: 1;
}

.image-glow:hover {
    transform: rotateX(var(--rx)) rotateY(var(--ry));
}

.profile-img {
    transform: translateZ(30px);
}

/* --- Cursor spotlight shared by about cards and showcase tiles --- */
.about-card,
.showcase-tile {
    position: relative;
    isolation: isolate;
}

.about-card::before,
.showcase-tile::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: -1;
    background: radial-gradient(520px circle at var(--x, 50%) var(--y, 50%), rgba(242, 67, 59, 0.07), transparent 40%);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.about-card:hover::before,
.showcase-tile:hover::before {
    opacity: 1;
}

.about-card:hover,
.showcase-tile:hover {
    box-shadow: 0 24px 50px -24px rgba(242, 67, 59, 0.25);
}

/* --- Project card header: logo box keeps its size, long names wrap --- */
.project-icon-wrapper {
    flex: 0 0 48px;
    aspect-ratio: 1;
}

.project-meta {
    min-width: 0;
}

.project-title {
    overflow-wrap: break-word;
}

.project-number {
    flex-shrink: 0;
}

/* --- Project card footer: tags wrap, link button never shrinks --- */
.project-footer {
    gap: 1rem;
    align-items: flex-end;
}

.project-tags {
    flex: 1 1 auto;
    min-width: 0;
}

.project-link {
    flex: 0 0 38px;
    aspect-ratio: 1;
}

/* --- Marquee: edge fade via mask (works on any background), slower drift --- */
.tools-grid {
    animation-duration: 40s;
}

.logo-slider {
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
}

.logo-slider::before,
.logo-slider::after {
    display: none;
}

/* --- Contact card: slow rotating accent edge --- */
@property --edge-angle {
    syntax: "<angle>";
    initial-value: 0deg;
    inherits: false;
}

.contact-card {
    border-color: transparent;
    background:
        linear-gradient(135deg, #0c0c0f, #060608) padding-box,
        conic-gradient(from var(--edge-angle), var(--border) 0deg, rgba(242, 67, 59, 0.55) 60deg, var(--border) 120deg, var(--border) 360deg) border-box;
}

/* ==========================================================================
   MOTION SYSTEM
   Everything below only runs when the visitor has not asked for reduced
   motion, and only after JS adds .motion-ready (no-JS keeps content visible).
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {

    /* Hero entrance: staggered rise */
    .motion-ready .hero-text-content > * {
        opacity: 0;
        transform: translateY(var(--reveal-distance));
        animation: rise 0.9s var(--ease-out) forwards;
        animation-delay: calc(0.15s + var(--i, 0) * 0.1s);
    }

    .motion-ready .hero-image-wrapper {
        opacity: 0;
        animation: portrait-in 1.2s var(--ease-out) 0.35s forwards;
    }

    .motion-ready .image-glow::before {
        animation: breathe 6s ease-in-out 1.5s infinite;
    }

    /* Header slides in */
    .motion-ready .site-header {
        animation: drop-in 0.8s var(--ease-out) both;
    }

    /* Scroll reveals */
    /* :where() keeps these at zero specificity so card hover transforms still win */
    :where(.motion-ready [data-reveal]) {
        opacity: 0;
        transform: translateY(var(--reveal-distance));
    }

    .motion-ready [data-reveal] {
        transition:
            opacity 0.8s var(--ease-out),
            transform 0.8s var(--ease-out);
        transition-delay: calc(var(--i, 0) * 90ms);
    }

    :where(.motion-ready [data-reveal="scale"]) {
        transform: translateY(16px) scale(0.97);
    }

    :where(.motion-ready [data-reveal].is-visible) {
        opacity: 1;
        transform: none;
    }

    /* Once revealed, hand transform back to hover styles quickly */
    .motion-ready [data-reveal].is-settled {
        transition: all var(--transition-normal);
        transition-delay: 0s;
    }

    .motion-ready .section-line {
        transform: scaleX(0);
        transition: transform 0.9s var(--ease-out) 0.25s;
    }

    .motion-ready .is-visible .section-line,
    .motion-ready .section-header.is-visible .section-line {
        transform: scaleX(1);
    }

    /* Showcase thumbnails fan in */
    .motion-ready .showcase-tile .showcase-thumb-icon,
    .motion-ready .showcase-tile .showcase-thumb-cert {
        opacity: 0;
        translate: 0 12px;
        transition: opacity 0.6s var(--ease-out), translate 0.6s var(--ease-out), transform var(--transition-normal);
    }

    .motion-ready .showcase-tile.is-visible .showcase-thumb-icon,
    .motion-ready .showcase-tile.is-visible .showcase-thumb-cert {
        opacity: 1;
        translate: 0 0;
    }

    .motion-ready .showcase-tile.is-visible :is(.showcase-thumb-icon, .showcase-thumb-cert):nth-child(1) { transition-delay: 0.30s, 0.30s, 0s; }
    .motion-ready .showcase-tile.is-visible :is(.showcase-thumb-icon, .showcase-thumb-cert):nth-child(2) { transition-delay: 0.38s, 0.38s, 0s; }
    .motion-ready .showcase-tile.is-visible :is(.showcase-thumb-icon, .showcase-thumb-cert):nth-child(3) { transition-delay: 0.46s, 0.46s, 0s; }
    .motion-ready .showcase-tile.is-visible :is(.showcase-thumb-icon, .showcase-thumb-cert):nth-child(4) { transition-delay: 0.54s, 0.54s, 0s; }
    .motion-ready .showcase-tile.is-visible :is(.showcase-thumb-icon, .showcase-thumb-cert):nth-child(5) { transition-delay: 0.62s, 0.62s, 0s; }

    .showcase-tile:hover .showcase-cta i {
        transform: translateX(6px);
    }

    /* Modals: backdrop fade + panel spring, cards stagger in */
    .showcase-modal.active,
    .contact-modal.active,
    .cert-modal.active {
        animation: fade-in 0.3s ease-out both;
    }

    .showcase-modal-content,
    .contact-modal-content {
        animation: panel-in 0.55s var(--ease-out) both;
    }

    .showcase-modal.active :is(.project-card, .cert-card) {
        animation: rise 0.6s var(--ease-out) backwards;
        animation-delay: calc(0.12s + var(--i, 0) * 70ms);
    }

    /* Contact edge rotation */
    .contact-card {
        animation: edge-spin 8s linear infinite;
    }

    /* Floating chat button: gentle attention ping, a few times only */
    .floating-chat-btn::after {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: inherit;
        border: 2px solid var(--primary);
        opacity: 0;
        animation: ping 2.4s var(--ease-out) 3s 3;
        pointer-events: none;
    }
}

@keyframes rise {
    from { opacity: 0; transform: translateY(var(--reveal-distance)); }
    to   { opacity: 1; transform: none; }
}

@keyframes portrait-in {
    from { opacity: 0; transform: translateY(24px) scale(0.94); filter: blur(8px); }
    to   { opacity: 1; transform: none; filter: blur(0); }
}

@keyframes breathe {
    0%, 100% { opacity: 0.15; transform: translate(-50%, -50%) scale(1); }
    50%      { opacity: 0.26; transform: translate(-50%, -50%) scale(1.08); }
}

@keyframes drop-in {
    from { transform: translateY(-100%); }
    to   { transform: none; }
}

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes panel-in {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}

@keyframes edge-spin {
    to { --edge-angle: 360deg; }
}

@keyframes ping {
    0%   { opacity: 0.7; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.7); }
}

/* Reduced motion: static, fully composed, no loops */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    .tools-grid { animation: none; }

    .image-glow,
    .image-glow:hover {
        transform: none;
    }

    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Touch devices: no hover tilt */
@media (hover: none) {
    .image-glow,
    .image-glow:hover {
        transform: none;
    }
}

@media (max-width: 768px) {
    :root { --reveal-distance: 18px; }

    .project-title {
        font-size: 1.1rem;
    }

    .hero-title {
        line-height: 1.12;
        letter-spacing: -0.03em;
    }

    .site-header.is-condensed .header-container {
        height: 60px;
    }
}

/* Wider screens: keep the full name on one line */
@media (min-width: 769px) {
    .hero-title .highlight {
        white-space: nowrap;
    }
}

/* Small phones: give project cards more room for their titles */
@media (max-width: 480px) {
    .showcase-modal-body {
        padding: 1rem;
    }

    .project-card {
        padding: 1.4rem;
    }

    .project-header {
        gap: 0.9rem;
    }
}
