/* TextToBrand Conversion Tools - Frontend
   Lightweight, mobile-first, respects prefers-reduced-motion. */

/* === Custom properties (overridden inline by PHP) === */
:root {
    --ttb-primary: #4F46E5;
    --ttb-text: #1F2937;
    --ttb-bg: #FFFFFF;
    --ttb-radius: 12px;
    --ttb-shadow: 0 4px 24px rgba(0, 0, 0, 0.10);
    --ttb-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

/* === Buttons === */
.ttb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4em;
    font-family: var(--ttb-font);
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.4;
    padding: 0.65em 1.5em;
    border-radius: calc(var(--ttb-radius) * 0.65);
    border: 2px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.15s ease;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}
.ttb-btn:focus-visible {
    outline: 2px solid var(--ttb-primary);
    outline-offset: 2px;
}

/* Primary */
.ttb-btn--primary {
    background: var(--ttb-primary);
    color: #fff;
}
.ttb-btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}
.ttb-btn--primary:active {
    transform: translateY(0);
}

/* Secondary */
.ttb-btn--secondary {
    background: transparent;
    color: var(--ttb-primary);
    border-color: var(--ttb-primary);
}
.ttb-btn--secondary:hover {
    background: var(--ttb-primary);
    color: #fff;
}

/* Outline */
.ttb-btn--outline {
    background: transparent;
    color: var(--ttb-text);
    border-color: #D1D5DB;
}
.ttb-btn--outline:hover {
    border-color: var(--ttb-primary);
    color: var(--ttb-primary);
}

/* Minimal */
.ttb-btn--minimal {
    background: transparent;
    color: var(--ttb-primary);
    padding-left: 0.5em;
    padding-right: 0.5em;
}
.ttb-btn--minimal:hover {
    opacity: 0.75;
}

/* Sizes */
.ttb-btn--sm { font-size: 0.825rem; padding: 0.45em 1em; }
.ttb-btn--lg { font-size: 1.1rem; padding: 0.8em 2em; }


/* === Animations === */
@media (prefers-reduced-motion: no-preference) {
    .ttb-anim--pulse {
        animation: ttb-pulse 2.5s ease-in-out 1;
    }
    .ttb-anim--glow {
        animation: ttb-glow 2s ease-in-out 1;
    }
    .ttb-anim--arrow .ttb-btn__label::after {
        content: ' \2192';
        display: inline-block;
        animation: ttb-arrow 1.5s ease-in-out 1;
    }
    .ttb-anim--once {
        animation: ttb-attention 0.6s ease-out 1;
    }
}

@keyframes ttb-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
    50% { box-shadow: 0 0 0 8px rgba(79, 70, 229, 0.15); }
}
@keyframes ttb-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
    50% { box-shadow: 0 0 20px 4px rgba(79, 70, 229, 0.2); }
}
@keyframes ttb-arrow {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(4px); }
}
@keyframes ttb-attention {
    0% { transform: scale(1); }
    30% { transform: scale(1.04); }
    60% { transform: scale(0.98); }
    100% { transform: scale(1); }
}


/* === Sticky CTA (desktop) === */
.ttb-sticky {
    position: fixed;
    left: 0;
    right: 0;
    z-index: 9990;
    padding: 0.75rem 1rem;
    background: var(--ttb-bg);
    box-shadow: var(--ttb-shadow);
    transform: translateY(100%);
    transition: transform 0.35s ease;
    font-family: var(--ttb-font);
}
.ttb-sticky--bottom { bottom: 0; transform: translateY(100%); }
.ttb-sticky--top    { top: 0; transform: translateY(-100%); }
.ttb-sticky[data-ttb-visible="true"] {
    transform: translateY(0);
}
.ttb-sticky__inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.ttb-sticky__content { flex: 1; min-width: 0; }
.ttb-sticky__heading {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ttb-text);
}
.ttb-sticky__text {
    margin: 0.15rem 0 0;
    font-size: 0.825rem;
    color: #6B7280;
}
.ttb-sticky__actions {
    flex-shrink: 0;
}
.ttb-sticky__close {
    flex-shrink: 0;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #9CA3AF;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    border-radius: 4px;
}
.ttb-sticky__close:hover { color: var(--ttb-text); }
.ttb-sticky__close:focus-visible {
    outline: 2px solid var(--ttb-primary);
    outline-offset: 2px;
}

