/* ==========================================================================
   Thanyh experience layer (2026-10)
   Loaded after base.css + responsive.css on every page.
   New components use the .th-x- prefix; existing components are only
   adjusted where noted. Motion = transform/opacity only.
   ========================================================================== */

:root {
    --th-x-ease: cubic-bezier(.22, .8, .24, 1);
    --th-x-ring: 0 0 0 3px #fff, 0 0 0 5px var(--th-blue);
    --th-x-shadow-lg: 0 30px 80px rgba(16, 24, 40, .16);
}

/* Visible keyboard focus everywhere the theme did not define one. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--th-blue);
    outline-offset: 2px;
}

html.th-x-lock,
html.th-x-lock body {
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   Homepage hero: text + interactive 3D stage
   -------------------------------------------------------------------------- */

.th-home-hero.th-x-hero {
    position: relative;
    overflow: hidden;
    padding-block: 56px 40px;
    text-align: start;
    background:
        radial-gradient(60% 70% at 15% 40%, rgba(23, 105, 232, .13), transparent 70%),
        radial-gradient(40% 50% at 90% 0%, rgba(23, 105, 232, .08), transparent 70%),
        linear-gradient(180deg, #fff 0%, var(--th-bg) 100%);
}

.th-x-hero > .th-container {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
    align-items: center;
    gap: clamp(24px, 4vw, 56px);
}

.th-x-hero .th-hero-content {
    max-width: 620px;
    margin: 0;
}

.th-x-hero .th-hero-content > p {
    margin-inline: 0;
    font-size: 18px;
    line-height: 1.8;
}

.th-x-hero .th-hero-buttons,
.th-x-hero .th-hero-mini-features {
    justify-content: flex-start;
}

.th-x-hero .th-hero-buttons .th-btn-primary {
    min-width: 170px;
    box-shadow: 0 12px 28px rgba(23, 105, 232, .28);
}

.th-x-hero .th-hero-mini-features {
    gap: 10px;
    font-size: 13px;
}

.th-x-hero .th-hero-mini-features span {
    padding: 7px 12px;
    border: 1px solid var(--th-border);
    border-radius: 999px;
    background: rgba(255, 255, 255, .8);
    color: var(--th-text);
    font-weight: 600;
}

/* Stage */

.th-x-stage {
    position: relative;
    min-height: 460px;
    height: 100%;
    isolation: isolate;
    touch-action: pan-y;
    user-select: none;
}

.th-x-stage-glow {
    position: absolute;
    inset: 12% 14%;
    z-index: -1;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(23, 105, 232, .22), rgba(23, 105, 232, 0) 68%);
    filter: blur(8px);
}

.th-x-stage-canvas {
    position: absolute;
    inset: 0;
    width: 100% !important; /* three.js sets inline pixel sizes */
    height: 100% !important;
    opacity: 0;
    transition: opacity .8s var(--th-x-ease);
}

.th-x-stage.is-3d .th-x-stage-canvas {
    opacity: 1;
}

/* Static fallback: three tilted product cards (no-JS, no-WebGL, reduced motion). */

.th-x-stage-fallback {
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 0;
    list-style: none;
    transition: opacity .5s ease;
}

.th-x-stage.is-3d .th-x-stage-fallback {
    opacity: 0;
    pointer-events: none;
}

.th-x-stage-fallback li {
    --x: calc((var(--i) - 1) * 34%);
    --r: calc((var(--i) - 1) * 9deg);
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(46%, 220px);
    aspect-ratio: 1;
    padding: 8px;
    border-radius: 22px;
    background: #fff;
    box-shadow: var(--th-x-shadow-lg);
    transform: translate(calc(-50% + var(--x)), -50%) rotate(var(--r));
    animation: th-x-float 6s ease-in-out infinite;
    animation-delay: calc(var(--i) * -2s);
}

.th-x-stage-fallback li:nth-child(2) {
    z-index: 2;
    width: min(54%, 260px);
}

.th-x-stage-fallback img {
    width: 100%;
    height: 100%;
    border-radius: 15px;
    object-fit: cover;
}

@keyframes th-x-float {
    50% {
        transform: translate(calc(-50% + var(--x)), calc(-50% - 12px)) rotate(var(--r));
    }
}

.th-x-stage-tip {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 3;
    max-width: 220px;
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--th-dark);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.5;
    text-align: center;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    will-change: transform;
}

/* --------------------------------------------------------------------------
   "How it works" — exactly 3 steps, 3-col → 1-col grid
   -------------------------------------------------------------------------- */

