/* ==========================================================================
   Giuse Petroso — biglietto digitale
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: #000;
  color: #e9f3f0;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a { text-decoration: none; }
button { font: inherit; }
[hidden] { display: none !important; }

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

@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes softblink { 0%, 100% { opacity: 1; } 50% { opacity: .15; } }
@keyframes flicker { 0%, 91%, 94%, 98%, 100% { opacity: 1; } 92% { opacity: .55; } 93% { opacity: .85; } 99% { opacity: .75; } }
@keyframes flashw { 0% { opacity: 1; } 35% { opacity: 1; } 100% { opacity: 0; } }
@keyframes popin { 0% { opacity: 0; transform: translateY(14px) scale(.96); } 100% { opacity: 1; transform: none; } }

/* --------------------------------------------------------------------------
   Desktop
   -------------------------------------------------------------------------- */

.desktop {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #000;
}

.wallpaper { position: absolute; inset: 0; display: none; }
.desktop[data-wallpaper="macchina"] .wp-macchina,
.desktop[data-wallpaper="404"] .wp-404,
.desktop[data-wallpaper="bsod"] .wp-bsod { display: flex; }

.wp-macchina {
  background:
    radial-gradient(circle at 72% 64%, #ffd59a 0 70px, rgba(255,190,120,.35) 71px, transparent 220px),
    linear-gradient(180deg, #24183f 0%, #5a2f63 42%, #c9655a 76%, #f0a868 100%);
}
.wp-mountains {
  position: absolute; left: 0; right: 0; bottom: 0; height: 23%;
  background: #1b1230;
  clip-path: polygon(0 60%, 14% 30%, 26% 55%, 40% 18%, 55% 52%, 68% 34%, 82% 58%, 100% 26%, 100% 100%, 0 100%);
}
.wp-quote {
  position: absolute; left: 64px; bottom: 54px;
  display: flex; flex-direction: column; gap: 10px;
}
.wp-quote-text {
  font-family: 'Playfair Display', serif; font-style: italic; font-weight: 600;
  font-size: clamp(36px, 6vw, 62px); line-height: 1.05; color: #fff6ea;
  text-shadow: 0 2px 20px rgba(0,0,0,.35);
}
.wp-quote-by {
  font-family: 'JetBrains Mono', monospace; font-size: 14px; letter-spacing: .08em;
  color: rgba(255,246,234,.75);
}

.wp-404 {
  background: radial-gradient(ellipse at 50% 40%, #23272d, #121418 75%);
  flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  text-align: center; padding: 0 24px;
}
.wp-404-num {
  font-family: 'Space Grotesk', sans-serif; font-weight: 700;
  font-size: clamp(120px, 24vw, 240px); line-height: .9;
  color: transparent; -webkit-text-stroke: 2px #343a42;
}
.wp-404-title { font-family: 'Space Grotesk', sans-serif; font-weight: 500; font-size: 24px; color: #8a939c; }
.wp-404-sub { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: #59626b; }

.wp-bsod {
  background: #0a63c9; color: #fff;
  padding: clamp(40px, 10vw, 120px);
  flex-direction: column; gap: 26px;
}
.wp-bsod-face { font-family: 'Space Grotesk', sans-serif; font-weight: 500; font-size: clamp(90px, 13vw, 150px); line-height: 1; }
.wp-bsod-msg { font-family: 'Space Grotesk', sans-serif; font-weight: 500; font-size: clamp(20px, 2.4vw, 28px); line-height: 1.35; max-width: 760px; }
.wp-bsod-pct { font-family: 'Space Grotesk', sans-serif; font-weight: 500; font-size: clamp(18px, 2vw, 24px); }
.wp-bsod-code { font-family: 'JetBrains Mono', monospace; font-size: 14px; opacity: .8; }

/* Icona */
.desk-icon {
  position: absolute; top: 26px; right: 26px; width: 100px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 0; border: 0; background: none; cursor: default; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.desk-icon-img {
  width: 64px; height: 64px; border-radius: 16px;
  background: linear-gradient(180deg, #3a3f46 0 13px, #15181c 13px);
  border: 1px solid #4a5058; display: flex;
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
.desk-icon-img span {
  font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: 22px;
  color: #e9f3f0; align-self: flex-start; margin: 20px 0 0 10px; letter-spacing: -.02em;
}
.desk-icon-label {
  font-family: -apple-system, 'Helvetica Neue', sans-serif; font-size: 12px; font-weight: 600;
  color: #fff; padding: 2px 7px; border-radius: 4px; text-shadow: 0 1px 3px rgba(0,0,0,.7);
}
.desk-icon.is-selected .desk-icon-img { box-shadow: 0 6px 18px rgba(0,0,0,.35), 0 0 0 3px rgba(255,255,255,.55); }
.desk-icon.is-selected .desk-icon-label { background: #2f6fde; text-shadow: none; }
.desk-icon:focus-visible { outline: 2px solid #2f6fde; outline-offset: 4px; border-radius: 8px; }

/* --------------------------------------------------------------------------
   Finestra
   -------------------------------------------------------------------------- */

.window {
  position: absolute; z-index: 2;
  top: 40px; left: 48px; right: 48px; bottom: 40px;
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.05);
  transform-origin: var(--origin, 97% 3.8%);
  transition:
    transform .38s cubic-bezier(.3,.7,.2,1), opacity .34s ease,
    top .3s ease, left .3s ease, right .3s ease, bottom .3s ease,
    border-radius .3s ease, visibility 0s linear 0s;
}
.window.is-max { top: 0; left: 0; right: 0; bottom: 0; border-radius: 0; box-shadow: none; }
.window.is-max .term { border-radius: 0; }

.window:not([data-state="open"]) {
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: scale(.06);
  transition-delay: 0s, 0s, 0s, 0s, 0s, 0s, 0s, .38s;
}
.window[data-state="closing"] { transform: scale(.94); transform-origin: 50% 50%; }

.term {
  position: absolute; inset: 0;
  border-radius: 12px; overflow: hidden;
  display: flex; flex-direction: column;
}

.titlebar { flex: none; display: flex; align-items: center; min-width: 0; }

.light {
  flex: none; padding: 0; border: none; cursor: pointer; text-align: center;
  color: transparent;
}
.light::before { content: var(--sym); }
.light-close { --sym: "×"; }
.light-min { --sym: "−"; }
.light-max { --sym: "+"; }

.title { display: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.window[data-theme="cyberpunk"] .title-cyberpunk,
.window[data-theme="chill"] .title-chill,
.window[data-theme="retro"] .title-retro { display: inline; }

.themes { margin-left: auto; display: flex; align-items: center; flex: none; }
.themes button { cursor: pointer; white-space: nowrap; }
.themes button[aria-pressed="true"] { cursor: default; }
.themes-label { display: none; }

.logo { flex: none; display: block; }

.term-body {
  position: relative;
  flex: 1; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: none;
}
.term-body::-webkit-scrollbar { display: none; }

.line, .prompt { white-space: pre-wrap; word-break: break-word; margin: 0; }
.pre::before { content: var(--pre); }
.cursor { display: inline-block; }

.links { display: flex; flex-wrap: wrap; }

.prompt { position: relative; min-height: 2em; cursor: text; }
.prompt.is-busy .pre,
.prompt.is-busy .typed,
.prompt.is-busy .cursor { display: none; }
.prompt input {
  position: absolute; inset: 0; width: 100%;
  opacity: 0; border: none; padding: 0; margin: 0; background: none;
  font-size: 16px; /* evita lo zoom automatico su iOS */
  color: transparent; caret-color: transparent;
}

.gif { display: block; width: 300px; max-width: 100%; border-radius: 4px; margin: 10px 0 14px; }

.scanlines { display: none; position: absolute; inset: 0; pointer-events: none; z-index: 5; }

/* --------------------------------------------------------------------------
   Tema: cyberpunk
   -------------------------------------------------------------------------- */

.window[data-theme="cyberpunk"] { --pre: "❯ "; }
.window[data-theme="cyberpunk"] .term { background: #05070a; border: 1px solid #1a2229; }
.window[data-theme="cyberpunk"] .titlebar {
  height: 46px; gap: 10px; padding: 0 20px;
  background: #090d12; border-bottom: 1px solid #131c24;
}
.window[data-theme="cyberpunk"] .light { width: 12px; height: 12px; border-radius: 50%; font: 700 10px/12px sans-serif; }
.window[data-theme="cyberpunk"] .light:hover { color: #05070a; }
.window[data-theme="cyberpunk"] .light-close { background: rgba(44,232,197,.6); }
.window[data-theme="cyberpunk"] .light-min { background: rgba(216,241,38,.6); }
.window[data-theme="cyberpunk"] .light-max { background: #3d4c52; }
.window[data-theme="cyberpunk"] .title { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: #5c6f75; margin-left: 10px; }
.window[data-theme="cyberpunk"] .themes { gap: 4px; }
.window[data-theme="cyberpunk"] .themes-label { display: inline; font-family: 'JetBrains Mono', monospace; font-size: 11px; color: #3d4c52; margin-right: 6px; }
.window[data-theme="cyberpunk"] .themes button {
  font-family: 'JetBrains Mono', monospace; font-size: 11px; padding: 4px 10px;
  border: 1px solid transparent; border-radius: 3px; background: none; color: #5c6f75;
}
.window[data-theme="cyberpunk"] .themes button:hover { color: #b9cdd0; border-color: #232c33; }
.window[data-theme="cyberpunk"] .themes button[aria-pressed="true"] {
  border-color: rgba(44,232,197,.5); background: rgba(44,232,197,.08); color: #2ce8c5;
}
.window[data-theme="cyberpunk"] .logo { width: 26px; height: 26px; border-radius: 6px; margin-left: 12px; }
.window[data-theme="cyberpunk"] .term-body { padding: 40px 48px; animation: flicker 7s infinite; }
.window[data-theme="cyberpunk"] .line,
.window[data-theme="cyberpunk"] .prompt { font-family: 'JetBrains Mono', monospace; font-size: 16.5px; line-height: 2; }
.window[data-theme="cyberpunk"] .pre { color: #d8f126; }
.window[data-theme="cyberpunk"] .k-cmd,
.window[data-theme="cyberpunk"] .typed { color: #e9f3f0; }
.window[data-theme="cyberpunk"] .k-big {
  color: #2ce8c5; font-size: 40px; font-weight: 700; font-family: 'Space Grotesk', sans-serif;
  letter-spacing: .02em; line-height: 1.3;
}
.window[data-theme="cyberpunk"] .k-dim { color: #7d8b8f; }
.window[data-theme="cyberpunk"] .k-norm { color: #b9cdd0; }
.window[data-theme="cyberpunk"] .k-err { color: #ff4f8b; }
.window[data-theme="cyberpunk"] .k-sys { color: #7d8b8f; }
.window[data-theme="cyberpunk"] .k-joke { color: #d8f126; }
.window[data-theme="cyberpunk"] .cursor {
  width: 9px; height: 19px; background: #2ce8c5; margin-left: 3px; vertical-align: -3px;
  animation: blink 1.1s steps(1) infinite;
}
.window[data-theme="cyberpunk"] .links { gap: 14px; margin: 14px 0 24px; }
.window[data-theme="cyberpunk"] .links a {
  font-family: 'JetBrains Mono', monospace; font-size: 14px; padding: 9px 20px;
  border: 1px solid rgba(44,232,197,.4); border-radius: 4px; color: #2ce8c5;
}
.window[data-theme="cyberpunk"] .links a:hover { background: rgba(44,232,197,.1); border-color: #2ce8c5; color: #d8f126; }
.window[data-theme="cyberpunk"] .scanlines { display: block; background: repeating-linear-gradient(0deg, rgba(0,0,0,.2) 0 1px, transparent 1px 3px); }

/* --------------------------------------------------------------------------
   Tema: chill
   -------------------------------------------------------------------------- */

.window[data-theme="chill"] { --pre: "➜ "; }
.window[data-theme="chill"] .term {
  background:
    radial-gradient(ellipse 60% 55% at 85% 0%, rgba(244,169,160,.10), transparent 70%),
    radial-gradient(ellipse 50% 50% at 0% 100%, rgba(195,177,225,.08), transparent 70%),
    #1f1b26;
  border: 1px solid #2e2838;
}
.window[data-theme="chill"] .titlebar {
  height: 50px; gap: 9px; padding: 0 22px;
  background: #252030; border-bottom: 1px solid #2e2838;
}
.window[data-theme="chill"] .light { width: 12px; height: 12px; border-radius: 50%; font: 700 10px/12px sans-serif; }
.window[data-theme="chill"] .light:hover { color: #1f1b26; }
.window[data-theme="chill"] .light-close { background: #f4a9a0; }
.window[data-theme="chill"] .light-min { background: #f1d39b; }
.window[data-theme="chill"] .light-max { background: #9fc5a8; }
.window[data-theme="chill"] .title { font-family: 'Fira Code', monospace; font-size: 12.5px; color: #8a8197; margin-left: 12px; }
.window[data-theme="chill"] .themes { gap: 4px; background: #1c1823; padding: 3px; border-radius: 999px; }
.window[data-theme="chill"] .themes button {
  font-family: 'Quicksand', sans-serif; font-weight: 700; font-size: 12px; padding: 5px 13px;
  border: none; border-radius: 999px; background: none; color: #8a8197;
}
.window[data-theme="chill"] .themes button:hover { color: #e8dcc8; }
.window[data-theme="chill"] .themes button[aria-pressed="true"] { background: #f4a9a0; color: #1f1b26; }
.window[data-theme="chill"] .logo { width: 28px; height: 28px; border-radius: 50%; margin-left: 12px; }
.window[data-theme="chill"] .term-body { padding: 44px 52px; }
.window[data-theme="chill"] .line,
.window[data-theme="chill"] .prompt { font-family: 'Fira Code', monospace; font-size: 16.5px; line-height: 2.05; }
.window[data-theme="chill"] .pre { color: #9fc5a8; }
.window[data-theme="chill"] .k-cmd,
.window[data-theme="chill"] .typed { color: #e8dcc8; }
.window[data-theme="chill"] .k-big { color: #f4a9a0; font-size: 42px; font-weight: 700; font-family: 'Quicksand', sans-serif; line-height: 1.35; }
.window[data-theme="chill"] .k-dim { color: #c3b1e1; }
.window[data-theme="chill"] .k-norm { color: #e8dcc8; }
.window[data-theme="chill"] .k-err { color: #f4a9a0; }
.window[data-theme="chill"] .k-sys { color: #8a8197; }
.window[data-theme="chill"] .k-joke { color: #c3b1e1; }
.window[data-theme="chill"] .cursor {
  width: 9px; height: 19px; border-radius: 2px; background: #f4a9a0; margin-left: 3px; vertical-align: -3px;
  animation: softblink 1.6s ease-in-out infinite;
}
.window[data-theme="chill"] .links { gap: 12px; margin: 16px 0 24px; }
.window[data-theme="chill"] .links a {
  font-family: 'Quicksand', sans-serif; font-weight: 700; font-size: 15px; padding: 10px 22px;
  border-radius: 999px; --c: #f4a9a0; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c);
}
.window[data-theme="chill"] .links a:nth-child(2) { --c: #c3b1e1; }
.window[data-theme="chill"] .links a:nth-child(3) { --c: #9fc5a8; }
.window[data-theme="chill"] .links a:hover { background: var(--c); color: #1f1b26; }

/* --------------------------------------------------------------------------
   Tema: retro
   -------------------------------------------------------------------------- */

.window[data-theme="retro"] { --pre: "▶ "; }
.window[data-theme="retro"] .term {
  background: #000; border: 4px solid #fff;
  box-shadow: inset 0 0 0 4px #000, inset 0 0 0 8px #e40058;
}
.window[data-theme="retro"] .titlebar {
  height: 54px; gap: 14px; padding: 0 26px; margin: 8px 8px 0;
  border-bottom: 4px solid #e40058;
}
.window[data-theme="retro"] .light {
  width: 18px; height: 18px; color: #000;
  font-family: 'Press Start 2P', monospace; font-size: 8px; line-height: 18px;
  box-shadow: 3px 3px 0 #333;
}
.window[data-theme="retro"] .light:hover { transform: translate(1px, 1px); box-shadow: 2px 2px 0 #333; }
.window[data-theme="retro"] .light-close { background: #e40058; --sym: "X"; }
.window[data-theme="retro"] .light-min { background: #fcb800; --sym: "_"; }
.window[data-theme="retro"] .light-max { background: #fff; }
.window[data-theme="retro"] .title { font-family: 'Press Start 2P', monospace; font-size: 11px; color: #fff; margin-left: 8px; }
.window[data-theme="retro"] .retro-1up { color: #e40058; margin-right: 8px; }
.window[data-theme="retro"] .themes { gap: 6px; }
.window[data-theme="retro"] .themes button {
  font-family: 'Press Start 2P', monospace; font-size: 9px; padding: 7px 9px;
  border: none; background: none; color: #8a8aa0;
}
.window[data-theme="retro"] .themes button:hover { color: #fff; }
.window[data-theme="retro"] .themes button[aria-pressed="true"] { background: #fcb800; color: #000; }
.window[data-theme="retro"] .logo { width: 28px; height: 28px; image-rendering: pixelated; margin-left: 6px; }
.window[data-theme="retro"] .term-body { padding: 40px 52px; }
.window[data-theme="retro"] .line,
.window[data-theme="retro"] .prompt { font-family: 'Press Start 2P', monospace; font-size: 13px; line-height: 2.7; }
.window[data-theme="retro"] .pre { color: #e40058; }
.window[data-theme="retro"] .k-cmd,
.window[data-theme="retro"] .typed { color: #fff; }
.window[data-theme="retro"] .k-big { display: inline-block; color: #fcb800; font-size: 34px; line-height: 1.7; text-shadow: 4px 4px 0 #e40058; }
.window[data-theme="retro"] .k-dim { color: #3cbcfc; }
.window[data-theme="retro"] .k-norm { color: #fff; }
.window[data-theme="retro"] .k-err { color: #e40058; }
.window[data-theme="retro"] .k-sys { color: #8a8aa0; }
.window[data-theme="retro"] .k-joke { color: #fcb800; }
.window[data-theme="retro"] .cursor {
  width: 13px; height: 13px; background: #fcb800; margin-left: 4px; vertical-align: -1px;
  animation: blink .8s steps(1) infinite;
}
.window[data-theme="retro"] .links { gap: 22px; margin: 22px 0 26px; }
.window[data-theme="retro"] .links a {
  font-family: 'Press Start 2P', monospace; font-size: 12px; padding: 14px 18px; text-transform: uppercase;
  background: #fcb800; color: #000; box-shadow: 5px 5px 0 #e40058;
}
.window[data-theme="retro"] .links a:hover { background: #fff; transform: translate(2px, 2px); box-shadow: 3px 3px 0 #e40058; }
.window[data-theme="retro"] .scanlines { display: block; background: repeating-linear-gradient(0deg, rgba(0,0,0,.35) 0 2px, transparent 2px 4px); }

/* Focus da tastiera */
.window button:focus-visible,
.window a:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

/* --------------------------------------------------------------------------
   Bright mode (easter egg)
   -------------------------------------------------------------------------- */

.bright {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(0,0,0,.62);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.bright-flash {
  position: absolute; inset: 0; background: #fff; pointer-events: none;
  animation: flashw .8s ease-out forwards;
}
.bright-modal {
  position: relative; width: 540px; max-width: 100%;
  background: #fff; color: #111; border-radius: 10px;
  padding: 36px 40px 32px;
  box-shadow: 0 30px 90px rgba(0,0,0,.6);
  animation: popin .35s .5s both;
}
.bright-code { font-family: 'JetBrains Mono', monospace; font-size: 12px; letter-spacing: .1em; color: #c2185b; }
.bright-title { font-family: 'Space Grotesk', sans-serif; font-size: 44px; font-weight: 700; margin-top: 14px; line-height: 1.1; }
.bright-desc { font-family: 'Space Grotesk', sans-serif; font-size: 18px; line-height: 1.5; color: #444; margin-top: 12px; text-wrap: pretty; }
.bright-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-top: 26px; }
.bright-actions button {
  font-family: 'JetBrains Mono', monospace; font-size: 14px; padding: 12px 22px;
  border: none; border-radius: 6px; background: #05070a; color: #2ce8c5; cursor: pointer;
}
.bright-actions button:hover { background: #131c24; }
.bright-actions span { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: #888; }

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

@media (max-width: 900px) {
  .window[data-theme] .title { display: none; }
  .window[data-theme="cyberpunk"] .themes-label { display: none; }
}

@media (max-width: 640px) {
  .window { top: 12px; left: 10px; right: 10px; bottom: 12px; }
  .desk-icon { top: 18px; right: 12px; }
  .wp-quote { left: 24px; right: 24px; bottom: 36px; }
  .wp-quote-by { font-size: 12px; }

  .window[data-theme="cyberpunk"] .titlebar { padding: 0 14px; }
  .window[data-theme="cyberpunk"] .themes button { padding: 4px 7px; }
  .window[data-theme="chill"] .titlebar { padding: 0 14px; }
  .window[data-theme="chill"] .themes button { padding: 5px 9px; font-size: 11.5px; }
  .window[data-theme="retro"] .titlebar { padding: 0 12px; gap: 10px; }
  .window[data-theme="retro"] .themes { gap: 2px; }
  .window[data-theme="retro"] .themes button { font-size: 7px; padding: 6px 5px; }

  .window[data-theme] .term-body { padding: 24px 20px; }
  .window[data-theme="cyberpunk"] .line, .window[data-theme="cyberpunk"] .prompt,
  .window[data-theme="chill"] .line, .window[data-theme="chill"] .prompt { font-size: 14px; }
  .window[data-theme="cyberpunk"] .k-big { font-size: 30px; }
  .window[data-theme="chill"] .k-big { font-size: 32px; }
  .window[data-theme="retro"] .line, .window[data-theme="retro"] .prompt { font-size: 10px; line-height: 2.5; }
  .window[data-theme="retro"] .k-big { font-size: 20px; text-shadow: 3px 3px 0 #e40058; }
  .window[data-theme="retro"] .links { gap: 14px; }
  .window[data-theme="retro"] .links a { font-size: 10px; padding: 12px 14px; }

  .bright-modal { padding: 28px 24px 24px; }
  .bright-title { font-size: 34px; }
  .bright-desc { font-size: 16px; }
}

@media (max-width: 400px) {
  .window[data-theme] .logo { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .window, .window[data-theme] .term-body { transition: none; animation: none; }
  .bright-flash { animation: none; opacity: 0; }
  .bright-modal { animation: none; }
}