/* Hide desktop sticky on mobile */
@media (max-width: 768px) {
    .ttb-sticky { display: none; }
}


/* === Mobile sticky CTA === */
.ttb-mobile {
    display: none;
}
@media (max-width: 768px) {
    .ttb-mobile {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 9990;
        padding: 0.6rem 0.75rem;
        padding-bottom: calc(0.6rem + env(safe-area-inset-bottom, 0px));
        background: var(--ttb-bg);
        box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.08);
        align-items: center;
        gap: 0.5rem;
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }
    .ttb-mobile[data-ttb-visible="true"] {
        transform: translateY(0);
    }
    .ttb-mobile__btn {
        flex: 1;
        text-align: center;
        min-height: 44px;
    }
    .ttb-mobile__close {
        flex-shrink: 0;
        background: none;
        border: none;
        font-size: 1.2rem;
        color: #9CA3AF;
        cursor: pointer;
        padding: 0.4rem;
        min-width: 36px;
        min-height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 4px;
    }
    .ttb-mobile__close:hover { color: var(--ttb-text); }
    .ttb-mobile__close:focus-visible {
        outline: 2px solid var(--ttb-primary);
        outline-offset: 2px;
    }
}
/* Hide mobile CTA on desktop */
@media (min-width: 769px) {
    .ttb-mobile { display: none !important; }
}


/* === Overlay (exit intent, popup) === */
.ttb-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    font-family: var(--ttb-font);
}
.ttb-overlay[hidden] { display: none; }
.ttb-overlay__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    cursor: pointer;
}
.ttb-overlay__panel {
    position: relative;
    background: var(--ttb-bg);
    border-radius: var(--ttb-radius);
    padding: 2rem 2.25rem;
    max-width: 460px;
    width: 100%;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
    text-align: center;
    animation: ttb-panel-in 0.3s ease;
}
@media (prefers-reduced-motion: reduce) {
    .ttb-overlay__panel { animation: none; }
}
@keyframes ttb-panel-in {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.ttb-overlay__close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #9CA3AF;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    border-radius: 4px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ttb-overlay__close:hover { color: var(--ttb-text); }
.ttb-overlay__close:focus-visible {
    outline: 2px solid var(--ttb-primary);
    outline-offset: 2px;
}
.ttb-overlay__heading {
    margin: 0 0 0.5rem;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ttb-text);
}
.ttb-overlay__text {
    margin: 0 0 1.5rem;
    font-size: 1rem;
    color: #6B7280;
    line-height: 1.5;
}
.ttb-overlay__actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

@media (max-width: 480px) {
    .ttb-overlay__panel {
        padding: 1.5rem;
    }
}


/* === Scroll CTA === */
.ttb-scroll {
    font-family: var(--ttb-font);
}
.ttb-scroll[hidden] { display: none; }

/* Slide-in */
.ttb-scroll--slide-in {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9989;
}
.ttb-scroll--slide-in .ttb-scroll__panel {
    background: var(--ttb-bg);
    border-radius: var(--ttb-radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--ttb-shadow);
    max-width: 340px;
    animation: ttb-slide-in 0.35s ease;
}
@media (prefers-reduced-motion: reduce) {
    .ttb-scroll--slide-in .ttb-scroll__panel { animation: none; }
}
@keyframes ttb-slide-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Popup (reuses overlay styles) */
.ttb-scroll--popup {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.ttb-scroll--popup .ttb-scroll__panel {
    position: relative;
    background: var(--ttb-bg);
    border-radius: var(--ttb-radius);
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
    text-align: center;
    animation: ttb-panel-in 0.3s ease;
}

/* Inline */
.ttb-scroll--inline {
    position: relative;
    z-index: 1;
}
.ttb-scroll--inline .ttb-scroll__panel {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: var(--ttb-radius);
    padding: 1.25rem 1.5rem;
    text-align: center;
    max-width: 600px;
    margin: 1.5rem auto;
}

.ttb-scroll__heading {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ttb-text);
}
.ttb-scroll__close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #9CA3AF;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    border-radius: 4px;
}
.ttb-scroll__close:hover { color: var(--ttb-text); }
.ttb-scroll__close:focus-visible {
    outline: 2px solid var(--ttb-primary);
    outline-offset: 2px;
}

