/* =============================================================================
   KOTOVA BOOKS · early-access.css — the early access page
   (kotova.io/books/early-access)
   -----------------------------------------------------------------------------
   Load AFTER /styles.css, /x/x.css and /books/books.css. Every class is
   prefixed bkea-; nothing here styles bare elements, body or :root, and the
   tokens are the site's (--color-*, --spacing-*, --radius-*) and books.css's
   (--bk-*). Dark theme only, like the rest of kotova.io; color-scheme: dark
   keeps the native controls (the country select, checkbox) dark. The software
   field is a custom select (.bkea-combo) in the app.kotova.io account look.
   The field, phone and button rules follow /books/demo.css (bkd-), so both
   Books forms look and behave alike; change them together.

   Layout
     >1024px  two columns: intro (head + points) left, the card right
     <=1024px one column: intro head, the card, then the points and links
     <=640px  16px side gutters, card padding 20px (16px at <=360px)
   No horizontal page scroll from 320px. Inputs use 16px text so iOS does not
   zoom on focus, and every control is at least 44px tall. Turnstile (only
   when the API asks for it) gets its box reserved: 65px, 140px where the
   card is too narrow for the 300px widget and early-access.js renders the
   compact one.

   Sections
     1. Page frame and intro
     2. The card, views, alert
     3. Fields: contact pair, phone with country code, consent, honeypot
     4. Buttons, busy state, Turnstile
     5. Done / confirm / unsubscribe views
     6. Phones
   ========================================================================== */


/* =============================================================================
   1. PAGE FRAME AND INTRO
   ========================================================================== */

.bkea {
    color-scheme: dark;
}

.bkea-hero {
    padding-bottom: var(--spacing-3xl);
}

.bkea-grid {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    grid-template-rows: auto 1fr;
    grid-template-areas:
        "head card"
        "more card";
    gap: var(--spacing-xl) var(--spacing-3xl);
    align-items: start;
}

.bkea-intro-head {
    grid-area: head;
    min-width: 0;
}

.bkea-intro-more {
    grid-area: more;
    min-width: 0;
}

.bkea-card {
    grid-area: card;
    min-width: 0;
}

.bkea-h1 {
    font-size: clamp(2rem, 4.4vw, 3.1rem);
}

.bkea-intro-head .bkea-h1 + .bk-lead {
    margin-top: var(--spacing-lg);
}

.bkea-points {
    display: grid;
    gap: 14px;
    list-style: none;
}

.bkea-points li {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    color: var(--bk-ink-2);
    line-height: 1.55;
}

.bkea-points li > span:first-child {
    display: grid;
    place-items: center;
    flex: none;
    width: 24px;
    height: 24px;
    margin-top: 1px;
    border-radius: 50%;
    background: var(--bk-gold-tint-2);
    color: var(--color-secondary);
}

.bkea-points .bk-ico {
    width: 14px;
    height: 14px;
}

.bkea-links {
    display: grid;
    justify-items: start;
    gap: var(--spacing-md);
    margin-top: var(--spacing-xl);
}

.bkea-links .bk-link {
    min-height: 44px;
}

.bkea-question {
    color: var(--color-text-secondary);
    line-height: 1.55;
}

.bkea-question a {
    color: var(--color-secondary);
    font-weight: 600;
}

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

@media (max-width: 1024px) {
    .bkea-grid {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        grid-template-areas:
            "head"
            "card"
            "more";
        gap: var(--spacing-xl);
    }

    .bkea-intro-head,
    .bkea-card {
        max-width: 720px;
    }
}


/* =============================================================================
   2. THE CARD, VIEWS, ALERT
   ========================================================================== */

.bkea-card {
    position: relative;
    padding: 32px;
    border: 1px solid var(--bk-line);
    border-radius: var(--radius-xl);
    background: var(--bk-surface);
    box-shadow: var(--shadow-lg);
}

/* .btn sets display, so the hidden attribute needs the weight. */
.bkea-card [hidden] {
    display: none !important;
}

/* Opened from a confirm / unsubscribe link (inline script in <head>) until
   early-access.js shows that view. */
.bkea-link #bkea-form {
    display: none;
}

.bkea-h {
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--color-text-primary);
    text-wrap: balance;
}

.bkea-h:focus {
    outline: none;
}

.bkea-h:focus-visible {
    outline: 2px solid rgba(197, 165, 114, 0.6);
    outline-offset: 4px;
    border-radius: 4px;
}

