/* How the site answers a tap or a click, on every page (app/layout.tsx).
   Hover effects are in each page's CSS, inside @media (hover: hover), so
   they only run with a mouse; on a touch screen, these press styles are the
   feedback instead. */

/* ---------- Press feedback ----------
   Buttons and cards give way the moment they are pressed (`transition:
   scale 0s`) and spring back with a slight overshoot when let go: each
   one's own transition in its page's CSS ends with
   `scale 0.45s cubic-bezier(0.34, 1.56, 0.64, 1)`, and the :where() rule
   below gives the same spring to the ones without a transition of their own
   (it has no specificity, so any page rule wins). `scale` stacks on top of
   any transform they already have (hover lifts, centering). */
:is(button, .btn, .btn-back, .btn-main, .btn-dash, .btn-outline, .btn-obsidian, .price-btn, .nav-btn,
    .fancy-btn, .discord-btn, .edit-cart-btn, .features-cta-btn, .features-jump a, .cart-empty__btn, .store-brand, .partner-hero .brand) {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* a quick double tap or double click doesn't select the label */
:is(button, .btn, .btn-back, .btn-main, .btn-dash, .btn-outline, .btn-obsidian, .price-btn, .nav-btn,
    .fancy-btn, .discord-btn, .edit-cart-btn, .features-cta-btn, .features-jump a, .cart-empty__btn) {
    -webkit-user-select: none;
    user-select: none;
}

:where(button, .features-cta-btn) {
    transition: scale 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

:is(button, .btn, .btn-back, .btn-main, .btn-dash, .btn-outline, .btn-obsidian, .price-btn, .nav-btn,
    .fancy-btn, .discord-btn, .edit-cart-btn, .features-cta-btn, .features-jump a, .cart-empty__btn):active:not(:disabled) {
    scale: 0.96;
    transition: scale 0s;
}

/* the menu buttons, a little more (the id outranks the list above) */
:is(#open-btn, .open-btn, .close-btn):active {
    scale: 0.9;
}

/* cards: a smaller give, they are big */
:is(.product-card:not(.product-card--coming-soon), .team-cards .card, .thumb, .option-card, .feature-item,
    .shipping-option-label) {
    -webkit-tap-highlight-color: transparent;
}

:is(.product-card:not(.product-card--coming-soon), .team-cards .card, .thumb, .option-card, .feature-item,
    .shipping-option-label):active {
    scale: 0.98;
    transition: scale 0s;
}

/* links in lists (menu, footer): dim while pressed, like a native list */
:is(.sidebar nav a, .footer-column > a, .social-icons a, .social-links a, .store-brand, .partner-hero .brand) {
    -webkit-tap-highlight-color: transparent;
}

:is(.sidebar nav a, .footer-column > a, .store-brand, .partner-hero .brand):active {
    opacity: 0.6;
    transition: opacity 0s;
}

.social-icons a:active,
.social-links a:active {
    opacity: 1;
    scale: 0.88;
    transition: scale 0s, opacity 0s;
}

/* ---------- The main buttons: depth, shine and glow ----------
   The buttons that move an order forward (Checkout, Continue, Pre-order,
   Find my order, Join the Discord...) get the same finish on every page: a
   soft gloss on the top half, a band of light that sweeps across once when
   the mouse arrives, a lift, and a glow in the button's own color (--glow,
   r,g,b; the shop's blue when a button doesn't set one). The gloss and the shine are pseudo-elements under the label
   (z-index -1 inside the button's own stacking context), so the text stays
   crisp; neither needs overflow: hidden, so the glow isn't clipped. */
:is(.place-order-btn, .checkout-btn, .buy-btn, .preorder-submit, .lookup-card button, .features-cta-btn,
    .discord-btn, .result-btn:not(.result-btn--quiet), .cart-empty__btn, .buy-bar__btn, .btn-obsidian) {
    position: relative;
    isolation: isolate;
    transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease, opacity 0.25s ease,
        box-shadow 0.3s ease, transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
        scale 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.place-order-btn { --glow: 40, 167, 69; }
.place-order-btn.back-btn { --glow: 0, 123, 255; }
.buy-btn--preorder, .preorder-submit { --glow: 255, 159, 67; }
.lookup-card button { --glow: 0, 255, 204; }
.discord-btn { --glow: 88, 101, 242; }

:is(.place-order-btn, .checkout-btn, .buy-btn, .preorder-submit, .lookup-card button, .features-cta-btn,
    .discord-btn, .result-btn:not(.result-btn--quiet), .cart-empty__btn, .buy-bar__btn, .btn-obsidian)::before,
:is(.place-order-btn, .checkout-btn, .buy-btn, .preorder-submit, .lookup-card button, .features-cta-btn,
    .discord-btn, .result-btn:not(.result-btn--quiet), .cart-empty__btn, .buy-bar__btn, .btn-obsidian)::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    pointer-events: none;
}

/* gloss: light from above */
:is(.place-order-btn, .checkout-btn, .buy-btn, .preorder-submit, .lookup-card button, .features-cta-btn,
    .discord-btn, .result-btn:not(.result-btn--quiet), .cart-empty__btn, .buy-bar__btn, .btn-obsidian)::before {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0) 55%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}

/* shine: parked off the left edge; crosses to the right on hover */
:is(.place-order-btn, .checkout-btn, .buy-btn, .preorder-submit, .lookup-card button, .features-cta-btn,
    .discord-btn, .result-btn:not(.result-btn--quiet), .cart-empty__btn, .buy-bar__btn, .btn-obsidian)::after {
    background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.4) 50%, transparent 60%) no-repeat;
    background-size: 250% 100%;
    background-position: 130% 0;
}

