/* ══════════════════════════════════════════════════════════════════════════════
   ICAM Cioccolato PWA — Custom Stylesheet
   Brand: Warm chocolate browns, cream/ivory, natural greens, gold accents
   Typography: Playfair Display (display) + Source Sans 3 (body)
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ──────────────────────────────────────────────────── */
:root {
    /* Brand Colors */
    --icam-brown-900: #1E0D05;
    --icam-brown-800: #3C1A0A;
    --icam-brown-700: #5C2E14;
    --icam-brown-600: #7A3E1C;
    --icam-brown-500: #8B4C24;
    --icam-brown-400: #A66A3E;
    --icam-brown-300: #C49164;
    --icam-brown-200: #D9B68C;
    --icam-brown-100: #ECD4B5;
    --icam-brown-50:  #F7EDE0;

    /* Accent Colors */
    --icam-cream:     #FAF5ED;
    --icam-ivory:     #FFFBF5;
    --icam-gold:      #C5993A;
    --icam-gold-light:#E8D5A3;
    --icam-green:     #4A7C59;
    --icam-green-light:#6B9E7A;
    --icam-red:       #B5403E;
    --icam-red-light: #D46A68;

    /* Semantic */
    --icam-success:   #4A7C59;
    --icam-danger:    #B5403E;
    --icam-warning:   #C5993A;

    /* Typography */
    --font-display:   'Playfair Display', Georgia, 'Times New Roman', serif;
    --font-body:      'Source Sans 3', 'Segoe UI', Tahoma, Geneva, sans-serif;

    /* Spacing */
    --section-padding: 2rem;

    /* Shadows */
    --shadow-card:    0 2px 20px rgba(30, 13, 5, 0.08);
    --shadow-card-hover: 0 8px 32px rgba(30, 13, 5, 0.15);
    --shadow-btn:     0 2px 8px rgba(30, 13, 5, 0.2);

    /* Borders */
    --border-radius:  12px;
    --border-radius-sm: 8px;
}

/* ── Base Reset & Typography ────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.6;
    color: var(--icam-brown-800);
    background-color: var(--icam-cream);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--icam-brown-800);
    line-height: 1.3;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.icam-header {
    background: linear-gradient(135deg, var(--icam-brown-800) 0%, var(--icam-brown-900) 100%);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 12px rgba(30, 13, 5, 0.3);
}

.icam-logo {
    filter: brightness(0) invert(1);
    transition: transform 0.3s ease;
}

.icam-logo:hover {
    transform: scale(1.05);
}

.header-divider {
    height: 3px;
    background: linear-gradient(90deg, var(--icam-gold), var(--icam-gold-light), var(--icam-gold));
}

/* ── Main Content ───────────────────────────────────────────────────────────── */
.icam-main {
    flex: 1;
    padding-bottom: 2rem;
}

/* ── Screen Management ──────────────────────────────────────────────────────── */
.screen {
    display: none;
    animation: fadeInUp 0.5s ease-out;
}

.screen.active {
    display: block;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Splash Screen ──────────────────────────────────────────────────────────── */
#screen-splash.active {
    display: flex;
    min-height: calc(100vh - 120px);
    align-items: center;
    justify-content: center;
}

.splash-content {
    animation: fadeIn 1s ease-out;
}

.splash-logo {
    filter: drop-shadow(0 4px 12px rgba(30, 13, 5, 0.2));
}

.display-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    font-style: italic;
    color: var(--icam-brown-700);
    letter-spacing: -0.02em;
}

.lead-text {
    font-family: var(--font-body);
    font-size: 1.15rem;
    font-weight: 300;
    color: var(--icam-brown-400);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.text-warm {
    color: var(--icam-brown-500) !important;
}

/* ── Cacao Divider ──────────────────────────────────────────────────────────── */
.cacao-divider {
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--icam-gold), transparent);
    border: none;
}

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.icam-card {
    background: #fff;
    border: 1px solid rgba(196, 145, 100, 0.15);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-card);
    transition: all 0.3s ease;
}

