/**
 * Cube Catania Registration - Public Styles
 * Family feeling: catania.cubechallenges.it
 * Brand color: #2DFDDB (cyan), background scuro con pattern constellation
 */

.ccr-wrapper {
    --ccr-cyan: #2DFDDB;
    --ccr-cyan-glow: rgba(45, 253, 219, 0.4);
    --ccr-cyan-soft: rgba(45, 253, 219, 0.15);
    --ccr-bg-dark: #051F2A;
    --ccr-bg-mid: #0A2F3D;
    --ccr-bg-card: #0e3a4a;
    --ccr-text: #ffffff;
    --ccr-text-muted: #8fb8c2;
    --ccr-error: #ff5b6b;
    --ccr-border: rgba(45, 253, 219, 0.25);
    --ccr-border-focus: rgba(45, 253, 219, 0.7);

    /*
     * MOBILE-FIRST: comportamento naturale, larghezza al 100% del contenitore.
     * Su mobile evitiamo 100vw + margini negativi perche' su iOS Safari creano
     * uno "scatto" durante lo scroll quando la barra dell'indirizzo si
     * nasconde/riappare (100vw viene ricalcolato).
     * La tecnica full-bleed si applica solo da desktop in poi (vedi media query
     * piu' in basso).
     */
    position: relative;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh; /* dynamic viewport: niente "scatto" su iOS quando la barra address si nasconde */
    padding: 40px 16px;
    background-color: #051F2A;
    background-image:
        radial-gradient(ellipse at top right, rgba(45, 253, 219, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at bottom left, rgba(45, 253, 219, 0.05) 0%, transparent 50%),
        linear-gradient(135deg, #051F2A 0%, #0A2F3D 50%, #051F2A 100%);
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--ccr-text);
    box-sizing: border-box;
    /* Scroll fluido su iOS Safari */
    -webkit-overflow-scrolling: touch;
}

/*
 * DESKTOP (≥ 769px): applica la tecnica full-bleed per coprire eventuali
 * bande nere del tema YoungoShop ai lati del contenuto.
 * 100vw qui non causa problemi perche' su desktop il viewport e' stabile.
 */
@media (min-width: 769px) {
    .ccr-wrapper {
        width: 100vw;
        margin-left: calc(-50vw + 50%);
        margin-right: calc(-50vw + 50%);
        overflow-x: hidden;
    }
}

/* Sfondo "constellation" — SVG inline (puntini collegati da linee sottili) */
.ccr-wrapper::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.5;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1600 1000' preserveAspectRatio='xMidYMid slice'><g fill='%232DFDDB' stroke='%232DFDDB' stroke-width='0.5' stroke-opacity='0.4'><line x1='120' y1='80' x2='280' y2='160' /><line x1='280' y1='160' x2='420' y2='90' /><line x1='420' y1='90' x2='560' y2='180' /><line x1='560' y1='180' x2='700' y2='110' /><line x1='1100' y1='60' x2='1240' y2='150' /><line x1='1240' y1='150' x2='1380' y2='80' /><line x1='1380' y1='80' x2='1500' y2='190' /><line x1='1100' y1='60' x2='1180' y2='220' /><line x1='1240' y1='150' x2='1180' y2='220' /><circle cx='120' cy='80' r='2.5' /><circle cx='280' cy='160' r='2' /><circle cx='420' cy='90' r='2.5' /><circle cx='560' cy='180' r='2' /><circle cx='700' cy='110' r='2.5' /><circle cx='1100' cy='60' r='2' /><circle cx='1240' cy='150' r='2.5' /><circle cx='1380' cy='80' r='2' /><circle cx='1500' cy='190' r='2.5' /><circle cx='1180' cy='220' r='2' /><line x1='180' y1='480' x2='320' y2='560' /><line x1='320' y1='560' x2='240' y2='680' /><line x1='240' y1='680' x2='120' y2='620' /><line x1='120' y1='620' x2='180' y2='480' /><line x1='320' y1='560' x2='460' y2='600' /><line x1='460' y1='600' x2='400' y2='720' /><line x1='240' y1='680' x2='400' y2='720' /><circle cx='180' cy='480' r='2.5' /><circle cx='320' cy='560' r='2' /><circle cx='240' cy='680' r='2.5' /><circle cx='120' cy='620' r='2' /><circle cx='460' cy='600' r='2.5' /><circle cx='400' cy='720' r='2' /><line x1='1080' y1='460' x2='1240' y2='420' /><line x1='1240' y1='420' x2='1380' y2='510' /><line x1='1380' y1='510' x2='1480' y2='420' /><line x1='1480' y1='420' x2='1380' y2='340' /><line x1='1380' y1='340' x2='1240' y2='420' /><line x1='1080' y1='460' x2='1180' y2='580' /><line x1='1180' y1='580' x2='1380' y2='510' /><line x1='1180' y1='580' x2='1320' y2='660' /><line x1='1320' y1='660' x2='1480' y2='580' /><circle cx='1080' cy='460' r='2.5' /><circle cx='1240' cy='420' r='2' /><circle cx='1380' cy='510' r='2.5' /><circle cx='1480' cy='420' r='2' /><circle cx='1380' cy='340' r='2.5' /><circle cx='1180' cy='580' r='2' /><circle cx='1320' cy='660' r='2.5' /><circle cx='1480' cy='580' r='2' /><line x1='160' y1='820' x2='300' y2='880' /><line x1='300' y1='880' x2='220' y2='950' /><line x1='220' y1='950' x2='80' y2='900' /><line x1='80' y1='900' x2='160' y2='820' /><circle cx='160' cy='820' r='2' /><circle cx='300' cy='880' r='2.5' /><circle cx='220' cy='950' r='2' /><circle cx='80' cy='900' r='2.5' /><line x1='720' y1='40' x2='820' y2='110' /><line x1='820' y1='110' x2='760' y2='200' /><line x1='760' y1='200' x2='660' y2='130' /><line x1='660' y1='130' x2='720' y2='40' /><circle cx='720' cy='40' r='2' /><circle cx='820' cy='110' r='2' /><circle cx='760' cy='200' r='2' /><circle cx='660' cy='130' r='2' /><circle cx='1550' cy='400' r='3' fill='%232DFDDB' fill-opacity='0.6'/><circle cx='50' cy='350' r='2' fill='%232DFDDB' fill-opacity='0.5'/><circle cx='800' cy='850' r='2' fill='%232DFDDB' fill-opacity='0.5'/><circle cx='950' cy='820' r='2.5' fill='%232DFDDB' fill-opacity='0.6'/><circle cx='600' cy='400' r='1.5' fill='%232DFDDB' fill-opacity='0.4'/><circle cx='900' cy='300' r='1.5' fill='%232DFDDB' fill-opacity='0.4'/></g></svg>");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.ccr-wrapper *,
.ccr-wrapper *::before,
.ccr-wrapper *::after {
    box-sizing: border-box;
}

/* Glow di sfondo decorativi (più sottili sopra il pattern) */
.ccr-bg-glow {
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
}
.ccr-bg-glow-1 {
    background: var(--ccr-cyan);
    top: -100px;
    left: -150px;
    animation: ccr-float 8s ease-in-out infinite;
}
.ccr-bg-glow-2 {
    background: var(--ccr-cyan);
    bottom: -100px;
    right: -150px;
    animation: ccr-float 10s ease-in-out infinite reverse;
}
@keyframes ccr-float {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(30px, -30px); }
}

