/* ==========================================================================
   Max Trip — maxtrip.it
   ========================================================================== */

@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f3f1ec;
  --surface: #ebe8e1;
  --fg: #121212;
  --muted: #67635c;
  --line: rgba(18, 18, 18, 0.12);
  --line-strong: rgba(18, 18, 18, 0.24);
  --field-line: rgba(18, 18, 18, 0.5);
  --wave-rest: rgba(18, 18, 18, 0.16);
  --accent: #cc2f12;
  --on-accent: #ffffff;

  --font: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --gutter: clamp(16px, 4vw, 48px);
  --max: 1280px;
  --radius: 16px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f0f0e;
    --surface: #171715;
    --fg: #efece6;
    --muted: #928e86;
    --line: rgba(239, 236, 230, 0.12);
    --line-strong: rgba(239, 236, 230, 0.26);
    --field-line: rgba(239, 236, 230, 0.42);
    --wave-rest: rgba(239, 236, 230, 0.16);
    --accent: #ff5535;
    --on-accent: #0f0f0e;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f0e;
  --surface: #171715;
  --fg: #efece6;
  --muted: #928e86;
  --line: rgba(239, 236, 230, 0.12);
  --line-strong: rgba(239, 236, 230, 0.26);
  --field-line: rgba(239, 236, 230, 0.42);
  --wave-rest: rgba(239, 236, 230, 0.16);
  --accent: #ff5535;
  --on-accent: #0f0f0e;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

::selection { background: var(--accent); color: var(--on-accent); }