.icam-card:hover {
    box-shadow: var(--shadow-card-hover);
}

.card-title-icam {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 600;
    color: var(--icam-brown-700);
    margin-bottom: 0.5rem;
}

.text-muted-icam {
    color: var(--icam-brown-400) !important;
}

/* ── Step Icons ─────────────────────────────────────────────────────────────── */
.step-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--icam-brown-50) 0%, var(--icam-brown-100) 100%);
    border: 2px solid var(--icam-gold-light);
    font-size: 1.8rem;
    color: var(--icam-brown-600);
}

/* ── Form Elements ──────────────────────────────────────────────────────────── */
.form-label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--icam-brown-700);
    margin-bottom: 0.35rem;
}

.required {
    color: var(--icam-red);
}

.icam-input {
    border: 1.5px solid var(--icam-brown-100);
    border-radius: var(--border-radius-sm);
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    color: var(--icam-brown-800);
    background: var(--icam-ivory);
    transition: all 0.2s ease;
}

.icam-input:focus {
    border-color: var(--icam-gold);
    box-shadow: 0 0 0 3px rgba(197, 153, 58, 0.15);
    background: #fff;
}

.icam-input::placeholder {
    color: var(--icam-brown-200);
}

.icam-input.is-invalid {
    border-color: var(--icam-red);
    box-shadow: 0 0 0 3px rgba(181, 64, 62, 0.1);
}

.icam-check {
    border-color: var(--icam-brown-200);
    border-radius: 4px;
    width: 1.1em;
    height: 1.1em;
}

.icam-check:checked {
    background-color: var(--icam-brown-600);
    border-color: var(--icam-brown-600);
}

.icam-check:focus {
    box-shadow: 0 0 0 3px rgba(197, 153, 58, 0.2);
}

.invalid-feedback {
    font-size: 0.82rem;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn-icam-primary {
    background: linear-gradient(135deg, var(--icam-brown-600) 0%, var(--icam-brown-700) 100%);
    color: #fff;
    border: none;
    border-radius: var(--border-radius-sm);
    padding: 0.7rem 2rem;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    box-shadow: var(--shadow-btn);
    transition: all 0.25s ease;
}

.btn-icam-primary:hover,
.btn-icam-primary:focus {
    background: linear-gradient(135deg, var(--icam-brown-700) 0%, var(--icam-brown-800) 100%);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(30, 13, 5, 0.3);
}

.btn-icam-primary:active {
    transform: translateY(0);
}

.btn-icam-primary:disabled {
    background: var(--icam-brown-200);
    box-shadow: none;
    transform: none;
    cursor: not-allowed;
}

.btn-icam-outline {
    background: transparent;
    color: var(--icam-brown-600);
    border: 1.5px solid var(--icam-brown-300);
    border-radius: var(--border-radius-sm);
    padding: 0.6rem 1.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.25s ease;
}

.btn-icam-outline:hover,
.btn-icam-outline:focus {
    background: var(--icam-brown-600);
    color: #fff;
    border-color: var(--icam-brown-600);
    transform: translateY(-1px);
}

.link-icam {
    color: var(--icam-brown-600);
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s;
}

.link-icam:hover {
    color: var(--icam-brown-800);
}

/* ── Video Select Cards ─────────────────────────────────────────────────────── */
.video-card,
.action-card {
    cursor: pointer;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.video-card::before,
.action-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--icam-gold), var(--icam-brown-300));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.video-card:hover::before,
.video-card.selected::before,
.action-card:hover::before {
    transform: scaleX(1);
}

.video-card:hover,
.action-card:hover {
    border-color: var(--icam-gold-light);
    transform: translateY(-4px);
}

.video-card.selected {
    border-color: var(--icam-gold);
    box-shadow: 0 0 0 3px rgba(197, 153, 58, 0.2), var(--shadow-card-hover);
}

/* ── Action Icons ───────────────────────────────────────────────────────────── */
.action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    font-size: 1.8rem;
    transition: transform 0.3s ease;
}