/* Container principale */
.ccr-container {
    position: relative;
    z-index: 1;
    max-width: 720px;
    margin: 0 auto;
    background: rgba(10, 47, 61, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--ccr-border);
    border-radius: 24px;
    padding: 36px 36px 40px 36px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.4),
        0 0 80px var(--ccr-cyan-soft);
}

/* Header / logo */
.ccr-header {
    text-align: center;
    margin-bottom: 32px;
}

.ccr-logo {
    margin-bottom: 20px;
    line-height: 1;
}

.ccr-logo-img {
    max-width: 240px;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 0 24px rgba(45, 253, 219, 0.25));
}

.ccr-title {
    margin: 0 0 8px 0;
    font-size: 30px;
    font-weight: 900;
    letter-spacing: 2px;
    color: var(--ccr-text);
    text-transform: uppercase;
}

.ccr-subtitle {
    margin: 0;
    font-size: 16px;
    font-weight: 400;
    color: var(--ccr-text-muted);
}

/* Form */
.ccr-form-section {
    margin-bottom: 24px;
}

.ccr-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.ccr-field {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
}
.ccr-grid-2 .ccr-field {
    margin-bottom: 0;
}

.ccr-field label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--ccr-text-muted);
    margin-bottom: 8px;
}

.ccr-required {
    color: var(--ccr-cyan);
    margin-left: 2px;
}