:is(.place-order-btn, .checkout-btn, .buy-btn, .preorder-submit, .lookup-card button, .features-cta-btn,
    .discord-btn, .result-btn:not(.result-btn--quiet), .cart-empty__btn, .buy-bar__btn, .btn-obsidian):disabled::before {
    opacity: 0.35;
}

@media (hover: hover) {
    :is(.place-order-btn, .checkout-btn, .buy-btn, .preorder-submit, .lookup-card button, .features-cta-btn,
        .discord-btn, .result-btn:not(.result-btn--quiet), .cart-empty__btn, .buy-bar__btn, .btn-obsidian):hover:not(:disabled) {
        box-shadow: 0 0 0 1px rgba(var(--glow, 79, 195, 255), 0.35),
            0 10px 26px -8px rgba(var(--glow, 79, 195, 255), 0.75),
            0 0 28px -6px rgba(var(--glow, 79, 195, 255), 0.55);
    }
}

/* the movement only when the system doesn't ask for less of it */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    :is(.place-order-btn, .checkout-btn, .buy-btn, .preorder-submit, .lookup-card button, .features-cta-btn,
        .discord-btn, .result-btn:not(.result-btn--quiet), .cart-empty__btn, .buy-bar__btn, .btn-obsidian):hover:not(:disabled) {
        transform: translateY(-2px);
    }

    :is(.place-order-btn, .checkout-btn, .buy-btn, .preorder-submit, .lookup-card button, .features-cta-btn,
        .discord-btn, .result-btn:not(.result-btn--quiet), .cart-empty__btn, .buy-bar__btn, .btn-obsidian):hover:not(:disabled)::after {
        background-position: -30% 0;
        transition: background-position 0.9s cubic-bezier(0.45, 0, 0.25, 1);
    }
}

/* pressed: settles back down and gives way at once (the spring is on the
   way back up, as everywhere) */
:is(.place-order-btn, .checkout-btn, .buy-btn, .preorder-submit, .lookup-card button, .features-cta-btn,
    .discord-btn, .result-btn:not(.result-btn--quiet), .cart-empty__btn, .buy-bar__btn, .btn-obsidian):active:not(:disabled) {
    transform: translateY(0);
    scale: 0.96;
    transition: scale 0s, transform 0.1s ease, box-shadow 0.1s ease;
}

/* waiting on the server (aria-busy, set by the page's script while the
   button says "Verifying...", "Processing..."): a spinner on the right
   instead of the shine */
:is(.place-order-btn, .checkout-btn, .buy-btn, .lookup-card button):disabled[aria-busy="true"] {
    cursor: progress;
}

:is(.place-order-btn, .checkout-btn, .buy-btn, .lookup-card button):disabled[aria-busy="true"]::after {
    inset: 50% 1em auto auto;
    width: 1em;
    height: 1em;
    margin-top: -0.5em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    background: none;
    opacity: 0.85;
    animation: feel-spin 0.7s linear infinite;
}

@keyframes feel-spin {
    to {
        rotate: 1turn;
    }
}

/* ---------- Quieter buttons: a glowing edge ----------
   Back, Edit Your Cart, the quiet "Contact us": the edge lights up in the
   shop's blue and the button lifts a little. */
@media (hover: hover) {
    :is(.btn-back, .edit-cart-btn, .detail-back, .result-btn--quiet):hover {
        border-color: rgba(79, 195, 255, 0.45);
        box-shadow: 0 0 0 1px rgba(79, 195, 255, 0.12), 0 8px 20px -10px rgba(79, 195, 255, 0.6);
    }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    :is(.btn-back, .edit-cart-btn, .detail-back, .result-btn--quiet):hover {
        transform: translateY(-1px);
    }
}

