/* Landing feed Instagram — griglia 3:4 come il profilo Instagram */

:root {
  --gap: 2px;
  --bg: #fff;
  --fg: #262626;
  --muted: #737373;
  --tile-bg: #efefef;
  --accent: #0095f6;
  --accent-hover: #1877f2;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (min-width: 736px) {
  :root { --gap: 4px; }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Colonna centrale con margini bianchi ---------- */

.hero,
main {
  width: 100%;
  max-width: calc(var(--col) + 2 * var(--side));
  margin-inline: auto;
  padding-inline: var(--side);
}
:root { --side: 12px; --col: 1200px; }   /* --col = larghezza massima della griglia */
@media (min-width: 736px) { :root { --side: 32px; } }
@media (min-width: 1280px) { :root { --side: 48px; } }

/* ---------- Titolo ---------- */
/* Grottesco "bastone" come i testi nelle immagini del feed (Helvetica/Arial): font di sistema,
   nessuna richiesta a servizi esterni. */

.hero {
  padding-top: 28px;
  padding-bottom: 20px;
  font-family: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", sans-serif;
  color: #000;
}
.hero-title {
  margin: 0;
  font-size: clamp(30px, 6vw, 64px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  text-transform: lowercase;
  overflow-wrap: anywhere; /* su schermi molto stretti va a capo invece di uscire dalla colonna */
}
.hero-copy {
  margin: .5em 0 0;
  font-size: clamp(15px, 1.8vw, 20px);
  font-weight: 400;
  line-height: 1.2;
}
@media (min-width: 736px) {
  .hero { padding-top: 48px; padding-bottom: 32px; }
}

/* ---------- Griglia ---------- */

.ig-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}

.tile {
  position: relative;
  display: block;
  aspect-ratio: var(--tile-ratio, 3 / 4); /* impostato da index.php in base a GRID_RATIO */
  overflow: hidden;
  background: var(--tile-bg);
  color: #fff;
  text-decoration: none;
}
.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .3);
  opacity: 0;
  transition: opacity .15s ease;
}
.tile:hover::after { opacity: 1; }
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.tile:focus-visible::after { opacity: 1; }

.tile-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.tile-empty svg { width: 40px; height: 40px; fill: currentColor; }

.tile-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  width: 22px;
  height: 22px;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, .45));
}
.tile-icon svg { width: 100%; height: 100%; fill: #fff; }

@media (max-width: 735px) {
  .tile-icon { top: 5px; right: 5px; width: 16px; height: 16px; }
}

/* ---------- Carica altri / link ---------- */

.more, .follow, .pager, .notice {
  display: flex;
  justify-content: center;
  margin: 0;
  padding: 28px 16px;
  text-align: center;
}
.pager { padding: 16px; }
.more + .follow { padding-top: 0; }

.more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 160px;
  padding: 9px 20px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transition: background-color .15s ease;
}
.more-btn:hover { background: var(--accent-hover); }
.more-btn:focus-visible { outline: 3px solid var(--fg); outline-offset: 2px; }
.more-btn.is-loading { pointer-events: none; opacity: .7; }
.more-btn.is-loading::after {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.follow a, .pager a, .notice a { color: var(--accent); font-weight: 600; text-decoration: none; }
.follow a:hover, .pager a:hover, .notice a:hover { text-decoration: underline; }

/* ---------- Overlay ---------- */

html.viewer-open { overflow: hidden; }

.viewer {
  /* box 4:5 (il formato verticale massimo di Instagram) che sta sempre nello schermo */
  --box-w: min(94vw, calc((100vh - 120px) * .8), 1080px);
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  overflow: hidden;
}
.viewer[open] {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
@supports (height: 100dvh) {
  .viewer { --box-w: min(94vw, calc((100dvh - 120px) * .8), 1080px); }
}
.viewer::backdrop { background: rgba(0, 0, 0, .86); }

.viewer-frame {
  position: relative;
  width: var(--box-w);
  aspect-ratio: 4 / 5;
  transform-origin: 0 0;
}
.viewer-track {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.viewer-track::-webkit-scrollbar { display: none; }

.viewer-item {
  position: relative;
  flex: 0 0 100%;
  height: 100%;
  margin: 0;
  scroll-snap-align: center;
  display: grid;
  place-items: center;
}
.viewer-item img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.viewer-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.viewer-play svg {
  width: 72px;
  height: 72px;
  fill: #fff;
  filter: drop-shadow(0 0 8px rgba(0, 0, 0, .5));
}

.viewer button {
  font: inherit;
  cursor: pointer;
  border: 0;
  color: #fff;
  background: none;
}
.viewer button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.viewer-slide {
  position: absolute;
  top: 50%;
  width: 30px;
  height: 30px;
  margin-top: -15px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .85) !important;
  color: #262626 !important;
  font-size: 22px;
  line-height: 28px;
  box-shadow: 0 0 4px rgba(0, 0, 0, .3);
}
.viewer-slide--prev { left: 10px; }
.viewer-slide--next { right: 10px; }
.viewer-slide[hidden] { display: none; }

.viewer-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  display: flex;
  justify-content: center;
  gap: 4px;
  pointer-events: none;
}
.viewer-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .45);
  transition: background-color .15s ease;
}
.viewer-dots span.is-active { background: #fff; }

.viewer-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  width: var(--box-w);
  font-size: 14px;
}
.viewer-date { color: rgba(255, 255, 255, .85); }
.viewer-link { margin-left: auto; color: #fff; font-weight: 600; text-decoration: none; }
.viewer-link:hover { text-decoration: underline; }

.viewer-close {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 44px;
  height: 44px;
  font-size: 36px;
  line-height: 1;
}
.viewer-nav {
  position: absolute;
  top: 50%;
  width: 44px;
  height: 64px;
  margin-top: -32px;
  font-size: 44px;
  line-height: 1;
  opacity: .85;
}
.viewer-nav:hover { opacity: 1; }
.viewer-nav--prev { left: 4px; }
.viewer-nav--next { right: 4px; }
.viewer-nav[disabled] { opacity: .2; cursor: default; }

@media (max-width: 735px) {
  .viewer-nav { width: 32px; font-size: 34px; text-shadow: 0 0 6px rgba(0, 0, 0, .6); }
  .viewer-bar { padding: 0 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .tile::after, .more-btn, .viewer-dots span { transition: none; }
}