.action-card:hover .action-icon {
    transform: scale(1.1);
}

.action-icon-formazione {
    background: linear-gradient(135deg, var(--icam-brown-50) 0%, var(--icam-brown-100) 100%);
    color: var(--icam-brown-600);
    border: 2px solid var(--icam-gold-light);
}

.action-icon-checkin {
    background: linear-gradient(135deg, rgba(74, 124, 89, 0.08) 0%, rgba(74, 124, 89, 0.15) 100%);
    color: var(--icam-green);
    border: 2px solid rgba(74, 124, 89, 0.3);
}

/* ── Check-in / Check-out ───────────────────────────────────────────────────── */
.checkin-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    font-size: 2.5rem;
}

.checkin-badge.success {
    background: rgba(74, 124, 89, 0.1);
    color: var(--icam-success);
    border: 3px solid var(--icam-success);
}

.checkin-badge.checkout {
    background: rgba(139, 76, 36, 0.1);
    color: var(--icam-brown-500);
    border: 3px solid var(--icam-brown-300);
}

.alert-warning-icam {
    background: rgba(197, 153, 58, 0.1);
    border: 1px solid rgba(197, 153, 58, 0.3);
    border-radius: var(--border-radius-sm);
    padding: 1rem 1.25rem;
    color: var(--icam-brown-700);
    font-size: 0.9rem;
    text-align: left;
}

.btn-icam-checkout {
    background: linear-gradient(135deg, var(--icam-brown-400) 0%, var(--icam-brown-500) 100%);
    color: #fff;
    border: none;
    border-radius: var(--border-radius-sm);
    padding: 0.8rem 2rem;
    font-weight: 600;
    font-size: 1rem;
    box-shadow: var(--shadow-btn);
    transition: all 0.25s ease;
}

.btn-icam-checkout:hover,
.btn-icam-checkout:focus {
    background: linear-gradient(135deg, var(--icam-brown-500) 0%, var(--icam-brown-600) 100%);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(30, 13, 5, 0.25);
}

.btn-icam-checkout:disabled {
    background: var(--icam-brown-200);
    box-shadow: none;
    transform: none;
}

.video-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--icam-brown-50);
    font-size: 1.5rem;
    color: var(--icam-brown-500);
}

/* ── Video Player ───────────────────────────────────────────────────────────── */
.video-wrapper {
    background: var(--icam-brown-900);
}

.icam-video-player {
    width: 100%;
    display: block;
    background: #000;
    max-height: 70vh;
}

.icam-progress {
    height: 6px;
    background: var(--icam-brown-100);
    border-radius: 3px;
    overflow: hidden;
}

.icam-progress .progress-bar {
    background: linear-gradient(90deg, var(--icam-gold), var(--icam-brown-500));
    transition: width 0.5s ease;
}

/* ── Quiz ───────────────────────────────────────────────────────────────────── */
.quiz-question {
    background: #fff;
    border: 1px solid var(--icam-brown-100);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    transition: all 0.3s ease;
}

.quiz-question:hover {
    box-shadow: var(--shadow-card);
}

.quiz-question-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--icam-brown-600);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.quiz-question-text {
    font-weight: 600;
    font-size: 1rem;
    color: var(--icam-brown-800);
    display: flex;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.quiz-option {
    display: block;
    padding: 0.6rem 1rem;
    margin-bottom: 0.4rem;
    border: 1.5px solid var(--icam-brown-100);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--icam-ivory);
}

.quiz-option:hover {
    border-color: var(--icam-gold-light);
    background: var(--icam-brown-50);
}

.quiz-option input[type="radio"] {
    display: none;
}

.quiz-option input[type="radio"]:checked + .quiz-option-label {
    /* Handled by parent styling below */
}

.quiz-option.selected {
    border-color: var(--icam-gold);
    background: rgba(197, 153, 58, 0.08);
    box-shadow: 0 0 0 2px rgba(197, 153, 58, 0.15);
}

