/* ============================================================
   FILE: /public/css/album.css
   Stile Album Fotografico - mosaico con card stile Polaroid
   (i campi e i pulsanti dei form sono in components.css)
   ============================================================ */

:root {
    /* Carattere delle didascalie. Per provarne un altro basta cambiare
       il nome qui (e nel <link> Google Fonts in album.html). */
    --font-didascalia: 'Caveat', 'Segoe Script', 'Bradley Hand', 'Comic Sans MS', cursive;
}

/* ------------------------------------------------------------
   SFONDO ALBUM (PC + MOBILE)
   ------------------------------------------------------------ */

.album-body {
    background: url('/GENS-images/album-pc.jpg') no-repeat center center fixed;
    background-size: cover;
    min-height: 100vh;
    font-family: 'Inter', sans-serif;
}

@media (max-width: 767px) {
    .album-body {
        background: url('/GENS-images/album-mobile.jpg') no-repeat center center fixed;
        background-size: cover;
    }
}

/* ------------------------------------------------------------
   BARRA PULSANTI IN ALTO A SINISTRA
   Per ora c'è solo "Aggiungi media"; gli altri pulsanti
   (menu, profilo, dashboard...) andranno qui dentro, di fianco.
   ------------------------------------------------------------ */

.album-toolbar {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 10px;
}

#btn-aggiungi-foto {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 999px;
    background: #fff;
    color: #222;
    font-size: 1rem;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#btn-aggiungi-foto:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.45);
}

#btn-aggiungi-foto .plus {
    font-size: 1.5rem;
    line-height: 1;
}

@media (max-width: 767px) {
    .album-toolbar {
        top: 16px;
        left: 12px;
    }

    #btn-aggiungi-foto {
        padding: 10px 16px;
        font-size: 0.95rem;
    }
}

/* Menu (☰) */

.album-menu-wrap {
    position: relative;
}

#btn-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border: none;
    border-radius: 999px;
    background: #fff;
    color: #222;
    font-size: 1rem;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#btn-menu:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.45);
}

#btn-menu .menu-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.album-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 230px;
    padding: 6px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.album-menu-item {
    display: block;
    width: 100%;
    padding: 12px 14px;
    border: none;
    border-radius: 8px;
    background: none;
    color: #222;
    font: inherit;
    font-size: 1rem;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.album-menu-item:hover {
    background: #f0f0f0;
}

#btn-menu:focus-visible,
.album-menu-item:focus-visible {
    outline: 3px solid #4a90e2;
    outline-offset: 2px;
}

@media (max-width: 767px) {
    #btn-menu {
        padding: 10px 14px;
    }

    #btn-menu .label {
        display: none;      /* su telefono resta solo l'icona ☰ */
    }
}

/* ------------------------------------------------------------
   CONTENITORE PRINCIPALE (MOSAICO / MASONRY)
   Le foto scorrono per colonne: le più vecchie in alto,
   le più recenti verso il basso.
   ------------------------------------------------------------ */

.album-container {
    max-width: 1300px;
    margin: 120px auto 0 auto;
    padding: 20px;
    display: flex;        /* le colonne le crea album.js: 4 su PC, 2 su telefono */
    align-items: flex-start;
    gap: 20px;
}

.album-colonna {
    flex: 1 1 0;
    min-width: 0;
}

.album-colonna .photo-card {
    display: block;
    box-sizing: border-box;
}

@media (max-width: 767px) {
    .album-container {
        gap: 12px;
        margin: 90px auto 0 auto;
        padding: 12px;
    }
}

/* ------------------------------------------------------------
   CARD FOTO - stile Polaroid (bordo bianco arrotondato + didascalia)
   ------------------------------------------------------------ */

.photo-card {
    break-inside: avoid;   /* evita che una card si spezzi tra due colonne */
    display: inline-block; /* necessario per il masonry con "columns" */
    width: 100%;
    margin-bottom: 20px;
    padding: 10px 10px 8px 10px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    text-align: left;
    color: #333;
}

.photo-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.45);
}

@media (max-width: 767px) {
    .photo-card {
        margin-bottom: 12px;
        padding: 7px 7px 6px 7px;
        border-radius: 10px;
    }
}

.photo-img {
    width: 100%;
    border-radius: 8px;
    display: block;
    cursor: pointer;
}

@media (max-width: 767px) {
    .photo-img {
        border-radius: 6px;
    }
}

/* Didascalia: titolo + descrizione a sinistra, icone a destra */

