/* ==========================================================================
   La Zia Acida — Portale Sarcasmo Aziendale
   Custom Pulp Satire & Preserved Screensaver Styles
   ========================================================================== */

html {
  scroll-padding-top: 100px;
}

/* Halftone Pattern utilities */
.halftone-bg {
  background-image: radial-gradient(#1c1c17 20%, transparent 20%), radial-gradient(#1c1c17 20%, transparent 20%);
  background-color: #e5c662;
  background-position: 0 0, 4px 4px;
  background-size: 8px 8px;
  background-repeat: repeat;
}
.halftone-bg-red {
  background-image: radial-gradient(#1c1c17 20%, transparent 20%), radial-gradient(#1c1c17 20%, transparent 20%);
  background-color: #9e4128;
  background-position: 0 0, 4px 4px;
  background-size: 8px 8px;
  background-repeat: repeat;
}
.halftone-bg-white {
  background-image: radial-gradient(#1c1c17 15%, transparent 15%), radial-gradient(#1c1c17 15%, transparent 15%);
  background-color: #f7f4eb;
  background-position: 0 0, 4px 4px;
  background-size: 8px 8px;
  background-repeat: repeat;
}

/* Brutalist Shadows */
.brutal-shadow {
  box-shadow: 4px 4px 0px 0px rgba(28, 28, 23, 1);
}
.brutal-shadow-hover {
  transition: transform 0.2s, box-shadow 0.2s;
}
.brutal-shadow-hover:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0px 0px rgba(28, 28, 23, 1);
}

/* Paper texture overlay */
.paper-texture {
  position: relative;
}
.paper-texture::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  opacity: 0.04;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  z-index: 100;
}

body {
  min-height: max(884px, 100dvh);
}

/* 3D Flipping Book Layout (Preserved and styled) */
.book-cover-wrapper {
  position: relative;
  perspective: 1000px;
  width: 280px;
  height: 390px;
}

.book-card-3d {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
  cursor: pointer;
  box-shadow: 6px 6px 0px 0px rgba(28, 28, 23, 1);
  border: 3px solid #1c1c17;
}

.book-cover-wrapper:hover .book-card-3d,
.book-card-3d.flipped {
  transform: rotateY(-180deg);
}

.book-card-3d-front,
.book-card-3d-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  top: 0;
  left: 0;
}

.book-card-3d-front {
  background: #e5c662;
}

.book-card-3d-back {
  background: #9e4128;
  transform: rotateY(180deg);
}

.book-card-3d-front img,
.book-card-3d-back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.book-hint {
  text-align: center;
  margin-top: 16px;
  color: #9e4128;
  font-family: 'Anton', sans-serif;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  cursor: pointer;
}

/* WhatsApp custom dynamic styles inside chat simulator */
.msg-bubble {
  margin-bottom: 12px;
  padding: 7px 16px;
  font-size: 0.85rem;
  border: 2px solid #1c1c17;
  max-width: 85%;
  position: relative;
  box-shadow: 2px 2px 0px 0px rgba(28, 28, 23, 1);
}
.msg-received {
  background-color: #fcf9f0;
  align-self: flex-start;
  margin-right: auto;
}
.msg-sent {
  background-color: #ebe8df;
  align-self: flex-end;
  margin-left: auto;
  text-align: right;
}
.msg-zia-translation {
  background-color: #e5c662;
  border: 3px solid #1c1c17;
  box-shadow: 4px 4px 0px 0px rgba(28, 28, 23, 1);
  align-self: flex-end;
  margin-left: auto;
  width: 85%;
  margin-top: 6px;
}
.msg-zia-translation::before {
  content: "ZIA ACIDA TRANSLATION";
  display: block;
  font-family: 'Anton', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  background: #1c1c17;
  color: #e5c662;
  padding: 2px 8px;
  border: 1px solid #1c1c17;
  position: absolute;
  top: -12px;
  left: 8px;
}
.msg-meta {
  display: block;
  font-size: 0.65rem;
  color: #7e7665;
  margin-top: 4px;
}

/* Active WhatsApp contact tab and transitions */
.contact-tab {
  border-left: 6px solid transparent;
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.contact-tab:hover:not(.active) {
  background-color: #ebe8df !important; /* surface-container-high */
  border-left: 6px solid #9e4128 !important; /* brick red left border */
}
.contact-tab.active {
  background-color: #e5c662 !important; /* primary-container yellow */
  border-left: 6px solid #1c1c17 !important; /* dark border */
}

/* Sarcasm card dynamic snap tilt animation */
#frase-card {
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
#frase-card.flip {
  transform: scale(0.96) rotate(-2deg);
  box-shadow: 2px 2px 0px 0px rgba(28, 28, 23, 1);
}

