/* ═══════════════════════════════════════════════════════════════
   PIACQUE A DIO — App Styles
   Reset + Layout base
   ═══════════════════════════════════════════════════════════════ */

/* ─── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  min-height: 100%;
  font-family: var(--font-sans);
  background: var(--col-bg);
  color: var(--col-ivory);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;    /* l'overflow è gestito dentro .screen */
}
button { font-family: inherit; cursor: pointer; border: none; background: transparent; }
input, textarea { font-family: inherit; }
img { display: block; max-width: 100%; }
::-webkit-scrollbar { width: 0; height: 0; }

/* ─── App container ──────────────────────────────────────────── */
#app {
  width: 100vw;
  height: 100vh;
  height: 100dvh;           /* dynamic viewport height */
  position: relative;
  overflow: hidden;
  background: var(--col-bg);
}

/* ─── Loading screen (prima che JS carichi) ──────────────────── */
.loading-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--col-bg);
}
.loading-icon {
  width: 80px;
  height: auto;
  opacity: 0.6;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.95); }
  50%       { opacity: 0.8; transform: scale(1.05); }
}

/* ─── Splash screen ──────────────────────────────────────────── */
.splash {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 80% 60% at 50% 45%,
    var(--col-bg-soft) 0%, #120E09 35%, var(--col-bg) 65%, #050403 100%);
  padding: 60px 32px;
  overflow: hidden;
}
/* tessere ambient */
.splash::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.05;
  pointer-events: none;
  background-image: var(--mosaic-fine);
}
.splash-icon {
  width: 220px;
  max-width: 60vw;
  height: auto;
  filter: drop-shadow(0 0 30px rgba(194,139,44,0.5));
  animation: iconRise 1.2s ease-out both;
}
.splash-title {
  text-align: center;
  margin-top: 28px;
  animation: titleRise 1.2s ease-out 0.4s both;
}
.splash-title h1 {
  font-family: var(--font-serif);
  color: var(--col-cream);
  font-size: clamp(32px, 8vw, 44px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.5px;
}
.splash-title h1 em {
  color: var(--col-gold-hi);
  font-weight: 400;
}
.splash-subtitle {
  font-family: var(--font-sans);
  color: var(--col-gold-dim);
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  margin-top: 12px;
  font-weight: 500;
}
@keyframes iconRise {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes titleRise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.splash.fade-out {
  animation: splashFade 0.7s ease-in forwards;
}
@keyframes splashFade {
  to { opacity: 0; pointer-events: none; }
}

/* ─── Layout principale post-splash ─────────────────────────── */
.app-main {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.app-main.visible { opacity: 1; }

/* ─── Schermate ──────────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  bottom: var(--tabbar-height);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  display: none;
  background: var(--gradient-alba);
  background-attachment: local;
  /* Fade in contemplativo — gestito da JS, CSS come fallback */
  will-change: opacity;
}
.screen.active { display: block; }

/* Micro-animazione di ingresso per la schermata attiva */
@keyframes screenFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.screen.active.fade-enter {
  animation: screenFadeIn 0.2s ease forwards;
}

/* ─── Header schermate ───────────────────────────────────────── */
.screen-header {
  position: relative;
  padding: max(env(safe-area-inset-top, 0px), 48px) 20px 20px;
}
.screen-header::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 120% 80% at 50% 110%,
    rgba(232,184,76,0.12) 0%, rgba(194,139,44,0.08) 22%, transparent 55%);
}
.screen-kicker {
  font-family: var(--font-sans);
  color: var(--col-gold);
  font-size: 10.5px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 12px;
  position: relative;
}
.screen-title {
  font-family: var(--font-serif);
  color: var(--col-cream);
  font-size: clamp(34px, 9vw, 42px);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.4px;
  position: relative;
}
.screen-title em {
  color: var(--col-gold-hi);
  font-weight: 400;
}

/* ─── Card base ──────────────────────────────────────────────── */
.card {
  background: linear-gradient(145deg, var(--col-card) 0%, var(--col-bg-soft) 100%);
  border: 1px solid var(--col-border);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
}
/* pattern mosaicale su card */
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.045;
  pointer-events: none;
  background-image: var(--mosaic-fine);
  border-radius: inherit;
}
.card-content { position: relative; }