a { color: inherit; }
svg { display: block; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.wrap {
  max-width: var(--max);
  margin-inline: auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

.skip {
  position: absolute;
  left: -9999px;
  top: 12px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  text-decoration: none;
  font-size: 14px;
}
.skip:focus { left: 12px; }

/* Shared bits ------------------------------------------------------------ */
.label,
.hero-fullname,
.onair,
.wave-meta,
.field label,
.tool-top,
.tool-size,
.timeline dt,
.footer-row {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 54px;
  padding: 0 26px;
  border: 0;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.005em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease);
}
.btn .arrow { width: 18px; height: 18px; transition: transform 0.3s var(--ease); }
.btn:hover { background: var(--accent); color: var(--on-accent); }
.btn:hover .arrow { transform: translateX(4px); }
.btn[disabled] { opacity: 0.55; cursor: progress; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--fg);
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.icon-btn-lg { width: 54px; height: 54px; }
.icon-btn-lg svg { width: 21px; height: 21px; }

/* Topbar ----------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease);
}
.topbar.is-scrolled { border-bottom-color: var(--line); }

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 68px;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  font-size: 19px;
  font-weight: 800;
  font-stretch: 125%;
  letter-spacing: -0.03em;
  text-decoration: none;
}
.brand-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.nav { display: flex; gap: 32px; font-size: 15px; }
.nav a {
  position: relative;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}
.nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s var(--ease);
}
.nav a:hover,
.nav a[aria-current="true"] { color: var(--fg); }
.nav a[aria-current="true"]::after { transform: scaleX(1); }

.icons { display: flex; gap: 8px; }

/* Hero ------------------------------------------------------------------- */
.hero {
  padding-top: clamp(32px, 7vw, 88px);
  padding-bottom: clamp(56px, 8vw, 104px);
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.onair {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
}
.onair-dot,
.rec-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.onair-dot { animation: pulse 2.2s var(--ease) infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  70%  { box-shadow: 0 0 0 9px color-mix(in srgb, var(--accent) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.hero-fullname { color: var(--muted); }

.hero-title {
  margin: clamp(20px, 3vw, 36px) 0 0;
  font-size: clamp(4.25rem, 26vw, 9.5rem);
  font-weight: 800;
  font-stretch: 125%;
  line-height: 0.84;
  letter-spacing: -0.055em;
  margin-left: -0.04em;
}
.hero-title span { display: block; }

@media (min-width: 600px) {
  .hero-title { font-size: min(17.8vw, calc((var(--max) - 96px) / 5.1)); white-space: nowrap; }
  .hero-title span { display: inline; }
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 28px 24px;
  align-items: end;
  margin-top: clamp(28px, 4vw, 52px);
}
.hero-lead {
  grid-column: 1 / span 7;
  max-width: 30ch;
  margin: 0;
  font-size: clamp(1.3rem, 2.3vw, 1.85rem);
  font-weight: 450;
  line-height: 1.28;
  letter-spacing: -0.015em;
}
.hero-cta {
  grid-column: 8 / -1;
  justify-self: end;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.wave-wrap { margin-top: clamp(44px, 6vw, 80px); }
.wave {
  display: block;
  width: 100%;
  height: clamp(84px, 11vw, 136px);
  cursor: pointer;
  touch-action: pan-y;
}
.wave-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
}
.wave-meta .rec-dot { width: 6px; height: 6px; margin-right: 8px; vertical-align: 1px; }
.wave-left { display: flex; align-items: center; gap: 12px; }
.wave-toggle {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.wave-toggle svg { width: 14px; height: 14px; }
.wave-toggle .i-play,
.wave-toggle[aria-pressed="true"] .i-pause { display: none; }
.wave-toggle[aria-pressed="true"] .i-play { display: block; }
.wave-toggle:hover { background: var(--fg); border-color: var(--fg); color: var(--bg); }

.motion-paused .onair-dot { animation: none; }
.motion-paused .wave-meta .rec-dot { background: var(--muted); }
[data-timecode] { font-variant-numeric: tabular-nums; }

/* Sections --------------------------------------------------------------- */
.section {
  padding-block: clamp(80px, 11vw, 150px);
  border-top: 1px solid var(--line);
}

.section-head {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px 24px;
  margin-bottom: clamp(44px, 6vw, 80px);
}
.label {
  grid-column: 1 / span 3;
  padding-top: 0.9em;
  color: var(--muted);
}
.head-text { grid-column: 4 / -1; }
.head-text h2 {
  margin: 0;
  font-size: clamp(2.75rem, 7vw, 6rem);
  font-weight: 800;
  font-stretch: 115%;
  line-height: 0.92;
  letter-spacing: -0.045em;
}
.head-text p {
  max-width: 46ch;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 1.4vw, 1.2rem);
  line-height: 1.5;
}

/* Skills ----------------------------------------------------------------- */
.skills {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: clamp(24px, 5vw, 72px);
  margin: 0;
  padding: 0;
  list-style: none;
}
.skill {
  position: relative;
  display: grid;
  grid-template-columns: 52px 1fr;
  column-gap: 12px;
  padding: 30px 0 32px;
  border-top: 1px solid var(--line);
}
.skill::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.6s var(--ease);
}
.skill:hover::before { transform: scaleX(1); }
.skill:nth-last-child(-n+2) { border-bottom: 1px solid var(--line); }
.skill .n {
  padding-top: 0.55em;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  transition: color 0.3s var(--ease);
}
.skill:hover .n { color: var(--accent); }
.skill h3 {
  margin: 0;
  font-size: clamp(1.4rem, 2.1vw, 1.75rem);
  font-weight: 700;
  font-stretch: 112%;
  line-height: 1.15;
  letter-spacing: -0.025em;
}
.skill p {
  grid-column: 2;
  max-width: 44ch;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15.5px;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
  margin: clamp(56px, 7vw, 96px) 0 0;
}
.timeline div {
  padding-left: 16px;
  border-left: 1px solid var(--line-strong);
}
.timeline dt { color: var(--accent); }
.timeline dd { margin: 8px 0 0; font-size: 15.5px; line-height: 1.4; }

/* Tools ------------------------------------------------------------------ */
.tools {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 16px;
}
.tool {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.3s var(--ease), transform 0.4s var(--ease);
}
@media (hover: hover) {
  .tool:hover { border-color: var(--line-strong); transform: translateY(-3px); }
}
.tool-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 11.5px;
}
.badge {
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--fg);
}
.tool h3 {
  margin: 14px 0 0;
  font-size: 1.4rem;
  font-weight: 700;
  font-stretch: 110%;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.tool p { flex: 1; margin: 0; color: var(--muted); font-size: 15.5px; }
.tool-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.tool-size { color: var(--muted); }

.dl {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px 0 16px;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease);
}
.dl svg { width: 17px; height: 17px; }
.dl:hover { background: var(--accent); color: var(--on-accent); }
.dl.is-soon {
  background: transparent;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  cursor: default;
}

.tools-empty {
  margin: 0;
  padding: 40px 26px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

/* Contact ---------------------------------------------------------------- */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 40px 24px;
}

.direct {
  grid-column: 1 / span 3;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
}
.direct-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  text-decoration: none;
  background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 1px no-repeat;
  transition: background-size 0.4s var(--ease);
}
.direct-link svg { width: 18px; height: 18px; flex: none; }
.direct-link:hover { background-size: 100% 1px; }
.direct-place { margin-top: 6px; color: var(--muted); font-size: 15px; }

.form {
  position: relative;
  grid-column: 4 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 36px 28px;
}
.field { display: flex; flex-direction: column; min-width: 0; }
.field-full { grid-column: 1 / -1; }
.field label { margin-bottom: 6px; color: var(--muted); }

.field input,
.field textarea {
  width: 100%;
  padding: 10px 0 14px;
  border: 0;
  border-bottom: 1px solid var(--field-line);
  border-radius: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: clamp(1.15rem, 1.6vw, 1.4rem);
  letter-spacing: -0.01em;
  outline: none;
  transition: border-color 0.25s var(--ease);
}
.field textarea { min-height: 150px; line-height: 1.45; resize: vertical; }
.field input:focus,
.field textarea:focus { border-bottom-color: var(--fg); }
.field input:-webkit-autofill {
  -webkit-text-fill-color: var(--fg);
  -webkit-box-shadow: 0 0 0 100px var(--bg) inset;
}

.err { color: var(--accent); font-size: 13.5px; }
.err:empty { display: none; }
.field .err { margin-top: 8px; }
.has-error input,
.has-error textarea { border-bottom-color: var(--accent); }

.check-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.5;
  cursor: pointer;
}
.check-label input {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  place-items: center;
  flex: none;
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  border: 1.5px solid var(--field-line);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.check-label input::after {
  content: "";
  width: 10px;
  height: 5px;
  margin-top: -2px;
  border-left: 2px solid var(--bg);
  border-bottom: 2px solid var(--bg);
  transform: rotate(-45deg) scale(0);
  transition: transform 0.2s var(--ease);
}
.check-label input:checked { background: var(--fg); border-color: var(--fg); }
.check-label input:checked::after { transform: rotate(-45deg) scale(1); }
.check.has-error .check-label input { border-color: var(--accent); }
.check .err { display: block; margin: 8px 0 0 32px; }
.check .err:empty { display: none; }

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 20px 24px;
  flex-wrap: wrap;
}
.form-status { margin: 0; font-size: 15px; }
.form-status.is-ok { color: var(--fg); }
.form-status.is-ok::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 10px;
  border-radius: 50%;
  background: #23b26d;
  vertical-align: 1px;
}
.form-status.is-err { color: var(--accent); }

