/* Home del totem: logo, pulsanti, widget ATAC in basso (mai sovrapposti) */
html, body { height: 100%; }

body.home {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #c9d3df url(../img/bg.jpg) center / cover no-repeat;
  font-family: var(--k-font-condensed);
}

.home__main {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 4dvh, 80px);
  padding: max(clamp(16px, 4dvh, 80px), env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) clamp(16px, 3dvh, 48px) max(16px, env(safe-area-inset-left));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.home__logo {
  display: block;
  flex: none;
  width: min(560px, 72vw);
  height: auto;
  max-height: 14dvh;
  object-fit: contain;
  pointer-events: none;
}

.home__nav { width: 100%; max-width: 980px; flex: none; }

.home__tiles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: clamp(16px, 3vw, 40px);
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2dvh, 24px);
  min-height: 160px;
  height: 100%;
  padding: clamp(16px, 3dvh, 40px) 20px;
  border-radius: var(--k-radius);
  background: rgba(255, 255, 255, 0.72);
  color: var(--k-text);
  text-decoration: none;
  text-align: center;
  box-shadow: 10px 11px 23px 1px rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: transform 80ms ease, background-color 80ms ease, box-shadow 80ms ease;
}

.tile__icon {
  display: block;
  width: clamp(88px, 15vw, 180px);
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  pointer-events: none;
}

.tile__label {
  font-size: clamp(26px, 3.6vw, 42px);
  font-weight: 600;
  line-height: 1.05;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}

.tile:active,
.tile.is-pressed {
  transform: scale(0.97);
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 3px 4px 10px rgba(0, 0, 0, 0.4);
}

.tile:focus { outline: none; }
.tile:focus-visible { outline: 4px solid var(--k-brand); outline-offset: 4px; }

@media (hover: hover) {
  .tile:hover { background: rgba(255, 255, 255, 0.88); }
}

/* Su schermi stretti: icona a sinistra, testo a destra */
@media (max-width: 599px) {
  .tile { flex-direction: row; justify-content: flex-start; gap: 20px; padding: 16px 24px; text-align: left; }
  .tile__icon { width: 112px; }
}

.home__empty {
  margin: 0;
  padding: 24px;
  border-radius: var(--k-radius);
  background: rgba(255, 255, 255, 0.8);
  font-size: 32px;
  text-align: center;
}

/* Regione widget ATAC: altezza propria, la zona pulsanti usa solo lo spazio restante */
.home__atac {
  flex: 0 0 auto;
  height: clamp(min(460px, 30dvh), 38dvh, 900px);
  padding-bottom: env(safe-area-inset-bottom);
  overflow: hidden;
}

.home__atac-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

@media (orientation: landscape) and (min-width: 900px) {
  body.home { flex-direction: row; }
  .home__atac { height: auto; width: clamp(420px, 40vw, 760px); }
}

/* Overlay ATAC a schermo intero (QR app e mappa della fermata) */
.home-dlg {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: max(16px, 2vmin);
  border: 0;
  background: transparent;
  color: var(--k-text);
  font-family: var(--k-font-condensed);
  overflow: hidden;
}

.home-dlg::backdrop { background: rgba(20, 2, 8, 0.78); }

.home-dlg[open] { display: flex; align-items: center; justify-content: center; }

.home-dlg__box {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  padding: clamp(20px, 3vmin, 48px);
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.home-dlg__close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: max(var(--k-tap), 80px);
  height: max(var(--k-tap), 80px);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--k-atac);
  color: #fff;
  font: 700 56px/1 var(--k-font-ui);
  cursor: pointer;
  box-shadow: var(--k-shadow);
}

.home-dlg__close:active { background: var(--k-atac-dark); }
/* showModal() mette il focus sulla X: nessun anello su un totem solo touch */
.home-dlg__close:focus { outline: none; }

.home-dlg__title {
  margin: 0 96px 0.3em;
  color: var(--k-atac);
  font-size: clamp(36px, 6vmin, 84px);
  font-weight: 700;
  line-height: 1.05;
}

.home-dlg__text {
  margin: 0 0 0.5em;
  font-size: clamp(22px, 3.4vmin, 44px);
  line-height: 1.25;
}

.home-dlg__hint {
  margin: 0.5em 0 0;
  color: #6b6b6b;
  font-size: clamp(18px, 2.4vmin, 30px);
}

.home-dlg--qr .home-dlg__box {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(100%, 1000px);
}

.home-dlg--qr .home-dlg__text { margin-inline: 88px; }

.home-dlg__qr {
  display: block;
  width: min(84vw, 100dvh - 420px, 860px);
  min-width: 200px;
  height: auto;
  aspect-ratio: 1;
  pointer-events: none;
}

/* Mappa: testo sopra, area con pan/zoom (pinch, doppio tocco) */
.home-dlg--map .home-dlg__box {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  height: 100%;
  text-align: left;
}

.home-dlg--map .home-dlg__side { flex: none; padding-right: 96px; }
.home-dlg--map .home-dlg__title { margin: 0 0 0.25em; }

.home-dlg__viewport {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 16px;
  background: #f4f4f4;
  touch-action: none;
  cursor: grab;
}

.home-dlg__map {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  transform-origin: 0 0;
  pointer-events: none;
  user-select: none;
}

@media (orientation: landscape) and (min-width: 900px) {
  .home-dlg--map .home-dlg__box { flex-direction: row; }
  .home-dlg--map .home-dlg__side { flex: 0 0 34%; display: flex; flex-direction: column; justify-content: center; padding-right: 0; }
  .home-dlg--map .home-dlg__viewport { margin-top: 96px; }
}

@media (prefers-reduced-motion: reduce) {
  .tile { transition: none; }
}
