/* ============================================
   Pixel della Psiche — stylesheet
   ============================================ */

:root {
  --font-title: 'Italiana', serif;
  --font-body: 'Source Sans 3', sans-serif;

  --color-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-text-muted: #5a5a5a;
  --color-border: #e4e4e4;
  --color-accent: #000000;

  --max-width: 1180px;
  --section-padding: 6rem 1.5rem;

  --transition-fast: 0.2s ease;
  --transition-slow: 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-title);
  font-weight: 400;
  margin: 0 0 1rem;
  line-height: 1.15;
}

h2 {
  font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  text-align: center;
}

p { color: var(--color-text-muted); }

a { color: inherit; }

img { max-width: 100%; }

.section-inner, .footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.section { padding: var(--section-padding); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 0.85rem 1.9rem;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
  cursor: pointer;
  border: 2px solid var(--color-accent);
}

.btn-cta {
  background: var(--color-accent);
  color: #fff;
}
.btn-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
}

.btn-outline {
  background: transparent;
  color: var(--color-accent);
}
.btn-outline:hover {
  background: var(--color-accent);
  color: #fff;
  transform: translateY(-2px);
}

/* ---------- Hero ---------- */
.hero {
  min-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-top: 4rem;
}

.hero-inner {
  max-width: 720px;
}

.hero-title {
  font-size: clamp(2.6rem, 8vw, 5rem);
  position: relative;
  margin-bottom: 0.5rem;
  opacity: 0;
  animation: fade-in-up 1.8s ease forwards;
}

.hero-subtitle {
  font-family: var(--font-title);
  font-size: clamp(1.1rem, 2.4vw, 1.6rem);
  color: var(--color-accent);
  margin-bottom: 2.5rem;
  opacity: 0;
  animation: fade-in-up 1.8s ease forwards;
  animation-delay: 0.45s;
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hero-cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  opacity: 0;
  animation: fade-in-up 1.8s ease forwards;
  animation-delay: 0.9s;
}

.link-caption {
  display: inline-block;
  font-family: var(--font-title);
  font-size: 1rem;
  letter-spacing: 0.03em;
  color: var(--color-accent);
  text-decoration: none;
  border-bottom: 1px solid var(--color-accent);
  padding-bottom: 2px;
  transition: opacity var(--transition-fast);
}

.link-caption:hover {
  opacity: 0.6;
}

.hero-cover-caption {
  opacity: 0;
  animation: fade-in-up 1.4s ease forwards;
  animation-delay: 1.4s;
}

/* Glitch sull'immagine hero (RGB split via filtri SVG sui canali colore) */
.glitch-img {
  position: relative;
  width: 100%;
  max-width: clamp(320px, 42vw, 560px);
  margin: 0 auto;
  animation: glitch-jitter 4s infinite steps(1, end);
}

.glitch-img-base {
  display: block;
  width: 100%;
  height: auto;
}

.glitch-img-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  pointer-events: none;
}