/* ─── Tab bar ────────────────────────────────────────────────── */
.tabbar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: calc(var(--tabbar-height) + var(--safe-bottom));
  padding-bottom: calc(var(--space-lg) + var(--safe-bottom));
  padding-top: 10px;
  padding-left: 8px;
  padding-right: 8px;
  background: linear-gradient(180deg, transparent 0%, rgba(10,8,6,0.95) 35%, var(--col-bg) 100%);
  border-top: 1px solid var(--col-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  color: var(--col-muted);
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.tab-btn.active { color: var(--col-gold-hi); }
.tab-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 22px;
}
.tab-icon-glow {
  display: none;
  position: absolute;
  inset: -3px;
  border-radius: 12px;
  background: radial-gradient(circle, rgba(194,139,44,0.3) 0%, transparent 70%);
  filter: blur(4px);
}
.tab-btn.active .tab-icon-glow { display: block; }
.tab-label {
  font-family: var(--font-sans);
  font-size: 9.5px;
  font-weight: 400;
  letter-spacing: 0.04em;
}
.tab-btn.active .tab-label { font-weight: 600; }

/* ─── Mini player ────────────────────────────────────────────── */
.mini-player {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(var(--tabbar-height) + var(--safe-bottom) + 6px);
  z-index: 45;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: linear-gradient(120deg, #3A2A1F 0%, var(--col-card-hi) 100%);
  border: 1px solid rgba(194,139,44,0.4);
  box-shadow: 0 10px 30px rgba(0,0,0,0.65), 0 0 28px rgba(194,139,44,0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateY(0);
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.mini-player.hidden {
  transform: translateY(120%);
  opacity: 0;
  pointer-events: none;
}
.mini-player-thumb {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
  background: radial-gradient(circle at 28% 28%,
    var(--col-gold-hi) 0%, var(--col-gold) 50%, var(--col-gold-dim) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(232,184,76,0.5);
  position: relative;
  overflow: hidden;
}
.mini-player-thumb::before {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 8px;
  opacity: 0.35;
  background-image: repeating-linear-gradient(30deg, rgba(0,0,0,0.13) 0 1px, transparent 1px 5px),
                    repeating-linear-gradient(-30deg, rgba(0,0,0,0.13) 0 1px, transparent 1px 5px);
}
.mini-player-letter {
  font-family: var(--font-serif);
  color: #2A1E0E;
  font-size: 22px;
  font-style: italic;
  font-weight: 600;
  line-height: 1;
  position: relative;
}
.mini-player-info { flex: 1; min-width: 0; }
.mini-player-title {
  font-family: var(--font-serif);
  color: var(--col-cream);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-player-title em { color: var(--col-gold-hi); }
.mini-player-progress {
  position: relative;
  margin-top: 6px;
  height: 2px;
  border-radius: 2px;
  background: rgba(0,0,0,0.4);
}
.mini-player-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--col-gold), var(--col-gold-hi));
  box-shadow: 0 0 8px rgba(194,139,44,0.5);
  transition: width 0.2s linear;
}
.mini-player-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--col-gold-hi);
  box-shadow: 0 0 8px var(--col-gold-hi);
}
.mini-player-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
  background: radial-gradient(circle at 30% 30%, var(--col-gold-hi), var(--col-gold));
  box-shadow: 0 0 18px rgba(194,139,44,0.4), inset 0 0 0 1px var(--col-gold-hi);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── Capolettera miniato (thumbnail canti) ──────────────────── */
