/* ============================================
   Cheetah Theme - Footer Styles
   ============================================ */

/* CSS Custom Properties — Configurable via JS,
   Customizer, or inline styles for dynamic theming
--------------------------------------------- */
:root {
    /* Background & Surface */
    --cheetah-footer-bg: #1a1a1a;

    /* Typography Colors */
    --cheetah-footer-text: #a8a29e;
    --cheetah-footer-heading: #ffffff;
    --cheetah-footer-link: #a8a29e;
    --cheetah-footer-link-hover: #ffffff;
    --cheetah-copyright: #78716c;

    /* Accent */
    --cheetah-accent: #b8860b;
    --cheetah-accent-hover: #9a6d0a;

    /* Borders */
    --cheetah-border: rgba(255, 255, 255, 0.1);
    --cheetah-bottom-border: rgba(255, 255, 255, 0.1);

    /* Form Inputs */
    --cheetah-input-bg: rgba(255, 255, 255, 0.1);
    --cheetah-input-border: rgba(255, 255, 255, 0.2);
    --cheetah-input-placeholder: #78716c;

    /* Social */
    --cheetah-social-bg: rgba(255, 255, 255, 0.1);
    --cheetah-social-hover: #b8860b;

    /* Fonts */
    --cheetah-footer-font: 'Inter', sans-serif;
    --cheetah-brand-font: 'Playfair Display', serif;

    /* Layout */
    --cheetah-footer-max-width: 1280px;
    --cheetah-footer-padding-y: 48px;
    --cheetah-footer-padding-x: 16px;
    --cheetah-footer-gap: 32px;
    --cheetah-border-radius: 8px;

    /* Motion */
    --cheetah-transition: all 0.3s ease;
}

/* SVG Icon Utility
--------------------------------------------- */
.cheetah-icon {
    width: 1em;
    height: 1em;
    fill: currentColor;
    flex-shrink: 0;
}

/* Footer Main
--------------------------------------------- */
.site-footer {
    background: var(--cheetah-footer-bg);
    color: var(--cheetah-footer-text);
    font-family: var(--cheetah-footer-font);
    font-size: 0.875rem;
    line-height: 1.625;
    margin-top: auto;
    flex-shrink: 0;
}

.site-footer .cheetah-container {
    max-width: var(--cheetah-footer-max-width);
    margin: 0 auto;
    padding: var(--cheetah-footer-padding-y) var(--cheetah-footer-padding-x);
}

/* Footer Grid
--------------------------------------------- */
.footer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--cheetah-footer-gap);
}

/* Footer Columns
--------------------------------------------- */
.footer-col {
    min-width: 0; /* Prevent overflow in grid */
}

.footer-brand-name {
    font-family: var(--cheetah-brand-font);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--cheetah-footer-heading);
    display: block;
    margin-bottom: 1rem;
}

.footer-brand-name a {
    color: inherit;
    text-decoration: none;
    transition: var(--cheetah-transition);
}

.footer-brand-name a:hover {
    color: var(--cheetah-accent);
}

.footer-text {
    color: var(--cheetah-footer-text);
    line-height: 1.625;
    margin-bottom: 1rem;
}

.footer-heading {
    font-size: 1rem;
    font-weight: 600;
    color: var(--cheetah-footer-heading);
    margin-bottom: 1rem;
}

/* Links & Menus
--------------------------------------------- */
.footer-links {
    list-style: none;
    margin: 0;
    padding: 0;
}

.footer-links li {
    margin-bottom: 0.5rem;
}

.footer-links a {
    color: var(--cheetah-footer-link);
    text-decoration: none;
    transition: var(--cheetah-transition);
}

.footer-links a:hover {
    color: var(--cheetah-footer-link-hover);
}

/* Social Links
--------------------------------------------- */
.footer-socials {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.footer-social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--cheetah-social-bg);
    color: var(--cheetah-footer-heading);
    text-decoration: none;
    transition: var(--cheetah-transition);
}

.footer-social-link:hover {
    background: var(--cheetah-social-hover);
}

.footer-social-link .cheetah-icon {
    width: 0.875rem;
    height: 0.875rem;
}

/* Newsletter Form
--------------------------------------------- */
.footer-newsletter-text {
    color: var(--cheetah-footer-text);
    margin-bottom: 1rem;
    line-height: 1.625;
}

.footer-form {
    display: flex;
}