.th-x-how {
    padding-block: 28px 44px;
    background: var(--th-bg);
}

.th-x-how h2 {
    margin: 0 0 18px;
    color: var(--th-dark);
    font-size: clamp(20px, 2.4vw, 26px);
}

.th-x-how-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.th-x-how-grid li {
    display: grid;
    grid-template-columns: 44px 1fr;
    grid-template-rows: auto auto;
    column-gap: 14px;
    align-items: center;
    padding: 18px;
    border: 1px solid var(--th-border);
    border-radius: var(--th-radius);
    background: #fff;
}

.th-x-how-num {
    grid-row: 1 / 3;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--th-blue-soft);
    color: var(--th-blue);
    font-size: 18px;
    font-weight: 800;
}

.th-x-how-grid h3 {
    margin: 0;
    color: var(--th-dark);
    font-size: 16px;
}

.th-x-how-grid p {
    margin: 2px 0 0;
    color: var(--th-muted);
    font-size: 13.5px;
    line-height: 1.7;
}

/* --------------------------------------------------------------------------
   Header search: live suggestions + visible on mobile
   -------------------------------------------------------------------------- */

.th-site-header .th-header-search.th-x-search-ready {
    position: relative;
    overflow: visible;
}

/* The form already shows a focus-within border; avoid a second ring on the input. */
.th-site-header .th-header-search input:focus-visible {
    outline: none;
}

.th-x-search-ready input {
    border-start-start-radius: 10px;
    border-end-start-radius: 10px;
}

.th-x-search-ready.is-searching button svg {
    animation: th-x-pulse .9s ease-in-out infinite;
}

@keyframes th-x-pulse {
    50% { opacity: .35; }
}

.th-x-suggest {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline: 0;
    z-index: 120;
    max-height: min(70vh, 520px);
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--th-border);
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--th-x-shadow-lg);
    overscroll-behavior: contain;
}

.th-x-suggest-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 4px 10px;
    border-bottom: 1px solid var(--th-border);
    margin-bottom: 6px;
}

.th-x-suggest-cat {
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--th-blue-soft);
    color: var(--th-blue);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.th-x-suggest-item {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 10px;
    color: var(--th-text);
    text-decoration: none;
}

.th-x-suggest-item img {
    width: 44px;
    height: 44px;
    border-radius: 9px;
    object-fit: cover;
    background: var(--th-bg);
}

.th-x-suggest-title {
    overflow: hidden;
    font-size: 14px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.th-x-suggest-price {
    color: var(--th-blue);
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.th-x-suggest-price del {
    color: var(--th-muted-2);
    font-weight: 400;
}

.th-x-suggest-price img {
    width: auto;
    height: .9em;
}

.th-x-suggest-item:hover,
.th-x-suggest-item[aria-selected="true"],
.th-x-suggest-cat[aria-selected="true"],
.th-x-suggest-all[aria-selected="true"] {
    background: var(--th-blue-soft);
}

.th-x-suggest-cat[aria-selected="true"] {
    box-shadow: inset 0 0 0 1.5px var(--th-blue);
}

.th-x-suggest-all {
    display: block;
    margin-top: 4px;
    padding: 10px;
    border-radius: 10px;
    color: var(--th-blue);
    font-size: 13.5px;
    font-weight: 800;
    text-align: center;
    text-decoration: none;
}

.th-x-suggest-empty {
    margin: 0;
    padding: 14px 10px 6px;
    color: var(--th-muted);
    font-size: 14px;
    text-align: center;
}

/* --------------------------------------------------------------------------
   Add-to-cart button feedback
   -------------------------------------------------------------------------- */

.add_to_cart_button.is-loading,
.single_add_to_cart_button.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.add_to_cart_button.is-loading::after,
.single_add_to_cart_button.is-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255, 255, 255, .5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: th-x-spin .7s linear infinite;
}

.add_to_cart_button.is-added,
.single_add_to_cart_button.is-added {
    background: var(--th-green) !important;
    border-color: var(--th-green) !important;
    color: #fff !important;
}

/* WooCommerce injects a "View cart" link after AJAX adds; the drawer replaces it. */
.woocommerce ul.products li.product .added_to_cart,
.single-product form.cart .added_to_cart {
    display: none;
}

@keyframes th-x-spin {
    to { transform: rotate(360deg); }
}

/* Product cards: gentle lift on hover (transform only). */
@media (hover: hover) {
    .woocommerce ul.products li.product,
    .th-rail-card {
        transition: transform .25s var(--th-x-ease);
    }

    .woocommerce ul.products li.product:hover,
    .th-rail-card:hover {
        transform: translateY(-4px);
    }
}

/* --------------------------------------------------------------------------
   Cart drawer
   -------------------------------------------------------------------------- */

.th-x-drawer {
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.th-x-drawer-scrim {
    position: absolute;
    inset: 0;
    background: rgba(9, 13, 20, .5);
    opacity: 0;
    transition: opacity .28s ease;
}

.th-x-drawer-panel {
    position: absolute;
    top: 0;
    bottom: 0;
    inset-inline-end: 0;
    display: flex;
    flex-direction: column;
    width: min(420px, 100%);
    padding-top: env(safe-area-inset-top, 0px);
    background: #fff;
    box-shadow: var(--th-x-shadow-lg);
    transform: translateX(-104%);
    transition: transform .3s var(--th-x-ease);
    outline: none;
}

[dir="ltr"] .th-x-drawer-panel {
    transform: translateX(104%);
}

.th-x-drawer.is-open .th-x-drawer-scrim {
    opacity: 1;
}

.th-x-drawer.is-open .th-x-drawer-panel {
    transform: none;
}

.th-x-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--th-border);
}