/* The error line of the card (role=alert). */
.bkea-alert {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
    margin-bottom: var(--spacing-lg);
    padding: 12px 14px;
    border: 1px solid rgba(255, 107, 120, 0.4);
    border-radius: var(--radius-lg);
    background: rgba(255, 107, 120, 0.08);
    color: #FFC2C8;
    font-size: 0.925rem;
    line-height: 1.5;
}

.bkea-alert a {
    color: var(--color-secondary);
    font-weight: 600;
}

.bkea-noscript {
    color: var(--bk-ink-2);
    line-height: 1.6;
}

.bkea-noscript a {
    color: var(--color-secondary);
}


/* =============================================================================
   3. FIELDS
   ========================================================================== */

.bkea-form {
    display: grid;
    gap: 20px;
}

.bkea-field {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.bkea-label {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 8px;
    color: var(--color-text-primary);
    font-size: 0.925rem;
    font-weight: 600;
    line-height: 1.3;
}

.bkea-opt {
    color: var(--color-text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;      /* "optional" moves to the next line whole (German at 320px) */
    -webkit-hyphens: none;
    hyphens: none;
}

.bkea-input {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid var(--bk-line-strong);
    border-radius: var(--radius-lg);
    background: var(--color-background);
    color: var(--color-text-primary);
    font-family: var(--font-primary);
    font-size: 16px;              /* < 16px makes iOS zoom in on focus */
    line-height: 1.4;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    -webkit-appearance: none;
    appearance: none;
}

.bkea-input::placeholder {
    color: var(--color-text-muted);
}

.bkea-input:focus {
    border-color: var(--color-secondary);
    box-shadow: 0 0 0 3px rgba(197, 165, 114, 0.18);
}

.bkea-input[aria-invalid="true"] {
    border-color: rgba(255, 107, 120, 0.8);
}

/* Software: free text + suggestion list, styled like the app.kotova.io account
   dropdowns (apps/exchange account.css .acct-select / .acct-menu / .acct-option:
   glass menu, 44px rows, gold selected row with a check, chevron that turns
   when open). The list sits inside the field's wrapper (no portal), so no
   ancestor of the card may clip overflow. */
.bkea-combo {
    position: relative;
}

/* The open list must paint over the fields that follow (some of them are
   positioned, e.g. the country chip), so its field is lifted while open. */
.bkea-field.bkea-raised {
    position: relative;
    z-index: 40;
}

.bkea-combo-input {
    padding-right: 46px;
}

.bkea-combo.is-open .bkea-combo-input {
    border-color: var(--color-secondary);
    box-shadow: 0 0 0 3px rgba(197, 165, 114, 0.15);
}

.bkea-combo-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    transform: translateY(-50%);
    -webkit-tap-highlight-color: transparent;
}

.bkea-combo-toggle .bk-ico {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.bkea-combo.is-open .bkea-combo-toggle .bk-ico {
    transform: rotate(180deg);
}

.bkea-menu {
    position: absolute;
    z-index: 30;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 296px;
    margin: 0;
    padding: 4px;
    overflow-y: auto;
    overscroll-behavior: contain;
    list-style: none;
    background: rgba(20, 20, 25, 0.985);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 0, 0, 0.3);
    animation: bkea-pop-down 0.2s ease both;
}

.bkea-menu[hidden] {
    display: none;
}

/* Opens upwards when the room below the field is too small. */
.bkea-menu--up {
    top: auto;
    bottom: calc(100% + 8px);
    animation-name: bkea-pop-up;
}

.bkea-option {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 10px;
    box-sizing: border-box;
    min-height: 44px;
    padding: 4px 12px;
    border-radius: 8px;
    color: #C3CBD8;
    font-size: 15px;
    font-weight: 500;
    line-height: 20px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.bkea-option[hidden] {
    display: none;
}

.bkea-option-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The check of the selected row (drawn by early-access.js, like IconCheck). */
.bkea-option-check {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-left: auto;
    color: var(--color-secondary);
    opacity: 0;
}

/* "Other" ends the list, a hairline above it. */
.bkea-option--other {
    position: relative;
    margin-top: 3px;
    color: var(--color-text-secondary);
}

.bkea-option--other::before {
    content: "";
    position: absolute;
    top: -3px;
    left: 8px;
    right: 8px;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}

/* Keyboard / pointer highlight (the aria-activedescendant target). */
.bkea-option[data-active="true"] {
    background: rgba(197, 165, 114, 0.10);
    color: #F5F7FA;
}

.bkea-option[aria-selected="true"] {
    background: rgba(197, 165, 114, 0.15);
    color: var(--color-secondary);
}

.bkea-option[aria-selected="true"] .bkea-option-check {
    opacity: 1;
}

@media (hover: hover) {
    .bkea-option:hover {
        background: rgba(197, 165, 114, 0.10);
        color: #F5F7FA;
    }

    .bkea-option[aria-selected="true"]:hover {
        background: rgba(197, 165, 114, 0.15);
        color: var(--color-secondary);
    }

    .bkea-combo-toggle:hover {
        color: var(--color-text-primary);
    }
}

@keyframes bkea-pop-down {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bkea-pop-up {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.bkea-err {
    color: #FF9AA4;
    font-size: 0.85rem;
    line-height: 1.4;
}

.bkea-hint {
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    line-height: 1.45;
}

/* E-mail "or" Telegram: one group with a divider. */
.bkea-pair {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--bk-line);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.015);
}

.bkea-or {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--color-text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.bkea-or::before,
.bkea-or::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--bk-line);
}

/* "@" in front of the Telegram name. */
.bkea-adorn {
    position: relative;
}

.bkea-adorn > span {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 14px;
    display: flex;
    align-items: center;
    color: var(--color-text-secondary);
    font-size: 16px;
    pointer-events: none;
}

.bkea-adorn .bkea-input {
    padding-left: 32px;
}

/* Phone: the country chip ("🇩🇪 +49 ▾", a transparent native select over it)
   and the number. */
.bkea-phone {
    display: grid;
    grid-template-columns: 116px minmax(0, 1fr);
    gap: 8px;
}

.bkea-cc {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    min-height: 48px;
    padding: 0 10px 0 12px;
    border: 1px solid var(--bk-line-strong);
    border-radius: var(--radius-lg);
    background: var(--color-background);
    color: var(--color-text-primary);
    font-size: 16px;
    line-height: 1;
    white-space: nowrap;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.bkea-cc:focus-within {
    border-color: var(--color-secondary);
    box-shadow: 0 0 0 3px rgba(197, 165, 114, 0.18);
}

.bkea-cc-face {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
    font-variant-numeric: tabular-nums;
}

.bkea-cc-flag {
    font-size: 18px;
    line-height: 1;
}

.bkea-cc-iso {
    color: var(--color-text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
}

.bkea-cc .bk-ico {
    width: 16px;
    height: 16px;
    color: var(--color-text-secondary);
}

.bkea-cc select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    font-size: 16px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.bkea-card select option {
    background: var(--color-background);
    color: var(--color-text-primary);
}

/* Consent: a real checkbox (gold when ticked), the whole text is its label. */
.bkea-consent {
    display: grid;
    gap: 8px;
}

.bkea-check {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 12px 14px;
    border: 1px solid var(--bk-line);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.015);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.bkea-check:hover {
    border-color: var(--bk-line-strong);
}

.bkea-check input {
    width: 20px;
    height: 20px;
    margin: 1px 0 0;
    accent-color: var(--color-secondary);
    cursor: pointer;
}

.bkea-check input:focus-visible {
    outline: 2px solid rgba(197, 165, 114, 0.7);
    outline-offset: 3px;
}

.bkea-check input[aria-invalid="true"] {
    outline: 2px solid rgba(255, 107, 120, 0.8);
    outline-offset: 2px;
}

.bkea-check:has(input[aria-invalid="true"]) {
    border-color: rgba(255, 107, 120, 0.6);
}

.bkea-check-text {
    color: var(--bk-ink-2);
    font-size: 0.9rem;
    line-height: 1.55;
}

.bkea-check-text a {
    color: var(--color-secondary);
    font-weight: 600;
}

/* Honeypot: off-screen (not display:none, which some bots skip). */
.bkea-hp {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.bkea-fine {
    color: var(--color-text-secondary);
    font-size: 0.825rem;
    line-height: 1.5;
}


/* =============================================================================
   4. BUTTONS, BUSY STATE, TURNSTILE
   ========================================================================== */

.bkea-submit {
    width: 100%;
    min-height: 52px;
}

.bkea-card .btn:focus-visible,
.bkea-linkbtn:focus-visible {
    outline: 2px solid rgba(197, 165, 114, 0.7);
    outline-offset: 3px;
}

/* A plain text button that looks like a link ("Wrong address? …"). */
.bkea-linkbtn {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 4px;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--color-secondary);
    font: 600 0.9rem/1.3 var(--font-primary);
    text-align: left;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: rgba(197, 165, 114, 0.4);
    text-underline-offset: 3px;
}

.bkea-linkbtn:hover {
    text-decoration-color: currentColor;
}

/* Busy buttons: the label pair swaps, a spinner shows. */
.bkea-busy-label,
.bkea-spin {
    display: none;
}

[aria-busy="true"] > .bkea-idle-label {
    display: none;
}

[aria-busy="true"] > .bkea-busy-label {
    display: inline;
}

[aria-busy="true"] > .bkea-spin {
    display: inline-block;
}

.bkea-spin {
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: bkea-spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
    .bkea-spin {
        animation-duration: 2.4s;
    }

    .bkea-menu {
        animation: none;
    }

    .bkea-combo-toggle .bk-ico {
        transition: none;
    }
}

.bkea-card .btn[disabled],
.bkea-card .btn[aria-busy="true"] {
    cursor: progress;
    opacity: 0.75;
    transform: none;
    box-shadow: none;
}

/* Turnstile's box (300 x 65, compact 150 x 140), reserved before it renders. */
.bkea-bot {
    min-height: 65px;
}


/* =============================================================================
   5. DONE / CONFIRM / UNSUBSCRIBE
   ========================================================================== */

.bkea-ico {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin-bottom: var(--spacing-md);
    border-radius: 50%;
    background: rgba(34, 211, 173, 0.14);
    color: var(--bk-pos);
}

.bkea-ico--gold {
    background: var(--bk-gold-tint-2);
    color: var(--color-secondary);
}

.bkea-ico--muted {
    background: rgba(255, 255, 255, 0.06);
    color: var(--bk-ink-2);
}

.bkea-ico .bk-ico {
    width: 26px;
    height: 26px;
}

.bkea-say {
    margin-top: var(--spacing-md);
    color: var(--bk-ink-2);
    line-height: 1.6;
    overflow-wrap: anywhere;
    word-break: normal;
}

.bkea-say a {
    color: var(--color-secondary);
    font-weight: 600;
}

.bkea-summary {
    display: grid;
    gap: 4px;
    margin-top: var(--spacing-lg);
    padding: 16px 18px;
    border: 1px solid var(--bk-gold-line);
    border-radius: var(--radius-lg);
    background: var(--bk-gold-tint);
}

.bkea-summary-label {
    color: var(--bk-ink-2);
    font-size: 0.85rem;
    line-height: 1.4;
}

.bkea-summary-value {
    color: var(--color-text-primary);
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
    word-break: normal;
}

section.bkea-view .bkea-fine {
    margin-top: var(--spacing-md);
}

.bkea-acts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    margin-top: var(--spacing-xl);
}

.bkea-acts .btn:not(.bkea-submit) {
    padding: 12px 20px;
    font-size: 0.95rem;
}


/* =============================================================================
   6. PHONES
   ========================================================================== */

@media (max-width: 640px) {
    .bkea .container {
        padding-left: var(--spacing-md);
        padding-right: var(--spacing-md);
    }

    .bkea-card {
        padding: 20px;
    }

    .bkea-h {
        font-size: 1.3rem;
    }

    .bkea-pair {
        padding: 14px;
    }

    .bkea-phone {
        grid-template-columns: 108px minmax(0, 1fr);
    }

    .bkea-acts .btn {
        flex: 1 1 100%;
    }
}

/* Under 372px the card has less than 300px inside: compact Turnstile. */
@media (max-width: 371.98px) {
    .bkea-bot {
        min-height: 140px;
    }
}

@media (max-width: 360px) {
    .bkea-card {
        padding: 16px;
    }

    .bkea-pair {
        padding: 12px;
    }

    .bkea-check {
        padding: 12px;
    }

    /* 112 px and tighter insides: at 100 px the chip cut its own dial code on a 320 px phone. */
    .bkea-phone {
        grid-template-columns: 112px minmax(0, 1fr);
    }

    .bkea-cc {
        gap: 4px;
        padding: 0 8px 0 10px;
    }

    .bkea-cc-face {
        gap: 5px;
    }
}
