/* =========================================================================
   GRO Auth Modal — split-screen overlay (Figma 7939-39537 adapted as modal).
   2026-05-26 rev 1.1 — split layout (gold arrow LEFT + form RIGHT) + X close.
   Mobile (<768px): fullscreen sheet, arrow скрыта, single column form.
   ========================================================================= */

/* ───── Overlay ───── */
.gro-auth-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
    font-family: "Golos Text", -apple-system, BlinkMacSystemFont, sans-serif;
    color: #141414;
    -webkit-font-smoothing: antialiased;
}
.gro-auth-modal[aria-hidden="false"] {
    display: flex;
}

.gro-auth-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 20, 20, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: gro-auth-backdrop-in 0.2s ease-out;
}
@keyframes gro-auth-backdrop-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ───── Container card — split-screen (Figma) ───── */
.gro-auth-modal__container {
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: 32px;
    width: 100%;
    max-width: min(960px, calc(100vw - 48px)); /* fit-to-viewport на узких экранах */
    max-height: calc(100vh - 48px);
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
    animation: gro-auth-card-in 0.25s ease-out;

    display: grid;
    grid-template-columns: 1fr 1.3fr; /* arrow меньше, form больше */
    min-height: 540px;
}
/* CSS grid blowout protection — content в grid cell может overflow по умолчанию */
.gro-auth-modal__container > * {
    min-width: 0;
}
@keyframes gro-auth-card-in {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ───── Close button (X в правом верхнем углу) ───── */
.gro-auth-modal__close {
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 10;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #141414;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}
.gro-auth-modal__close:hover,
.gro-auth-modal__close:focus-visible {
    background: rgba(0, 0, 0, 0.05);
    outline: none;
}
.gro-auth-modal__close:focus-visible {
    outline: 2px solid #D9B648;
    outline-offset: 2px;
}

/* ───── LEFT: gold arrow art + logo (по Figma) ───── */
.gro-auth-modal__side {
    position: relative;
    padding: 40px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.gro-auth-modal__arrow {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden; /* tail уходит за пределы side panel */
}
.gro-auth-modal__arrow svg {
    position: absolute;
    /* Зажат в bottom-left угол. Apex (top-right SVG) визуально становится "стрелка вверх-вправо".
       SVG масштабирован больше container чтобы tail уходил за нижне-левый угол. */
    left: -8%;
    bottom: -8%;
    width: 90%;
    height: auto;
    aspect-ratio: 1;
    display: block;
}
.gro-auth-modal__arrow svg {
    width: 100%;
    height: auto;
    display: block;
}

/* ───── RIGHT: form area ───── */
.gro-auth-modal__form-wrap {
    padding: 64px 56px 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow-y: auto;
    max-height: calc(100vh - 48px);
    min-width: 0; /* grid blowout protection */
}

/* ───── Method tabs (показывается только если методов >1) ───── */
.gro-auth-modal__methods {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: #f4f1e8;
    border-radius: 100px;
    margin-bottom: 24px;
}
.gro-auth-modal__method-tab {
    flex: 1;
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, color 0.15s ease;
}
.gro-auth-modal__method-tab.is-active {
    background: #fff;
    color: #141414;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ───── Panel switcher ───── */
.gro-auth-modal__panel[hidden] {
    display: none !important;
}

/* ───── Title (responsive) ───── */
.gro-auth-modal__title {
    margin: 0 0 28px;
    font-size: clamp(22px, 2.3vw, 30px);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.03em;
    color: #141414;
    word-break: break-word;
}

/* ───── Form: input ───── */
.gro-auth-modal__field {
    margin-bottom: 28px;
}
.gro-auth-modal__label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: #888;
    font-weight: 400;
}
.gro-auth-modal__input {
    width: 100%;
    padding: 8px 0;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
    font-size: 18px;
    font-weight: 500;
    color: #141414;
    font-family: inherit;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s ease;
}
.gro-auth-modal__input::placeholder {
    color: #b8b8b8;
    font-weight: 400;
}
.gro-auth-modal__input:focus {
    border-bottom-color: #141414;
}
.gro-auth-modal__hint {
    margin: 8px 0 0;
    font-size: 13px;
    color: #888;
    line-height: 1.4;
}
.gro-auth-modal__hint--error {
    color: #d33b3b;
    display: none;
}

/* Error state */
.gro-auth-modal__container[data-state="email-error"] .gro-auth-modal__hint--default { display: none; }
.gro-auth-modal__container[data-state="email-error"] .gro-auth-modal__hint--error { display: block; }
.gro-auth-modal__container[data-state="email-error"] .gro-auth-modal__input { border-bottom-color: #d33b3b; }

/* A8: email typo suggestion button */
.gro-auth-modal__typo-fix {
    background: transparent;
    border: none;
    color: #D9B648;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
    font-size: inherit;
}
.gro-auth-modal__typo-fix:hover { color: #b8a040; }

/* ───── Consents (checkboxes) ───── */
.gro-auth-modal__consents {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 32px;
}
.gro-auth-modal__check {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.4;
    color: #555;
}
.gro-auth-modal__check input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.gro-auth-modal__check-box {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 1.5px solid rgba(0, 0, 0, 0.24);
    border-radius: 5px;
    background: #fff;
    margin-top: 1px;
    position: relative;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.gro-auth-modal__check input:checked + .gro-auth-modal__check-box {
    background: #D9B648;
    border-color: #D9B648;
}
.gro-auth-modal__check input:checked + .gro-auth-modal__check-box::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 6px;
    height: 11px;
    border: solid #141414;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.gro-auth-modal__check input:focus-visible + .gro-auth-modal__check-box {
    outline: 2px solid #D9B648;
    outline-offset: 2px;
}
/* A12: error highlight на чекбоксе если pdn unchecked при submit */
.gro-auth-modal__check--error .gro-auth-modal__check-box {
    border-color: #d33b3b;
    box-shadow: 0 0 0 3px rgba(211, 59, 59, 0.15);
    animation: gro-auth-check-shake 0.3s ease-out;
}
@keyframes gro-auth-check-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}
.gro-auth-modal__consent-error {
    margin: 8px 0 0;
    padding: 8px 12px;
    background: rgba(211, 59, 59, 0.08);
    border-left: 3px solid #d33b3b;
    border-radius: 6px;
    font-size: 13px;
    color: #c12d2d;
    line-height: 1.4;
}
.gro-auth-modal__check-label a {
    color: #141414;
    text-decoration: underline;
}

/* ───── Submit button ───── */
.gro-auth-modal__submit {
    width: 100%;
    padding: 16px 24px;
    background: #141414;
    color: #fff;
    border: none;
    border-radius: 100px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease;
}
.gro-auth-modal__submit:hover:not(:disabled) {
    background: #000;
}
.gro-auth-modal__submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ───── Magic Login Pro shortcode (hidden backend transport) ───── */
.gro-auth-modal__magic-host {
    display: none !important;
}

/* ───── SENT state ───── */
.gro-auth-modal__sent-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 16px;
}
.gro-auth-modal__sent-head .gro-auth-modal__title {
    margin-bottom: 0;
}
.gro-auth-modal__envelope {
    flex-shrink: 0;
}
.gro-auth-modal__sent-text {
    margin: 0 0 12px;
    font-size: 15px;
    line-height: 1.5;
    color: #444;
}
.gro-auth-modal__sent-text strong {
    color: #141414;
    font-weight: 500;
}
.gro-auth-modal__sent-text--marketing {
    color: #666;
}

.gro-auth-modal__resend {
    margin: 16px 0 24px;
}
.gro-auth-modal__resend-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    padding: 0;
    font-size: 14px;
    color: #888;
    cursor: pointer;
    font-family: inherit;
}
.gro-auth-modal__resend-btn:not(:disabled) {
    color: #141414;
}
.gro-auth-modal__resend-btn:disabled {
    cursor: default;
}
.gro-auth-modal__resend-timer {
    color: #141414;
    font-weight: 500;
}
.gro-auth-modal__resend-btn:not(:disabled) .gro-auth-modal__resend-timer { display: none; }

.gro-auth-modal__sent-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.gro-auth-modal__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 24px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.gro-auth-modal__btn--primary {
    background: #141414;
    color: #fff;
}
.gro-auth-modal__btn--primary:hover {
    background: #000;
    color: #fff;
}
.gro-auth-modal__btn--secondary {
    background: #fff;
    color: #141414;
    border: 1px solid rgba(0, 0, 0, 0.12);
}
.gro-auth-modal__btn--secondary:hover {
    background: #fafaf7;
    border-color: rgba(0, 0, 0, 0.24);
}
.gro-auth-modal__sent-footnote {
    margin: 0;
    font-size: 13px;
    color: #888;
}

/* ───── COOLDOWN state ───── */
.gro-auth-modal__cooldown-text {
    margin: 0;
    font-size: 15px;
    color: #d33b3b;
    line-height: 1.5;
}

/* ───── Body scroll lock (когда modal open) ───── */
body.gro-auth-modal-open {
    overflow: hidden;
}

/* =========================================================================
   Breakpoint: tablet 768-1100 — стрелка меньше, padding form компактнее
   ========================================================================= */
@media (max-width: 1100px) {
    .gro-auth-modal__container {
        grid-template-columns: 1fr 1.5fr; /* arrow ещё уже */
    }
    .gro-auth-modal__form-wrap {
        padding: 56px 40px 40px;
    }
    .gro-auth-modal__arrow {
        width: 70%;
        max-width: 220px;
    }
    .gro-auth-modal__side {
        padding: 32px;
    }
}
@media (max-width: 900px) {
    .gro-auth-modal__container {
        grid-template-columns: 0.7fr 1.8fr;
        min-height: 480px;
    }
    .gro-auth-modal__form-wrap {
        padding: 48px 32px 32px;
    }
    .gro-auth-modal__side {
        padding: 24px;
    }
    .gro-auth-modal__arrow {
        max-width: 180px;
    }
}

/* =========================================================================
   Breakpoint: < 768 (mobile = fullscreen sheet)
   Стрелка скрыта, single column, form занимает весь экран
   ========================================================================= */
@media (max-width: 767px) {
    .gro-auth-modal {
        padding: 0;
        align-items: stretch;
    }
    .gro-auth-modal__backdrop {
        background: rgba(20, 20, 20, 0.3);
    }
    .gro-auth-modal__container {
        max-width: 100%;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        min-height: auto;
        animation: gro-auth-card-in-mobile 0.25s ease-out;
    }
    @keyframes gro-auth-card-in-mobile {
        from { opacity: 0; transform: translateY(20px); }
        to   { opacity: 1; transform: translateY(0); }
    }
    .gro-auth-modal__close {
        top: 16px;
        right: 16px;
        width: 40px;
        height: 40px;
    }
    .gro-auth-modal__side {
        padding: 20px 20px 0;
        min-height: auto;
        overflow: visible;
    }
    .gro-auth-modal__arrow {
        display: none;
    }
    .gro-auth-modal__form-wrap {
        padding: 24px 20px 32px;
        max-height: none;
        overflow-y: auto;
    }
    .gro-auth-modal__title {
        font-size: 24px;
        margin-bottom: 24px;
    }
    .gro-auth-modal__input {
        font-size: 16px; /* iOS не зумит при focus если ≥16px */
    }
    .gro-auth-modal__sent-head {
        flex-direction: row;
        align-items: flex-start;
    }
    .gro-auth-modal__envelope svg {
        width: 44px;
        height: 44px;
    }
    .gro-auth-modal__sent-actions {
        flex-direction: column;
    }
    .gro-auth-modal__btn {
        width: 100%;
    }
}