.glitch-img-r {
  filter: url(#glitch-channel-r);
  mix-blend-mode: screen;
  animation: glitch-slice-1 4s infinite steps(1, end);
}

.glitch-img-b {
  filter: url(#glitch-channel-b);
  mix-blend-mode: screen;
  animation: glitch-slice-2 4s infinite steps(1, end);
}

/* jitter/skew sull'immagine durante il burst — ogni fase dura almeno 60ms, ben oltre un frame */
@keyframes glitch-jitter {
  0%, 87% { transform: translate(0, 0) skew(0deg) scaleX(1); }
  88%   { transform: translate(-4px, 1px) skew(-6deg) scaleX(1.02); }
  89.5% { transform: translate(6px, -2px) skew(5deg) scaleX(0.98); }
  91%   { transform: translate(-3px, 2px) skew(-4deg) scaleX(1.01); }
  92.5% { transform: translate(5px, -1px) skew(3deg) scaleX(0.99); }
  94%   { transform: translate(-6px, 0) skew(-5deg) scaleX(1.03); }
  95.5% { transform: translate(3px, 2px) skew(2deg) scaleX(1); }
  97%, 100% { transform: translate(0, 0) skew(0deg) scaleX(1); }
}

/* layer rosso: fette che saltano in modo scoordinato */
@keyframes glitch-slice-1 {
  0%, 87% { opacity: 0; clip-path: inset(0 0 100% 0); transform: translate(0, 0); }
  88%   { opacity: 1; clip-path: inset(6% 0 60% 0); transform: translate(-14px, 2px); }
  89.5% { opacity: 1; clip-path: inset(40% 0 15% 0); transform: translate(10px, -3px); }
  91%   { opacity: 0; clip-path: inset(0 0 100% 0); transform: translate(0, 0); }
  92.5% { opacity: 1; clip-path: inset(2% 0 75% 0); transform: translate(-9px, 3px); }
  94%   { opacity: 1; clip-path: inset(62% 0 6% 0); transform: translate(12px, -2px); }
  95.5% { opacity: 1; clip-path: inset(20% 0 45% 0); transform: translate(-7px, -3px); }
  97%, 100% { opacity: 0; clip-path: inset(0 0 100% 0); transform: translate(0, 0); }
}

/* layer blu: sfasato rispetto al rosso per l'effetto RGB split */
@keyframes glitch-slice-2 {
  0%, 87% { opacity: 0; clip-path: inset(0 0 100% 0); transform: translate(0, 0); }
  88%   { opacity: 1; clip-path: inset(58% 0 8% 0); transform: translate(12px, -2px); }
  89.5% { opacity: 1; clip-path: inset(12% 0 66% 0); transform: translate(-11px, 3px); }
  91%   { opacity: 0; clip-path: inset(0 0 100% 0); transform: translate(0, 0); }
  92.5% { opacity: 1; clip-path: inset(70% 0 4% 0); transform: translate(9px, -3px); }
  94%   { opacity: 1; clip-path: inset(8% 0 68% 0); transform: translate(-13px, 2px); }
  95.5% { opacity: 1; clip-path: inset(45% 0 20% 0); transform: translate(8px, 3px); }
  97%, 100% { opacity: 0; clip-path: inset(0 0 100% 0); transform: translate(0, 0); }
}

/* ---------- Book promo ---------- */
.book-promo-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 3rem;
  align-items: start;
}

.book-promo-cover img {
  width: 100%;
  max-width: 340px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.15);
  border-radius: 4px;
}

.book-promo-text h2 { text-align: left; }

.book-promo-text p {
  text-align: justify;
  hyphens: auto;
  margin-bottom: 1.2rem;
}

.book-promo-ctas {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.book-promo-text > .link-caption {
  margin-top: 1rem;
}

@media (max-width: 720px) {
  .book-promo-grid { grid-template-columns: 1fr; text-align: center; }
  .book-promo-text h2 { text-align: center; }
  .book-promo-cover { display: flex; justify-content: center; }
  .book-promo-ctas { justify-content: center; }
}

/* ---------- Candida ---------- */
.candida {
  background: #fafafa;
  text-align: center;
}

.candida-inner {
  max-width: 640px;
  margin: 0 auto;
}

.candida-inner .btn {
  margin-top: 0.5rem;
}

.candida-cta {
  margin-top: 1.5rem;
}

/* ---------- Esplora per capitolo ---------- */
.capitoli-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  justify-content: center;
  margin: 2.5rem 0 3rem;
}

.capitolo-frase {
  font-family: var(--font-body);
  font-size: clamp(0.95rem, 1.4vw, 1.15rem);
  line-height: 1.6;
  color: var(--color-text);
  text-align: center;
  max-width: 680px;
  margin: 0 auto 2.5rem;
}

.frase-intro {
  display: block;
  font-family: var(--font-title);
  font-size: clamp(1.15rem, 1.8vw, 1.4rem);
  margin-bottom: 0.5rem;
}

