/* ============================================
   CUP8 — Forum (Paper Cut)
   Caricato SOLO nelle pagine /forum/*. Riusa i token di styles.css
   (--cream/--teal/--blue/--koi, Fraunces/Inter, --radius, ombre).
   ============================================ */

.forum {
  max-width: 980px;
  margin: 0 auto;
  padding: 120px 24px 80px;
}
.forum__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}
.forum__title { font-size: clamp(2rem, 5vw, 3rem); }
.forum__title em { color: var(--teal-deep); font-style: italic; }
.forum__lead { color: var(--blue); opacity: 0.85; margin-top: 6px; max-width: 56ch; }

/* ---- Barra autenticazione ---- */
.fauth {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.fauth__user { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.fauth__avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--sky); display: grid; place-items: center;
  font-family: 'Fraunces', serif; color: var(--blue-deep); font-weight: 700;
  overflow: hidden; flex-shrink: 0;
}
.fauth__avatar img { width: 100%; height: 100%; object-fit: cover; }
.fauth__warn {
  width: 100%;
  background: #FFF3E0; color: var(--koi-deep);
  border: 1px solid var(--koi); border-radius: 14px;
  padding: 8px 14px; font-size: 0.9rem; font-weight: 600;
}

/* ---- Bottoni forum (sopra .btn di styles.css) ---- */
.fbtn {
  font-family: 'Inter', sans-serif;
  border: 0; cursor: pointer;
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 700; font-size: 0.95rem;
  background: var(--koi); color: #fff;
  transition: transform .25s var(--ease), background .25s;
  text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
}
.fbtn:hover { transform: translateY(-2px); background: var(--koi-deep); }
.fbtn--ghost { background: transparent; color: var(--blue-deep); border: 2px solid var(--blue-deep); }
.fbtn--ghost:hover { background: var(--cream-soft); }
.fbtn--small { padding: 6px 14px; font-size: 0.85rem; }
.fbtn--danger { background: #C0392B; }
.fbtn--danger:hover { background: #A93226; }
.fbtn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.fbell {
  position: relative; background: none; border: 0; cursor: pointer;
  font-size: 1.4rem; line-height: 1; color: var(--blue-deep);
}
.fbell__count {
  position: absolute; top: -6px; right: -8px;
  background: var(--koi); color: #fff; font-size: 0.7rem; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 4px;
  display: grid; place-items: center;
}

/* ---- Ricerca + categorie ---- */
.forum__toolbar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 28px; }
.forum__search {
  flex: 1; min-width: 220px;
  border: 2px solid rgba(13,59,92,.15); border-radius: 999px;
  padding: 10px 18px; font: inherit; background: #fff; color: var(--blue-deep);
}
.forum__search:focus { outline: none; border-color: var(--teal); }

/* Card categoria "pillola": immagine paper-cut (4:5, leggermente verticale) sopra, testo sotto.
   Niente altezza fissa: il pannello testo cresce col contenuto → mai tagliato.
   Le card nella stessa riga si allineano alla più alta (align-items:stretch). */
.cat-grid { display: grid; gap: 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 44px; }
@media (max-width: 720px) { .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 460px) { .cat-grid { grid-template-columns: 1fr; } }
.cat-card {
  display: flex; flex-direction: column;
  text-decoration: none; color: var(--blue-deep);
  background: var(--cream); border-radius: 28px; overflow: hidden;
  box-shadow: var(--shadow-paper);
  border: 1px solid rgba(13,59,92,.06);
  transition: transform .3s var(--ease), box-shadow .3s;
}
.cat-card:hover { transform: translateY(-3px) rotate(-.5deg); box-shadow: var(--shadow-soft); }
.cat-card__img {
  aspect-ratio: 4 / 5; flex: none; position: relative;
  /* Gradiente marino: sfondo sotto l'immagine e fallback se l'immagine manca. */
  background: linear-gradient(160deg, var(--sky), var(--teal) 65%, var(--teal-deep));
}
.cat-card__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cat-card__body { flex: 1 1 auto; display: flex; flex-direction: column; padding: 16px 18px 18px; }
.cat-card__body h3 { font-size: 1.1rem; line-height: 1.2; margin-bottom: 6px; }
.cat-card__body p {
  font-size: 0.84rem; opacity: 0.8; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cat-card__meta { margin-top: auto; padding-top: 10px; font-size: 0.78rem; color: var(--teal-deep); font-weight: 600; }

/* ---- Lista discussioni ---- */
.thread-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.thread-row {
  display: flex; align-items: center; gap: 16px;
  background: #fff; border-radius: 18px; padding: 16px 20px;
  box-shadow: var(--shadow-paper); text-decoration: none; color: inherit;
  transition: transform .25s var(--ease);
}
.thread-row:hover { transform: translateX(4px); }
.thread-row__main { flex: 1; min-width: 0; }
.thread-row__title { font-family: 'Fraunces', serif; font-weight: 600; font-size: 1.1rem; }
.thread-row__sub { font-size: 0.82rem; color: var(--blue); opacity: 0.75; margin-top: 2px; }
.thread-row__stat { text-align: center; flex-shrink: 0; min-width: 56px; }
.thread-row__stat b { display: block; font-size: 1.2rem; color: var(--teal-deep); }
.thread-row__stat span { font-size: 0.7rem; text-transform: uppercase; letter-spacing: .04em; opacity: 0.7; }
.thread-row .pin { color: var(--koi); margin-right: 6px; }
.thread-row .lock { opacity: 0.6; margin-right: 6px; }

/* ---- Vista discussione ---- */
.thread__title { font-size: clamp(1.6rem, 4vw, 2.4rem); margin-bottom: 6px; }
.thread__meta { color: var(--blue); opacity: 0.8; font-size: 0.9rem; margin-bottom: 28px; }
.thread__admin { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 28px; }

.post {
  background: #fff; border-radius: var(--radius); padding: 22px 24px;
  box-shadow: var(--shadow-paper); margin-bottom: 16px;
  display: grid; grid-template-columns: 56px 1fr; gap: 18px;
}
.post--op { border-left: 4px solid var(--koi); }
.post--deleted { opacity: 0.55; font-style: italic; }
.post__avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--sky); display: grid; place-items: center;
  font-family: 'Fraunces', serif; font-weight: 700; color: var(--blue-deep);
  overflow: hidden;
}
.post__avatar img { width: 100%; height: 100%; object-fit: cover; }
.post__head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.post__author { font-weight: 700; }
.post__author .badge-admin { font-size: 0.7rem; background: var(--koi); color: #fff; border-radius: 6px; padding: 1px 6px; margin-left: 6px; }
.post__date { font-size: 0.8rem; opacity: 0.7; }
.post__body { white-space: pre-wrap; word-wrap: break-word; line-height: 1.7; }
.post__actions { margin-top: 12px; display: flex; gap: 14px; }
.post__actions button { background: none; border: 0; color: var(--blue); cursor: pointer; font-size: 0.82rem; font-weight: 600; }
.post__actions button:hover { color: var(--koi-deep); }

/* ---- Immagini allegate ai post ---- */
.post__images { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 10px; }
.post__images img {
  max-width: 100%; width: auto; max-height: 360px;
  border-radius: 16px; box-shadow: var(--shadow-paper); display: block;
  cursor: zoom-in; transition: transform .2s var(--ease);
}
.post__images img:hover { transform: scale(1.02); }

/* ---- Lightbox: foto a piena pagina in pop-up ---- */
.forum-lightbox {
  position: fixed; inset: 0; z-index: 10002;
  background: rgba(8, 42, 71, 0.92);
  display: none; align-items: center; justify-content: center; padding: 24px;
  cursor: zoom-out;
}
.forum-lightbox.is-open { display: flex; }
.forum-lightbox__img {
  max-width: 95vw; max-height: 92vh; border-radius: 12px;
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.6); cursor: default;
}
.forum-lightbox__close {
  position: fixed; top: 14px; right: 22px;
  background: none; border: 0; color: #fff; font-size: 2.4rem; line-height: 1;
  cursor: pointer; opacity: 0.85;
}
.forum-lightbox__close:hover { opacity: 1; }

