/* ============================================================
   BREACH HOUSE — WIDGETS
   Styling for _alert_cta.html, _alert_modal.html and
   _feedback_widget.html. Kept out of the partials so it is
   cached once instead of inlined on every page.

   Dark-theme native: styles_v2.css declares no prefers-color-scheme
   and no [data-theme] hook (the only data-theme in the tree is the
   Cloudflare Turnstile attribute), so the site is dark-only and
   these widgets commit to the same palette.

   Layer plan — .top-navbar is 1000, .scanline is 10000:
     .feedback-launcher  9000   above the navbar, below any modal
     .bh-modal          10001   above the scanline
   ============================================================ */

/* --- SHARED HELPERS --- */
.bh-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;
}

/* Scroll lock while a widget dialog is open. */
body.bh-modal-open {
    overflow: hidden;
}

/* ============================================================
   1. ALERT CTA  (_alert_cta.html)
   Mirrors .sponsor-card (styles_v2.css:391) but in --primary.
   ============================================================ */
.alert-cta {
    background: var(--card-bg);
    border: 1px solid var(--primary);
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.12);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
}

.alert-cta::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: var(--primary);
}

.alert-cta__body {
    min-width: 0;
}

.alert-cta__eyebrow {
    display: inline-block;
    font-family: 'Space Mono', monospace;
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    color: var(--primary);
    border: 1px solid rgba(0, 242, 255, 0.45);
    border-radius: 3px;
    padding: 2px 8px;
    margin-bottom: 8px;
}

.alert-cta__title {
    font-size: 1.05rem;
    line-height: 1.45;
    color: #fff;
}

.alert-cta__title strong {
    color: var(--primary);
}

.alert-cta__sub {
    color: var(--text-dim);
    font-size: 0.92rem;
    line-height: 1.5;
    margin-top: 4px;
}

.alert-cta__btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

@media (max-width: 760px) {
    .alert-cta {
        flex-direction: column;
        align-items: stretch;
        padding: 18px 20px;
        gap: 16px;
    }

    .alert-cta__btn {
        width: 100%;
    }
}

/* ============================================================
   2. MODAL SHELL  (_alert_modal.html + _feedback_widget.html)
   Same overlay recipe as templates/telegram_gate.html.
   ============================================================ */
.bh-modal {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

/* Beats the .bh-modal display:flex above — [hidden] alone would not. */
.bh-modal[hidden] {
    display: none;
}

.bh-modal__panel {
    background: var(--card-bg);
    border: 1px solid var(--primary);
    border-radius: 12px;
    box-shadow: 0 0 40px rgba(0, 242, 255, 0.15);
    padding: 28px 28px 24px;
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    position: relative;
}

.bh-modal__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
}

.bh-modal__title {
    color: var(--primary);
    font-family: 'Space Mono', monospace;
    font-size: 1.1rem;
    margin: 0;
    line-height: 1.4;
}

.bh-modal__close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: var(--transition);
}

.bh-modal__close:hover {
    color: var(--primary);
    background: var(--primary-dim);
}

.bh-modal__intro {
    color: var(--text-dim);
    font-size: 0.92rem;
    line-height: 1.6;
    margin: 0 0 20px;
}

.bh-modal__intro strong {
    color: var(--text-main);
}

/* ============================================================
   3. SHARED FORM BITS
   ============================================================ */
.bh-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.bh-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bh-label {
    font-family: 'Space Mono', monospace;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--primary);
    padding: 0;
}

.bh-hint {
    color: var(--text-dim);
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.72rem;
    margin-left: 6px;
}

/* .cyber-input has min-width:250px + flex-grow — neutralise it inside the panel. */
.bh-form .cyber-input {
    min-width: 0;
    width: 100%;
    flex-grow: 0;
}

.bh-textarea {
    resize: vertical;
    min-height: 120px;
    font-family: 'Space Grotesk', sans-serif;
    line-height: 1.6;
}

.bh-fieldset {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 14px 16px 16px;
    margin: 0;
    min-width: 0;
}

.bh-checkgrid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
    margin-top: 10px;
}

.bh-check {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
    line-height: 1.3;
}

.bh-check input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    cursor: pointer;
}

.bh-check:hover {
    color: var(--primary);
}

.bh-counter {
    font-family: 'Space Mono', monospace;
    font-size: 0.72rem;
    color: var(--text-dim);
    margin: 0;
    text-align: right;
}

.bh-captcha {
    display: flex;
    justify-content: center;
}

.bh-form__actions {
    display: flex;
    justify-content: flex-end;
}

.bh-form__actions .cyber-button-outline {
    min-width: 170px;
}

