/**
 * B09 - Newsletter Signup Styles
 *
 * Implements the Saly Front design (B09-NewsletterSignup.dc.html).
 * - Isolated `.saly-ps-` classes (renders on storefront AND in PS /preview).
 * - Neutral / semantic colours use literal Saly Front token values; the brand
 *   ACCENT (button, focus, surface tint, checkbox) is driven by runtime brand
 *   CSS vars `var(--brand-*, <DEFAULT theme fallback>)` so a tenant colour swap
 *   re-themes the block without a rebuild.
 * - Mirrors `.btn`/`.btn-primary`/`.form-control` geometry from the front DS:
 *   40px controls, radius 4px, weight 600, focus ring 3px @ 12%.
 *
 * **NEVER CACHED**: this block contains dynamic CSRF tokens.
 */

/* ---------------------------------------------------------------- CONTAINER */
.saly-ps-block-newsletter {
    margin-bottom: 2rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #333333; /* --black */
}

.saly-ps-newsletter-surface {
    background: var(--brand-100, #F4F1FE); /* --primary-100 tint, themeable */
    border-radius: 0.75rem;                /* --radius-lg (12px) */
    padding: 40px;
}

/* --------------------------------------------------------------- TYPOGRAPHY */
.saly-ps-newsletter-title {
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 6px;
    color: #333333; /* --black */
}

.saly-ps-newsletter-description {
    font-size: 0.875rem;  /* --size-2 */
    line-height: 1.5;
    margin: 0;
    color: #4E4F55;       /* --gray-900 */
}

/* ----------------------------------------------------------- LAYOUT: HORIZONTAL */
.saly-ps-newsletter-horizontal {
    display: flex;
    align-items: center;
    gap: 40px;
    flex-wrap: wrap;
}

.saly-ps-newsletter-horizontal .saly-ps-newsletter-title {
    font-size: 1.5rem; /* --size-7 (24px) */
}

.saly-ps-newsletter-text {
    flex: 1;
    min-width: 260px;
}

.saly-ps-newsletter-form-col {
    flex: 1;
    min-width: 320px;
}

.saly-ps-newsletter-row {
    display: flex;
    gap: 10px;
}

.saly-ps-newsletter-row .saly-ps-newsletter-input {
    flex: 1;
}

/* ------------------------------------------------------------- LAYOUT: VERTICAL */
.saly-ps-newsletter-vertical {
    max-width: 480px;
    margin: 0 auto;
    text-align: center;
}

.saly-ps-newsletter-vertical .saly-ps-newsletter-title {
    font-size: 1.75rem; /* --size-8 (28px) */
    margin: 0 0 8px;
}

.saly-ps-newsletter-vertical .saly-ps-newsletter-description {
    margin: 0 0 20px;
}

.saly-ps-newsletter-vertical .saly-ps-newsletter-input {
    margin-bottom: 10px;
}

/* -------------------------------------------------------------- LAYOUT: COMPACT */
.saly-ps-newsletter-compact {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: center;
}

.saly-ps-newsletter-compact-label {
    font-weight: 700;
    font-size: 1.125rem; /* --size-4 (18px) */
    color: #333333;
}

.saly-ps-newsletter-input-group {
    display: flex;
    width: 100%;
    max-width: 380px;
}

.saly-ps-newsletter-input-group .saly-ps-newsletter-input {
    flex: 1;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.saly-ps-newsletter-input-group .saly-ps-newsletter-button {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* ------------------------------------------------------------------ CONTROLS */
.saly-ps-newsletter-form {
    width: 100%;
}

/* Input — mirrors .form-control */
.saly-ps-newsletter-input {
    width: 100%;
    min-height: 2.5rem;          /* 40px */
    padding: 0 0.75rem;
    border: 1px solid #DEE2E6;   /* --gray-400 */
    border-radius: 0.25rem;      /* --radius-sm (4px) */
    background: #FFFFFF;
    color: #333333;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.875rem;         /* --size-2 */
    letter-spacing: -0.02em;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
    outline: none;
}

.saly-ps-newsletter-input::placeholder {
    color: #A2A5AE; /* --gray-700 */
    font-weight: 600;
}

.saly-ps-newsletter-input:hover {
    border-color: #C1C4CC; /* --gray-600 */
}

.saly-ps-newsletter-input:focus {
    border-color: var(--brand-500, #5E2CED);
    /* progressive enhancement: brand-rgb ring overrides the literal fallback */
    box-shadow: 0 0 0 3px rgba(94, 44, 237, 0.12);
    box-shadow: 0 0 0 3px rgba(var(--brand-500-rgb), 0.12);
}

/* Button — mirrors .btn.btn-primary */
.saly-ps-newsletter-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;          /* 40px */
    padding: 0 0.75rem;
    border: 1px solid transparent;
    border-radius: 0.25rem;      /* --radius-sm */
    font-family: inherit;
    font-weight: 600;
    font-size: 0.875rem;         /* --size-2 */
    line-height: 1;
    color: #FFFFFF;
    background: var(--brand-500, #5E2CED);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}

.saly-ps-newsletter-button:hover,
.saly-ps-newsletter-button:active {
    background: var(--brand-700, #3D10BE);
    border-color: var(--brand-700, #3D10BE);
    color: #FFFFFF;
}

.saly-ps-newsletter-button:focus-visible {
    outline: 2px solid var(--brand-700, #3D10BE);
    outline-offset: 2px;
}

.saly-ps-newsletter-button:active {
    transform: scale(0.98);
}

.saly-ps-newsletter-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.saly-ps-newsletter-button--large {
    min-height: 3rem;       /* 48px — .btn-large */
    padding: 0 1rem;
}

.saly-ps-newsletter-button--block {
    width: 100%;
}

/* --------------------------------------------------------------- CONSENT */
.saly-ps-newsletter-consent {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 12px;
    cursor: pointer;
}

.saly-ps-newsletter-consent--center {
    justify-content: center;
    text-align: left;
}

.saly-ps-newsletter-consent-checkbox {
    width: 1.125rem;
    height: 1.125rem;
    margin-top: 1px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--brand-500, #5E2CED);
}

.saly-ps-newsletter-consent-text {
    font-size: 0.75rem;  /* --size-1 */
    line-height: 1.4;
    color: #4E4F55;      /* --gray-900 */
}

/* --------------------------------------------------------------- MESSAGES */
.saly-ps-newsletter-messages {
    margin-top: 1rem;
}

.saly-ps-newsletter-success,
.saly-ps-newsletter-error {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;       /* --radius (8px) */
    border: 1px solid transparent;
    font-size: 0.75rem;          /* --size-1 */
    line-height: 1.4;
}

.saly-ps-newsletter-success {
    background: #EBFAF0;  /* --success-200 */
    color: #29A355;       /* --success-700 */
    border-color: #DAF6E4;/* --success-300 */
}

.saly-ps-newsletter-error {
    background: #FBE9E9;  /* --danger-200 */
    color: #B01C1C;       /* --danger-700 */
    border-color: #F9D8D8;/* --danger-300 */
}

/* ------------------------------------------------------ ALREADY SUBSCRIBED */
.saly-ps-newsletter-subscribed {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    padding: 1.25rem;
    border-radius: 0.5rem;
    background: #EBFAF0;  /* --success-200 */
    color: #29A355;       /* --success-700 */
    font-weight: 700;
    font-size: 1rem;
}

.saly-ps-newsletter-check-icon {
    flex-shrink: 0;
}

/* ------------------------------------------------------- SCREEN READER ONLY */
.saly-ps-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ----------------------------------------------------------- LOADING STATE */
.saly-ps-newsletter-form.saly-ps-loading .saly-ps-newsletter-button {
    position: relative;
    color: transparent;
}

.saly-ps-newsletter-form.saly-ps-loading .saly-ps-newsletter-button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: saly-ps-spin 0.6s linear infinite;
}

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

/* ---------------------------------------------------------------- RESPONSIVE */
@media (max-width: 767px) {
    .saly-ps-newsletter-surface {
        padding: 24px;
    }

    .saly-ps-newsletter-horizontal {
        flex-direction: column;
        align-items: stretch;
        gap: 20px;
    }

    .saly-ps-newsletter-horizontal .saly-ps-newsletter-title {
        font-size: 1.375rem;
    }

    .saly-ps-newsletter-row {
        flex-direction: column;
    }

    .saly-ps-newsletter-row .saly-ps-newsletter-button {
        width: 100%;
    }

    .saly-ps-newsletter-vertical .saly-ps-newsletter-title {
        font-size: 1.5rem;
    }

    .saly-ps-newsletter-compact {
        flex-direction: column;
        align-items: stretch;
    }

    .saly-ps-newsletter-input-group {
        max-width: none;
    }
}
