/* FONT (self-hosted, niente richieste a Google) */

@font-face {
  font-family: "Press Start 2P";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/press-start-2p.woff2") format("woff2");
}

@font-face {
  font-family: "VT323";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/vt323.woff2") format("woff2");
}

:root {
  --bg: #090210;
  --panel: #180827;
  --panel-light: #280d40;
  --purple: #a92cff;
  --magenta: #ff2d95;
  --cyan: #35efff;
  --yellow: #ffd447;
  --green: #45e27a;
  --white: #ffffff;
  --muted: #dec9f5;
  --black: #030106;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* pixel art nitida, ma non sui loghi istituzionali */
.story-image,
.start-chick-img {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--white);
  font-family: "Press Start 2P", monospace;
  background:
    radial-gradient(circle at 50% 0%, #35115a 0%, transparent 38%),
    linear-gradient(180deg, #12051d, var(--bg));
  padding-top: 70px;
}

button,
input,
select {
  font: inherit;
}

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  opacity: 0.12;
  background: linear-gradient(
    transparent 50%,
    rgba(0, 0, 0, 0.55) 50%
  );
  background-size: 100% 4px;
}

.no-crt .scanlines {
  display: none;
}

/* HEADER HUD */

.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: 66px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(18, 5, 29, 0.96);
  border-bottom: 4px solid var(--magenta);
  box-shadow: 0 5px 24px rgba(255, 45, 149, 0.25);
}

.brand {
  color: var(--white);
  text-decoration: none;
  font-size: 10px;
  text-shadow: 2px 2px 0 var(--black);
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand span {
  color: var(--cyan);
}

.hud-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--yellow);
  font-size: 8px;
}

.hearts {
  color: #ff5b83;
  animation: pulse 1.2s infinite alternate;
}

@keyframes pulse {
  to {
    transform: scale(1.08);
  }
}

.pixel-btn {
  display: inline-block;
  padding: 14px 20px;
  color: var(--white);
  text-decoration: none;
  font-size: 9px;
  background: var(--magenta);
  border: 3px solid var(--black);
  box-shadow:
    inset -3px -3px 0 #a90052,
    inset 3px 3px 0 #ff75bb,
    4px 4px 0 var(--black);
  cursor: pointer;
  transition: 0.12s ease;
}

.pixel-btn:hover {
  transform: translate(-1px, -2px);
  color: var(--black);
  background: var(--cyan);
  box-shadow:
    inset -3px -3px 0 #00a9b3,
    inset 3px 3px 0 #93fbff,
    6px 6px 0 var(--black);
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sound-btn {
  padding: 8px 10px;
  font-size: 8px;
}

/* STRUTTURA */

main {
  width: min(1040px, calc(100% - 28px));
  margin: 0 auto;
  padding: 20px 0 80px;
}

.window {
  position: relative;
  margin-bottom: 46px;
  padding: 28px;
  background: linear-gradient(
    180deg,
    rgba(30, 11, 48, 0.98),
    rgba(17, 5, 28, 0.98)
  );
  border: 6px solid var(--black);
  box-shadow:
    8px 8px 0 #000,
    0 0 25px rgba(169, 44, 255, 0.22);
  text-align: center;
}

.window-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: -28px -28px 24px;
  padding: 11px 15px;
  color: var(--cyan);
  font-size: 9px;
  line-height: 1.4;
  background: var(--purple);
  border-bottom: 4px solid var(--black);
  text-shadow: 2px 2px 0 var(--black);
  text-align: left;
}

.badge {
  flex-shrink: 0;
  padding: 4px 7px;
  color: #fff;
  font-size: 7px;
  background: var(--magenta);
  border: 2px solid var(--black);
}

.title-box {
  max-width: 830px;
  margin: 0 auto 22px;
  padding: 22px 18px;
  text-align: center;
  background: #0e0318;
  border: 5px solid var(--black);
  box-shadow:
    inset 0 0 0 4px var(--purple),
    6px 6px 0 #000;
}

h1 {
  font-size: clamp(16px, 3vw, 25px);
  line-height: 1.55;
  text-shadow: 3px 3px 0 #000;
}

h1 span {
  color: var(--cyan);
}

h2 {
  margin-bottom: 12px;
  color: var(--yellow);
  font-size: 13px;
  line-height: 1.5;
  text-shadow: 2px 2px 0 #000;
  text-align: center;
}