.ccr-field input[type="text"],
.ccr-field input[type="email"],
.ccr-field input[type="tel"],
.ccr-field input[type="date"],
.ccr-field select {
    width: 100%;
    padding: 14px 16px;
    background: rgba(10, 14, 39, 0.6);
    border: 1.5px solid var(--ccr-border);
    border-radius: 12px;
    color: var(--ccr-text);
    font-size: 15px;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.25s ease;
    -webkit-appearance: none;
    appearance: none;
}

.ccr-field select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%232DFDDB' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 42px;
}

/* Campo CAP: largo solo quanto serve (5 cifre), non spropozionato */
.ccr-field input#ccr-postcode {
    max-width: 180px;
    letter-spacing: 4px;
    text-align: center;
    font-weight: 600;
}
@media (max-width: 600px) {
    .ccr-field input#ccr-postcode {
        max-width: 100%;
    }
}

.ccr-field input::placeholder {
    color: rgba(168, 176, 212, 0.5);
}

.ccr-field input:focus,
.ccr-field select:focus {
    outline: none;
    border-color: var(--ccr-border-focus);
    background: rgba(10, 14, 39, 0.8);
    box-shadow: 0 0 0 4px var(--ccr-cyan-soft);
}

.ccr-field input.ccr-input-error,
.ccr-field select.ccr-input-error {
    border-color: var(--ccr-error);
    box-shadow: 0 0 0 4px rgba(255, 91, 107, 0.15);
}

.ccr-error {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--ccr-error);
    min-height: 16px;
    font-weight: 500;
}

/* Toggle campi extra */
.ccr-toggle-extra {
    text-align: center;
    margin: 8px 0 24px 0;
    padding: 20px;
    background: rgba(45, 253, 219, 0.04);
    border: 1px dashed var(--ccr-border);
    border-radius: 12px;
}

.ccr-btn-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: none;
    color: var(--ccr-cyan);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    padding: 8px 16px;
    transition: all 0.2s ease;
}

.ccr-btn-toggle:hover {
    transform: translateY(-1px);
    text-shadow: 0 0 20px var(--ccr-cyan-glow);
}

.ccr-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--ccr-cyan);
    color: var(--ccr-bg-dark);
    border-radius: 50%;
    font-size: 18px;
    font-weight: 900;
    line-height: 1;
    transition: transform 0.3s ease;
}

.ccr-btn-toggle[aria-expanded="true"] .ccr-toggle-icon {
    transform: rotate(45deg);
}

.ccr-toggle-hint {
    margin: 8px 0 0 0;
    font-size: 12px;
    color: var(--ccr-text-muted);
    line-height: 1.4;
}

.ccr-extra-fields[hidden] {
    display: none;
}

.ccr-extra-fields {
    animation: ccr-slide-down 0.3s ease;
    padding: 24px;
    background: rgba(10, 14, 39, 0.4);
    border-radius: 12px;
    border: 1px solid var(--ccr-border);
}

@keyframes ccr-slide-down {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Termini e condizioni */
.ccr-terms {
    margin: 24px 0;
}

.ccr-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.5;
    color: var(--ccr-text-muted);
}

.ccr-checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.ccr-checkbox-custom {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin-top: 1px;
    background: rgba(10, 14, 39, 0.6);
    border: 2px solid var(--ccr-border);
    border-radius: 6px;
    transition: all 0.2s ease;
    position: relative;
}

.ccr-checkbox-label input[type="checkbox"]:checked + .ccr-checkbox-custom {
    background: var(--ccr-cyan);
    border-color: var(--ccr-cyan);
}

.ccr-checkbox-label input[type="checkbox"]:checked + .ccr-checkbox-custom::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 11px;
    border: solid var(--ccr-bg-dark);
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
}

