/* ig.css — il menu come un profilo Instagram.
   Colori e misure presi dall'app: carattere di sistema a 14px, nero pieno,
   grigio #737373 per le seconde righe, blu #0095f6 per l'azione principale.
   Alzare IG_VERSION in ig/index.php a ogni modifica. */

:root {
  --bg: #fff; --fg: #000; --fg2: #737373; --linea: #dbdbdb; --tasto: #efefef; --tasto-h: #dbdbdb;
  --blu: #0095f6; --blu-h: #1877f2; --link: #00376b;
  --anello: linear-gradient(45deg, #feda75, #fa7e1e 30%, #d62976 55%, #962fbf 78%, #4f5bd5);
  --fs: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000; --fg: #f5f5f5; --fg2: #a8a8a8; --linea: #262626; --tasto: #363636; --tasto-h: #262626; --link: #e0f1ff; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* i visori hanno un display proprio: hidden deve vincere */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 400 var(--fs)/18px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── barra in alto ── */
.ig-top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  height: 44px; padding: 0 16px; padding-top: env(safe-area-inset-top);
  background: var(--bg); border-bottom: 1px solid var(--linea);
}
.ig-top__back { display: flex; width: 28px; height: 28px; align-items: center; justify-content: center; margin-left: -6px; }
.ig-top__back svg { width: 24px; height: 24px; }
.ig-top__user { flex: 1; text-align: center; font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ig-top__lng { font-size: 13px; font-weight: 600; color: var(--fg2); }

.ig-main { max-width: 935px; margin: 0 auto; }

/* ── testata: avatar, numeri, bio, pulsanti ──
   Una griglia sola: sul telefono la bio va a tutta larghezza sotto l'avatar,
   sul computer sta nella colonna di destra, come nell'app e nel sito. */
.ig-profilo {
  display: grid; grid-template-columns: auto 1fr; column-gap: 28px; align-items: center;
  grid-template-areas: "av dx" "bio bio" "az az"; padding-top: 16px;
}
.ig-head__av { grid-area: av; margin-left: 16px; margin-bottom: 12px; width: 86px; height: 86px; border-radius: 50%; padding: 3px; display: grid; place-items: center; }
.ig-head__av:disabled { cursor: default; }
.ig-ring { background: var(--anello); }
.ig-avatar {
  width: 100%; height: 100%; border-radius: 50%; display: block;
  /* i loghi dei locali hanno ogni forma: dentro il cerchio stanno interi, su fondo bianco */
  object-fit: contain; background: #fff; border: 3px solid var(--bg); padding: 6px;
}
.ig-head__av:not(.ig-ring) .ig-avatar { border-color: var(--linea); border-width: 1px; }
.ig-avatar--sigla { display: grid; place-items: center; font-size: 34px; font-weight: 600; color: #262626; }
.ig-head__dx { grid-area: dx; min-width: 0; margin-bottom: 12px; padding-right: 16px; }
.ig-head__nome { margin: 0 0 10px; font-size: 16px; line-height: 20px; font-weight: 600; }
.ig-stats { display: flex; gap: 28px; margin: 0; padding: 0; list-style: none; }
.ig-stats li { display: flex; flex-direction: column; font-size: 14px; color: var(--fg); }
.ig-stats b { font-size: 16px; font-weight: 600; }

/* ── bio ── */
.ig-bio { grid-area: bio; padding: 0 16px 14px; }
.ig-bio__testo { margin: 0; white-space: normal; overflow-wrap: anywhere; }
.ig-bio__testo.is-corta { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ig-bio__altro { color: var(--fg2); }
.ig-bio__riga { display: flex; align-items: flex-start; gap: 6px; margin-top: 4px; }
.ig-bio__riga svg { flex: 0 0 auto; width: 14px; height: 14px; margin-top: 2px; stroke-width: 2.2; }
.ig-bio__link { color: var(--link); font-weight: 600; }

/* ── pulsanti ── */
.ig-azioni { grid-area: az; display: flex; gap: 6px; padding: 0 16px 16px; }
.ig-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; height: 32px; padding: 0 12px;
  border-radius: 8px; background: var(--tasto); font-weight: 600; font-size: 14px; white-space: nowrap;
}
.ig-btn:hover { background: var(--tasto-h); }
.ig-btn--blu { background: var(--blu); color: #fff; }
.ig-btn--blu:hover { background: var(--blu-h); }

/* ── storie in evidenza ── */
.ig-hl {
  display: flex; gap: 15px; padding: 2px 16px 16px; overflow-x: auto; scrollbar-width: none;
  overscroll-behavior-x: contain; scroll-snap-type: x proximity;
}
.ig-hl::-webkit-scrollbar { display: none; }
.ig-hl__el { flex: 0 0 auto; width: 66px; display: flex; flex-direction: column; align-items: center; gap: 6px; scroll-snap-align: start; }
.ig-hl__cerchio { width: 66px; height: 66px; border-radius: 50%; padding: 2px; border: 1px solid var(--linea); background: var(--bg); }
.ig-hl__cerchio img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; background: var(--tasto); }
.ig-hl__nome { width: 100%; font-size: 12px; line-height: 16px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── schede e griglia ── */
.ig-tabs { display: flex; justify-content: center; border-top: 1px solid var(--linea); }
.ig-tab { flex: 1; max-width: 200px; display: flex; justify-content: center; padding: 10px 0; color: var(--fg2); }
.ig-tab.is-on { color: var(--fg); box-shadow: inset 0 -1px 0 var(--fg); }
.ig-tab svg { width: 24px; height: 24px; stroke-width: 1.6; }

.ig-griglia { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.ig-griglia__el { display: block; aspect-ratio: 3 / 4; overflow: hidden; background: var(--tasto); }
.ig-griglia__el img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ig-griglia__el:active img { opacity: .8; }
.ig-vuoto { text-align: center; color: var(--fg2); padding: 60px 16px; }
.ig-vuoto--pref { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--fg); }
.ig-vuoto--pref b { font-size: 24px; line-height: 30px; font-weight: 800; }
.ig-vuoto--pref p { margin: 0; color: var(--fg2); max-width: 300px; }
.ig-vuoto__ico { width: 62px; height: 62px; border-radius: 50%; border: 2px solid var(--fg); display: grid; place-items: center; }
.ig-vuoto__ico svg { width: 30px; height: 30px; stroke-width: 1.6; }
.ig-piede { text-align: center; color: var(--fg2); font-size: 12px; padding: 28px 16px calc(28px + env(safe-area-inset-bottom)); }

/* ── computer: la disposizione del sito di Instagram ── */
@media (min-width: 736px) {
  /* la barra resta: porta alla vetrina e cambia lingua, che qui non hanno un altro posto */
  .ig-main { padding: 30px 20px 0; }
  .ig-profilo { grid-template-columns: 290px 1fr; column-gap: 0; align-items: start;
                grid-template-areas: "av dx" "av bio" "av az"; padding: 0 0 44px; }
  .ig-head__av { width: 168px; height: 168px; margin: 0 auto; justify-self: center; }
  .ig-head__dx { margin: 0; padding: 0; }
  .ig-avatar { padding: 14px; }
  .ig-head__nome { font-size: 20px; line-height: 25px; font-weight: 400; margin: 6px 0 22px; }
  .ig-stats { gap: 40px; margin-bottom: 18px; }
  .ig-stats li { flex-direction: row; gap: 5px; font-size: 16px; }
  .ig-bio { padding: 0 0 20px; }
  .ig-azioni { padding: 0; max-width: 420px; }
  .ig-hl { gap: 52px; padding: 0 0 44px 40px; }
  .ig-hl__el { width: 87px; }
  .ig-hl__cerchio { width: 87px; height: 87px; padding: 3px; }
  .ig-hl__nome { font-size: 12px; font-weight: 600; }
  .ig-tab { box-shadow: none; }
  .ig-tab.is-on { box-shadow: inset 0 1px 0 var(--fg); }
  .ig-griglia { gap: 4px; }
}

/* ══ visori: post e storie ═══════════════════════════════════════════════ */
body.ig-aperto { overflow: hidden; }

/* elenco dei post, come quando se ne tocca uno nel profilo */
.ig-feed { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto; overscroll-behavior: contain; }
.ig-feed__top {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 16px;
  padding-top: env(safe-area-inset-top); background: var(--bg); border-bottom: 1px solid var(--linea);
}
.ig-feed__top button { display: flex; width: 28px; height: 28px; align-items: center; justify-content: center; margin-left: -6px; }
.ig-feed__top svg { width: 24px; height: 24px; }
.ig-feed__top b { flex: 1; text-align: center; font-size: 16px; margin-right: 22px; }
.ig-feed__lista { max-width: 470px; margin: 0 auto; padding-bottom: env(safe-area-inset-bottom); }

.ig-post { border-bottom: 1px solid var(--linea); padding-bottom: 12px; scroll-margin-top: 44px; }
.ig-post__head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.ig-post__av { width: 32px; height: 32px; border-radius: 50%; padding: 2px; background: var(--anello); flex: 0 0 auto; }
.ig-post__av img, .ig-post__av span { width: 100%; height: 100%; border-radius: 50%; border: 2px solid var(--bg); object-fit: contain; background: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #262626; }
.ig-post__chi { min-width: 0; line-height: 16px; }
.ig-post__chi b { display: block; font-weight: 600; }
.ig-post__chi span { display: block; font-size: 12px; color: var(--fg2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ig-post__img { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; background: var(--tasto); }
.ig-post__az { display: flex; gap: 14px; padding: 8px 12px 4px; }
.ig-post__az button { display: flex; }
.ig-post__az svg { width: 24px; height: 24px; }
.ig-post__az [data-fav].is-on svg { fill: #ff3040; stroke: #ff3040; }
.ig-post__az [data-fav].is-pop svg { animation: ig-pop .35s ease; }
@keyframes ig-pop { 40% { transform: scale(1.25); } }
.ig-post__prezzo { padding: 0 12px; font-weight: 600; }
.ig-post__cap { padding: 4px 12px 0; overflow-wrap: anywhere; }
.ig-post__cap b { font-weight: 600; margin-right: 4px; }

/* storie a tutto schermo */
.ig-storia { position: fixed; inset: 0; z-index: 60; background: #1a1a1a; display: grid; place-items: center; touch-action: none; user-select: none; -webkit-user-select: none; }
.ig-storia__box { position: relative; width: 100%; height: 100%; overflow: hidden; background: #000; color: #fff; }
@media (min-width: 736px) { .ig-storia__box { width: auto; height: 92vh; aspect-ratio: 9 / 16; border-radius: 10px; } }
.ig-storia__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ig-storia__barre { position: absolute; top: calc(8px + env(safe-area-inset-top)); left: 8px; right: 8px; z-index: 3; display: flex; gap: 3px; }
.ig-storia__barre i { flex: 1; height: 2px; border-radius: 2px; background: rgba(255, 255, 255, .35); overflow: hidden; }
.ig-storia__barre i b { display: block; height: 100%; width: 0; background: #fff; }
.ig-storia__barre i.is-fatto b { width: 100%; }
.ig-storia__head {
  position: absolute; top: calc(18px + env(safe-area-inset-top)); left: 12px; right: 8px; z-index: 3;
  display: flex; align-items: center; gap: 8px; text-shadow: 0 1px 2px rgba(0, 0, 0, .4);
}
.ig-storia__head img, .ig-storia__head .ig-sigla { width: 32px; height: 32px; border-radius: 50%; object-fit: contain; background: #fff; flex: 0 0 auto; display: grid; place-items: center; color: #262626; font-weight: 700; }
.ig-storia__head b { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ig-storia__head button { width: 36px; height: 36px; display: grid; place-items: center; color: #fff; }
.ig-storia__head svg { width: 26px; height: 26px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .4)); }
.ig-storia__ombra { position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,.45), transparent 18%, transparent 55%, rgba(0,0,0,.75)); }
.ig-storia__testo { position: absolute; left: 18px; right: 18px; bottom: calc(26px + env(safe-area-inset-bottom)); z-index: 2; }
.ig-storia__desc { margin: 0 0 8px; font-size: 14px; line-height: 19px; opacity: .92; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.ig-storia__riga { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.ig-storia__nome { margin: 0; font-size: 22px; line-height: 26px; font-weight: 700; }
.ig-storia__prezzo {
  flex: 0 0 auto; font-weight: 700; font-size: 15px; padding: 5px 11px; border-radius: 999px;
  background: rgba(255, 255, 255, .92); color: #000;
}
.ig-storia__tap { position: absolute; top: 70px; bottom: 0; z-index: 2; width: 34%; }
.ig-storia__tap--sx { left: 0; }
.ig-storia__tap--dx { right: 0; width: 66%; }