.capolettera {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  flex-shrink: 0;
  background: radial-gradient(circle at 28% 28%,
    var(--col-gold-hi) 0%, var(--col-gold) 45%, var(--col-gold-dim) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(232,184,76,0.5), 0 3px 12px rgba(194,139,44,0.2);
  position: relative;
  overflow: hidden;
}
.capolettera::before {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 10px;
  opacity: 0.35;
  background-image: repeating-linear-gradient(30deg, rgba(0,0,0,0.13) 0 1px, transparent 1px 5px),
                    repeating-linear-gradient(-30deg, rgba(0,0,0,0.13) 0 1px, transparent 1px 5px);
}
.capolettera-letter {
  font-family: var(--font-serif);
  color: #2A1E0E;
  font-size: 32px;
  font-style: italic;
  font-weight: 600;
  line-height: 1;
  position: relative;
}

/* ─── Play button dorato ─────────────────────────────────────── */
.btn-play {
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--col-gold-hi), var(--col-gold));
  box-shadow: var(--glow-gold), inset 0 0 0 1px var(--col-gold-hi);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn-play:active { transform: scale(0.93); }

/* ─── Pill filtri ────────────────────────────────────────────── */
.pill {
  padding: 7px 14px;
  border-radius: 100px;
  white-space: nowrap;
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: 0.05em;
  border: 1px solid var(--col-border);
  color: var(--col-muted);
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.pill.active {
  background: linear-gradient(135deg, var(--col-gold-hi), var(--col-gold));
  border-color: var(--col-gold-hi);
  color: #2A1E0E;
  font-weight: 600;
  box-shadow: 0 0 16px rgba(194,139,44,0.4);
}

/* ─── Equalizer animato ──────────────────────────────────────── */
@keyframes eq1 { 0%,100%{height:30%} 50%{height:90%} }
@keyframes eq2 { 0%,100%{height:80%} 50%{height:20%} }
@keyframes eq3 { 0%,100%{height:50%} 50%{height:100%} }
.equalizer {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}
.eq-bar {
  width: 2.5px;
  background: var(--col-gold-hi);
  border-radius: 1px;
}
.eq-bar:nth-child(1) { animation: eq1 0.9s ease-in-out infinite; }
.eq-bar:nth-child(2) { animation: eq2 0.9s ease-in-out infinite 0.15s; }
.eq-bar:nth-child(3) { animation: eq3 0.9s ease-in-out infinite 0.3s; }

/* ─── Medaglione ciclo ───────────────────────────────────────── */
.medaglione {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--col-gold-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.medaglione::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.28;
  background-image: repeating-linear-gradient(30deg, rgba(0,0,0,0.3) 0 1px, transparent 1px 5px),
                    repeating-linear-gradient(-30deg, rgba(0,0,0,0.3) 0 1px, transparent 1px 5px);
}

/* ─── Overlay modale (La Nostra Icona) ───────────────────────── */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 80;
  background: var(--col-bg);
  overflow-y: auto;
  transform: scale(0.96);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.35s ease;
  pointer-events: none;
}
.overlay.open {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* ─── Rivelazione progressiva Ciclo III ──────────────────────── */
@keyframes rivelazioneFadeIn {
  0%   { opacity: 0; transform: translateY(8px) scale(0.98); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes haloBreathe {
  0%,100% { box-shadow: 0 0 0 1px rgba(232,184,76,0.35), 0 0 40px rgba(194,139,44,0.35), 0 0 90px rgba(61,107,74,0.25); }
  50%     { box-shadow: 0 0 0 1px rgba(232,184,76,0.55), 0 0 55px rgba(194,139,44,0.55), 0 0 110px rgba(61,107,74,0.35); }
}
.rivelazione-container {
  animation: rivelazioneFadeIn 1.6s ease-out both;
}
.rivelazione-img {
  border-radius: var(--radius-lg);
  width: 100%;
  height: auto;
  animation: haloBreathe 5s ease-in-out infinite;
}

/* ─── Utility ────────────────────────────────────────────────── */
.flex       { display: flex; }
.flex-col   { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.mx-auto { margin-left: auto; margin-right: auto; }
.px-md { padding-left: 20px; padding-right: 20px; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uppercase { text-transform: uppercase; letter-spacing: 0.22em; }
.gold-label {
  font-family: var(--font-sans);
  color: var(--col-gold);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  font-weight: 600;
}
.serif-quote {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  line-height: 1.4;
}
