/* Componente Organigramma della Comunità Capi.
   Usato da /comunita-capi.html e da /genitori.html#organigramma.
   I colori arrivano dalle variabili della pagina ospite (--paper, --ink, --line...)
   con un valore di riserva, così il componente si adatta anche al tema scuro. */

.organigramma, .og-overlay{
  --og-paper:var(--paper,#F8F7F4);
  --og-paper-2:var(--paper-2,#ECE9E6);
  --og-ink:var(--ink,#211638);
  --og-ink-soft:var(--ink-soft,#5B5570);
  --og-line:var(--line,rgba(33,22,56,0.14));
  --og-accent:var(--forest-900,#462678);
  --og-font-display:var(--font-display,"Roboto Slab",Georgia,"Times New Roman",serif);
  --og-lc:#FDC500;        /* Giallo: Branca L/C */
  --og-eg:#3C8C3C;        /* Verde: Branca E/G */
  --og-rs:#C0392B;        /* Rosso: Branca R/S */
  --og-cg:#7B3FE4;        /* Viola: pallino Capo Gruppo */
  --og-ae:#8B1E3F;        /* Bordeaux: croce potenziata Assistente Ecclesiastico */
  --og-support:#3FA9D6;   /* Azzurro: Supporto */
}

/* ---- Toggle Co.Ca. / Staff ---- */
.og-toggle-row{ display:flex; justify-content:flex-start; margin-bottom:30px; }
.og-toggle{
  position:relative; display:inline-flex;
  border:1px solid var(--og-line); border-radius:999px;
  background:var(--og-paper-2); padding:3px;
}
.og-toggle-knob{
  position:absolute; top:3px; bottom:3px; left:3px;
  width:calc(50% - 3px); border-radius:999px;
  background:var(--og-accent);
  transition:transform 0.25s ease;
}
.og-toggle[data-view="staff"] .og-toggle-knob{ transform:translateX(100%); }
.og-toggle-btn{
  position:relative; z-index:1; border:none; background:none; cursor:pointer;
  font-family:var(--og-font-display); font-weight:600; font-size:0.9rem;
  padding:9px 26px; border-radius:999px; color:var(--og-ink-soft);
  transition:color 0.2s ease;
}
.og-toggle[data-view="coca"] .og-toggle-btn[data-target="coca"],
.og-toggle[data-view="staff"] .og-toggle-btn[data-target="staff"]{ color:#F5F3FA; }

.og-view{ display:none; }
.og-view.active{ display:block; }

/* ---- Vista Co.Ca.: griglia unica con simboli ---- */
.og-coca-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(92px,1fr));
  gap:24px 14px;
}
.og-person{
  background:none; border:none; cursor:pointer;
  display:flex; flex-direction:column; align-items:center; gap:8px;
  font-family:inherit; padding:4px; border-radius:6px; flex-shrink:0;
}
.og-person:hover, .og-person:focus-visible{ background:var(--og-paper-2); outline:none; }
.og-photo-wrap{ position:relative; width:72px; height:72px; }
.og-photo{
  width:72px; height:72px; border-radius:50%;
  object-fit:cover; display:block;
  border:2px solid var(--og-line);
  background:var(--og-paper);
}
.og-photo-placeholder{
  width:72px; height:72px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  border:2px dashed var(--og-line);
  color:var(--og-ink-soft); font-size:0.72rem; font-weight:600; text-align:center;
  background:var(--og-paper);
}
.og-name{
  font-size:0.84rem; color:var(--og-ink); text-align:center; line-height:1.25;
  max-width:88px;
}

.og-symbols{
  position:absolute; top:-4px; right:-6px;
  display:flex; flex-direction:column; align-items:center; gap:2px;
}
.og-dot{
  width:14px; height:14px; border-radius:50%;
  border:2px solid var(--og-paper); box-shadow:0 0 0 1px rgba(0,0,0,0.08);
  background:var(--dot-color,#999);
}
.og-cross{
  width:14px; height:14px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  background:var(--og-paper); border:2px solid var(--og-paper);
  box-shadow:0 0 0 1px rgba(0,0,0,0.08);
}
.og-cross svg{ width:9px; height:9px; }

/* ---- Vista Staff: bande colorate con scroll orizzontale ---- */
.og-band{ margin-bottom:22px; }
.og-band[data-staff="Supporto"]{ background:none; border:1px dashed var(--og-line); border-radius:8px; padding:14px 14px 10px; }
.og-band:not([data-staff="Supporto"]){
  background:var(--band-color,var(--og-paper-2)); border-radius:8px; padding:14px 14px 10px;
}
.og-band-title{
  font-family:var(--og-font-display); font-weight:600; font-size:0.95rem;
  margin-bottom:12px; letter-spacing:0.02em;
  color:var(--band-title-color,var(--og-ink));
}
.og-band[data-staff="Supporto"] .og-band-title{ color:var(--og-ink-soft); }
.og-band:not([data-staff="Supporto"]) .og-band-title,
.og-band:not([data-staff="Supporto"]) .og-name{
  text-shadow:0 1px 2px rgba(0,0,0,0.3);
}
.og-band-row{
  display:flex; align-items:flex-start; gap:16px; overflow-x:auto; padding-bottom:6px;
  -webkit-overflow-scrolling:touch;
}
/* Miniature più grandi e di dimensione uniforme nella vista Staff, anche con nomi lunghi */
.og-band-row .og-person{ width:100px; padding:2px 0; gap:6px; flex-shrink:0; }
.og-band-row .og-photo-wrap{ width:92px; height:92px; }
.og-band-row .og-photo,
.og-band-row .og-photo-placeholder{ width:92px; height:92px; }
.og-band-row .og-name{
  max-width:100px; min-height:2.3em;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical;
  overflow:hidden; word-break:break-word;
}
.og-band-row .og-photo{ border-color:rgba(255,255,255,0.7); }
.og-band[data-staff="Supporto"] .og-band-row .og-photo{ border-color:var(--og-line); }
.og-band:not([data-staff="Supporto"]) .og-name{ color:var(--band-title-color,var(--og-ink)); }
.og-band:not([data-staff="Supporto"]) .og-person:hover,
.og-band:not([data-staff="Supporto"]) .og-person:focus-visible{ background:rgba(255,255,255,0.25); }

.og-error{ color:var(--og-ink-soft); }

/* ---- Scheda persona (modale) ---- */
.og-overlay{
  display:none;
  position:fixed; inset:0; z-index:50;
  background:rgba(33,22,56,0.55);
  align-items:center; justify-content:center;
  padding:6vw;
}
.og-overlay.active{ display:flex; }
.og-card{
  background:var(--og-paper); color:var(--og-ink); border-radius:8px;
  max-width:400px; width:100%;
  padding:28px 26px 24px;
  box-shadow:0 12px 40px rgba(0,0,0,0.3);
  position:relative;
}
.og-card-close{
  position:absolute; top:12px; right:12px;
  background:none; border:none; cursor:pointer;
  width:30px; height:30px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  color:var(--og-ink-soft);
}
.og-card-close:hover{ background:var(--og-paper-2); }
.og-card-close svg{ width:18px; height:18px; stroke:currentColor; }
.og-card-photo{
  width:110px; height:110px; border-radius:50%;
  object-fit:cover; display:block; margin:0 auto 16px;
  border:3px solid var(--og-accent);
}
.og-card-photo-placeholder{
  width:110px; height:110px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  margin:0 auto 16px; border:3px dashed var(--og-line);
  color:var(--og-ink-soft); font-size:0.75rem; text-align:center;
  background:var(--og-paper-2);
}
.og-card-name{
  font-family:var(--og-font-display); font-weight:600;
  font-size:1.25rem; text-align:center; margin-bottom:4px;
}
.og-card-roles{ text-align:center; margin-bottom:16px; }
.og-card-role{
  display:inline-block; font-size:0.76rem; font-weight:600;
  color:#fff; padding:3px 10px; border-radius:20px;
  margin:2px 3px; background:var(--role-color,var(--og-accent));
}
.og-card-field{
  display:flex; gap:8px; align-items:center;
  font-size:0.9rem; color:var(--og-ink-soft);
  padding:6px 0; border-bottom:1px dashed var(--og-line);
}
.og-card-field:last-of-type{ border-bottom:none; }
.og-card-field svg{ width:16px; height:16px; stroke:var(--og-accent); flex-shrink:0; }
.og-card-quote{
  margin-top:14px; font-family:var(--og-font-display); font-style:italic;
  color:var(--og-ink); font-size:0.98rem; text-align:center; line-height:1.5;
}