.bh-form__actions .cyber-button-outline[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

.bh-status {
    margin: 0;
    font-size: 0.88rem;
    font-family: 'Space Mono', monospace;
    line-height: 1.5;
}

/* Same success/error tones as .footer-newsletter__msg. */
.bh-status.is-ok {
    color: #46e8b0;
}

.bh-status.is-err {
    color: #ff6b6b;
}

/* ============================================================
   4. COUNTRY PICKER  (_alert_modal.html)
   ============================================================ */
.bh-countries {
    margin-top: 10px;
}

.bh-countries.is-empty {
    display: none;
}

.bh-countries__bar {
    display: flex;
    gap: 8px;
    align-items: stretch;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.bh-countries__bar .bh-countries__search {
    flex: 1 1 180px;
    min-width: 0;
    padding: 9px 14px;
}

.bh-countries__list {
    /* Positioned on purpose: this is the scroll container, so it must also be the
       offsetParent of the rows. Without it the nearest positioned ancestor is
       .bh-modal__panel and row.offsetTop measures from the top of the dialog —
       the "scroll the pre-checked country into view" maths in _alert_modal.html
       would then overshoot by the height of everything above the list. */
    position: relative;
    max-height: 210px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #16161f;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.bh-countries__list::-webkit-scrollbar {
    width: 8px;
}

.bh-countries__list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.bh-country {
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 0.86rem;
}

.bh-country:hover {
    background: var(--primary-dim);
}

.bh-country span {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bh-country__code {
    font-family: 'Space Mono', monospace;
    font-size: 0.68rem;
    color: var(--text-dim);
    font-style: normal;
    flex: 0 0 auto;
}

.bh-country.is-hidden {
    display: none;
}

.bh-countries__count {
    font-family: 'Space Mono', monospace;
    font-size: 0.72rem;
    color: var(--text-dim);
    margin: 8px 0 0;
}

/* ============================================================
   5. FEEDBACK LAUNCHER  (_feedback_widget.html)
   ============================================================ */
.feedback-launcher {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 9000;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 9px;
    background: var(--card-bg);
    color: var(--primary);
    border: 1px solid var(--primary);
    border-right: none;
    border-radius: 6px 0 0 6px;
    cursor: pointer;
    font-family: 'Space Mono', monospace;
    font-size: 0.72rem;
    font-weight: bold;
    letter-spacing: 0.14em;
    box-shadow: -4px 0 18px rgba(0, 0, 0, 0.45);
    transition: var(--transition);
}

.feedback-launcher__text {
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.feedback-launcher i {
    /* Keep the glyph upright inside the vertical rail. */
    writing-mode: horizontal-tb;
    font-size: 0.9rem;
}

.feedback-launcher:hover {
    background: var(--primary);
    color: var(--bg-color);
    box-shadow: var(--glow);
}

/* Slid out while the footer is on screen so it can never sit on top of the
   footer newsletter CTA. Toggled by an IntersectionObserver on .site-footer. */
.feedback-launcher.is-tucked {
    transform: translateY(-50%) translateX(110%);
    opacity: 0;
    pointer-events: none;
}

@media print {
    .feedback-launcher,
    .bh-modal {
        display: none !important;
    }
}

/* Small screens: a compact circular FAB, bottom-right. */
@media (max-width: 760px) {
    .feedback-launcher {
        top: auto;
        bottom: 18px;
        right: 16px;
        transform: none;
        width: 48px;
        height: 48px;
        padding: 0;
        border: 1px solid var(--primary);
        border-radius: 50%;
        justify-content: center;
        gap: 0;
    }

    .feedback-launcher__text {
        /* Icon-only at this size; the title/aria-label still name the control. */
        display: none;
    }

    .feedback-launcher i {
        font-size: 1.15rem;
    }

    .feedback-launcher.is-tucked {
        transform: translateX(160%);
    }
}

/* ============================================================
   6. FEEDBACK PANEL  (_feedback_widget.html)
   ============================================================ */
.feedback-panel {
    max-width: 620px;
}

.bh-drop {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    padding: 18px 16px;
    border: 1px dashed var(--border);
    border-radius: 6px;
    background: #16161f;
    color: var(--text-dim);
    font-size: 0.85rem;
    transition: var(--transition);
}

.bh-drop i {
    color: var(--primary);
    font-size: 1.1rem;
}

.bh-drop.is-over {
    border-color: var(--primary);
    border-style: solid;
    background: var(--primary-dim);
    color: var(--text-main);
}

.bh-drop__pick {
    cursor: pointer;
}

.bh-thumbs {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.bh-thumb {
    position: relative;
    width: 84px;
}

.bh-thumb img {
    width: 84px;
    height: 62px;
    object-fit: cover;
    display: block;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #000;
}

.bh-thumb__rm {
    position: absolute;
    top: -7px;
    right: -7px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-dim);
    font-size: 0.7rem;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition);
}

.bh-thumb__rm:hover {
    color: #ff6b6b;
    border-color: #ff6b6b;
}

.bh-thumb__cap {
    display: block;
    font-family: 'Space Mono', monospace;
    font-size: 0.64rem;
    color: var(--text-dim);
    margin-top: 4px;
    text-align: center;
}

.bh-progress {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.bh-progress__bar {
    height: 100%;
    width: 0;
    background: var(--primary);
    box-shadow: var(--glow);
    transition: width 0.2s linear;
}

/* ============================================================
   7. FOCUS + MOTION
   ============================================================ */
.alert-cta__btn:focus-visible,
.bh-modal__close:focus-visible,
.feedback-launcher:focus-visible,
.bh-thumb__rm:focus-visible,
.bh-drop__pick:focus-visible,
.bh-form .cyber-input:focus-visible,
.bh-check input:focus-visible,
.bh-countries__bar .btn:focus-visible,
.bh-form__actions .cyber-button-outline:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* The file input is visually hidden, so surface its focus on the drop zone instead. */
.bh-drop:focus-within {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {

    .alert-cta,
    .alert-cta__btn,
    .bh-modal__close,
    .feedback-launcher,
    .bh-drop,
    .bh-thumb__rm,
    .bh-progress__bar,
    .bh-form .cyber-input {
        transition: none !important;
    }
}