:is(.btn-back, .edit-cart-btn, .detail-back, .result-btn--quiet) {
    transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease, box-shadow 0.3s ease,
        transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), scale 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------- The homepage's buttons ----------
   Shop Calculators and Dashboard get the same sweep of light (on ::before:
   their ::after is the bigger tap area on touch screens) and a purple glow;
   the outlined ones a blue edge. */
:is(.btn-main, .btn-dash, .btn-outline) {
    position: relative;
    isolation: isolate;
}

:is(.btn-main, .btn-dash)::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.28) 50%, transparent 60%) no-repeat;
    background-size: 250% 100%;
    background-position: 130% 0;
}

@media (hover: hover) {
    .btn-main:hover {
        box-shadow: 0 0 0 1px rgba(150, 100, 210, 0.35), 0 10px 26px -8px rgba(118, 75, 162, 0.85),
            0 0 30px -8px rgba(150, 100, 210, 0.6);
    }

    .btn-dash:hover {
        box-shadow: 0 0 0 1px rgba(150, 100, 210, 0.4), 0 10px 26px -8px rgba(118, 75, 162, 0.9),
            0 0 34px -6px rgba(150, 100, 210, 0.65);
    }

    .btn-outline:hover {
        background: rgba(79, 195, 255, 0.06);
        box-shadow: 0 0 0 1px rgba(79, 195, 255, 0.12), 0 8px 20px -10px rgba(79, 195, 255, 0.6);
    }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    :is(.btn-main, .btn-dash):hover::before {
        background-position: -30% 0;
        transition: background-position 0.9s cubic-bezier(0.45, 0, 0.25, 1);
    }

    .btn-outline:hover {
        transform: translateY(-2px);
    }
}

/* ---------- Two-way switches slide ----------
   The product page's Text / Camera and Buy New / Modify Mine: the blue pill
   slides to the side picked instead of jumping. Browsers without :has()
   keep the plain highlighted button. */