.ccr-checkbox-label input[type="checkbox"]:focus + .ccr-checkbox-custom {
    box-shadow: 0 0 0 4px var(--ccr-cyan-soft);
}

.ccr-terms-text a {
    color: var(--ccr-cyan);
    text-decoration: underline;
    text-decoration-color: var(--ccr-border);
    transition: text-decoration-color 0.2s ease;
}

.ccr-terms-text a:hover {
    text-decoration-color: var(--ccr-cyan);
}

/* Pulsanti */
.ccr-submit-wrap {
    text-align: center;
    margin-top: 24px;
}

.ccr-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 240px;
    padding: 16px 40px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ccr-btn-primary {
    background: var(--ccr-cyan);
    color: var(--ccr-bg-dark);
    box-shadow:
        0 4px 20px var(--ccr-cyan-glow),
        0 0 0 0 var(--ccr-cyan-glow);
}

.ccr-btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow:
        0 8px 30px var(--ccr-cyan-glow),
        0 0 0 6px var(--ccr-cyan-soft);
}

.ccr-btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.ccr-btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.ccr-btn-secondary {
    background: transparent;
    color: var(--ccr-cyan);
    border: 2px solid var(--ccr-cyan);
}

.ccr-btn-secondary:hover {
    background: var(--ccr-cyan);
    color: var(--ccr-bg-dark);
}

/* Stato di caricamento */
.ccr-btn.ccr-loading .ccr-btn-text {
    visibility: hidden;
}
.ccr-btn-spinner {
    display: none;
    position: absolute;
    width: 22px;
    height: 22px;
    border: 3px solid rgba(10, 14, 39, 0.3);
    border-top-color: var(--ccr-bg-dark);
    border-radius: 50%;
    animation: ccr-spin 0.7s linear infinite;
}
.ccr-btn.ccr-loading .ccr-btn-spinner {
    display: inline-block;
}
@keyframes ccr-spin {
    to { transform: rotate(360deg); }
}

/* Errore form generico */
.ccr-form-error {
    margin-top: 16px;
    padding: 14px 18px;
    background: rgba(255, 91, 107, 0.1);
    border: 1px solid var(--ccr-error);
    border-radius: 12px;
    color: var(--ccr-error);
    font-size: 14px;
    font-weight: 500;
    text-align: center;
}

/* Stato di successo */
.ccr-success {
    text-align: center;
    padding: 20px 0;
    animation: ccr-fade-in 0.5s ease;
}

@keyframes ccr-fade-in {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.ccr-success-icon {
    margin: 0 auto 24px auto;
    width: 80px;
    height: 80px;
    filter: drop-shadow(0 0 20px var(--ccr-cyan-glow));
    animation: ccr-pulse 2s ease infinite;
}

@keyframes ccr-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.ccr-success-title {
    margin: 0 0 12px 0;
    font-size: 36px;
    font-weight: 900;
    color: var(--ccr-cyan);
    letter-spacing: 2px;
    text-transform: uppercase;
    text-shadow: 0 0 30px var(--ccr-cyan-glow);
}

.ccr-success-message {
    margin: 0 0 32px 0;
    font-size: 17px;
    color: var(--ccr-text);
    line-height: 1.5;
}

/* Responsive */
@media (max-width: 600px) {
    .ccr-wrapper {
        padding: 24px 12px;
    }
    .ccr-container {
        padding: 24px 18px 28px 18px;
        border-radius: 18px;
    }
    .ccr-grid-2 {
        grid-template-columns: 1fr;
    }
    .ccr-grid-2 .ccr-field {
        margin-bottom: 16px;
    }
    .ccr-grid-2 .ccr-field:last-child {
        margin-bottom: 0;
    }
    .ccr-logo-img {
        max-width: 180px;
    }
    .ccr-title {
        font-size: 22px;
    }
    .ccr-subtitle {
        font-size: 14px;
    }
    .ccr-success-title {
        font-size: 28px;
    }
    .ccr-btn {
        min-width: 100%;
        padding: 16px 24px;
    }
    .ccr-extra-fields {
        padding: 16px;
    }
}

/* Accessibilità: rispetta prefer-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .ccr-bg-glow,
    .ccr-success-icon,
    .ccr-extra-fields {
        animation: none;
    }
    .ccr-btn {
        transition: none;
    }
}