.footer-input {
    flex: 1;
    background: var(--cheetah-input-bg);
    border: 1px solid var(--cheetah-input-border);
    border-right: none;
    border-radius: var(--cheetah-border-radius) 0 0 var(--cheetah-border-radius);
    padding: 10px 16px;
    font-size: 0.875rem;
    color: var(--cheetah-footer-heading);
    font-family: var(--cheetah-footer-font);
    outline: none;
    transition: var(--cheetah-transition);
}

.footer-input::placeholder {
    color: var(--cheetah-input-placeholder);
}

.footer-input:focus {
    border-color: var(--cheetah-accent);
}

.footer-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cheetah-accent);
    border: none;
    border-radius: 0 var(--cheetah-border-radius) var(--cheetah-border-radius) 0;
    padding: 0 16px;
    color: var(--cheetah-footer-heading);
    cursor: pointer;
    transition: var(--cheetah-transition);
}

.footer-submit:hover {
    background: var(--cheetah-accent-hover);
}

.footer-submit .cheetah-icon {
    width: 0.875rem;
    height: 0.875rem;
}

/* Footer Bottom
--------------------------------------------- */
.footer-bottom {
    border-top: 1px solid var(--cheetah-bottom-border);
    margin-top: 48px;
    padding-top: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.footer-copyright {
    margin: 0;
    font-size: 0.75rem;
    color: var(--cheetah-copyright);
}

.footer-legal {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.footer-legal a {
    font-size: 0.75rem;
    color: var(--cheetah-copyright);
    text-decoration: none;
    transition: var(--cheetah-transition);
}

.footer-legal a:hover {
    color: var(--cheetah-footer-link-hover);
}

/* Back to Top Button
--------------------------------------------- */
/*
 * The button is fully self-contained: every visual property is driven
 * by a CSS custom property whose value is emitted inline by the PHP
 * template. The defaults below are the fallbacks used before the
 * inline style is parsed (they should never apply in practice) and are
 * deliberately identical to the theme's shipped defaults.
 *
 * Visibility is driven purely by CSS. There is no `hidden` attribute
 * on the element and no JS-side `display` toggle — the JS only adds
 * and removes the `.is-visible` class. That eliminates the whole class
 * of "the attribute was never removed" bugs that made the previous
 * button permanently invisible.
 */
.cheetah-back-to-top {
    /* Shipped defaults — overridden inline by the PHP template. */
    --cheetah-btt-size: 48px;
    --cheetah-btt-radius: 50%;
    --cheetah-btt-icon-size: 20px;
    --cheetah-btt-icon-color: #ffffff;
    --cheetah-btt-bg: var(--cheetah-primary, #2563eb);
    --cheetah-btt-bg-hover: var(--cheetah-primary-hover, #1d4ed8);
    --cheetah-btt-offset-x: 30px;
    --cheetah-btt-offset-y: 30px;
    --cheetah-btt-mobile-offset: 20px;

    position: fixed;
    z-index: 999;
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: var(--cheetah-btt-size);
    height: var(--cheetah-btt-size);
    padding: 0;

    color: var(--cheetah-btt-icon-color);
    background-color: var(--cheetah-btt-bg);
    border: 0;
    border-radius: var(--cheetah-btt-radius);
    cursor: pointer;

    /*
     * Elevation. Two stacked shadows — a tight contact shadow to ground
     * the button against the page, and a wider soft shadow to suggest
     * height. The same treatment is reused on hover and focus-visible
     * so the elevation system stays consistent across states.
     */
    box-shadow:
            0 4px 12px rgba(15, 23, 42, 0.12),
            0 1px 3px rgba(15, 23, 42, 0.08);

    /*
     * Hidden state. `visibility` is kept so screen readers do not pick
     * up the button while it is off-screen, and `pointer-events` keeps
     * it from intercepting clicks during the fade transition. The
     * `transform` origin is bottom-center so the button appears to rise
     * up into place rather than scale from a corner.
     */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(12px) scale(0.9);
    transform-origin: bottom center;

    /*
     * The `visibility` transition uses a delay in the hidden direction
     * so the fade-out completes before the element is removed from the
     * accessibility tree. The `.is-visible` rule below reverses that
     * delay so the fade-in starts immediately.
     */
    transition:
            opacity 220ms cubic-bezier(0.22, 1, 0.36, 1),
            transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
            visibility 0ms linear 220ms,
            background-color 150ms ease,
            box-shadow 150ms ease;

    /* Suppress the iOS / Android tap flash on this circular surface. */
    -webkit-tap-highlight-color: transparent;
}

.cheetah-back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);

    transition:
            opacity 220ms cubic-bezier(0.22, 1, 0.36, 1),
            transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
            visibility 0ms linear 0ms,
            background-color 150ms ease,
            box-shadow 150ms ease;
}

.cheetah-back-to-top:hover {
    background-color: var(--cheetah-btt-bg-hover);
    transform: translateY(-2px) scale(1);
    box-shadow:
            0 8px 20px rgba(15, 23, 42, 0.16),
            0 2px 6px rgba(15, 23, 42, 0.1);
}

.cheetah-back-to-top:active {
    transform: translateY(0) scale(0.97);
    box-shadow:
            0 2px 6px rgba(15, 23, 42, 0.12),
            0 1px 2px rgba(15, 23, 42, 0.08);
}

.cheetah-back-to-top:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
    box-shadow:
            0 0 0 4px color-mix(in srgb, var(--cheetah-btt-bg) 40%, transparent),
            0 8px 20px rgba(15, 23, 42, 0.16);
}

.cheetah-back-to-top__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--cheetah-btt-icon-size);
    height: var(--cheetah-btt-icon-size);
    /* Kill the inline-element baseline gap that some browsers add. */
    line-height: 0;
}