@supports selector(:has(*)) {
    .method-toggle {
        position: relative;
        isolation: isolate;
    }

    .method-toggle::before {
        content: "";
        position: absolute;
        z-index: -1;
        top: 4px;
        bottom: 4px;
        left: 4px;
        width: calc((100% - 8px - 6px) / 2);
        border-radius: 7px;
        background: linear-gradient(180deg, #6fd0ff, #4fc3ff 60%);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 4px 14px rgba(79, 195, 255, 0.3);
        transition: translate 0.4s cubic-bezier(0.34, 1.12, 0.64, 1), opacity 0.2s ease;
        pointer-events: none;
    }

    .method-toggle:has(> .toggle-btn:nth-child(2).active)::before {
        translate: calc(100% + 6px) 0;
    }

    .method-toggle:not(:has(> .toggle-btn.active))::before {
        opacity: 0;
    }

    .method-toggle > .toggle-btn.active {
        background: transparent;
        box-shadow: none;
    }
}

/* ---------- Text fields: a soft ring while typing ---------- */
:is(.lookup-card input, .preorder-input-row input) {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.lookup-card input:focus {
    box-shadow: 0 0 0 3px rgba(79, 195, 255, 0.2);
}

.preorder-input-row input:focus {
    box-shadow: 0 0 0 3px rgba(255, 159, 67, 0.2);
}

/* ---------- Quantity steppers: - [ n ] + ----------
   The product page and the cart lines. The number box is still a real
   input (type a number, or use the buttons); the browser's own tiny arrows
   are hidden. The whole control rings while the box has focus. */
.stepper {
    display: inline-flex;
    align-items: stretch;
    height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* while typing in the box (not after a click on - or +, which keeps the
   button focused in Chrome) */
.stepper:has(input:focus) {
    border-color: #4fc3ff;
    box-shadow: 0 0 0 3px rgba(79, 195, 255, 0.18);
}

.stepper input {
    width: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #fff;
    text-align: center;
    font: inherit;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    appearance: textfield;
    -moz-appearance: textfield;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.stepper input:focus {
    outline: none;
    box-shadow: none;
}

.stepper-btn {
    display: grid;
    place-items: center;
    width: 34px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #bfe9ff;
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, scale 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stepper-btn:first-child {
    border-radius: 9px 0 0 9px;
}

.stepper-btn:last-child {
    border-radius: 0 9px 9px 0;
}

@media (hover: hover) {
    .stepper-btn:hover:not(:disabled) {
        background: rgba(79, 195, 255, 0.14);
        color: #fff;
    }
}

.stepper-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

/* ---------- Product cards: light follows the mouse ----------
   A soft glow under the pointer (its position, --mx/--my, is set by the
   small script in app/layout.tsx). Under the card's content, over its
   background. */
.product-card:not(.product-card--coming-soon)::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    pointer-events: none;
    background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 0%), rgba(79, 195, 255, 0.18), transparent 60%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.product-card {
    isolation: isolate;
}

@media (hover: hover) {
    .product-card:not(.product-card--coming-soon):hover::after {
        opacity: 1;
    }
}

/* ---------- Back to top (components/ToTop.tsx) ----------
   On the long pages. Hidden until the page is scrolled a way down, then it
   rises in; it glows and lifts under the mouse like the other buttons. */
.to-top {
    position: fixed;
    right: max(20px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
    z-index: 900;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(79, 195, 255, 0.35);
    background: rgba(10, 16, 22, 0.78);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: #bfe9ff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    opacity: 0;
    translate: 0 14px;
    pointer-events: none;
    transition: opacity 0.25s ease, translate 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease,
        border-color 0.2s ease, color 0.2s ease, box-shadow 0.25s ease, scale 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.to-top.is-shown {
    opacity: 1;
    translate: 0 0;
    pointer-events: auto;
}

.to-top svg {
    width: 20px;
    height: 20px;
}

@media (hover: hover) {
    .to-top.is-shown:hover {
        color: #0a1016;
        background: #4fc3ff;
        border-color: #4fc3ff;
        box-shadow: 0 0 0 4px rgba(79, 195, 255, 0.18), 0 10px 26px -8px rgba(79, 195, 255, 0.9);
    }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    .to-top.is-shown:hover {
        translate: 0 -3px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .to-top {
        translate: none;
    }
}

/* ---------- Keyboard focus ----------
   One clear ring on whatever Tab lands on (a mouse click or a tap doesn't
   show it). No specificity, so the menu links, the product cards and the
   form fields keep the focus styles they have. */
:where(a, button, [role="button"], [tabindex]:not([tabindex="-1"]), summary, select):focus-visible {
    outline: 2px solid #4fc3ff;
    outline-offset: 3px;
}

/* ---------- Moving between pages ----------
   A short crossfade from one page to the next instead of a blank flash
   (Chrome, Edge and Safari; other browsers just change page). */
@media (prefers-reduced-motion: no-preference) {
    @view-transition {
        navigation: auto;
    }

    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation-duration: 0.2s;
    }

    /* the features page's jump links glide to their section */
    html:has(.features-jump) {
        scroll-behavior: smooth;
    }
}

/* ---------- Touch screens ---------- */
@media (hover: none) {
    /* the image carousel's arrows only appeared on hover; a finger can't
       hover, so they show all the time */
    .carousel-container .carousel-button {
        opacity: 1;
    }
}

/* Bigger tap targets, without moving anything: an invisible area around
   small controls that a finger can hit (WCAG asks for 24px, Apple and
   Google for 44-48px). */
@media (pointer: coarse) {
    .social-icons a,
    .remove-btn,
    .edit-cart-btn,
    .btn-main,
    .btn-dash,
    .btn-outline {
        position: relative;
    }

    /* footer links: 22px tall, 10px apart. 5px more above and below (the
       margins take it back, so nothing moves); the areas meet in the gap */
    .footer-column > a {
        padding-block: 5px;
        margin-block: -5px 5px;
    }

    /* 40px round icons, 14px apart: 48px each, not overlapping */
    .social-icons a::after {
        content: "";
        position: absolute;
        inset: -4px;
    }

    /* the cart's 28px remove button */
    .remove-btn::after {
        content: "";
        position: absolute;
        inset: -10px;
    }

    /* the homepage's 32px buttons, the checkout's Edit Your Cart */
    .edit-cart-btn::after,
    .btn-main::after,
    .btn-dash::after,
    .btn-outline::after {
        content: "";
        position: absolute;
        inset: -6px 0;
    }
}

/* ---------- Less motion when the system asks for it ---------- */
@media (prefers-reduced-motion: reduce) {
    :is(button, .btn, .btn-back, .btn-main, .btn-dash, .btn-outline, .btn-obsidian, .price-btn, .nav-btn,
        .fancy-btn, .discord-btn, .edit-cart-btn, .features-cta-btn, .features-jump a, .cart-empty__btn, .product-card,
        .team-cards .card, .thumb, .option-card, .feature-item, .shipping-option-label, .social-icons a,
        .social-links a, #open-btn, .open-btn, .close-btn):active {
        scale: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    /* the switch's pill jumps instead of sliding */
    .method-toggle::before {
        transition: none;
    }
}