.th-x-drawer-head h2 {
    margin: 0;
    color: var(--th-dark);
    font-size: 18px;
}

.th-x-icon-btn {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--th-border);
    border-radius: 10px;
    background: #fff;
    color: var(--th-text);
    cursor: pointer;
}

.th-x-icon-btn svg,
.th-x-drawer svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.th-x-icon-btn:hover {
    border-color: var(--th-border-dark);
    background: var(--th-bg);
}

.th-x-drawer-status {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.th-x-drawer-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    transition: opacity .2s ease;
}

.th-x-drawer.is-busy .th-x-drawer-body {
    opacity: .5;
}

.th-x-drawer-items {
    flex: 1;
    margin: 0;
    padding: 8px 20px;
    overflow-y: auto;
    list-style: none;
    overscroll-behavior: contain;
}

.th-x-drawer-item {
    display: grid;
    grid-template-columns: 60px 1fr auto;
    grid-template-areas:
        "thumb info remove"
        "thumb price price";
    gap: 4px 12px;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--th-border);
    transition: opacity .2s ease;
}

.th-x-drawer-item.is-removing {
    opacity: .4;
}

.th-x-drawer-thumb {
    grid-area: thumb;
}

.th-x-drawer-thumb img {
    display: block;
    width: 60px;
    height: 60px;
    border-radius: 12px;
    object-fit: cover;
    background: var(--th-bg);
}

.th-x-drawer-info {
    grid-area: info;
    min-width: 0;
}

.th-x-drawer-info a,
.th-x-drawer-info span {
    display: block;
    overflow: hidden;
    color: var(--th-text);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.5;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.th-x-drawer-info small {
    color: var(--th-muted);
    font-size: 12px;
}

.th-x-drawer-price {
    grid-area: price;
    color: var(--th-blue);
    font-size: 14px;
    font-weight: 800;
}

.th-x-drawer-remove {
    grid-area: remove;
    width: 34px;
    height: 34px;
    color: var(--th-muted);
}

.th-x-drawer-foot {
    display: grid;
    gap: 10px;
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--th-border);
    background: #fff;
}

.th-x-drawer-subtotal {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    color: var(--th-text);
    font-size: 15px;
}

.th-x-drawer-subtotal strong {
    color: var(--th-dark);
    font-size: 20px;
}

.th-x-drawer-checkout {
    gap: 8px;
    width: 100%;
    font-size: 16px;
}

.th-x-drawer-cartlink {
    color: var(--th-muted);
    font-size: 13px;
    text-align: center;
}

.th-x-drawer-trust {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0;
    color: var(--th-muted);
    font-size: 12px;
}

.th-x-drawer-trust svg {
    width: 14px;
    height: 14px;
    color: var(--th-green);
}

.th-x-drawer-empty {
    display: grid;
    flex: 1;
    place-content: center;
    justify-items: center;
    gap: 12px;
    padding: 30px;
    color: var(--th-muted);
    text-align: center;
}

.th-x-drawer-empty svg {
    width: 52px;
    height: 52px;
    color: var(--th-border-dark);
}

.th-x-drawer-empty p {
    margin: 0;
}