.lead {
  max-width: 850px;
  margin: 0 auto 23px;
  color: var(--muted);
  text-align: center;
  font-family: "VT323", monospace;
  font-size: clamp(23px, 3vw, 30px);
  line-height: 1.25;
}

/* IMMAGINI */

.story-image {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 8.4;
  overflow: hidden;
  background-position: center;
  background-size: cover;
  border: 6px solid var(--black);
  box-shadow:
    inset 0 0 25px #000,
    0 0 24px rgba(53, 239, 255, 0.12);
  cursor: pointer;
}

.story-image::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    transparent 58%,
    rgba(5, 1, 8, 0.55)
  );
}

.room {
  background-image: url("../img/room.webp");
}

.learning {
  background-image: url("../img/learning.webp");
}

.work {
  background-image: url("../img/work.webp");
}

.screen-glow {
  position: absolute;
  z-index: 2;
  right: 10%;
  bottom: 15%;
  width: 35%;
  height: 40%;
  pointer-events: none;
  background: rgba(53, 239, 255, 0.16);
  filter: blur(24px);
  animation: glow 0.7s infinite alternate;
}

@keyframes glow {
  to {
    opacity: 0.25;
  }
}

/* DIALOGO */

.dialogue {
  position: relative;
  min-height: 85px;
  margin-top: 16px;
  padding: 16px 42px 16px 16px;
  color: var(--yellow);
  font-family: "VT323", monospace;
  font-size: clamp(23px, 3vw, 29px);
  line-height: 1.25;
  background: #0c0214;
  border: 4px solid var(--purple);
  box-shadow: inset 3px 3px 0 #000;
  text-align: left;
}

.dialogue::after {
  content: "▼";
  position: absolute;
  right: 14px;
  bottom: 10px;
  color: var(--cyan);
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  animation: blink 0.8s infinite alternate;
}

@keyframes blink {
  from {
    opacity: 0.2;
  }

  to {
    opacity: 1;
  }
}

/* LOADING SCREEN */

