/**
 * MASTERKA — Footer (hybrid 1 × 4 × 8)
 * Big CTA + numbered links (inline on desktop, a list on mobile) + bottom bar,
 * cursor dot grid, orange glow, grain and an entrance animation (driven by assets/js/footer.js).
 *
 * Performance: the glow moves with a transform (compositor only), the dot mask is updated
 * on its own layer at most once per frame and only while the pointer is over the footer,
 * and the grain is baked into the background (no blend mode over animated content).
 *
 * Rounded corners: the dark panel (.mf-body) carries the radius, the outer section (.mf)
 * is painted with the colour of the section above (--mf-corner, set by footer.js),
 * so the corners read correctly in every state, including while the panel scales in.
 */

.mf {
    position: relative;
    background: var(--mf-corner, transparent);
    font-family: 'Manrope', sans-serif;
}

.mf-body {
    --mf-bg: #111;
    --mf-fg: #F4F2EE;
    --mf-mut: #8b8b8b;
    --mf-line: rgba(255, 255, 255, 0.1);
    --mf-hi: #FF4400;
    --mf-radius: 2rem;

    position: relative;
    isolation: isolate;
    overflow: hidden;
    overflow: clip;
    /* Grain baked into the background: a static tile, painted once */
    background:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='.07'/></svg>"),
        var(--mf-bg);
    color: var(--mf-fg);
    border-radius: var(--mf-radius) var(--mf-radius) 0 0;
    /* Keeps transformed children clipped to the rounded corners in Safari */
    transform: translateZ(0);
}

@media (min-width: 768px) {
    .mf-body { --mf-radius: 3rem; }
}

/* ── Background layers ── */
.mf-dots {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image: radial-gradient(#ccc 1.5px, transparent 1.5px);
    background-size: 30px 30px;
    opacity: 0.08;
    -webkit-mask-image: radial-gradient(circle 60vw at var(--mx, 50%) var(--my, 30%), black 0%, transparent 100%);
    mask-image: radial-gradient(circle 60vw at var(--mx, 50%) var(--my, 30%), black 0%, transparent 100%);
    /* Own layer, so mask updates never repaint the content above */
    will-change: transform;
}

.mf-glow {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 0;
    width: 1400px;
    height: 1400px;
    margin: -700px 0 0 -700px;
    pointer-events: none;
    border-radius: 50%;
    background: radial-gradient(circle closest-side, rgba(255, 68, 0, 0.17) 0%, rgba(255, 68, 0, 0.06) 45%, transparent 100%);
    opacity: 0;
    transform: translate3d(50vw, 30%, 0);
    transition: opacity 0.8s ease;
    will-change: transform, opacity;
}

.mf-body:hover .mf-glow {
    opacity: 1;
}

@media (hover: none), (pointer: coarse) {
    .mf-dots { -webkit-mask-image: none; mask-image: none; opacity: 0.05; will-change: auto; }
    .mf-glow { display: none; }
}

/* ── Content ── */
.mf-inner {
    position: relative;
    z-index: 2;
    max-width: 1400px;
    margin: 0 auto;
    padding: clamp(88px, min(13vw, 18vh), 200px) clamp(20px, 5vw, 72px) 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.mf-badge {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-family: 'Victor Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--mf-mut);
}

.mf-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22C55E;
    flex-shrink: 0;
    animation: mf-pulse 2s infinite;
}

@keyframes mf-pulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
    70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* CTA — sized to the container width by footer.js */
.mf-cta {
    position: relative;
    display: block;
    width: 100%;
    margin-top: clamp(28px, 4vh, 56px);
    padding: 0.06em 0;
    color: var(--mf-hi);
    text-decoration: none;
}

.mf-cta-t {
    display: inline-block;
    white-space: nowrap;
    margin: 0;
    /* Clips the letters while they rise in */
    padding: 0.1em 0 0.06em;
    overflow: hidden;
    overflow: clip;
    font-family: 'Manrope', sans-serif;
    font-weight: 800;
    font-size: clamp(4rem, 15vw, 14rem);
    line-height: 0.86;
    letter-spacing: -0.035em;
    color: var(--mf-hi);
}

.mf-pill {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 5;
    pointer-events: none;
}

.mf-pill span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    background: #fff;
    color: #111;
    border-radius: 99px;
    padding: 12px 20px;
    font-family: 'Victor Mono', monospace;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.5);
    /* Sits just below the custom cursor dot */
    transform: translate(-50%, 26px) scale(0) rotate(-6deg);
    transition: transform 0.35s cubic-bezier(0.3, 1.5, 0.5, 1);
}

.mf-cta:hover .mf-pill span {
    transform: translate(-50%, 26px) scale(1) rotate(-3deg);
}

.mf-pill svg {
    width: 14px;
    height: 14px;
}

@media (hover: none), (pointer: coarse) {
    .mf-pill { display: none; }
}

/* Gesto — fluid ring drawn round "TALK" on hover (footer.js + fluid-ring.js) */
.mf-cta .mf-ring {
    position: absolute;
    z-index: 4;
    color: var(--paper, #F4F4F0);
    transform: rotate(-4deg);
}


/* Numbered inline links */
.mf-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25em 1.1em;
    margin-top: clamp(40px, 7vh, 96px);
    font-family: 'Instrument Serif', serif;
    font-size: clamp(26px, 2.6vw, 40px);
    line-height: 1.15;
}

