/* tbe-forms.css — Subscription form styles
 *
 * BEM class structure:
 *   .tbe-form                 outer wrapper div
 *   .tbe-form--boxed          modifier — form has its own background, so it gets padding
 *   .tbe-form__form           the <form> element
 *   .tbe-form__field          row wrapping a single input
 *   .tbe-form__field--required  modifier for required fields
 *   .tbe-form__label          optional visible label above an input
 *   .tbe-form__input          text / email input
 *   .tbe-form__submit         submit button
 *   .tbe-form__success        success message paragraph
 *   .tbe-form__error          inline error paragraph (injected by JS)
 *   .tbe-form__challenge      the extra step a form under attack asks for (injected by JS)
 *
 * Tenant appearance settings arrive as CSS custom properties written onto the
 * .tbe-form wrapper by FormRenderer::style_attr(). Every rule below reads them
 * through a var() fallback, so an unstyled form is byte-identical to what it
 * rendered before the settings existed — and a styled one needs no extra CSS.
 */

.tbe-form {
    max-width: 480px;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    background: var(--tbe-form-bg, transparent);
    color: var(--tbe-form-text, inherit);
}

/* A form with its own background needs breathing room, otherwise the colour
   stops flush against the first input. Only applied when a background is set. */
.tbe-form--boxed {
    padding: 20px;
    border-radius: calc(var(--tbe-form-radius, 6px) + 4px);
}

.tbe-form__label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: inherit;
}

.tbe-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ------------------------------------------------------------------
 * Loading skeleton — shown by tbe-embed.js while the form HTML is
 * being fetched. Bootstrap-style "wave": a diagonal mask band sweeps
 * across each bar. https://getbootstrap.com/docs/5.1/components/placeholders/
 * ------------------------------------------------------------------ */

.tbe-form__skeleton {
    display: block;
}

@keyframes tbe-form-skeleton-wave {
    100% { -webkit-mask-position: -200% 0; mask-position: -200% 0; }
}

