/* ============================================================
   Responsive
   Breakpoint: 1024 (tablet / nav compatta) · 768 · 480 · landscape basso · touch
   ============================================================ */

/* ---------- Tablet e sotto: nav compatta, sezioni a altezza naturale ---------- */
@media (max-width: 1024px) {
  /* Nav: logo a sinistra, tema + burger raggruppati a destra */
  .pf-nav { padding: 12px clamp(16px, 4vw, 40px); }
  .pf-nav-links { display: none; }
  .pf-burger { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; margin-left: 8px; flex-shrink: 0; }
  .pf-theme-btn { margin-left: auto; width: 44px; height: 44px; }
  .pf-nav-scrolled { top: 10px; width: min(420px, calc(100vw - 24px)); padding: 6px 6px 6px 18px; }
  .pf-logo { font-size: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

  /* Menu a tutto schermo: scrollabile se lo schermo è basso */
  .pf-mobile-menu { height: 100vh; height: 100dvh; overflow-y: auto; justify-content: flex-start; gap: 22px; padding: 96px 24px 48px; }
  .pf-mobile-menu a { font-size: clamp(20px, 5vw, 26px); padding: 4px 12px; }
  .pf-mobile-menu a:first-child { margin-top: auto; }
  .pf-mobile-menu a:last-child { margin-bottom: auto; }

  /* Niente più "una sezione = una schermata": l'altezza segue il contenuto */
  .pf-section { min-height: auto; justify-content: flex-start; padding: 72px clamp(16px, 5vw, 56px) 48px; }
  .pf-section-head { margin-bottom: 28px; }
  .pf-footer { min-height: auto; padding: 48px clamp(16px, 5vw, 56px) calc(32px + env(safe-area-inset-bottom)); }

  /* Hero */
  .pf-hero { min-height: 100vh; min-height: 100svh; padding: 88px clamp(16px, 5vw, 56px) 36px; }
  .pf-hero-inner { grid-template-columns: 1fr; gap: 8px; text-align: center; align-items: center; }
  .pf-hero-text { order: 2; padding-bottom: 0; }
  .pf-hero-skin { order: 1; min-height: 0; }
  .pf-avatar--hero { width: min(68vw, 340px, 42svh); margin-bottom: 10px; }
  .pf-skin-halo { width: min(300px, 90%); }
  #root .pf-hero-tagline { margin-left: auto; margin-right: auto; }
  .pf-hero-actions, .pf-social-row { justify-content: center; }
  .pf-scroll-hint { display: none; }

  /* Elementi decorativi / flottanti */
  .pf-dot-nav { display: none; }
  .pf-fab span { display: none; }
  .pf-fab { padding: 0; width: 52px; height: 52px; justify-content: center; }
  .pf-comp { width: calc(clamp(64px, 14vw, 100px) * var(--comp-scale, 1)); }
  .pf-comp-bubble { max-width: min(200px, 60vw); font-size: 12px; }


  /* Footer */
  .pf-footer-top { grid-template-columns: 1fr; gap: 28px; text-align: center; justify-items: center; }
  #root .pf-footer-brand p { margin-left: auto; margin-right: auto; }
  .pf-footer-links, .pf-footer-socials { align-items: center; }
  .pf-footer-bottom { justify-content: center; text-align: center; }
}

/* ---------- Smartphone ---------- */
@media (max-width: 768px) {
  .pf-hero h1 { font-size: clamp(34px, 11vw, 56px); }
  .pf-hero-actions { gap: 10px; }
  .pf-btn { padding: 13px 22px; font-size: 14px; }
  .pf-terrain-svg { height: 36px; }
  .pf-project-body { padding: 18px; }
  .pf-exp-card { padding: 18px; }
  .pf-cv-card { padding: 18px; }
}

@media (max-width: 480px) {
  .pf-nav-scrolled { padding-left: 14px; }
  .pf-logo-mark { width: 11px; height: 11px; }
  .pf-eyebrow { font-size: 10.5px; padding: 5px 12px; }
  .pf-hero-actions { flex-direction: column; align-items: stretch; }
  .pf-hero-actions .pf-btn { justify-content: center; }
  .pf-section-eyebrow { font-size: 11px; }
  .pf-exp-card-head { gap: 12px; }
  .pf-exp-logo-lg { width: 48px; height: 48px; border-radius: 14px; font-size: 22px; }
  .pf-exp-org { font-size: 17px; }

  /* Ruoli: la data va a capo sotto il titolo invece di schiacciarlo */
  .pf-role-chip { flex-wrap: wrap; row-gap: 2px; }
  .pf-role-chip-title { min-width: 0; flex: 1 1 60%; }
  .pf-role-chip-date { flex-basis: 100%; margin-left: 24px; }
  .pf-subrole-list { margin-left: 14px; padding-left: 16px; }
  .pf-subrole-item::before { left: -16px; width: 16px; }

  .pf-cv-edu-top { flex-direction: column; gap: 2px; }
  .pf-footer-bottom { flex-direction: column; }
}

@media (max-width: 380px) {
  .pf-comp { width: calc(56px * var(--comp-scale, 1)); }
  .pf-project-actions { gap: 6px; }
}

/* ---------- Smartphone in orizzontale / schermi molto bassi ---------- */
@media (max-height: 520px) and (orientation: landscape) {
  .pf-nav { padding-top: 8px; padding-bottom: 8px; }
  .pf-hero { min-height: auto; padding-top: 72px; padding-bottom: 24px; }
  .pf-hero-inner { grid-template-columns: 1.1fr 0.9fr; text-align: left; align-items: center; }
  .pf-hero-text { order: 1; }
  .pf-hero-skin { order: 2; }
  .pf-avatar--hero { width: min(100%, 260px, 62svh); }
  #root .pf-hero-tagline { margin-left: 0; margin-right: 0; }
  .pf-hero-actions, .pf-social-row { justify-content: flex-start; }
  .pf-hero-actions { flex-direction: row; align-items: center; margin-top: 16px; }
  .pf-hero h1 { font-size: clamp(30px, 6vw, 44px); }
  .pf-section { padding-top: 64px; }
  .pf-mobile-menu { padding-top: 70px; gap: 12px; }
}

/* ---------- Dispositivi touch: niente effetti hover "appiccicosi" ---------- */
@media (hover: none) {
  .pf-project-card:hover, .pf-exp-card:hover, .pf-cv-card:hover,
  .pf-btn:hover, .pf-social-icon:hover, .pf-fab:hover, .pf-back-top:hover,
  .pf-footer-link:hover, .pf-role-chip:hover, .pf-theme-btn:hover { transform: none; }
  .pf-theme-btn:hover { background: var(--panel); color: var(--text); }
  .pf-social-icon { width: 44px; height: 44px; }
  /* background-attachment: fixed è lento/ignorato su iOS e Android */
  #root { background-attachment: scroll; }
}

/* ---------- Schermi molto grandi ---------- */
@media (min-width: 1600px) {
  .pf-hero-inner, .pf-footer-top, .pf-footer-bottom { max-width: 1320px; }
  .pf-section > .pf-section-head, .pf-section > .pf-project-grid, .pf-section > .pf-exp-grid,
  .pf-section > .pf-cv-grid, .pf-section > .pf-skills-grid { max-width: 1320px; }
}

/* ============================================================
   Revisione tablet
   ============================================================ */

/* Righe di testo più equilibrate (niente parole orfane tipo "online.") */
.pf-hero-tagline, .pf-section-desc, .pf-project-desc, .pf-exp-summary,
.pf-contact-fs-text p, .pf-footer-brand p, #root h1, #root h2 { text-wrap: balance; }
.pf-project-desc, .pf-exp-summary { text-wrap: pretty; }

/* Riquadri esperienza: le righe dei ruoli si adattano alla larghezza REALE del
   riquadro (non a quella dello schermo), così le date non sbordano mai. */
.pf-exp-card { container-type: inline-size; }
.pf-exp-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.pf-role-chip-title { min-width: 0; overflow-wrap: anywhere; }
@container (max-width: 430px) {
  .pf-role-chip { flex-wrap: wrap; row-gap: 2px; }
  .pf-role-chip-title { flex: 1 1 55%; }
  .pf-role-chip-date { flex-basis: 100%; margin-left: 24px; }
}
@container (max-width: 540px) {
  .pf-role-sub { flex-wrap: wrap; row-gap: 2px; }
  .pf-role-sub .pf-role-chip-title { flex: 1 1 55%; }
  .pf-role-sub .pf-role-chip-date { flex-basis: 100%; margin-left: 24px; }
}


/* Tablet (601–1024px): hero più grande e testi più leggibili */
@media (min-width: 601px) and (max-width: 1024px) {
  .pf-hero-inner { max-width: 720px; gap: 12px; }
  .pf-avatar--hero { width: min(58vw, 440px, 44svh); }
  .pf-skin-halo { width: min(420px, 96%); }
  .pf-eyebrow { font-size: 12.5px; }
  .pf-hero h1 { font-size: clamp(52px, 9vw, 76px); }
  .pf-hero-role { font-size: clamp(18px, 2.6vw, 22px); }
  .pf-hero-tagline { font-size: clamp(16px, 2.3vw, 19px); max-width: 52ch; }
  .pf-hero-actions { margin-top: 28px; }
  .pf-btn { padding: 15px 30px; font-size: 15.5px; }
  .pf-social-icon { width: 46px; height: 46px; }
  .pf-section { padding-left: clamp(28px, 6vw, 64px); padding-right: clamp(28px, 6vw, 64px); }
  .pf-section-desc { font-size: 16px; }
  .pf-project-title { font-size: 20px; }
  .pf-project-desc { font-size: 14.5px; }
  .pf-tag { font-size: 11.5px; }
  .pf-project-action { font-size: 13px; padding: 8px 14px; }
  .pf-exp-summary { font-size: 14px; }
  .pf-role-chip-title { font-size: 14.5px; }
  .pf-role-sub .pf-role-chip-title { font-size: 13.5px; }
  .pf-role-chip-date { font-size: 12px; }
  .pf-cv-card h3 { font-size: 16px; }
  .pf-cv-info-list li, .pf-cv-lang-top { font-size: 14.5px; }
  .pf-cv-edu-title { font-size: 14px; }
  .pf-cv-edu-inst, .pf-cv-cert-issuer { font-size: 13px; }
  .pf-cv-cert-title { font-size: 14px; }
  .pf-cv-edu-dates, .pf-cv-cert-year, .pf-cv-lang-level { font-size: 11.5px; }
  .pf-footer-brand p, .pf-footer-link { font-size: 15px; }
}

/* Popup contatti: su schermi piccoli resta ancorato sopra il tastino */
@media (max-width: 480px) {
  .pf-contact-popup { right: max(16px, env(safe-area-inset-right)); width: calc(100vw - 32px); padding: 18px 18px 20px; }
}
@media (max-height: 520px) {
  .pf-contact-popup { max-height: calc(100dvh - 166px); padding-top: 14px; }
  .pf-avatar--contact { width: min(72px, 22svh); }
}