@media (max-width: 768px) {
    .ttb-scroll--slide-in {
        bottom: calc(60px + env(safe-area-inset-bottom, 0px));
        right: 0.75rem;
        left: 0.75rem;
    }
    .ttb-scroll--slide-in .ttb-scroll__panel {
        max-width: none;
    }
}


/* === CTA Injection === */
.ttb-inject {
    border-top: 1px solid #E5E7EB;
    border-bottom: 1px solid #E5E7EB;
    padding: 1.5rem 0;
    margin: 2rem 0;
    text-align: center;
    font-family: var(--ttb-font);
}
.ttb-inject__heading {
    margin: 0 0 0.75rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ttb-text);
}


/* === Block: CTA === */
.ttb-block-cta {
    margin: 1.5rem 0;
}
.ttb-align-center { text-align: center; }
.ttb-align-left   { text-align: left; }
.ttb-align-right  { text-align: right; }
.ttb-block-cta__desc {
    margin: 0 0 0.5rem;
    font-size: 0.925rem;
    color: #6B7280;
    font-family: var(--ttb-font);
}


/* === Block: Trust === */
.ttb-block-trust {
    margin: 1.5rem 0;
    font-family: var(--ttb-font);
}
.ttb-trust__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
}
.ttb-trust--vertical .ttb-trust__list {
    flex-direction: column;
    gap: 0.35rem;
}
.ttb-trust--compact .ttb-trust__list {
    gap: 0.25rem 1rem;
    font-size: 0.875rem;
}
.ttb-trust__item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--ttb-text);
    font-size: 0.925rem;
    line-height: 1.5;
}
.ttb-trust__check {
    color: #10B981;
    font-weight: 700;
    flex-shrink: 0;
}
/* Editor */
.ttb-trust__item-edit {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}
.ttb-trust__item-edit .components-text-control__input {
    flex: 1;
}


/* === Block: Social Proof === */
.ttb-block-social {
    margin: 1.5rem 0;
    text-align: center;
    font-family: var(--ttb-font);
}
.ttb-social__text {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ttb-text);
}
.ttb-social__sub {
    margin: 0.25rem 0 0;
    font-size: 0.9rem;
    color: #6B7280;
}


/* === Block: Countdown === */
.ttb-block-countdown {
    margin: 1.5rem 0;
    text-align: center;
    font-family: var(--ttb-font);
}
.ttb-countdown__msg {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--ttb-text);
}
.ttb-countdown__digits {
    display: inline-flex;
    align-items: baseline;
    gap: 0.15rem;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--ttb-text);
    font-variant-numeric: tabular-nums;
}
.ttb-countdown__label {
    font-size: 0.7rem;
    font-weight: 500;
    color: #9CA3AF;
    text-transform: lowercase;
    margin-right: 0.25rem;
}
.ttb-countdown__sep {
    font-weight: 400;
    color: #D1D5DB;
    margin: 0 0.1rem;
}


/* === Block: Notice === */
.ttb-block-notice {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    border-radius: calc(var(--ttb-radius) * 0.65);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--ttb-font);
    font-size: 0.9rem;
}
.ttb-notice--info {
    background: #EFF6FF;
    color: #1E40AF;
}
.ttb-notice--success {
    background: #ECFDF5;
    color: #065F46;
}
.ttb-notice--highlight {
    background: #EEF2FF;
    color: #4338CA;
}
.ttb-notice__text { flex: 1; }
.ttb-notice__cta {
    font-weight: 600;
    text-decoration: none;
    color: inherit;
    white-space: nowrap;
    flex-shrink: 0;
}
.ttb-notice__cta:hover {
    text-decoration: underline;
}
