/* ==========================================================================
   Timber Tots — Global Floating Purchase Bar + Mini-Cart Drawer
   Loaded site-wide from includes/header.php. Warm/premium palette matching
   the store. Mobile-first with iPhone safe-area support and 56px+ touch
   targets. Uses transforms/opacity for GPU-friendly slide-in animation.
   ========================================================================== */

:root {
    --tt-fbar-height: 68px;
    --tt-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* --------------------------------------------------------------------------
   FLOATING BAR
   -------------------------------------------------------------------------- */
.tt-fbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1200;
    background: rgba(255, 251, 246, 0.98);
    border-top: 1px solid #E7D8C9;
    box-shadow: 0 -6px 20px rgba(109, 60, 29, 0.14);
    padding: 10px 16px calc(10px + var(--tt-safe-bottom));
    /* Hidden by default; slides up when .is-visible is added */
    transform: translateY(120%);
    opacity: 0;
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.32s ease;
    will-change: transform, opacity;
}
.tt-fbar.is-visible {
    transform: translateY(0);
    opacity: 1;
}
/* Cart-only pill hides itself when empty (set by JS via .tt-fbar--empty) */
.tt-fbar--cartonly.tt-fbar--empty { display: none; }

.tt-fbar-inner {
    max-width: 1200px;              /* centered container (desktop req.) */
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.tt-fbar-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;                   /* allow ellipsis */
}
.tt-fbar-name {
    font-family: 'Georgia', serif;
    font-weight: bold;
    color: #5A351C;
    font-size: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tt-fbar-price {
    color: #B5713A;
    font-weight: bold;
    font-size: 18px;
}

.tt-fbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}
.tt-fbar-actions--cartonly { flex: 1 1 auto; justify-content: flex-end; }

.tt-fbar-btn {
    border: none;
    border-radius: 10px;
    font-family: 'Georgia', serif;
    font-weight: bold;
    font-size: 15px;
    cursor: pointer;
    padding: 12px 20px;
    min-height: 48px;
    transition: background 0.2s, transform 0.08s;
    white-space: nowrap;
}
.tt-fbar-btn:active { transform: scale(0.98); }
.tt-fbar-btn:disabled { opacity: 0.7; cursor: default; }

.tt-fbar-add {
    background: #B5713A;
    color: #fff;
}
.tt-fbar-add:hover:not(:disabled) { background: #9D5F2E; }

.tt-fbar-view {
    background: #F4E0CC;
    color: #6D3C1D;
    border: 1px solid #DABDA1;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.tt-fbar-view:hover { background: #EED2B8; }
.tt-fbar-view-short { display: none; }   /* compact label reserved for mobile */

.tt-fbar-count {
    font-weight: bold;
    display: inline-block;
}
/* Bump animation when the quantity changes */
.tt-fbar-count.tt-bump { animation: ttCountBump 0.4s ease; }
@keyframes ttCountBump {
    0% { transform: scale(1); }
    40% { transform: scale(1.35); color: #B5713A; }
    100% { transform: scale(1); }
}

/* --------------------------------------------------------------------------
   BODY PADDING — reserve space so the bar never covers page content
   Added by JS (body.tt-fbar-active) only while the bar is visible.
   -------------------------------------------------------------------------- */
body.tt-fbar-active {
    padding-bottom: calc(var(--tt-fbar-height) + var(--tt-safe-bottom));
}

/* --------------------------------------------------------------------------
   MINI-CART DRAWER
   -------------------------------------------------------------------------- */
.tt-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(45, 26, 14, 0.45);
    z-index: 1300;
    opacity: 0;
    transition: opacity 0.28s ease;
}
.tt-drawer-overlay.is-open { opacity: 1; }

.tt-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(420px, 92vw);
    background: #FFFBF6;
    z-index: 1400;
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 28px rgba(109, 60, 29, 0.22);
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}
.tt-drawer.is-open { transform: translateX(0); }

.tt-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid #EEDFCF;
}
.tt-drawer-title {
    font-size: 20px;
    color: #6D3C1D;
    margin: 0;
}
.tt-drawer-close {
    background: transparent;
    border: none;
    font-size: 30px;
    line-height: 1;
    color: #8B4F24;
    cursor: pointer;
    padding: 0 6px;
}

.tt-drawer-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px 20px;
    -webkit-overflow-scrolling: touch;
}
.tt-drawer-loading,
.tt-drawer-empty {
    color: #7A5C42;
    text-align: center;
    padding: 30px 10px;
}