/*
 * IMPORTANT — do NOT set `fill` or `stroke` here.
 *
 * An earlier version of this rule declared `stroke: currentColor` and
 * `fill: currentColor` on the SVG. That broke every outline preset:
 *
 *   • Presentation attributes (like `fill="none"` on the <svg>) are
 *     inherited by child elements, but CSS always wins over them.
 *   • The bundled outline presets rely on `fill="none"` to render as
 *     thin line art. When CSS forces `fill: currentColor` on the
 *     <svg>, the child <polyline>/<path> inherit the fill and the
 *     open shapes close into solid silhouettes — a chevron becomes a
 *     filled triangle, an arrow becomes a filled arrowhead.
 *   • The result was that the frontend icon looked completely
 *     different from the same icon in the admin picker (which never
 *     applied a fill override), and much heavier/less elegant.
 *
 * The presets already declare `stroke="currentColor"` (or
 * `fill="currentColor"` for solid shapes) as presentation attributes.
 * `currentColor` resolves against the button's own `color`, which is
 * set to `var(--cheetah-btt-icon-color)` above, so the icons still
 * track the "Icon Colour" theme option — they just do it through the
 * SVG's own attributes instead of a CSS override that fights them.
 *
 * If you ever need a genuinely new colour behaviour for a specific
 * preset, add it to that preset's SVG markup (e.g. by wrapping the
 * shape in a <g fill="currentColor">), not to this rule.
 */
.cheetah-back-to-top__icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* Corner anchoring
--------------------------------------------- */
.cheetah-back-to-top[data-position="bottom-right"] {
    right: var(--cheetah-btt-offset-x);
    bottom: var(--cheetah-btt-offset-y);
    left: auto;
    top: auto;
}

.cheetah-back-to-top[data-position="bottom-left"] {
    left: var(--cheetah-btt-offset-x);
    bottom: var(--cheetah-btt-offset-y);
    right: auto;
    top: auto;
}

/* Mobile overrides
--------------------------------------------- */
@media (max-width: 767px) {
    /*
     * On mobile the offsets collapse to a single tighter value so the
     * button never collides with the device's home indicator, the
     * floating mini-cart, or the on-screen keyboard.
     */
    .cheetah-back-to-top {
        --cheetah-btt-offset-x: var(--cheetah-btt-mobile-offset);
        --cheetah-btt-offset-y: var(--cheetah-btt-mobile-offset);
    }
}

/* Reduced motion
--------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    /*
     * With reduced motion the button simply appears and disappears
     * without any transition. Using `display: none` on the hidden state
     * is the cleanest way to guarantee no animation runs — `visibility`
     * alone would still fire a repaint frame.
     */
    .cheetah-back-to-top {
        transition: none !important;
        transform: none !important;
    }

    .cheetah-back-to-top.is-visible {
        transition: none !important;
        transform: none !important;
    }

    .cheetah-back-to-top:hover {
        transform: none !important;
    }

    .cheetah-back-to-top:active {
        transform: none !important;
    }
}

/* Responsive Breakpoints
--------------------------------------------- */
@media screen and (min-width: 640px) {
    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }

    .footer-bottom {
        flex-direction: row;
        justify-content: space-between;
    }
}

@media screen and (min-width: 1024px) {
    :root {
        --cheetah-footer-padding-y: 64px;
        --cheetah-footer-padding-x: 32px;
        --cheetah-footer-gap: 48px;
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr 1fr 1fr;
    }
}