/* ===== QUIZ SYSTEM BRUTALIST STYLING ===== */
.quiz-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.quiz-progress-bar {
  flex: 1;
  height: 20px;
  border: 3px solid #1c1c17;
  background-color: #fcf9f0;
  position: relative;
  overflow: hidden;
}
.quiz-progress-fill {
  height: 100%;
  background-color: #9e4128; /* brick red */
  background-image: radial-gradient(#1c1c17 20%, transparent 20%), radial-gradient(#1c1c17 20%, transparent 20%);
  background-position: 0 0, 3px 3px;
  background-size: 6px 6px;
  background-repeat: repeat;
  border-right: 3px solid #1c1c17;
  transition: width 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.quiz-progress-text {
  font-family: 'Anton', sans-serif;
  font-size: 1rem;
  color: #1c1c17;
}
.quiz-domanda-testo {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.4;
  margin-top: 8px;
  margin-bottom: 20px;
  color: #1c1c17;
  border-left: 4px solid #9e4128;
  padding-left: 12px;
}
.quiz-risposte {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.quiz-risposta {
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border: 3px solid #1c1c17;
  background-color: #fcf9f0;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: #1c1c17;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: 2px 2px 0px 0px rgba(28, 28, 23, 1);
}
.quiz-risposta:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0px 0px rgba(28, 28, 23, 1);
  background-color: #ebe8df;
}
.quiz-risposta.selected {
  background-color: #e5c662 !important; /* mustard yellow */
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0px 0px rgba(28, 28, 23, 1);
}
.quiz-risposta-letter {
  width: 24px;
  height: 24px;
  border: 2px solid #1c1c17;
  background-color: #1c1c17;
  color: #fcf9f0;
  font-family: 'Anton', sans-serif;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}
.quiz-risposta.selected .quiz-risposta-letter {
  background-color: #9e4128;
  color: #ffffff;
}

/* Result Card */
.risultato-card {
  border: 3px solid #1c1c17;
  background-color: #fcf9f0;
  padding: 24px;
  box-shadow: 4px 4px 0px 0px rgba(28, 28, 23, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.risultato-emoji {
  font-size: 3.5rem;
  margin-bottom: 12px;
  filter: drop-shadow(2px 2px 0px #1c1c17);
  animation: popEmoji 0.6s cubic-bezier(0.25, 0.8, 0.25, 1.25) forwards;
}
@keyframes popEmoji {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}
.risultato-titolo {
  font-family: 'Anton', sans-serif;
  font-size: 1.5rem;
  text-transform: uppercase;
  color: #9e4128;
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}
.risultato-descrizione {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #4c4637;
  margin-bottom: 20px;
}
.risultato-frase {
  width: 100%;
  background-color: #ebe8df;
  border: 2px solid #1c1c17;
  padding: 16px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-style: italic;
  color: #1c1c17;
  margin-bottom: 24px;
  position: relative;
  box-shadow: 2px 2px 0px 0px rgba(28, 28, 23, 1);
}
.risultato-frase::before {
  content: "RISPOSTA TIPICA DELLA ZIA";
  position: absolute;
  top: -10px;
  left: 10px;
  font-family: 'Anton', sans-serif;
  font-size: 0.65rem;
  background-color: #1c1c17;
  color: #e5c662;
  padding: 2px 8px;
  letter-spacing: 0.05em;
}
.risultato-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
.risultato-actions .btn {
  width: 100%;
  padding: 12px;
  border: 3px solid #1c1c17;
  font-family: 'Anton', sans-serif;
  text-transform: uppercase;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  box-shadow: 3px 3px 0px 0px rgba(28, 28, 23, 1);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.risultato-actions .btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0px 0px rgba(28, 28, 23, 1);
}
.risultato-actions .btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px 0px rgba(28, 28, 23, 1);
}
.risultato-actions .btn-primary {
  background-color: #9e4128;
  color: #ffffff;
}
.risultato-actions .btn-primary:hover {
  background-color: #7f2a14;
}
.risultato-actions .btn-outline {
  background-color: #e5c662;
  color: #1c1c17;
}
.risultato-actions .btn-outline:hover {
  background-color: #ffe081;
}
.risultato-actions .btn-dark {
  background-color: #1c1c17;
  color: #fcf9f0;
}
.risultato-actions .btn-dark:hover {
  background-color: #31312b;
}

/* ===== SCREENSAVER MODE (Preserved EXACT Dark & Typewriter experience) ===== */
.screensaver-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: radial-gradient(circle, #181819 10%, #0d0d0e 90%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  transition: opacity 0.5s ease, visibility 0.5s ease;
  cursor: default;
}

.screensaver-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.btn-close-screensaver {
  position: absolute;
  top: 30px;
  right: 30px;
  width: 52px;
  height: 52px;
  background: #e5c662; /* Mustard Yellow */
  border: 3px solid #1c1c17; /* Spesso bordo nero brutalista */
  border-radius: 50%;
  color: #ba1a1a; /* Rosso vibrante per contrasto elevato */
  font-size: 2rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
  z-index: 10001;
  box-shadow: 3px 3px 0px #1c1c17; /* Ombra piatta */
}

.btn-close-screensaver:hover {
  background: #ffe081; /* Giallo chiaro */
  color: #93000a; /* Rosso scuro */
  transform: scale(1.1) rotate(90deg);
  box-shadow: 4px 4px 0px #1c1c17;
}

.screensaver-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.typewriter-container {
  text-align: center;
  line-height: 1.5;
  width: 100%;
}

#screensaver-text {
  font-family: 'Courier Prime', Courier, monospace;
  font-size: clamp(1.8rem, 4.2vw, 2.8rem);
  font-weight: 700;
  color: #ebdcb2; /* Parchment glow */
  text-shadow: 0 0 10px rgba(235, 220, 178, 0.12);
  word-wrap: break-word;
  white-space: pre-wrap;
}

.typewriter-cursor {
  font-family: 'Courier Prime', Courier, monospace;
  font-size: clamp(1.8rem, 4.2vw, 2.8rem);
  color: #9e4128;
  font-weight: 700;
  margin-left: 4px;
  animation: blinkCursor 0.8s steps(2, start) infinite;
}

@keyframes blinkCursor {
  to { opacity: 0; }
}

/* Screensaver branding and animations */
.screensaver-logo {
  position: absolute;
  bottom: 30px;
  right: 35px;
  width: clamp(90px, 12vw, 130px);
  height: auto;
  opacity: 0.45;
  z-index: 10001;
  pointer-events: none;
}

#screensaver-text.fly-away {
  display: inline-block;
  animation: flyAwayText 0.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes flyAwayText {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    opacity: 1;
    filter: blur(0px);
  }
  20% {
    transform: translate(-10px, 8px) scale(0.98) rotate(-1deg);
    opacity: 0.95;
    filter: blur(0px);
  }
  100% {
    transform: translate(400px, -200px) scale(0.5) rotate(10deg);
    opacity: 0;
    filter: blur(6px);
  }
}

.screensaver-action-container {
  margin-top: 32px;
  display: flex;
  justify-content: center;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  pointer-events: none;
}

.screensaver-action-container.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#btn-screensaver-share {
  background-color: #9e4128;
  border-color: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

#btn-screensaver-share:hover {
  background-color: #7f2a14;
  transform: translateY(-1px);
}

#btn-screensaver-share:active {
  transform: translateY(1px);
}