.photo-caption {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
    padding-top: 8px;
    min-height: 34px;
}

.photo-text {
    flex: 1;
    min-width: 0;          /* permette al testo lungo di andare a capo */
    font-family: var(--font-didascalia);
}

.photo-title {
    font-weight: 700;
    font-size: 1.45rem;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.photo-desc {
    margin-top: 3px;
    font-weight: 500;
    font-size: 1.2rem;
    line-height: 1.15;
    color: #555;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 3;      /* massimo 3 righe, il resto si legge aprendo la foto */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 767px) {
    .photo-title { font-size: 1.25rem; }
    .photo-desc  { font-size: 1.05rem; }
}

.photo-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.icon-btn {
    background: none;
    border: none;
    padding: 4px 5px;
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.08);
}

.icon-btn:focus-visible,
#btn-aggiungi-foto:focus-visible,
.add-card:focus-visible {
    outline: 3px solid #4a90e2;
    outline-offset: 2px;
}

/* ------------------------------------------------------------
   FINTA POLAROID "AGGIUNGI MEDIA" (in fondo all'album)
   Centro nero, + giallo ben visibile, didascalia a mano.
   ------------------------------------------------------------ */

.album-add-wrap {
    display: flex;
    justify-content: center;
    padding: 30px 20px 100px 20px;
}

.add-card {
    display: block;
    width: 200px;
    max-width: 100%;
    margin: 0;
    padding: 10px 10px 8px 10px;
    background: #fff;
    border: none;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
    color: #333;
    font: inherit;
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.add-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.45);
}

.add-card-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 4 / 3;
    background: #111;
    border-radius: 8px;
}

/* Il "+" è disegnato con due barre gialle, così resta sempre ben centrato */
.add-card-plus {
    position: relative;
    display: block;
    width: 48px;
    height: 48px;
}

.add-card-plus::before,
.add-card-plus::after {
    content: '';
    position: absolute;
    background: #ffd600;
    border-radius: 5px;
    box-shadow: 0 0 16px rgba(255, 214, 0, 0.45);
}

.add-card-plus::before {   /* barra orizzontale */
    left: 0;
    right: 0;
    top: 50%;
    height: 7px;
    transform: translateY(-50%);
}

.add-card-plus::after {    /* barra verticale */
    top: 0;
    bottom: 0;
    left: 50%;
    width: 7px;
    transform: translateX(-50%);
}

.add-card-caption {
    display: block;
    min-height: 34px;
    padding-top: 10px;
    text-align: center;
    font-family: var(--font-didascalia);
    font-weight: 700;
    font-size: 1.2rem;
    line-height: 1.1;
}

@media (max-width: 767px) {
    .album-add-wrap {
        padding: 20px 12px 100px 12px;
    }

    .add-card {
        width: 40vw;
        max-width: 150px;
        padding: 7px 7px 6px 7px;
        border-radius: 10px;
    }

    .add-card-frame  { border-radius: 6px; }
    .add-card-plus   { width: 34px; height: 34px; }
    .add-card-plus::before { height: 5px; }
    .add-card-plus::after  { width: 5px; }
    .add-card-caption { font-size: 1.05rem; min-height: 28px; }
}

/* ------------------------------------------------------------
   FINESTRE (modifica foto, conferma eliminazione)
   L'aspetto di pannello, campi e pulsanti viene da components.css
   (.form-panel, .form-field, .btn-form): è lo stesso dei moduli di accesso.
   Qui c'è solo la disposizione.
   ------------------------------------------------------------ */

.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0,0,0,0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    /* ⭐ LARGHEZZA DI QUESTA FINESTRA (modifica foto) ⭐
       Cambia solo questo numero per farla più larga o più stretta.
       Era 920px, ora è 550px (circa il 40% più piccola). */
    max-width: 550px;
    max-height: 88vh;
    max-height: 88dvh;      /* dvh = altezza davvero visibile (esclude la barra del browser sul telefono) */
    overflow: hidden;      /* a scorrere sarà solo .modal-body, i pulsanti restano sempre visibili */
    padding: 16px 20px;    /* un po' meno spazio ai bordi: la finestra occupa meno altezza */
}

/* Finestra foto: titolo e campi più compatti, così entra meglio nello schermo */
#photo-modal .modal-content h2 { margin: 0 0 8px 0; font-size: 1.25rem; }
#photo-modal .form-field { margin-bottom: 10px; }
#photo-modal .form-field label { margin-bottom: 3px; }
#photo-modal .modal-file-top { margin-bottom: 0; flex: none; }
#photo-modal .modal-actions { margin-top: 10px; }
#photo-modal textarea { min-height: 60px; height: 64px; }