.tbe-form__skeleton-bar {
    display: block;
    background: #e5e7eb;
    border-radius: 6px;
    margin-bottom: 12px;
    -webkit-mask-image: linear-gradient(130deg, #000 55%, rgba(0, 0, 0, 0.8) 75%, #000 95%);
    mask-image: linear-gradient(130deg, #000 55%, rgba(0, 0, 0, 0.8) 75%, #000 95%);
    -webkit-mask-size: 200% 100%;
    mask-size: 200% 100%;
    animation: tbe-form-skeleton-wave 1.8s linear infinite;
}

.tbe-form__skeleton-bar--label {
    width: 40%;
    height: 12px;
    margin-bottom: 6px;
}

.tbe-form__skeleton-bar--input {
    width: 100%;
    height: 42px;
}

.tbe-form__skeleton-bar--btn {
    width: 100%;
    height: 44px;
    margin-bottom: 0;
}

@media (prefers-reduced-motion: reduce) {
    .tbe-form__skeleton-bar {
        animation: none;
        -webkit-mask-image: none;
        mask-image: none;
    }
}

.tbe-form__field {
    margin-bottom: 12px;
}

.tbe-form__input {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: var(--tbe-form-radius, 6px);
    font-size: 15px;
    font-family: inherit;
    background: #fff;
    color: #111827;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tbe-form__input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.tbe-form__input::placeholder {
    color: #9ca3af;
}

.tbe-form__submit,
.tbe-form__challenge-btn {
    display: block;
    width: 100%;
    padding: 11px 20px;
    background: var(--tbe-form-btn-bg, #3b82f6);
    color: var(--tbe-form-btn-text, #fff);
    border: none;
    border-radius: var(--tbe-form-radius, 6px);
    font-size: 15px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, filter 0.15s ease;
}

/* Darken the default blue on hover, but a tenant-chosen colour has no matching
   "darker" token — brightness() derives one from whatever they picked. */
.tbe-form__submit:hover,
.tbe-form__challenge-btn:hover {
    background: #2563eb;
}

.tbe-form[style*="--tbe-form-btn-bg"] .tbe-form__submit:hover,
.tbe-form[style*="--tbe-form-btn-bg"] .tbe-form__challenge-btn:hover {
    background: var(--tbe-form-btn-bg);
    filter: brightness(0.92);
}

.tbe-form__submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.tbe-form__success {
    color: #16a34a;
    font-weight: 500;
    margin: 0;
}

.tbe-form__gated-btn {
    display: inline-block;
    margin-top: 12px;
    padding: 11px 28px;
    background: #4d7cff;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: filter 0.15s ease;
}

.tbe-form__gated-btn:hover {
    filter: brightness(1.12);
}

.tbe-form__error {
    color: #dc2626;
    font-size: 14px;
    margin: 8px 0 0;
}

/* Shown in place of the submit button while a form is under attack: one line of
   explanation and a button that opens the check in a new tab. */
.tbe-form__challenge {
    margin-top: 12px;
}

.tbe-form__challenge:empty {
    display: none;
}

.tbe-form__challenge-text {
    color: var(--tbe-form-text, inherit);
    font-size: 14px;
    line-height: 1.5;
    margin: 0 0 10px;
}

.tbe-form__domain-error {
    font-size: 13px;
    color: #9ca3af;
    border: 1px dashed #d1d5db;
    border-radius: 6px;
    padding: 12px 16px;
    margin: 0;
}

/* ------------------------------------------------------------------
 * Landing page <-> form integration
 *
 * NOTE: The landing-page layout (.tbe-lp, .tbe-lp__block, .tbe-lp__heading,
 * .tbe-lp__text, .tbe-lp__image, .tbe-lp__btn, .tbe-lp__divider, .tbe-lp__embed
 * …) is generated INLINE by LandingPage::render_html() and must live ONLY there.
 * Do not re-add those rules here: this stylesheet is injected wherever a form is
 * embedded (the form REST render appends its own <link> to this file), so any
 * .tbe-lp rule here loads AFTER the page's inline <style> and overrides it —
 * which silently reverts published landing pages to an old, constrained layout
 * whenever the page contains a form. Only form-scoped rules belong here.
 * ------------------------------------------------------------------ */

.tbe-lp .tbe-form {
    max-width: 100%;
}

/* ------------------------------------------------------------------
 * Branding (shown on free-plan forms)
 * ------------------------------------------------------------------ */

.tbe-form__branding {
    margin: 10px 0 0;
    font-size: 12px;
    text-align: center;
    color: #9ca3af;
}

.tbe-form__branding a {
    color: #9ca3af;
    text-decoration: none;
}

.tbe-form__branding a:hover {
    color: #6b7280;
    text-decoration: underline;
}

/* ------------------------------------------------------------------
 * Cookie consent banner (GA4 Consent Mode)
 *
 * Markup is emitted by GoogleAnalytics::render_consent_banner() into the
 * footer. Hidden by default — the banner script adds .is-visible only when
 * no choice is stored yet.
 * ------------------------------------------------------------------ */

.tbe-cc {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2147483647;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 14px 18px;
    background: #1a1d27;
    color: #fff;
    font: 14px/1.4 system-ui, -apple-system, sans-serif;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, .3);
}

.tbe-cc.is-visible {
    display: flex;
}

.tbe-cc__text {
    max-width: 640px;
}

.tbe-cc__btn {
    cursor: pointer;
    border: none;
    border-radius: 8px;
    padding: 9px 20px;
    font-weight: 600;
    font-size: 14px;
}

.tbe-cc__btn--accept {
    background: #4d7cff;
    color: #fff;
}

.tbe-cc__btn--decline {
    background: transparent;
    color: #8a8fa8;
    border: 1px solid #3a3d50;
}

/* Route to the cookie policy from inside the banner. Consent is only valid if
   it is informed, so this link is not decoration — it is what makes the choice
   above it mean anything. */
.tbe-cc__link {
    color: #6b93ff;
    text-decoration: underline;
    white-space: nowrap;
}

.tbe-cc__link:hover,
.tbe-cc__link:focus-visible {
    color: #8fb0ff;
}

/* ------------------------------------------------------------------
 * Legal bar — standalone pages (hosted landing pages)
 *
 * Markup from LegalPages::links_html(). A landing page has no theme footer,
 * so this is the only place a visitor can reach the policies or reopen the
 * cookie banner. Colours are deliberately neutral rather than tied to the
 * page's accent, so it reads as platform chrome, not tenant content.
 * ------------------------------------------------------------------ */

.tbe-legal-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 28px 20px 32px;
    font: 13px/1.5 system-ui, -apple-system, sans-serif;
    opacity: .55;
}

.tbe-legal-bar__link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* The cookie-settings control is a <button> so it is announced as an action,
   not a destination. Stripped back to look identical to its sibling links. */
.tbe-legal-bar__btn {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    cursor: pointer;
}

.tbe-legal-bar__link:hover,
.tbe-legal-bar__link:focus-visible {
    opacity: .85;
}

.tbe-legal-bar__sep {
    opacity: .5;
}