.form-note { display: none; grid-column: 1 / -1; margin: 0; }
.form-note:target { display: block; }
.form-note.is-err { color: var(--accent); }

.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Footer ----------------------------------------------------------------- */
.footer {
  padding-block: 32px max(32px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px 32px;
  color: var(--muted);
  font-size: 11.5px;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.footer-links a {
  display: inline-block;
  padding-block: 6px;
  text-decoration: none;
  transition: color 0.2s var(--ease);
}
.footer-links a:hover { color: var(--fg); }

/* Pagina privacy ----------------------------------------------------------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-block: 10px;
  color: var(--muted);
  font-size: 15px;
  text-decoration: none;
  transition: color 0.2s var(--ease);
}
.back-link svg { width: 16px; height: 16px; transform: rotate(180deg); }
.back-link:hover { color: var(--fg); }

.legal { padding-block: clamp(40px, 7vw, 96px) clamp(72px, 10vw, 128px); }
.legal h1 {
  margin: 18px 0 0;
  font-size: clamp(2.5rem, 7vw, 5.5rem);
  font-weight: 800;
  font-stretch: 115%;
  line-height: 0.95;
  letter-spacing: -0.045em;
}
.legal-updated { margin: 20px 0 0; color: var(--muted); font-size: 15px; }
.legal-body { max-width: 72ch; margin-top: clamp(40px, 6vw, 72px); }
.legal-body h2 {
  margin: 48px 0 12px;
  font-size: clamp(1.3rem, 2vw, 1.6rem);
  font-weight: 700;
  font-stretch: 110%;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.legal-body h2:first-child { margin-top: 0; }
.legal-body p,
.legal-body li { color: var(--muted); }
.legal-body p { margin: 0 0 14px; }
.legal-body ul { margin: 0 0 14px; padding-left: 1.2em; }
.legal-body li { margin-bottom: 8px; }
.legal-body strong { color: var(--fg); font-weight: 600; }
.legal-body a { color: var(--fg); text-underline-offset: 3px; }

/* Reveal on scroll ------------------------------------------------------- */
.js .reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
}
.js .reveal.is-in { opacity: 1; transform: none; }

/* Responsive ------------------------------------------------------------- */
@media (max-width: 860px) {
  .label,
  .head-text,
  .hero-lead,
  .hero-cta,
  .direct,
  .form { grid-column: 1 / -1; }
  .label { padding-top: 0; }
  .hero-cta { justify-self: start; }
  .skills { grid-template-columns: 1fr; }
  .skill:nth-last-child(2) { border-bottom: 0; }
  .timeline { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 32px; }
  .direct { flex-direction: row; flex-wrap: wrap; gap: 14px 28px; }
  .direct-place { margin-top: 0; }
}

@media (max-width: 640px) {
  .nav { display: none; }
  .hero-fullname { display: none; }
  .wave-meta-mid { display: none; }
  .form { grid-template-columns: 1fr; }
  .skill { grid-template-columns: 40px 1fr; }
  .tool { padding: 22px; }
}

@media (max-width: 400px) {
  .wave-spec { display: none; }
  .btn { padding: 0 22px; }
}

/* Schermi molto grandi */
@media (min-width: 1800px) {
  :root { --max: 1520px; }
  body { font-size: 18px; }
}

/* Modalità a contrasto elevato di Windows */
@media (forced-colors: active) {
  .check-label input { appearance: auto; -webkit-appearance: auto; }
  .check-label input::after { display: none; }
  .btn, .dl { border: 1px solid ButtonText; }
}

@media print {
  .topbar, .wave-wrap, .hero-cta, .form, .skip { display: none !important; }
  body { background: #fff; color: #000; }
  .section { padding-block: 32px; }
  .js .reveal { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .js .reveal { opacity: 1; transform: none; }
}
