/* ============================================
   MAIN.CSS — Reset, Variables, Global Layout
   Liquid Glass Design System
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  /* Glass properties */
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-bg-hover: rgba(255, 255, 255, 0.12);
  --glass-bg-active: rgba(255, 255, 255, 0.16);
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-border-bright: rgba(255, 255, 255, 0.4);
  --glass-blur: 40px;
  --glass-saturation: 180%;
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  --glass-shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.2);
  --glass-highlight: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.05) 100%);
  --glass-radius-sm: 8px;
  --glass-radius-md: 12px;
  --glass-radius-lg: 16px;
  --glass-radius-xl: 24px;
  --glass-radius-pill: 50px;

  /* Colors */
  --accent: #8a8a8e;
  --accent-hover: #6e6e73;
  --accent-active: #5a5a5f;
  --accent-light: rgba(138, 138, 142, 0.2);
  --accent-glow: rgba(138, 138, 142, 0.35);
  --success: #34C759;
  --success-bg: rgba(52, 199, 89, 0.15);
  --warning: #FF9F0A;
  --warning-bg: rgba(255, 159, 10, 0.15);
  --error: #FF3B30;
  --error-bg: rgba(255, 59, 48, 0.15);
  --info: #5AC8FA;
  --info-bg: rgba(90, 200, 250, 0.15);

  /* Text */
  --text-primary: rgba(255, 255, 255, 0.95);
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-tertiary: rgba(255, 255, 255, 0.35);
  --text-on-accent: #ffffff;

  /* Background */
  --bg-primary: #111113;
  --bg-gradient: linear-gradient(135deg, #111113 0%, #1c1c1e 50%, #2c2c2e 100%);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Transitions */
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;

  /* Layout */
  --sidebar-width: 260px;
  --container-max: 1200px;
  --bottom-nav-height: 60px;
}

/* --- Material Symbols --- */
.material-symbols-rounded {
  font-variation-settings:
    'FILL' 0,
    'wght' 400,
    'GRAD' 0,
    'opsz' 24;
  vertical-align: middle;
  line-height: 1;
}

/* --- CSS Reset --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--bg-gradient);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-hover);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

ul,
ol {
  list-style: none;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
}

input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* --- Global Layout --- */
.site-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  padding-bottom: calc(var(--bottom-nav-height) + var(--space-2xl));
}

/* Sulle pagine con footer (tutte tranne la Home) il contenuto occupa almeno
   l'altezza della viewport, così il footer resta sotto la piega e non risale
   sopra i contenuti corti. */
body:not(.home-page) .main-content {
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

/* Grid system */
.grid {
  display: grid;
  gap: var(--space-lg);
}

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

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

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

/* --- Section Spacing --- */
.section {
  /* padding: var(--space-3xl) 0; */
}

.section-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: var(--space-sm);
  letter-spacing: -0.02em;
}

.section-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-2xl);
}