.modal-content.small {
    /* ⭐ LARGHEZZA DI QUESTA FINESTRA (conferma eliminazione) ⭐
       Era 440px, ora è 260px (circa il 41% più piccola). */
    max-width: 260px;
}

.modal-text {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
}

/* Corpo: foto a sinistra, campi a destra (su telefono uno sotto l'altro) */

.modal-body {
    /* Foto sopra e campi sotto: con la finestra più stretta di prima,
       affiancarli li avrebbe resi troppo piccoli. */
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: stretch;
    flex: 1;
    min-height: 0;         /* necessario perché il corpo possa scorrere */
    overflow-y: auto;
}

.modal-preview {
    flex: none;
    max-width: 100%;
}

.modal-preview img {
    display: block;
    width: 100%;
    max-height: 20vh;      /* più bassa: ora la foto sta sopra ai campi, non affianco */
    object-fit: contain;
    margin: 0;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.08);
}

.modal-preview img:not([src]) {
    display: none;         /* nessuna foto scelta: niente icona "immagine rotta" */
}

.modal-form {
    flex: 1;
    min-width: 0;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
    margin-top: 16px;
}

@media (max-width: 767px) {
    .modal {
        padding: 8px;
    }

    .modal-content {
        max-height: 86vh;
        max-height: 86dvh;
        padding: 12px;
    }

    .modal-body {
        flex-direction: column;
        gap: 10px;
    }

    .modal-preview {
        flex: none;
        max-width: 100%;
        width: 100%;
    }

    .modal-preview img {
        max-height: 18vh;   /* su telefono l'anteprima resta piccola */
    }

    .modal-actions {
        margin-top: 10px;
    }

    .modal-actions .btn-form {
        flex: 1;            /* pulsanti larghi, facili da premere col pollice */
    }
}

/* ------------------------------------------------------------
   LIGHTBOX - la foto in grande, come una polaroid
   ------------------------------------------------------------ */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0,0,0,0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.lightbox.hidden {
    display: none;
}

.lightbox-inner {
    position: relative;
    max-width: 100%;
}

.lightbox-polaroid {
    display: flex;
    flex-direction: column;
    min-width: min(320px, 88vw);
    max-width: 88vw;
    padding: 14px 14px 10px 14px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6);
    color: #333;
}

.lightbox-polaroid img {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 62vh;      /* così foto + didascalia stanno sempre nello schermo */
    margin: 0 auto;
    border-radius: 10px;
}

.lightbox-caption {
    max-height: 20vh;
    overflow-y: auto;      /* se la descrizione è lunga, scorre solo quella */
    padding-top: 10px;
    text-align: center;
    font-family: var(--font-didascalia);
}

.lightbox-caption[hidden] {
    display: none;
}

#lightbox-title {
    font-weight: 700;
    font-size: 1.9rem;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

#lightbox-desc {
    margin-top: 4px;
    font-weight: 500;
    font-size: 1.45rem;
    line-height: 1.2;
    color: #555;
    overflow-wrap: anywhere;
    white-space: pre-line;  /* rispetta gli "a capo" scritti nella descrizione */
}

/* Frecce per passare alla foto precedente / successiva */

.lightbox-arrow {
    position: absolute;
    top: 50%;
    z-index: 2;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    padding: 0 0 6px 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 2.4rem;
    line-height: 1;
    cursor: pointer;
}

.lightbox-arrow:hover {
    background: rgba(255, 255, 255, 0.4);
}

.lightbox-arrow[hidden] {
    display: none;         /* alla prima/ultima foto la freccia sparisce */
}

.lightbox-arrow-prev { left: 16px; }
.lightbox-arrow-next { right: 16px; }

.lightbox-arrow:focus-visible,
#lightbox-close:focus-visible {
    outline: 3px solid #4a90e2;
    outline-offset: 2px;
}

#lightbox-counter {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 1rem;
    opacity: 0.85;
}

#lightbox-close {
    position: absolute;
    top: -14px;
    right: -14px;
    width: 38px;
    height: 38px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #333;
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

#lightbox-close:hover {
    background: #000;
}