/* Hero section top margin adjustment */
#hero {
  margin-top: 20px !important;
}

/* Chat messages background size */
#chat-messages-container {
  background-size: 12px 12px;
}

/* Hide backdrop by default on desktop */
.chat-backdrop {
  display: none;
}

/* Mobile Chat Drawer styles */
@media (max-width: 767px) {
  .chat-sidebar-drawer {
    position: absolute;
    top: 0;
    left: 0;
    width: 290px;
    height: 100%;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    background-color: #ffffff;
    border-right: 3px solid #1c1c17;
    box-shadow: 6px 0px 0px 0px #1c1c17;
    display: flex;
    flex-direction: column;
  }
  
  .chat-sidebar-drawer.open {
    transform: translateX(0);
  }
  
  .chat-backdrop {
    display: block;
    position: absolute;
    inset: 0;
    background-color: rgba(28, 28, 23, 0.6);
    z-index: 30;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  
  .chat-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Retro Brutalist vibration loop - repeats every 4s, shakes for a full 2s (50% to 100%) */
@keyframes brutal-vibrate {
  0%, 50%, 100% {
    transform: translate(0, 0) rotate(0deg);
  }
  53% {
    transform: translate(-2px, 1px) rotate(-1deg);
  }
  57% {
    transform: translate(1px, -2px) rotate(1.5deg);
  }
  61% {
    transform: translate(-1px, 2px) rotate(-0.5deg);
  }
  65% {
    transform: translate(2px, -1px) rotate(1deg);
  }
  69% {
    transform: translate(-2px, 2px) rotate(-1.5deg);
  }
  73% {
    transform: translate(1px, -1px) rotate(1deg);
  }
  77% {
    transform: translate(-1px, -2px) rotate(-1deg);
  }
  81% {
    transform: translate(2px, 1px) rotate(1.5deg);
  }
  85% {
    transform: translate(-2px, -1px) rotate(-0.5deg);
  }
  89% {
    transform: translate(1px, 2px) rotate(1deg);
  }
  93% {
    transform: translate(-1px, -1px) rotate(-1.5deg);
  }
  97% {
    transform: translate(2px, -2px) rotate(1deg);
  }
}
.brutal-vibrate-loop {
  animation: brutal-vibrate 4s infinite ease-in-out;
}

/* Retro Brutalist slow floating buoyancy animation for floating buttons */
@keyframes brutal-float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}
.brutal-float {
  animation: brutal-float 3s infinite ease-in-out;
}
.brutal-float:hover {
  animation-play-state: paused;
}

/* WhatsApp Brand Color Button styling - Brutalist Theme */
.btn-whatsapp-style {
  background-color: #25d366 !important; /* WhatsApp Green */
  color: #ffffff !important;
  border-color: #1c1c17 !important; /* brutalist black border */
}
.btn-whatsapp-style:hover {
  background-color: #1ea852 !important; /* darker WhatsApp Green on hover */
}

/* Single-shot 2-second brutalist shake/vibration animation */
@keyframes shake-two-seconds {
  0%, 100% {
    transform: translate(0, 0) rotate(0deg);
  }
  5%, 15%, 25%, 35%, 45%, 55%, 65%, 75%, 85%, 95% {
    transform: translate(-3px, 2px) rotate(-1.5deg);
  }
  10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90% {
    transform: translate(3px, -2px) rotate(1.5deg);
  }
}
.shake-once-active {
  animation: shake-two-seconds 2s ease-in-out;
}

/* ==========================================================================
   OTTIMIZZAZIONI MOBILE SPECIALI (Solo per schermi < 768px)
   ========================================================================== */
@media (max-width: 767px) {
  
  /* 1. RIDUZIONE FONT E PADDING DEI PULSANTI (PULSANTI PIÙ COMPATTI) */
  button,
  .btn,
  a[class*="bg-tertiary"],
  a[class*="btn-"],
  a.brutal-shadow-hover {
    font-size: 0.8rem !important;   /* Riduce la dimensione del testo a circa 12.8px */
    padding-top: 8px !important;    /* Riduce l'altezza interna (padding verticale) */
    padding-bottom: 8px !important;
    padding-left: 12px !important;  /* Riduce la larghezza interna (padding orizzontale) */
    padding-right: 12px !important;
  }

  /* Mantieni il pulsante del menu hamburger mobile accessibile senza rimpicciolirlo */
  #mobile-menu-toggle {
    padding: 8px !important;
  }

  /* 2. RIDUZIONE PADDING DEI BOX DI TESTO (TESTO PIÙ VICINO AI BORDI) */
  
  /* Bolle della chat di WhatsApp (Spy Chat Simulator) */
  .msg-bubble {
    padding: 6px 10px !important; /* Riduce il padding laterale da 16px a 10px */
    max-width: 90% !important;    /* Permette alla bolla di allargarsi di più su schermi stretti */
  }
  
  /* Box di traduzione della Zia nella chat */
  .msg-zia-translation {
    width: 90% !important;
    padding: 12px 10px 8px 10px !important;
  }

  /* Box del Generatore di Sarcasmo (Frase del giorno) */
  #frase-card {
    padding: 16px 12px !important; /* Riduce il padding interno per massimizzare lo spazio di testo */
    min-height: 120px !important;   /* Riduce l'altezza minima superflua */
  }

  /* Box del Quiz Aziendale */
  .quiz-container {
    padding: 16px 12px !important; /* Riduce il padding sui lati da 20px a 12px */
  }

  /* Singole risposte all'interno del quiz */
  .quiz-risposta {
    padding: 8px 10px !important; /* Più compatte per evitare che risposte lunghe vadano a capo troppe volte */
    font-size: 0.8rem !important;  /* Testo leggermente più piccolo per far entrare più parole */
  }

  /* Box del risultato tipico del quiz */
  .risultato-frase {
    padding: 12px 10px !important; /* Testo più vicino ai bordi brutalisti */
  }
  
  .risultato-card {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0 !important;
    width: 100% !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  
  .risultato-titolo {
    font-size: 1.3rem !important;
    margin-bottom: 8px !important;
  }

  .risultato-descrizione {
    font-size: 0.8rem !important;
    line-height: 1.45 !important;
    margin-bottom: 16px !important;
  }

  /* Riduce il padding delle schede Bento (lg:col-span-6) su mobile a 8px (equivalente a p-2) */
  .lg\:col-span-6 {
    padding: 8px !important;
  }
}
