/* ========================================================================
   src/recipe.css - DESIGN PARALLAX MODERNO (Clean & Unified)
   ======================================================================== */

/* --- Layout Base --- */
body {
    background-color: var(--bg-color); 
    padding-bottom: 0;
    margin: 0;
}

.recipe-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    min-height: 100vh;
}

/* ========================================================================
   1. HEADER PARALLAX & CAROSELLO
   ======================================================================== */
.recipe-header {
    position: sticky; 
    top: 0;
    left: 0;
    width: 100%;
    height: 45vh; /* Altezza dell'immagine */
    z-index: 0;   /* Livello basso, così il contenuto ci scorre sopra */
    overflow: hidden;
    background-color: #333;
}

/* Sfumatura scura in basso per leggere meglio i dots */
.recipe-header::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0; height: 100px;
    background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 100%);
    pointer-events: none;
    z-index: 2;
}

/* Track Slider */
.hero-carousel {
    display: flex;
    width: 100%;
    height: 100%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    cursor: grab;
}
.hero-carousel::-webkit-scrollbar { display: none; }
.hero-carousel.active { cursor: grabbing; scroll-snap-type: none; }

.recipe-header .carousel-slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100% !important;
    object-fit: cover;
    object-position: center;
    scroll-snap-align: center;
    display: block;
    -webkit-user-drag: none; user-drag: none;
}

/* Puntini del carosello (in basso al centro) */
.carousel-dots {
    position: absolute;
    bottom: 4\0px;
    left: 0; right: 0;
    display: flex; justify-content: center; gap: 8px;
    z-index: 5;
}
.dot {
    width: 8px; height: 8px; background: rgba(255,255,255,0.5);
    border-radius: 50%; transition: all 0.3s;
}
.dot.active { background: #fff; transform: scale(1.3); }

/* ========================================================================
   2. NAVIGAZIONE (Overlay Top & Bottom)
   ======================================================================== */

/* A. BARRA SUPERIORE (Indietro + Condividi) */
.recipe-nav-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    display: flex;
    justify-content: space-between; /* Indietro a sx, Condividi a dx */
    align-items: center;
    padding: 0 15px;
    z-index: 20; 
    pointer-events: none; /* Clicca attraverso lo spazio vuoto */
    
    /* Leggero gradiente per stacco su foto chiare */
    background: linear-gradient(to bottom, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0) 100%);
    box-sizing: border-box;
}