/* --- Typography Scale --- */
h1 {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

h2 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h3 {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

h4 {
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.4;
}

h5 {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.4;
}

h6 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
}

p {
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
  line-height: 1.7;
}

small,
.text-small {
  font-size: 0.875rem;
}

.text-muted {
  color: var(--text-tertiary);
}

/* --- Utility Classes --- */
.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.mt-sm {
  margin-top: var(--space-sm);
}

.mt-md {
  margin-top: var(--space-md);
}

.mt-lg {
  margin-top: var(--space-lg);
}

.mt-xl {
  margin-top: var(--space-xl);
}

.mt-2xl {
  margin-top: var(--space-2xl);
}

.mb-sm {
  margin-bottom: var(--space-sm);
}

.mb-md {
  margin-bottom: var(--space-md);
}

.mb-lg {
  margin-bottom: var(--space-lg);
}

.mb-xl {
  margin-bottom: var(--space-xl);
}

.mb-2xl {
  margin-bottom: var(--space-2xl);
}

.flex {
  display: flex;
}

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

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

.gap-lg {
  gap: var(--space-lg);
}

/* --- Animations --- */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInFromBottom {
  from {
    opacity: 0;
    transform: translateY(100%);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* --- Home Background Images --- */
.home-bg-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.home-bg-image {
  position: absolute;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(30px) brightness(0.25) saturate(0.8);
  opacity: 0;
  animation: bgFadeInOut 25s ease-in-out infinite;
}

.home-bg-image:nth-child(1) {
  animation-delay: 0s;
}

.home-bg-image:nth-child(2) {
  animation-delay: 5s;
}

.home-bg-image:nth-child(3) {
  animation-delay: 10s;
}

.home-bg-image:nth-child(4) {
  animation-delay: 15s;
}

.home-bg-image:nth-child(5) {
  animation-delay: 20s;
}

@keyframes bgFadeInOut {
  0% {
    opacity: 0;
    transform: scale(1.1);
  }

  10% {
    opacity: 0.6;
    transform: scale(1);
  }

  20% {
    opacity: 0;
    transform: scale(1.1);
  }

  100% {
    opacity: 0;
    transform: scale(1.1);
  }
}

/* --- Page Background Image (static, single image) --- */
.page-bg-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.page-bg-image {
  position: absolute;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(30px) brightness(0.25) saturate(0.8);
  opacity: 0;
  animation: pageBgFadeIn 1.5s ease-out 0.3s forwards;
}

@keyframes pageBgFadeIn {
  0% {
    opacity: 0;
    transform: scale(1.1);
  }

  100% {
    opacity: 0.6;
    transform: scale(1);
  }
}

/* --- Home Page Layout --- */
body.home-page {
  overflow: hidden;
  height: 100vh;
  --bg-primary: #111113;
  background: var(--bg-gradient);
}

/* Home page animations - force animation on load */
body.home-page .home-logo {
  animation: fadeInUp 0.8s ease-out 0.1s both;
}

body.home-page .home-name {
  animation: fadeInUp 0.8s ease-out 0.2s both;
}

body.home-page .home-roles {
  animation: fadeInUp 0.8s ease-out 0.4s both;
}

body.home-page .home-profile {
  animation: fadeInUp 0.8s ease-out 0.6s both;
}

body.home-page .home-info {
  animation: fadeInUp 0.8s ease-out 0.8s both;
}

.home-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(var(--space-md), 2vh, var(--space-2xl));
  padding-bottom: calc(var(--bottom-nav-height) + clamp(var(--space-md), 2vh, var(--space-2xl)));
  max-width: 1400px;
  margin: 0 auto;
  box-sizing: border-box;
}

.home-header {
  text-align: center;
  margin-bottom: clamp(var(--space-xl), 3vh, var(--space-3xl));
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: left;
  gap: var(--space-lg);
}

.home-logo {
  width: clamp(80px, 10vw, 120px);
  flex-shrink: 0;
}

.home-logo img {
  width: 100%;
  height: auto;
}

.home-name {
  font-size: clamp(2.5rem, 4vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: var(--space-xs);
  color: #ffffff;
}

.home-roles {
  font-size: clamp(1rem, 1.5vw, 1.25rem);
  color: var(--text-secondary);
  font-weight: 500;
}

.home-content {
  display: grid;
  grid-template-columns: clamp(180px, 22vw, 400px) 1fr;
  gap: clamp(var(--space-lg), 3vw, var(--space-3xl));
  align-items: center;
}

/* Profile Image */
.home-profile {
  display: flex;
  justify-content: center;
}

.home-profile-image {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.home-profile-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Info Card */
.home-info-card {
  padding: clamp(var(--space-md), 2vh, var(--space-2xl));
  display: flex;
  flex-direction: column;
  gap: clamp(var(--space-sm), 1.5vh, var(--space-lg));
}

.home-bio {
  font-size: clamp(0.85rem, 1.1vw, 1rem);
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 0;
}

.home-bio strong {
  color: var(--text-primary);
  font-weight: 600;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding-top: clamp(var(--space-sm), 1.5vh, var(--space-lg));
  border-top: 1px solid var(--glass-border);
  margin-top: clamp(var(--space-xs), 1vh, var(--space-md));
}

/* --- Responsive --- */
@media (max-width: 1200px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

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

@media (max-width: 768px) {
  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.75rem;
  }

  h3 {
    font-size: 1.375rem;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .container {
    padding: 0 var(--space-md);
  }

  .section {
    padding: var(--space-2xl) 0;
  }

  body.home-page {
    overflow: auto;
    height: auto;
  }

  .home-container {
    height: auto;
    min-height: 100vh;
    padding: var(--space-lg);
    padding-bottom: calc(var(--bottom-nav-height) + var(--space-lg));
  }

  .home-content {
    grid-template-columns: 1fr;
    gap: var(--space-xl);
  }

  .home-profile {
    max-width: 280px;
    margin: 0 auto;
  }

  .home-info-card {
    padding: var(--space-lg);
  }

  .home-bio {
    font-size: 0.9375rem;
  }

  .home-actions {
    flex-direction: column;
  }

  .home-actions .glass-btn {
    width: 100%;
    justify-content: center;
  }

  .home-header {
    flex-direction: column;
    text-align: center;
    gap: var(--space-md);
  }
}

/* --- Page Loader --- */
.page-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.page-loader.loaded {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.page-loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  animation: loaderSpin 0.7s linear infinite;
}

@keyframes loaderSpin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   Transizioni di pagina (Vue Router <Transition>)
   - slide-left / slide-right tra le sezioni della navbar (direzionale)
   - fade per i drill-down (blog/progetti/riassunti)
   ============================================ */
.slide-left-enter-active,
.slide-left-leave-active,
.slide-right-enter-active,
.slide-right-leave-active {
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.slide-left-enter-from {
  opacity: 0;
  transform: translateX(40px);
}
.slide-left-leave-to {
  opacity: 0;
  transform: translateX(-40px);
}
.slide-right-enter-from {
  opacity: 0;
  transform: translateX(-40px);
}
.slide-right-leave-to {
  opacity: 0;
  transform: translateX(40px);
}

.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.2s ease;
}
.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {

  .slide-left-enter-active,
  .slide-left-leave-active,
  .slide-right-enter-active,
  .slide-right-leave-active,
  .fade-enter-active,
  .fade-leave-active {
    transition: opacity 0.15s ease;
  }

  .slide-left-enter-from,
  .slide-left-leave-to,
  .slide-right-enter-from,
  .slide-right-leave-to {
    transform: none;
  }
}