/*
 * BizBook public site: shadcn/Radix-style form primitives and motion helpers, MyResidenta look.
 * Plain CSS loaded after site.css (no build step). Works with the existing .input, .check,
 * .btn, .menu-panel, x-select and x-auth-field markup, so no Blade changes are needed.
 * Animations are driven by public/js/bizbook-motion.js (GSAP + Motion).
 */
/* Everything sits in Tailwind's "components" layer (declared by site.css), so utility
   classes in the markup, such as sr-only, absolute or hidden, always win over these rules. */
@layer components {
    :root {
        --bb-glow: color-mix(in oklab, var(--brand, #0d6b57) 15%, transparent);
        --bb-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
        --bb-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    /* ---------- Site header: dark frosted glass (macOS-style vibrancy) ---------- */
    .bb-glass-header {
        background:#091440;
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        backdrop-filter: saturate(180%) blur(20px);
        border-bottom: 1px solid rgb(255 255 255 / 0.08);
        box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06), 0 10px 30px -18px rgb(0 0 0 / 0.6);
    }
    /* browsers without blur get the solid gradient */
    @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
        .bb-glass-header { background: linear-gradient(180deg, black, #24282d); }
    }
    .bb-glass-header .nav-item-active::after { bottom: -13px; background: #fff; }
    /* the main button in the bar: white pill on the dark glass */
    .bb-glass-header .btn-primary { background: #fff; color: #111a16; box-shadow: 0 6px 16px -8px rgb(0 0 0 / 0.6); }
    .bb-glass-header .btn-primary:hover { background: #f1f1ee; }

    /* ---------- Fields ---------------------------------------------------------- */
    .input { transition: border-color 0.18s var(--bb-ease), box-shadow 0.18s var(--bb-ease), background-color 0.18s var(--bb-ease); }
    .input:focus, .biz-select button.input[aria-expanded='true'] { border-color: var(--color-brand); box-shadow: 0 0 0 4px var(--bb-glow); }
    .input-invalid, .input[aria-invalid='true'] { border-color: #ef4444; }
    .input-invalid:focus, .input[aria-invalid='true']:focus { box-shadow: 0 0 0 4px rgb(239 68 68 / 0.15); }
    /* error lines under fields slide in */
    .input ~ p[id$='-error'], .field-wrap + p[id$='-error'], p[id$='-error'] { animation: bb-msg-in 0.22s var(--bb-ease) both; }
    /* the icon inside a field lights up while typing */
    .field-wrap:focus-within .input-icon, .relative:focus-within > .input-icon { color: var(--color-brand); }

    /* ---------- Checkbox + radio (shadcn) --------------------------------------- */
    .check {
        appearance: none; -webkit-appearance: none; display: inline-grid; place-content: center;
        width: 1.125rem; height: 1.125rem; margin: 0; border: 1.5px solid color-mix(in oklab, var(--color-ink) 25%, transparent);
        border-radius: 0.375rem; background: #fff; cursor: pointer; flex-shrink: 0;
        transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    }
    .check[type='radio'] { border-radius: 9999px; }
    .check::before {
        content: ''; width: 0.7rem; height: 0.7rem; scale: 0; background: #fff;
        transition: scale 0.25s var(--bb-spring);
        -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='black' fill-rule='evenodd' d='M16.7 5.3a1 1 0 0 1 0 1.4l-8 8a1 1 0 0 1-1.4 0l-4-4a1 1 0 1 1 1.4-1.4l3.3 3.3 7.3-7.3a1 1 0 0 1 1.4 0Z'/%3E%3C/svg%3E") center / contain no-repeat;
                mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='black' fill-rule='evenodd' d='M16.7 5.3a1 1 0 0 1 0 1.4l-8 8a1 1 0 0 1-1.4 0l-4-4a1 1 0 1 1 1.4-1.4l3.3 3.3 7.3-7.3a1 1 0 0 1 1.4 0Z'/%3E%3C/svg%3E") center / contain no-repeat;
    }
    .check[type='radio']::before { width: 0.45rem; height: 0.45rem; border-radius: 9999px; -webkit-mask: none; mask: none; }
    .check:hover:not(:checked):not(:disabled) { border-color: var(--color-brand); }
    .check:checked { background: var(--color-brand); border-color: var(--color-brand); animation: bb-check-pop 0.32s var(--bb-spring); }
    .check:checked::before { scale: 1; }
    .check:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--bb-glow); }
    .check:disabled { opacity: 0.55; cursor: not-allowed; }

    /* ---------- Switch (shadcn) — <input type="checkbox" class="switch"> ---------- */
    .switch {
        appearance: none; -webkit-appearance: none; position: relative; flex-shrink: 0; cursor: pointer;
        width: 2.75rem; height: 1.5rem; margin: 0; border-radius: 9999px;
        background: color-mix(in oklab, var(--color-ink) 14%, white);
        box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--color-ink) 8%, transparent);
        transition: background-color 0.2s var(--bb-ease), box-shadow 0.2s var(--bb-ease);
    }
    .switch::before {
        content: ''; position: absolute; top: 0.125rem; left: 0.125rem; width: 1.25rem; height: 1.25rem; border-radius: 9999px; background: #fff;
        box-shadow: 0 1px 2px rgb(17 26 22 / 0.18), 0 2px 6px -1px rgb(17 26 22 / 0.2);
        transition: translate 0.32s var(--bb-spring), width 0.15s ease;
    }
    .switch:checked { background: var(--color-brand); box-shadow: none; }
    .switch:checked::before { translate: 1.25rem 0; }
    .switch:active::before { width: 1.5rem; }
    .switch:checked:active::before { translate: 1rem 0; }
    .switch:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--bb-glow); }

    /* ---------- Popovers: menus, searchable select ------------------------------------ */
    .menu-panel, .biz-select [role='listbox'], .biz-select [x-show='open'] {
        transform-origin: top center;
        box-shadow: 0 1px 2px rgb(17 26 22 / 0.05), 0 18px 40px -14px rgb(17 26 22 / 0.28), 0 0 0 1px rgb(17 26 22 / 0.05);
    }
    .biz-select [role='option'] { border-radius: 0.7rem; transition: background-color 0.12s ease, color 0.12s ease; }
    .biz-select [role='option'][aria-selected='true'] { color: var(--color-brand); font-weight: 650; }

    /* ---------- Buttons --------------------------------------------------------- */
    .btn { transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.18s ease, translate 0.18s var(--bb-ease), scale 0.12s ease; }
    .btn:not(:disabled):hover { translate: 0 -1px; }
    .btn:not(:disabled):active { translate: 0 0; scale: 0.97; }
    /* main actions: slow light sweep, like MyResidenta's .shine */
    :is(.btn-primary, .btn-dark, .btn-ink) { position: relative; overflow: hidden; isolation: isolate; }
    :is(.btn-primary, .btn-dark, .btn-ink)::after {
        content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
        background: linear-gradient(110deg, transparent 30%, rgb(255 255 255 / 0.25) 50%, transparent 70%);
        translate: -120% 0;
    }
    :is(.btn-primary, .btn-dark, .btn-ink):hover::after { animation: bb-shine 0.9s var(--bb-ease); }
    .btn-dark::after { animation: bb-shine 3.6s ease-in-out 1.2s infinite; }
    .btn-dark:hover::after { animation: bb-shine 0.9s var(--bb-ease); }

    /* ---------- Cards: mouse spotlight (MyResidenta .glow) ----------------------------- */
    .card-hover { position: relative; isolation: isolate; }
    .card-hover::before {
        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, 50%), color-mix(in oklab, var(--brand, #0d6b57) 12%, transparent), transparent 60%);
        opacity: 0; transition: opacity 0.3s ease;
    }
    .card-hover:hover::before { opacity: 1; }

    /* ---------- Reveal-on-scroll (set up by bizbook-motion.js) ------------------------ */
    /* Hidden only when the script is running, so pages never stay blank without JS. */
    /* (bb-motion is set in the page head; bb-ready once the script has taken over, or after 2.5s as a safety net) */
    .bb-motion:not(.bb-ready) :is([data-reveal], [data-hero-title], [data-reveal-tiles] > li) { opacity: 0; }
    .bb-word { display: inline-block; will-change: transform, opacity, filter; }

    /* ---------- Keyframes ------------------------------------------------------- */
    @keyframes bb-msg-in { from { opacity: 0; translate: 0 -3px; } to { opacity: 1; translate: 0 0; } }
    @keyframes bb-check-pop { 0% { scale: 0.7; } 60% { scale: 1.12; } 100% { scale: 1; } }
    @keyframes bb-shine { 0%, 55% { translate: -120% 0; } 100% { translate: 120% 0; } }

    @media (prefers-reduced-motion: reduce) {
        .bb-motion :is([data-reveal], [data-hero-title], [data-reveal-tiles] > li) { opacity: 1 !important; }
        .btn-dark::after { animation: none !important; }
    }
}