.nav-overlay-btn {
    pointer-events: auto; /* Riattiva il click */
    background-color: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.4);
    color: white;
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.nav-overlay-btn:hover {
    background-color: white;
    color: var(--primary-color, #008a8a);
    transform: scale(1.1);
}
.nav-overlay-btn .material-symbols-outlined { font-size: 22px; }

/* B. PULSANTE ESPANDI (Basso a Destra) */
.expand-button {
    position: absolute;
    bottom: 35px; 
    right: 15px;
    /* Reset vecchi stili */
    top: auto; 
    
    width: 35px; height: 35px;
    background-color: rgba(0, 0, 0, 0.5); /* Scuro per contrasto coi puntini */
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    display: flex; justify-content: center; align-items: center;
    cursor: pointer;
    z-index: 10; 
    transition: transform 0.2s, background-color 0.2s;
}
.expand-button:hover {
    background-color: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}
.expand-button .material-symbols-outlined { font-size: 20px; }

/* C. FRECCE CAROSELLO (Solo desktop/tablet) */
.nav-arrow {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(0,0,0,0.3); color: white; border: none;
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 10; transition: background 0.2s;
}
.nav-arrow:hover { background: rgba(0,0,0,0.6); }
.nav-arrow.prev { left: 10px; }
.nav-arrow.next { right: 10px; }




/* ========================================================================
   3. CONTENUTO FOGLIO (Parallax Effect)
   ======================================================================== */
.recipe-main-content {
    position: relative;
    z-index: 10;      /* Passa SOPRA l'immagine */
    margin-top: -30px; /* Effetto sovrapposizione */
    
    background-color: var(--card-bg-color);
    border-top-left-radius: 30px;
    border-top-right-radius: 30px;
    box-shadow: 0 -5px 25px rgba(0,0,0,0.1);
    padding: 30px 20px 20px 20px;
    min-height: 60vh; 
}

/* Maniglia decorativa per il "foglio" */
.recipe-main-content::before {
    content: ''; position: absolute;
    top: 12px; left: 50%; transform: translateX(-50%);
    width: 50px; height: 5px;
    background-color: #e0e0e0; border-radius: 10px;
}

.title-container {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 15px; margin-bottom: 10px; padding-top: 10px;
}
.title-container h1 {
    margin: 0; font-size: 1.8rem; font-weight: 800; line-height: 1.2;
    color: var(--text-color);
}

.favorite-button {
    background: #f5f5f5; border: none; width: 45px; height: 45px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0; transition: all 0.2s;
}
.favorite-button:active { transform: scale(0.9); }
.favorite-button .material-symbols-outlined {
    font-size: 28px; color: #ccc; font-variation-settings: 'FILL' 0; transition: color 0.3s;
}
.favorite-button.is-favorite { background-color: #fff9c4; }
.favorite-button.is-favorite .material-symbols-outlined {
    color: #FFD700; font-variation-settings: 'FILL' 1;
}

#preview-banner { margin-top: 10px; margin-bottom: 20px; }

/* --- HEADER META (Autore + Macchine + Tag) --- */
.meta-header-row {
    display: flex;
    flex-wrap: wrap; 
    align-items: center;
    gap: 12px;      
    margin-bottom: 25px;
    margin-top: 5px;
}

/* Link Autore */
.recipe-author-line {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 0.95rem; color: var(--accent-color); 
    text-decoration: none; font-weight: 600;
    transition: opacity 0.2s; margin: 0 !important; margin-right: 5px;
}
.recipe-author-line:hover { opacity: 0.8; text-decoration: underline; }
.recipe-author-line .material-symbols-outlined { font-size: 18px; }

/* Pillole (Macchine e Tag) */
.recipe-machine-pill, .recipe-tag-pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; border-radius: 12px;
    font-size: 0.8rem; font-weight: 600; text-decoration: none;
    transition: transform 0.2s; white-space: nowrap;
    margin: 5px;
}
.recipe-machine-pill {
    background-color: #e0f7fa; color: #006064; border: 1px solid #b2ebf2;
}
.recipe-tag-pill {
    background-color: #fff3e0; color: #e65100; border: 1px solid #ffe0b2;
}
.recipe-machine-pill:hover, .recipe-tag-pill:hover { transform: translateY(-1px); }
.recipe-tag-pill::before { content: '#'; opacity: 0.5; margin-right: 2px; }


/* --- INFO RAPIDE --- */
.quick-info {
    display: flex; justify-content: space-between;
    padding: 15px 0; border-bottom: 1px solid #eee; margin-bottom: 25px;
}
.info-item {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    font-size: 0.85rem; color: var(--secondary-text-color); flex: 1;
    position: relative;
}
.info-item:not(:last-child)::after {
    content: ''; position: absolute; right: 0; top: 10%; height: 80%;
    width: 1px; background-color: #eee;
}
.info-item .material-symbols-outlined { font-size: 24px; color: var(--accent-color); }

/* --- TABS --- */
/* In src/recipe.css */

.tab-navigation {
    display: flex;
    background: var(--profile-bg-color);
    padding: 5px;
    border-radius: 12px;
    margin-bottom: 25px;
    
    /* MODIFICA: Abilita lo scorrimento orizzontale se i pulsanti non entrano */
    overflow-x: auto;
    
    /* Nasconde la scrollbar antiestetica ma mantiene lo scorrimento */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    
    /* Scroll fluido su iOS */
    -webkit-overflow-scrolling: touch; 
}

/* Nasconde scrollbar su Chrome/Safari/Opera */
.tab-navigation::-webkit-scrollbar {
    display: none;
}

.tab-button {
    flex: 1; 
    padding: 10px; 
    border: none; 
    background: none;
    border-radius: 8px; 
    color: var(--secondary-text-color);
    font-weight: 600; 
    font-size: 0.9rem; 
    cursor: pointer; 
    transition: all 0.2s;
    
    /* MODIFICA: Impedisce al testo di andare a capo e garantisce larghezza minima */
    white-space: nowrap; 
    min-width: fit-content; 
}
.tab-button.active {
    background-color: var(--card-bg-color);
    color: var(--text-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.tab-pane { display: none; animation: fadeIn 0.3s; }
.tab-pane.active { display: block; }
@keyframes fadeIn { from{opacity:0; transform:translateY(5px);} to{opacity:1; transform:translateY(0);} }


/* ========================================================================
   4. LISTE E COMPONENTI (Ingredienti & Procedimento)
   ======================================================================== */

/* Ingredienti */
#ingredients-list { list-style: none; padding: 0; margin: 0; }
#ingredients-list li {
    padding: 12px 0; border-bottom: 1px solid #f5f5f5;
    font-size: 1.05rem; display: flex; align-items: center;
}
#ingredients-list li::before {
    content: "•"; color: var(--accent-color); font-size: 1.5rem;
    margin-right: 12px; line-height: 0;
}

/* Gruppi e Header Fisarmonica */
.step-group-wrapper { margin-bottom: 30px; }
.step-group-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 10px; margin-bottom: 15px;
    background-color: var(--profile-bg-color); border-radius: 10px;
    cursor: pointer; transition: background-color 0.2s;
}
.step-group-header:hover { 
    opacity: 0.8;

}