/* ---- Voti like / dislike ---- */
.vote-bar { display: flex; gap: 10px; margin: 8px 0 24px; }
.vote-btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 2px solid rgba(13,59,92,.15); background: #fff; color: var(--blue-deep);
  border-radius: 999px; padding: 8px 16px; font: inherit; font-weight: 700; cursor: pointer;
  transition: transform .2s var(--ease), border-color .2s, background .2s;
}
.vote-btn:hover { transform: translateY(-2px); }
.vote-btn.is-on { border-color: var(--teal); background: var(--sky); }
.vote-btn--down.is-on { border-color: var(--koi-deep); background: #FFE3D3; }
.vote-btn span { font-variant-numeric: tabular-nums; }

/* ---- Punteggio nella lista discussioni ---- */
.thread-row__stat--score b { color: var(--koi-deep); }

/* ---- Allega foto (reply / nuova discussione) ---- */
.reply-img {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 0.9rem; font-weight: 600; color: var(--blue);
}
.reply-img input[type="file"] { font: inherit; font-weight: 400; }
.reply-img__preview { font-size: 0.85rem; color: var(--teal-deep); }

/* ---- Box risposta / form ---- */
.reply-box, .modal__body { display: flex; flex-direction: column; gap: 12px; }
.reply-box { margin-top: 28px; }
.field-label { font-weight: 600; font-size: 0.9rem; }
.forum textarea, .forum input[type="text"], .forum input[type="email"], .forum input[type="password"], .forum select {
  font: inherit; width: 100%;
  border: 2px solid rgba(13,59,92,.15); border-radius: 14px;
  padding: 12px 16px; background: #fff; color: var(--blue-deep);
}
.forum textarea:focus, .forum input:focus, .forum select:focus { outline: none; border-color: var(--teal); }
.forum textarea { min-height: 120px; resize: vertical; }

/* honeypot: invisibile agli umani */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ---- Modale (login / nuova discussione / nickname) ---- */
.modal { position: fixed; inset: 0; z-index: 10000; display: none; }
.modal.is-open { display: grid; place-items: center; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(8,42,71,.55); }
.modal__panel {
  position: relative; z-index: 1; width: min(440px, 92vw);
  background: var(--cream); border-radius: var(--radius-lg);
  padding: 32px; box-shadow: var(--shadow-deep);
  max-height: 90vh; overflow: auto;
}
.modal__panel h2 { margin-bottom: 4px; }
.modal__panel p.modal__lead { font-size: 0.9rem; opacity: 0.8; margin-bottom: 18px; }
.modal__close { position: absolute; top: 14px; right: 18px; background: none; border: 0; font-size: 1.5rem; cursor: pointer; color: var(--blue-deep); }
.modal__divider { text-align: center; font-size: 0.8rem; opacity: 0.6; margin: 6px 0; }
.modal__error { color: #C0392B; font-size: 0.85rem; font-weight: 600; }
.modal__switch { background: none; border: 0; color: var(--teal-deep); cursor: pointer; font-weight: 600; text-decoration: underline; }

/* ---- Notifiche ---- */
.notif-panel {
  position: absolute; top: 64px; right: 24px; z-index: 9000;
  width: min(360px, 92vw); max-height: 60vh; overflow: auto;
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-deep);
  padding: 12px; display: none;
}
.notif-panel.is-open { display: block; }
.notif-item { display: block; text-decoration: none; color: inherit; padding: 12px; border-radius: 12px; }
.notif-item:hover { background: var(--cream-soft); }
.notif-item.is-unread { background: var(--sky); }
.notif-item small { display: block; opacity: 0.7; font-size: 0.75rem; margin-top: 2px; }
.notif-empty { padding: 20px; text-align: center; opacity: 0.7; }

/* ---- Stati ---- */
.forum__empty, .forum__loading { text-align: center; padding: 60px 20px; opacity: 0.75; }
.forum__gate {
  text-align: center; background: #fff; border-radius: var(--radius);
  padding: 48px 28px; box-shadow: var(--shadow-paper);
  max-width: 480px; margin: 40px auto;
}
.forum__gate h2 { font-family: 'Fraunces', serif; margin-bottom: 8px; }
.forum__gate p { color: var(--blue); opacity: 0.85; margin-bottom: 20px; }
.forum__error { background: #FDEDEC; color: #C0392B; border-radius: 14px; padding: 14px 18px; font-weight: 600; }

@media (max-width: 600px) {
  .forum { padding-top: 96px; }
  .post { grid-template-columns: 1fr; }
  .post__avatar { display: none; }
  .thread-row__stat { display: none; }
}