.loading-screen {
  margin: 38px 0 48px;
  padding: 30px 20px;
  text-align: center;
  background-color: #050108;
  background-image:
    radial-gradient(1px 1px at 20px 30px, #fff, transparent),
    radial-gradient(1px 1px at 80px 60px, var(--cyan), transparent),
    radial-gradient(1px 1px at 150px 25px, var(--magenta), transparent),
    radial-gradient(2px 2px at 240px 80px, #fff, transparent),
    radial-gradient(1px 1px at 320px 35px, var(--yellow), transparent);
  background-size: 350px 120px;
  border: 4px solid #fff;
}

.loading-title {
  margin-bottom: 18px;
  font-size: 13px;
  letter-spacing: 2px;
}

.loading-bar {
  max-width: 560px;
  height: 31px;
  margin: 0 auto 17px;
  padding: 4px;
  overflow: hidden;
  background: #000;
  border: 4px solid #fff;
}

.loading-fill {
  width: 0;
  height: 100%;
  background: repeating-linear-gradient(
    90deg,
    #fff 0 13px,
    #000 13px 17px
  );
  animation: load 4s infinite ease-in-out;
}

@keyframes load {
  0% {
    width: 0;
  }

  65% {
    width: 76%;
  }

  100% {
    width: 100%;
  }
}

.terminal {
  max-width: 660px;
  margin: 16px auto 0;
  color: var(--muted);
  text-align: left;
  font-family: "VT323", monospace;
  font-size: 22px;
  line-height: 1.3;
}

.ok {
  color: var(--green);
}

.cursor {
  color: var(--cyan);
  animation: blink 0.65s infinite alternate;
}

/* MATCHMAKING */

.matchmaking {
  margin: 36px 0 48px;
  padding: 22px;
  text-align: center;
  background: #08010f;
  border: 4px dashed var(--cyan);
}

.matchmaking-title {
  color: var(--cyan);
  font-size: 9px;
}

.match-track {
  height: 21px;
  margin-top: 13px;
  overflow: hidden;
  background: #210b35;
  border: 3px solid #000;
}

.match-progress {
  width: 0;
  height: 100%;
  background: var(--cyan);
  animation: match 4s infinite ease-in-out;
}

@keyframes match {
  0% {
    width: 0;
  }

  60% {
    width: 72%;
  }

  100% {
    width: 100%;
  }
}

/* CARDS EQUIPAGGIAMENTO (4 PILASTRI) */

.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  margin-top: 20px;
}

.card {
  min-height: 185px;
  padding: 20px 14px;
  text-align: center;
  background: var(--panel-light);
  border: 4px solid #000;
  box-shadow: 6px 6px 0 #000;
  transition: 0.15s;
  cursor: pointer;
}

.card:hover {
  transform: translateY(-5px);
  border-color: var(--cyan);
  box-shadow: 8px 8px 0 #000, 0 0 15px rgba(53, 239, 255, 0.3);
}

.card-icon {
  display: block;
  margin-bottom: 10px;
  font-size: 34px;
}

.card-title {
  margin-bottom: 9px;
  color: var(--magenta);
  font-size: 9px;
  line-height: 1.4;
}

.card p {
  color: var(--muted);
  font-family: "VT323", monospace;
  font-size: 21px;
  line-height: 1.2;
}

/* ACCORDION RETE SKILLLAB */

.accordion-group {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.pixel-accordion-item {
  border: 4px solid var(--black);
  background: #0d0317;
}

/* <details>/<summary> nativi: accessibili da tastiera e screen reader senza JS */
.pixel-accordion-btn {
  list-style: none;
  background: var(--panel-light);
  color: #fff;
  padding: 14px 16px;
  font-size: 8px;
  line-height: 1.6;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  box-shadow: inset -2px -2px 0 #120324, inset 2px 2px 0 #6e25b3;
}

.pixel-accordion-btn::-webkit-details-marker {
  display: none;
}

.pixel-accordion-btn::after {
  content: "+";
  flex-shrink: 0;
}

.pixel-accordion-item[open] > .pixel-accordion-btn::after {
  content: "−";
}

.pixel-accordion-btn:hover {
  background: var(--purple);
  color: var(--cyan);
}

.pixel-accordion-content {
  padding: 16px;
  background: #0c0414;
  border-top: 3px solid var(--black);
  font-family: "VT323", monospace;
  font-size: 22px;
  line-height: 1.4;
  color: var(--muted);
}

/* ANCHOR BUTTONS PIXEL ART */

.anchor-btn-wrapper {
  text-align: right;
  margin-top: 24px;
  padding-top: 12px;
  border-top: 2px dashed var(--purple);
}

.pixel-anchor-btn {
  display: inline-block;
  background: var(--yellow);
  color: #000;
  text-decoration: none;
  padding: 12px 18px;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  font-weight: bold;
  border: 3px solid #000;
  box-shadow: 4px 4px 0 #000;
  cursor: pointer;
  transition: all 0.15s;
}

.pixel-anchor-btn:hover {
  background: var(--cyan);
  transform: translateY(-2px);
  box-shadow: 6px 6px 0 #000;
}

/* FORM FINALE */

.final {
  text-align: center;
  background:
    radial-gradient(
      circle at 50% 20%,
      rgba(169, 44, 255, 0.2),
      transparent 45%
    ),
    #08010e;
}

.one-up {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin: 2px 0 25px;
  color: var(--yellow);
  font-size: clamp(23px, 4vw, 38px);
  text-shadow: 4px 4px 0 #000;
  animation: float 1.1s infinite alternate ease-in-out;
}

@keyframes float {
  to {
    transform: translateY(-10px);
  }
}

.arrow {
  color: var(--green);
  filter: drop-shadow(0 0 8px var(--green));
}

.form {
  max-width: 620px;
  margin: 25px auto 0;
  text-align: left;
}

label {
  display: block;
  margin: 15px 0 7px;
  color: var(--magenta);
  font-size: 8px;
}

input,
select {
  width: 100%;
  padding: 13px;
  color: #fff;
  background: #0b0212;
  border: 3px solid var(--purple);
  border-radius: 0;
  outline: none;
  color-scheme: dark;
  font-family: "VT323", monospace;
  font-size: 23px;
}

input:focus,
select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 14px rgba(53, 239, 255, 0.25);
}

input:user-invalid,
select:user-invalid {
  border-color: var(--magenta);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.consent {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 22px;
  color: var(--muted);
  font-family: "VT323", monospace;
  font-size: 20px;
  line-height: 1.2;
}

.consent input {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  padding: 0;
  accent-color: var(--magenta);
}

.consent a,
.site-footer a {
  color: var(--cyan);
}

/* honeypot anti-spam: invisibile agli utenti, compilato dai bot */
.hp {
  position: absolute;
  left: -9999px;
}

.form-status {
  min-height: 1.2em;
  margin-top: 18px;
  font-family: "VT323", monospace;
  font-size: 24px;
  text-align: center;
}

.form-status.ok {
  color: var(--green);
}

.form-status.error {
  color: var(--magenta);
}

.pixel-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* LOGHI ISTITUZIONALI (fondo bianco come da linee guida) */

.logo-bar {
  background: #fff;
  border-bottom: 4px solid var(--black);
}

.logo-bar img {
  display: block;
  width: min(1040px, 100%);
  height: auto;
  margin: 0 auto;
  padding: 8px 14px;
}

.site-footer {
  border-top: 4px solid var(--magenta);
  text-align: center;
}

.site-footer .logo-bar {
  border-bottom: 0;
}

.footer-info {
  padding: 22px 14px 30px;
  color: var(--muted);
  font-family: "VT323", monospace;
  font-size: 20px;
  line-height: 1.4;
}

.center {
  text-align: center;
}

.small-note {
  margin-top: 16px;
  color: var(--muted);
  font-family: "VT323", monospace;
  font-size: 20px;
  line-height: 1.2;
}

/* XP FLOATING */

.floating-xp {
  position: absolute;
  z-index: 10;
  color: var(--green);
  font-size: 11px;
  font-weight: bold;
  text-shadow: 2px 2px #000;
  pointer-events: none;
  animation: floatXP 1s forwards ease-out;
}

@keyframes floatXP {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(-45px);
  }
}

/* OVERLAY PRESS START */

.start-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #050108;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.start-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

.start-card {
  width: min(650px, 100%);
  padding: 38px 22px;
  text-align: center;
  background: #12051d;
  border: 6px solid #000;
  box-shadow:
    inset 0 0 0 4px var(--purple),
    10px 10px 0 #000;
}

.start-chick-img {
  width: 140px;
  height: auto;
  margin-bottom: 18px;
  animation: float 1s infinite alternate ease-in-out;
}

.start-title {
  color: var(--cyan);
  font-size: clamp(18px, 4vw, 28px);
  line-height: 1.5;
  text-shadow: 3px 3px #000;
}

.start-sub {
  margin: 17px 0 25px;
  color: var(--muted);
  font-family: "VT323", monospace;
  font-size: 25px;
  line-height: 1.2;
  min-height: 60px;
}

.start-btn-animated {
  animation: startPulse 1.2s infinite ease-in-out;
}

@keyframes startPulse {
  0%, 100% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.06);
    filter: brightness(1.25);
    box-shadow: inset -3px -3px 0 #00a9b3, inset 3px 3px 0 #93fbff, 0 0 16px var(--cyan);
  }
}