.mf-link {
    display: inline-flex;
    align-items: baseline;
    gap: 0.2em;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.35s, color 0.35s;
}

.mf-link sup {
    align-self: flex-start;
    margin-top: 0.3em;
    font-family: 'Victor Mono', monospace;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--mf-mut);
    transition: color 0.35s;
}

.mf-link .mf-label {
    background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
    transition: background-size 0.4s cubic-bezier(0.7, 0, 0.2, 1);
}

.mf-link svg {
    align-self: center;
    width: 0.5em;
    height: 0.5em;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.35s;
}

.mf-link:hover,
.mf-link:focus-visible {
    color: var(--mf-hi);
}

.mf-link:hover sup { color: var(--mf-hi); }
.mf-link:hover .mf-label { background-size: 100% 1px; }
.mf-link:hover svg { transform: translate(2px, -2px); }

/* Focus the hovered link, quiet the rest (pointer devices only — taps would leave it stuck) */
@media (hover: hover) {
    .mf-links:hover .mf-link:not(:hover) {
        opacity: 0.35;
    }
}

.mf-link:focus-visible,
.mf-top:focus-visible,
.mf-cta:focus-visible {
    outline: 2px solid var(--mf-hi);
    outline-offset: 6px;
    border-radius: 6px;
}

/* Bottom bar */
.mf-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 24px;
    margin-top: clamp(64px, 12vh, 160px);
    padding-top: 18px;
    border-top: 1px solid var(--mf-line);
    font-size: 12px;
    color: var(--mf-mut);
}

.mf-logo {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: 'Instrument Serif', serif;
    font-style: italic;
    font-size: 26px;
    line-height: 1;
    color: var(--mf-fg);
    cursor: default;
}

.mf-logo svg {
    width: 0.5em;
    height: 0.5em;
    color: var(--mf-hi);
    transition: transform 0.5s;
}

.mf-logo svg path {
    transition: d 0.5s ease-in-out;
}

.mf-logo:hover svg { transform: rotate(90deg); }
.mf-logo:hover svg path { d: path('M50 0 L61 39 L100 50 L61 61 L50 100 L39 61 L0 50 L39 39 Z'); }

.mf-top {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    transition: color 0.3s;
}

.mf-top svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.3s;
}

.mf-top:hover { color: var(--mf-fg); }
.mf-top:hover svg { transform: translateY(-3px); }

/* ── Entrance (footer.js adds .mf-anim, then .mf-in once the footer is in view) ── */
.mf-char {
    display: inline-block;
}

.mf.mf-anim .mf-body {
    transform: scale(0.94);
    transform-origin: 50% 0;
    transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.mf.mf-anim .mf-char {
    transform: translate3d(0, 115%, 0) rotate(8deg);
    transition: transform 1s cubic-bezier(0.16, 1, 0.3, 1);
    transition-delay: calc(0.15s + var(--i, 0) * 0.045s);
}

.mf.mf-anim :is(.mf-badge, .mf-link, .mf-bar) {
    opacity: 0;
    transform: translate3d(0, 28px, 0);
    transition: opacity 0.8s ease, transform 1s cubic-bezier(0.16, 1, 0.3, 1);
    transition-delay: var(--d, 0s);
}

.mf.mf-anim .mf-bar { --d: 0.9s; }

.mf.mf-anim.mf-in .mf-body { transform: translateZ(0); }
.mf.mf-anim.mf-in .mf-char { transform: none; }
.mf.mf-anim.mf-in :is(.mf-badge, .mf-link, .mf-bar) { opacity: 1; transform: none; }

/* ── Mobile: roomier rhythm, links become a tappable list ── */
@media (max-width: 640px) {
    .mf-inner {
        padding: 104px 20px 32px;
    }

    .mf-badge {
        gap: 8px;
        font-size: 10px;
        letter-spacing: 0.12em;
        white-space: nowrap;
    }

    .mf-cta {
        margin-top: 40px;
    }

    .mf-links {
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 0;
        width: 100%;
        margin-top: 64px;
        font-size: 30px;
        line-height: 1;
        border-top: 1px solid var(--mf-line);
    }

    .mf-link {
        display: grid;
        grid-template-columns: 44px 1fr auto;
        align-items: center;
        width: 100%;
        min-height: 68px;
        padding: 18px 4px;
        border-bottom: 1px solid var(--mf-line);
        text-align: left;
    }

    .mf-link sup {
        margin: 0;
        align-self: center;
        vertical-align: baseline;
        line-height: 1;
        font-size: 11px;
    }

    .mf-link svg {
        width: 20px;
        height: 20px;
        color: var(--mf-mut);
    }

    .mf-link:active {
        color: var(--mf-hi);
    }

    .mf-bar {
        flex-direction: column;
        justify-content: center;
        gap: 16px;
        margin-top: 64px;
        padding-top: 0;
        border-top: 0;
        text-align: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mf-dot { animation: none; }
}