.step-group-header h4.group-title {
    margin: 0; font-size: 1.1rem; color: var(--text-color);
    font-weight: 700; text-transform: capitalize; border: none; padding: 0;
}
/* Titoli gruppi ingredienti (non cliccabili) */
h4.group-title {
    margin: 25px 0 10px 0; font-size: 1.1rem; color: var(--accent-color);
    border-bottom: 2px solid #eee; padding-bottom: 5px;
    text-transform: uppercase; letter-spacing: 0.5px;
}

/* Bottone Freccia (Header Passaggi) */
.toggle-btn-wrapper {
    width: 36px; height: 36px;
    background-color: var(--accent-color); color: white;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.15); transition: transform 0.3s ease, background-color 0.2s;
}
.toggle-btn-wrapper:hover { background-color: #007a7a; }
.toggle-btn-wrapper.closed { transform: rotate(-90deg); background-color: #ccc; }
.toggle-btn-wrapper .toggle-icon { font-size: 24px; font-weight: 700; }

/* Passaggi */
#steps-list { list-style: none; padding: 0; margin: 0; }
.step-group-list { list-style: none; padding: 0; margin: 0; animation: fadeIn 0.3s ease-in-out; }
.step-item { display: flex; gap: 15px; margin-bottom: 30px; }
.step-number {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--accent-color); color: white;
    display: flex; justify-content: center; align-items: center;
    font-weight: 700; font-size: 0.9rem; flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0, 138, 138, 0.3);
}
.step-content { line-height: 1.6; font-size: 1rem; color: var(--text-color); width: 100%; }