/* PAGINA GIOCO PIO (/giochi/pio) */

.game-shell {
  max-width: 960px;
  margin: 0 auto;
}

.game-screen {
  aspect-ratio: 16 / 9;
  background: #000;
  border: 5px solid var(--black);
  box-shadow: inset 0 0 0 4px var(--purple), 6px 6px 0 #000;
  padding: 4px;
}

.game-screen iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.game-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin-top: 22px;
}

.game-alt-btn {
  background: var(--panel-light);
  box-shadow:
    inset -3px -3px 0 #12051d,
    inset 3px 3px 0 #4a1c70,
    4px 4px 0 var(--black);
}

.game-note {
  margin-top: 18px;
  color: var(--muted);
  font-family: "VT323", monospace;
  font-size: 20px;
  line-height: 1.25;
}

.game-cta .pixel-btn {
  margin-top: 4px;
}

/* RESPONSIVE */

@media (max-width: 800px) {
  .hud-stats {
    display: none;
  }

  .window {
    padding: 18px;
  }

  .window-head {
    margin: -18px -18px 18px;
    font-size: 8px;
  }

  .cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 500px) {
  .hud {
    padding: 0 10px;
  }

  .brand {
    font-size: 8px;
  }

  .sound-btn {
    font-size: 7px;
  }

  .hud-actions {
    gap: 6px;
  }

  main {
    width: calc(100% - 18px);
  }
}

@media (max-width: 400px) {
  .hud-actions {
    gap: 4px;
  }

  .sound-btn {
    padding: 7px 6px;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .badge {
    display: none;
  }
}

/* ACCESSIBILITÀ: niente animazioni per chi le ha disattivate nel sistema */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .loading-fill,
  .match-progress {
    width: 100%;
  }
}