.tt-drawer-line {
    display: grid;
    grid-template-columns: 64px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #F0E5D8;
}
.tt-drawer-line img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
    background: #F5ECE2;
}
.tt-drawer-line-name {
    font-weight: bold;
    color: #5A351C;
    font-size: 14px;
}
.tt-drawer-line-meta {
    font-size: 12px;
    color: #7A5C42;
}
.tt-drawer-line-total {
    font-weight: bold;
    color: #6D3C1D;
    white-space: nowrap;
}

.tt-drawer-foot {
    border-top: 1px solid #EEDFCF;
    padding: 16px 20px calc(16px + var(--tt-safe-bottom));
    background: #FFF7EF;
}
.tt-drawer-subtotal {
    display: flex;
    justify-content: space-between;
    font-size: 16px;
    color: #5A351C;
    margin-bottom: 4px;
}
.tt-drawer-subtotal strong { color: #6D3C1D; }
.tt-drawer-note {
    font-size: 12px;
    color: #7A5C42;
    margin: 0 0 12px;
}
/* Discount code field inside the drawer */
.tt-drawer-promo-label {
    display: block;
    font-size: 12px;
    font-weight: bold;
    color: #7A5C42;
    margin-bottom: 6px;
}
.tt-drawer-promo {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #D8C7B7;
    border-radius: 8px;
    font-size: 15px;
    font-family: 'Georgia', serif;
    margin-bottom: 6px;
    min-height: 44px;
}
.tt-drawer-promo:focus { outline: none; border-color: #B5713A; }
.tt-drawer-promo-feedback {
    font-size: 12px;
    color: #7A5C42;
    margin: 0 0 12px;
    min-height: 1em;
}
.tt-drawer-checkout {
    width: 100%;
    background: #B5713A;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 15px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    min-height: 52px;
    transition: background 0.2s;
}
.tt-drawer-checkout:hover:not(:disabled) { background: #9D5F2E; }
.tt-drawer-checkout:disabled { opacity: 0.7; cursor: default; }
.tt-drawer-fulllink {
    display: block;
    text-align: center;
    margin-top: 12px;
    color: #B5713A;
    text-decoration: none;
    font-size: 13px;
}
.tt-drawer-msg {
    margin: 10px 0 0;
    font-size: 13px;
    color: #A63C2E;
    text-align: center;
    min-height: 1em;
}

/* --------------------------------------------------------------------------
   CONFIRMATION TOAST
   -------------------------------------------------------------------------- */
.tt-toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tt-fbar-height) + 24px + var(--tt-safe-bottom));
    transform: translate(-50%, 20px);
    z-index: 1500;
    background: #24613A;
    color: #fff;
    font-weight: bold;
    padding: 12px 22px;
    border-radius: 999px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.28s ease;
    font-size: 15px;
}
.tt-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* --------------------------------------------------------------------------
   INLINE FIELD VALIDATION ERROR (product personalization)
   -------------------------------------------------------------------------- */
.tt-field-error {
    color: #A63C2E;
    font-size: 13px;
    font-weight: bold;
    margin: 6px 0 0;
}
.tt-field-invalid {
    border-color: #C0392B !important;
    box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.15) !important;
}

/* --------------------------------------------------------------------------
   REDUCED MOTION — respect user preference
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .tt-fbar,
    .tt-drawer,
    .tt-drawer-overlay,
    .tt-toast,
    .tt-fbar-count.tt-bump {
        transition: none !important;
        animation: none !important;
    }
}

/* ==========================================================================
   MOBILE  ≤ 768px
   Spec: price + [Add To Cart] + [Cart (X)], full width, 56px+ targets,
   always visible while scrolling.
   ========================================================================== */
@media (max-width: 768px) {
    :root { --tt-fbar-height: 74px; }

    .tt-fbar-inner {
        gap: 10px;
        flex-wrap: wrap;
    }
    /* Product name hidden on phones; price stays visible above the buttons */
    .tt-fbar--product .tt-fbar-name { display: none; }
    .tt-fbar--product .tt-fbar-info {
        flex: 1 0 100%;
        flex-direction: row;
        align-items: baseline;
    }
    .tt-fbar--product .tt-fbar-actions {
        flex: 1 1 100%;
        display: flex;
    }
    .tt-fbar--product .tt-fbar-add { flex: 1 1 60%; }
    .tt-fbar--product .tt-fbar-view { flex: 1 1 40%; justify-content: center; }

    .tt-fbar-btn {
        min-height: 56px;           /* large thumb targets */
        font-size: 16px;
    }
    /* Use the compact "Cart" label on phones */
    .tt-fbar-view-full { display: none; }
    .tt-fbar-view-short { display: inline; }

    .tt-fbar--cartonly .tt-fbar-view {
        min-width: 150px;
        justify-content: center;
    }
    .tt-fbar--cartonly .tt-fbar-view-short { display: none; }
    .tt-fbar--cartonly .tt-fbar-view-full { display: inline; }
}