/* --- VISUALIZZATORE SETTAGGI MACCHINA (Robot da cucina) --- */
.machine-settings-wrapper {
    display: flex; flex-direction: column; align-items: center; margin: 15px 0;
}
.machine-mode-badge {
    background-color: #673AB7; color: white;
    font-size: 0.8rem; font-weight: 700; padding: 4px 12px;
    border-radius: 12px; margin-bottom: -10px; z-index: 2;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2); text-transform: uppercase;
}
.machine-settings-display {
    display: flex; justify-content: center; gap: 20px;
    padding: 15px 20px 10px 20px;
    background-color: var(--profile-bg-color); border-radius: 12px;
    position: relative; z-index: 1;
}
.machine-column { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.machine-caption { font-size: 0.75rem; color: #666; font-weight: 600; text-transform: uppercase; }

.machine-circle {
    width: 60px; height: 60px; background-color: var(--card-bg-color); border-radius: 50%;
    border: 2px solid var(--accent-color);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    box-shadow: 0 3px 6px rgba(0,0,0,0.1); position: relative;
}
.machine-circle.temp { border-color: #e74c3c; }
.machine-circle.speed { border-color: #27ae60; }
.machine-circle .material-symbols-outlined { font-size: 18px; color: #999; margin-bottom: 2px; }
.machine-circle .val {
    font-size: 0.8rem; font-weight: 700; color: var(--text-color); text-align: center;
    line-height: 1.1; max-width: 90%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rot-icon {
    position: absolute; bottom: -6px; right: -6px; background: white; border-radius: 50%;
    font-size: 16px !important; padding: 2px; box-shadow: 0 1px 3px rgba(0,0,0,0.2); font-weight: bold;
}

/* --- COMPONENTI EXTRA (Porzioni, Qty) --- */
.portion-selector {
    background: #e0f2f1; border-radius: 20px; padding: 3px;
    display: flex; align-items: center; gap: 8px;
}
.portion-btn {
    width: 22px; height: 22px; border-radius: 50%; border: none;
    background: var(--accent-color); color: white; font-weight: bold;
    font-size: 14px; cursor: pointer; display: flex; justify-content: center; align-items: center;
}
.portion-display { font-size: 0.9rem; font-weight: 700; color: var(--accent-color); min-width: 15px; text-align: center; }
.ing-qty { font-weight: 700; }
.ing-qty.changed { color: #d35400; background: #fff3e0; padding: 0 4px; border-radius: 4px; }

.dynamic-ingredient-span {
    color: var(--accent-color, #008a8a); font-weight: 700;
    background-color: #e0f2f1; padding: 0 4px; border-radius: 4px;
    border-bottom: 1px dashed var(--accent-color); cursor: help;
}
.dynamic-ingredient-span.changed {
    color: #d35400; background-color: #fff3e0; border-color: #d35400; transition: all 0.3s;
}

/* Lightbox */
.lightbox-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95); z-index: 2000;
    display: flex; justify-content: center; align-items: center;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.lightbox-modal.visible { opacity: 1; pointer-events: auto; }
.lightbox-image {
    max-width: 95%; max-height: 85%; object-fit: contain;
    transform: scale(0.9); transition: transform 0.3s;
}
.lightbox-modal.visible .lightbox-image { transform: scale(1); }
.lightbox-close {
    position: absolute; top: 20px; right: 20px; background: none; border: none;
    color: white; cursor: pointer; z-index: 2010;
}
.lightbox-close span { font-size: 36px; }
.lightbox-nav-btn {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(255,255,255,0.15); color: white; border: 1px solid rgba(255,255,255,0.3);
    width: 50px; height: 50px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 2010; transition: all 0.2s;
}
.lightbox-nav-btn:hover { background: rgba(255,255,255,0.3); transform: translateY(-50%) scale(1.1); }
.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }

/* src/recipe.css - Aggiungi in fondo */

/* --- SEZIONE COMMENTI --- */
.comments-container {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

#comment-text {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    resize: none;
    font-family: inherit;
    font-size: 0.95rem;
    margin-bottom: 10px;
    box-sizing: border-box;
    background-color: var(--input-bg); 
    color: var(--text-color);
}

.login-prompt {
    background-color: var(--profile-bg-color);
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    color: var(--secondary-text-color);
    font-size: 0.9rem;
}
.login-prompt a { color: var(--accent-color); font-weight: bold; text-decoration: none; }

/* Singolo Commento */
.comment-item {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

.comment-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.comment-body {
    background-color: var(--profile-bg-color);
    padding: 10px 15px;
    border-radius: 0 12px 12px 12px; /* Fumetto */
    flex: 1;
    position: relative;    
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.comment-author {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-color);
}

.comment-date {
    font-size: 0.75rem;
    color: #999;
}

.comment-content {
    font-size: 0.95rem;
    line-height: 1.4;
    color: var(--text-color);
    white-space: pre-wrap; /* Mantiene gli a capo */
}

/* Tasto elimina commento (X piccola) */
.btn-delete-comment {
    background: none; border: none;
    color: #ccc; cursor: pointer;
    font-size: 0.8rem; padding: 2px;
    transition: color 0.2s;
}
.btn-delete-comment:hover { color: #d32f2f; }

/* src/recipe.css */

/* Stile per le Risposte (Indentazione) */
.replies-list {
    margin-left: 50px; /* Sposta a destra */
    border-left: 2px solid #eee; /* Linea verticale guida */
    padding-left: 10px;
    margin-top: -10px; /* Avvicina al genitore */
    margin-bottom: 20px;
}

/* Pulsante Rispondi */
.btn-reply {
    background: none; border: none;
    color: var(--accent-color); font-weight: 600;
    font-size: 0.8rem; cursor: pointer;
    margin-left: 10px; padding: 2px 5px;
}
.btn-reply:hover { text-decoration: underline; }

/* Form di Risposta (Nascosto di default) */
.reply-input-container {
    margin-left: 50px;
    margin-bottom: 15px;
    display: none; /* Nascosto */
    animation: fadeIn 0.3s;
}
.reply-input-container.visible { display: block; }

.reply-textarea {
    width: 100%; padding: 8px;
    border: 1px solid var(--border-color); border-radius: 8px;
    font-size: 0.9rem; margin-bottom: 5px;
    resize: none;

    background-color: var(--input-bg);
    color: var(--text-color);
}


/* src/recipe.css - Aggiungi in fondo */

/* Toolbar sotto la textarea */
.comment-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
}

.icon-button {
    background: none; border: none;
    cursor: pointer; color: #666;
    padding: 5px; border-radius: 50%;
    transition: background 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.icon-button:hover { background-color: #f0f0f0; color: var(--accent-color); }

/* Anteprima prima dell'invio */
.comment-preview-box {
    position: relative;
    width: fit-content;
    margin-bottom: 10px;
}
.comment-preview-box.hidden { display: none; }

#comment-img-preview {
    height: 80px; width: auto;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.btn-remove-preview {
    position: absolute; top: -5px; right: -5px;
    background: #d32f2f; color: white;
    border: none; border-radius: 50%;
    width: 20px; height: 20px;
    cursor: pointer; font-size: 12px;
    display: flex; align-items: center; justify-content: center;
}

/* Immagine nel commento pubblicato */
.comment-attached-image {
    display: block;
    margin-top: 10px;
    max-width: 100%;
    max-height: 250px; /* Non farle giganti */
    border-radius: 8px;
    cursor: pointer; /* Opzionale: per aprirla in lightbox */
}



.ing-separator {
    margin: 0 6px;
    color: #bbb; /* Grigio chiaro per non appesantire */
    font-weight: normal;
}

.ingredient-group li strong {
    color: var(--text-color); /* O un colore d'accento */
    font-weight: 600;
}


/* --- RATING SYSTEM (LAYOUT ORIZZONTALE) --- */
.recipe-rating-box {
    background-color: var(--profile-bg-color, #f9f9f9);
    padding: 12px 20px;
    border-radius: 12px;
    margin: 20px 0;
    border: 1px solid #eee;

    /* LAYOUT A RIGA (FLEX) */
    display: flex;
    align-items: center;       /* Allinea verticalmente al centro */
    justify-content: center;   /* Centra tutto orizzontalmente */
    gap: 20px;                 /* Spazio tra Titolo, Stelle e Feedback */
    flex-wrap: wrap;           /* Permette di andare a capo su schermi piccolissimi */
}

.recipe-rating-box h3 {
    margin: 0;                 /* Rimuove margini per allinearsi alle stelle */
    font-size: 1rem;
    color: var(--text-color);
    white-space: nowrap;       /* Mantiene il titolo su una riga */
}

.rating-container {
    display: inline-flex;
    flex-direction: row-reverse; /* Mantiene la logica per l'hover */
    gap: 4px;
    position: relative;
    top: -2px; /* Piccolo aggiustamento ottico verticale */
}

.rating-container input { display: none; }

.rating-container label {
    font-size: 28px; /* Leggermente più piccole per stare bene in riga */
    color: #ddd;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
    line-height: 1; /* Importante per l'allineamento */
}

/* Hover e Checked */
.rating-container label:hover,
.rating-container label:hover ~ label,
.rating-container input:checked ~ label {
    color: #ffc107; 
    transform: scale(1.15);
}

/* Feedback testuale a destra */
#rating-feedback {
    font-size: 0.9rem;
    margin: 0;
    color: #666;
    font-weight: 500;
    border-left: 1px solid #ddd; /* Separatore visivo opzionale */
    padding-left: 20px;
    min-width: 120px; /* Evita che il testo salti mentre carica */
    text-align: left;
}

/* MOBILE: Su schermi piccoli torna in colonna per spazio */
@media (max-width: 600px) {
    .recipe-rating-box {
        flex-direction: column;
        gap: 10px;
    }
    #rating-feedback {
        border-left: none;
        padding-left: 0;
        text-align: center;
    }
}