.quiz-option-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.92rem;
    color: var(--icam-brown-700);
    cursor: pointer;
    margin: 0;
}

.quiz-option-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--icam-brown-200);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--icam-brown-400);
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.quiz-option.selected .quiz-option-marker {
    border-color: var(--icam-gold);
    background: var(--icam-gold);
    color: #fff;
}

.quiz-question.unanswered {
    border-color: var(--icam-red-light);
    box-shadow: 0 0 0 2px rgba(181, 64, 62, 0.1);
}

/* ── Results ────────────────────────────────────────────────────────────────── */
.result-icon {
    font-size: 3rem;
}

.result-icon.success {
    color: var(--icam-success);
}

.result-icon.fail {
    color: var(--icam-danger);
}

.score-circle {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    border: 4px solid;
    transition: all 0.5s ease;
}

.score-circle.success {
    border-color: var(--icam-success);
    background: rgba(74, 124, 89, 0.06);
}

.score-circle.fail {
    border-color: var(--icam-danger);
    background: rgba(181, 64, 62, 0.06);
}

.score-value {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

.score-label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--icam-brown-400);
    margin-top: 0.2rem;
}

.detail-box {
    padding: 0.75rem;
    background: var(--icam-brown-50);
    border-radius: var(--border-radius-sm);
    text-align: center;
}

.detail-box strong {
    display: block;
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--icam-brown-700);
}

.detail-box small {
    font-size: 0.78rem;
    color: var(--icam-brown-400);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.alert-danger {
    background: rgba(181, 64, 62, 0.08);
    border-color: rgba(181, 64, 62, 0.2);
    color: var(--icam-red);
    border-radius: var(--border-radius-sm);
}

/* ── Footer ─────────────────────────────────────────────────────────────────── */
.icam-footer {
    background: var(--icam-brown-900);
    color: rgba(255, 255, 255, 0.7);
    margin-top: auto;
}

.icam-footer .link-icam {
    color: var(--icam-gold-light);
    text-decoration: none;
}

.icam-footer .link-icam:hover {
    color: var(--icam-gold);
    text-decoration: underline;
}

.footer-logo {
    filter: brightness(0) invert(1);
    opacity: 0.7;
}

/* ── QR Verify Page ─────────────────────────────────────────────────────────── */
.verify-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.verify-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    font-size: 2.5rem;
}

.verify-badge.success {
    background: rgba(74, 124, 89, 0.1);
    color: var(--icam-success);
    border: 3px solid var(--icam-success);
}

.verify-badge.fail {
    background: rgba(181, 64, 62, 0.1);
    color: var(--icam-danger);
    border: 3px solid var(--icam-danger);
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 767.98px) {
    :root {
        --section-padding: 1rem;
    }

    .icam-card .card-body {
        padding: 1.25rem !important;
    }

    .quiz-question {
        padding: 1rem;
    }

    .score-circle {
        width: 110px;
        height: 110px;
    }

    .score-value {
        font-size: 2rem;
    }

    .step-icon {
        width: 50px;
        height: 50px;
        font-size: 1.4rem;
    }

    .display-title {
        font-size: 1.8rem;
    }
}

@media (max-width: 575.98px) {
    .video-card {
        margin-bottom: 0.5rem;
    }

    .quiz-option {
        padding: 0.5rem 0.75rem;
    }
}

/* ── Utility ────────────────────────────────────────────────────────────────── */
.btn-text,
.btn-loader {
    vertical-align: middle;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--icam-cream);
}

::-webkit-scrollbar-thumb {
    background: var(--icam-brown-200);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--icam-brown-300);
}

/* Focus visible */
*:focus-visible {
    outline: 2px solid var(--icam-gold);
    outline-offset: 2px;
}

/* Selection */
::selection {
    background: var(--icam-gold-light);
    color: var(--icam-brown-900);
}

/* Print */
@media print {
    .icam-header, .icam-footer, .btn {
        display: none !important;
    }
}