.pillola-capitolo {
  padding: 0.6rem 1.3rem;
  border-radius: 0;
  border: 2px solid var(--color-accent);
  background: #fff;
  color: var(--color-accent);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.pillola-capitolo:hover,
.pillola-capitolo.active {
  background: var(--color-accent);
  color: #fff;
}

.pillola-capitolo.active:hover {
  background: #fff;
  color: var(--color-accent);
}

.giochi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 340px));
  justify-content: center;
  align-items: start;
  gap: 2rem;
  min-height: 320px;
}

.esplora-cta {
  text-align: center;
  margin-top: 2.5rem;
}

.card-gioco {
  perspective: 1200px;
  width: 100%;
  height: 420px;
  outline: none;
  opacity: 0;
  transform: scale(0.9) translateY(20px);
}

.card-gioco.revealed {
  animation: card-reveal var(--transition-slow) forwards;
}

@keyframes card-reveal {
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.card-gioco-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.7s cubic-bezier(0.4, 0.2, 0.2, 1);
  will-change: transform;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 3px solid var(--cap-color, #1a1a1a);
}

.card-front {
  background: #1c1c1c;
}

/* "schermo" che contiene l'immagine di copertina.
   Posizionato in assoluto con inset fissi (non con % dentro un flex):
   dimensione garantita identica su ogni card, indipendente dal contenuto. */
.card-screen {
  position: absolute;
  top: 14px;
  right: 14px;
  bottom: 26px;
  left: 14px;
  border-radius: 4px;
  overflow: hidden;
  background: #000;
  box-shadow: inset 0 0 0 2px #000, inset 0 0 22px rgba(0, 0, 0, 0.7);
}

.card-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.05) 0px,
    rgba(255, 255, 255, 0.05) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
  pointer-events: none;
}

/* accensione dello schermo, tipo TV/console: parte una sola volta alla comparsa della card */
.card-gioco.revealed .card-screen {
  animation: screen-power-on 2.6s steps(1, end) both;
}

@keyframes screen-power-on {
  0%   { transform: scaleY(0.02); filter: brightness(6) contrast(0.3) saturate(0); }
  8%   { transform: scaleY(0.02); filter: brightness(8) contrast(0.2) saturate(0); }
  13%  { transform: scaleY(0.7);  filter: brightness(4) contrast(0.6) saturate(0.3); }
  18%  { transform: scaleY(0.05); filter: brightness(6) contrast(0.3) saturate(0); }
  24%  { transform: scaleY(1);    filter: brightness(2.5) contrast(1.4) saturate(0.6); }
  32%  { transform: scaleY(1);    filter: brightness(1.6) contrast(1.2) saturate(0.85); }
  48%  { transform: scaleY(1);    filter: brightness(1) contrast(1) saturate(1); }
  100% { transform: scaleY(1);    filter: brightness(1) contrast(1) saturate(1); }
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.9;
}

.card-titolo {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem;
  background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
  color: #fff;
  font-family: var(--font-title);
  font-size: 1.15rem;
}

.card-power-light {
  position: absolute;
  bottom: 10px;
  right: 16px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 4px #4ade80;
}

/* ---------- Censimento ---------- */
.censimento {
  background: #fafafa;
  text-align: center;
}

.censimento-inner {
  max-width: 640px;
  margin: 0 auto;
}

.censimento-ctas {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 2rem;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 3rem 1.5rem;
  text-align: center;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}

.footer-copy {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0;
}

.footer-credits {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.8;
  margin: 0;
}

.footer-credits a {
  color: var(--color-text);
  text-decoration: underline;
}

/* ---------- Scroll reveal ---------- */
.scroll-reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.scroll-reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Responsive ---------- */

/* Tablet */
@media (max-width: 900px) {
  :root { --section-padding: 4.5rem 1.5rem; }
  .hero { min-height: 80vh; }
  .card-gioco { height: 380px; }
}

/* Mobile */
@media (max-width: 600px) {
  :root { --section-padding: 3.5rem 1.2rem; }
  .hero { min-height: auto; padding: 4rem 1rem 3rem; }
  .glitch-img { max-width: min(340px, 82vw); }
  .card-gioco { height: 340px; }
  .censimento-ctas, .capitoli-nav { gap: 0.5rem; }
}