@media (max-width: 767px) {
    .lightbox {
        padding: 10px;
    }

    .lightbox-polaroid {
        padding: 10px 10px 8px 10px;
        border-radius: 14px;
    }

    .lightbox-polaroid img {
        max-height: 52vh;
        border-radius: 8px;
    }

    .lightbox-caption {
        max-height: 22vh;
    }

    #lightbox-title { font-size: 1.5rem; }
    #lightbox-desc  { font-size: 1.2rem; }

    .lightbox-arrow {
        width: 42px;
        height: 42px;
        font-size: 2rem;
    }

    .lightbox-arrow-prev { left: 6px; }
    .lightbox-arrow-next { right: 6px; }
}

/* ------------------------------------------------------------
   TAG: "chi c'è in questa foto?"
   ------------------------------------------------------------ */

.tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px 6px 12px;
    border-radius: 999px;
    background-color: #444;
    color: #fff;
    font-size: 0.9rem;
}

.tag-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 0.7rem;
    line-height: 1;
    cursor: pointer;
}

.tag-chip-remove:hover {
    background: rgba(255, 255, 255, 0.45);
}

.tag-search-wrap {
    position: relative;
}

.tag-search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 20;
    max-height: 180px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.tag-search-results.hidden {
    display: none;
}

.tag-search-item {
    padding: 10px 12px;
    font-size: 0.95rem;
    cursor: pointer;
}

.tag-search-item:hover {
    background-color: #f2f2f2;
}

.tag-new-toggle {
    display: inline-block;
    margin-top: 8px;
    background: none;
    border: none;
    padding: 0;
    color: #444;
    font-size: 0.92rem;
    text-decoration: underline;
    cursor: pointer;
}

.tag-new-toggle:hover {
    color: #000;
}

.tag-new-form {
    margin-top: 12px;
    padding: 12px;
    border: 1px dashed rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.03);
}

.tag-new-form.hidden {
    display: none;
}

.tag-new-form .form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.tag-new-form .form-field {
    margin-bottom: 10px;
}

.tag-new-message {
    min-height: 1.2em;
    margin-bottom: 6px;
    color: var(--rosso-errore);
    font-size: 0.88rem;
}

.tag-new-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.tag-new-actions.azioni-fisse { justify-content: flex-end; }

/* Nomi delle persone, sotto la didascalia della card */
.photo-people {
    margin-top: 4px;
    font-size: 0.95rem;
    color: #555;
}

.lightbox-people {
    margin-top: 4px;
    font-size: 0.95rem;
    color: #555;
    font-family: 'Inter', sans-serif;
}

@media (max-width: 767px) {
    .tag-new-form .form-row-2 {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

/* Nomi delle persone taggate: link cliccabile verso la scheda della persona */
.photo-people-link,
.lightbox-people a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: rgba(0, 0, 0, 0.3);
}

.photo-people-link:hover,
.lightbox-people a:hover {
    text-decoration-color: currentColor;
}

.lightbox-people a {
    color: #444;
    text-decoration-color: rgba(0, 0, 0, 0.35);
}

.lightbox-people a:hover {
    color: #000;
    text-decoration-color: currentColor;
}


/* ------------------------------------------------------------
   TAG - "chi è per te?" (parentela) sotto ai chip delle persone
   ------------------------------------------------------------ */

.tag-parentele {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 8px;
}

.tag-parentele:empty {
    display: none;
}

.tag-parentele-riga {
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tag-parentele-nome {
    font-weight: 600;
    font-size: 0.9rem;
}

.tag-parentele-select {
    width: 100%;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #b9a56a;
    background: #fffbe8;
    font-family: inherit;
    font-size: 0.9rem;
}

.tag-parentele-domanda {
    font-size: 0.85rem;
}

.tag-parentele-aiuto,
.tag-parentele-avviso {
    margin: 0;
    font-size: 0.8rem;
    font-style: italic;
    color: #555;
}


/* ============================================================
   Foto nuova: il modulo della persona è già aperto, quindi si
   nascondono etichetta, ricerca e il piccolo "+ Aggiungi una
   persona nuova" (restano nella modifica di una foto esistente)
   ============================================================ */
#photo-modal.modo-nuova #tag-label,
#photo-modal.modo-nuova #tag-search-wrap,
#photo-modal.modo-nuova #tag-new-btn,
#photo-modal.modo-nuova #tag-new-cancel {
    display: none;
}


/* Foto cifrata: mentre si apre c'è un riquadro chiaro; se non si riesce ad aprire resta una cornice vuota */
.photo-img.foto-in-apertura { min-height: 160px; background: rgba(0, 0, 0, 0.08); }
.photo-img.foto-non-leggibile { min-height: 120px; background: rgba(0, 0, 0, 0.15); }