/* --------------------------------------------------------------------------
   Purchase steps (cart + checkout)
   -------------------------------------------------------------------------- */

.th-x-steps {
    display: flex;
    gap: 0;
    max-width: 560px;
    margin: 0 auto 26px;
    padding: 0;
    list-style: none;
    counter-reset: none;
}

.th-x-steps li {
    position: relative;
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--th-muted);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

.th-x-steps li + li::before {
    content: "";
    position: absolute;
    top: 15px;
    inset-inline-end: 50%;
    z-index: 0;
    width: 100%;
    height: 2px;
    background: var(--th-border);
}

.th-x-steps li.is-done + li::before,
.th-x-steps li.is-done::before,
.th-x-steps li.is-current::before {
    background: var(--th-blue);
}

.th-x-step-dot {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 2px solid var(--th-border);
    border-radius: 50%;
    background: #fff;
    font-size: 13px;
}

.th-x-steps li.is-done,
.th-x-steps li.is-current {
    color: var(--th-dark);
}

.th-x-steps li.is-done .th-x-step-dot {
    border-color: var(--th-blue);
    background: var(--th-blue);
    color: #fff;
}

.th-x-steps li.is-current .th-x-step-dot {
    border-color: var(--th-blue);
    color: var(--th-blue);
    box-shadow: 0 0 0 4px var(--th-blue-soft);
}

/* --------------------------------------------------------------------------
   Sticky buy bar (single product, ≤ 900px)
   -------------------------------------------------------------------------- */

.th-x-buybar {
    display: none;
}

@media (max-width: 900px) {
    .th-x-buybar {
        position: fixed;
        inset-inline: 0;
        bottom: 0;
        z-index: 900;
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid var(--th-border);
        background: #fff;
        box-shadow: 0 -10px 30px rgba(16, 24, 40, .08);
        transform: translateY(110%);
        transition: transform .3s var(--th-x-ease);
    }

    .th-x-buybar.is-visible {
        transform: none;
    }

    .th-x-buybar-info {
        flex: 1;
        min-width: 0;
    }

    .th-x-buybar-info strong {
        display: block;
        overflow: hidden;
        color: var(--th-dark);
        font-size: 13px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .th-x-buybar-price {
        margin: 0;
        color: var(--th-blue);
        font-size: 15px;
        font-weight: 800;
    }

    .th-x-buybar-price img {
        width: auto;
        height: .9em;
    }

    .th-x-buybar .th-btn {
        flex: 0 0 auto;
        min-height: 46px;
        padding-inline: 22px;
    }

    body.th-x-has-buybar {
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 980px) {
    .th-x-hero > .th-container {
        grid-template-columns: 1fr;
    }

    .th-x-hero .th-hero-content {
        max-width: none;
        text-align: center;
    }

    .th-x-hero .th-hero-content > p {
        margin-inline: auto;
    }

    .th-x-hero .th-hero-buttons,
    .th-x-hero .th-hero-mini-features {
        justify-content: center;
    }

    .th-x-stage {
        min-height: 340px;
        height: 340px;
        margin-top: -6px;
    }
}

@media (max-width: 767px) {
    .th-home-hero.th-x-hero {
        padding-block: 34px 18px;
    }

    .th-x-hero .th-hero-content > p {
        font-size: 15px;
    }

    .th-x-stage {
        min-height: 280px;
        height: 280px;
        margin-top: -14px;
    }

    .th-x-how-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .th-x-how-grid li {
        padding: 14px;
    }

    /* Search was display:none on phones — bring it back as a full-width row. */
    .th-site-header .th-header-search {
        display: grid;
        grid-column: 1 / -1;
        grid-row: 2;
        max-width: none;
        min-height: 44px;
        margin-bottom: 10px;
    }

    .th-site-header .th-header-search input {
        font-size: 16px; /* prevents iOS zoom on focus */
    }

    .th-x-suggest {
        max-height: 60vh;
    }

    .th-x-steps {
        margin-bottom: 18px;
    }

    .th-x-steps li {
        font-size: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .th-x-stage-fallback li,
    .th-x-search-ready.is-searching button svg {
        animation: none;
    }

    .th-x-drawer-scrim,
    .th-x-drawer-panel,
    .th-x-buybar,
    .th-x-stage-canvas,
    .woocommerce ul.products li.product,
    .th-rail-card {
        transition: none;
    }

    .woocommerce ul.products li.product:hover,
    .th-rail-card:hover {
        transform: none;
    }
}
