:root{
  --blue-dark:#0B1F33;
  --blue:#143A5C;
  --gold:#C9A24D;
  --light:#F2F2F2;
  --white:#ffffff;

  --radius:18px;
  --shadow:0 12px 35px rgba(0,0,0,.10);
  --max:1120px;

  --topbar-h: 66px;
}

*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
html{ scroll-behavior:smooth; }

body{
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:var(--light);
  color:var(--blue-dark);
  line-height:1.55;
}

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

.container{ width:min(var(--max), 92vw); margin:0 auto; }

.section{ padding:56px 0; }
.section.dark{ background:var(--blue-dark); color:var(--white); }
.section.light{ background:var(--white); }

/* Offset ancore sotto topbar */
section{ scroll-margin-top: calc(var(--topbar-h) + 14px); }

.kicker{
  font-size:.95rem;
  opacity:.85;
  margin:0 0 10px;
  letter-spacing:.02em;
}

h1,h2,h3,h4{ margin:0 0 14px; line-height:1.15; }
h1{ font-size: clamp(1.8rem, 5vw, 2.6rem); }
h2{ font-size: clamp(1.4rem, 4vw, 2.0rem); }
h3{ font-size: 1.1rem; }
p{ margin:0 0 12px; }

.accent{ color:var(--gold); }
.lead{ font-size:1.05rem; opacity:.95; max-width:60ch; }
.muted{ opacity:.85; }

.grid{ display:grid; gap:16px; margin-top:18px; }
.grid-2, .grid-3, .grid-4{ grid-template-columns:1fr; }

@media (min-width:720px){
  .section{ padding:72px 0; }
  .grid-2{ grid-template-columns:repeat(2,1fr); }
  .grid-3{ grid-template-columns:repeat(3,1fr); }
  .grid-4{ grid-template-columns:repeat(4,1fr); }
}
@media (min-width:1024px){
  .grid{ gap:22px; }
}

.card{
  background:var(--white);
  border-radius:var(--radius);
  padding:20px;
  box-shadow:var(--shadow);
  border:1px solid rgba(11,31,51,.08);
}
.section.dark .card{
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.10);
  box-shadow:none;
}

.badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  background:var(--gold);
  color:var(--blue-dark);
  font-weight:700;
  padding:8px 12px;
  border-radius:999px;
  margin-top:10px;
  font-size:.95rem;
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:10px 14px;
  border-radius:999px;
  font-weight:800;
  text-decoration:none;
  border:1px solid transparent;
  line-height:1;
  white-space:nowrap;
}
.btn.primary{ background:var(--gold); color:var(--blue-dark); }
.btn.ghost{
  background:transparent;
  border-color:rgba(255,255,255,.28);
  color:var(--white);
}

/* HERO */
.hero{
  position:relative;
  overflow:hidden;
  border-radius:calc(var(--radius) + 6px);
  padding:26px;
  background:linear-gradient(135deg, rgba(201,162,77,.18), rgba(255,255,255,.06));
  border:1px solid rgba(255,255,255,.12);
}
.route{
  position:absolute;
  inset:auto -10% 14% -10%;
  height:2px;
  background:repeating-linear-gradient(
    90deg,
    rgba(201,162,77,.9) 0 18px,
    rgba(201,162,77,0) 18px 32px
  );
  transform:rotate(-6deg);
  opacity:.55;
}

/* =========================
   STICKY MENU + ACTIVE LINK
========================= */
.topbar{
  position:sticky;
  top:0;
  z-index:999;
  background:rgba(11,31,51,.92);
  backdrop-filter:blur(10px);
  border-bottom:1px solid rgba(255,255,255,.10);
}
.topbar-inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  min-height:var(--topbar-h);
  padding:10px 0;
}
.brand{
  display:flex; align-items:center; gap:10px;
  text-decoration:none; color:var(--white);
  font-weight:800; letter-spacing:.02em;
}
.brand-dot{
  width:12px;height:12px;border-radius:999px;
  background:var(--gold);
  box-shadow:0 0 0 4px rgba(201,162,77,.20);
}
.brand-text{ font-size:1.02rem; }

.nav{ display:none; gap:16px; }
.nav a{
  color:rgba(255,255,255,.80);
  text-decoration:none;
  font-weight:700;
  font-size:.95rem;
  padding:8px 10px;
  border-radius:999px;
  transition: background .2s ease, color .2s ease;
}
.nav a:hover{ color:var(--white); background: rgba(255,255,255,.08); }

/* ✅ Link attivo */
.nav a.active,
.mobile-nav a.active{
  color: var(--blue-dark);
  background: var(--gold);
}

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

.burger{
  display:inline-flex; flex-direction:column; gap:4px;
  background:transparent; border:0; padding:8px; cursor:pointer;
}
.burger span{
  width:22px; height:2px;
  background:rgba(255,255,255,.85);
  border-radius:2px;
}

.mobile-nav{
  padding:10px 0 18px;
  border-top:1px solid rgba(255,255,255,.10);
}
.mobile-nav a{
  display:block;
  padding:12px 0;
  color:rgba(255,255,255,.86);
  text-decoration:none;
  font-weight:800;
}
.mobile-actions{
  display:flex; gap:10px; flex-wrap:wrap;
  padding-top:12px;
}

@media (min-width:920px){
  .nav{ display:flex; }
  .actions{ display:flex; }
  .burger{ display:none; }
  .mobile-nav{ display:none !important; }
}

/* =========================
   HOLDING DIAGRAM
========================= */
.diagram{ margin-top:18px; display:grid; gap:14px; }
.diagram .node{
  border-radius:16px;
  padding:14px 16px;
  border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.06);
  text-align:center;
}
.section.light .diagram .node{
  border:1px solid rgba(11,31,51,.10);
  background:rgba(20,58,92,.03);
}
.node.holding{
  background:rgba(201,162,77,.16);
  border:1px solid rgba(201,162,77,.40);
}
.node small{ opacity:.85; display:block; margin-top:4px; }
.diagram .children{
  display:grid; gap:14px; grid-template-columns:1fr;
}
@media (min-width:720px){
  .diagram .children{ grid-template-columns:repeat(3,1fr); }
}
.connector{
  width:2px; height:18px;
  background:rgba(201,162,77,.85);
  margin:8px auto;
  border-radius:2px;
  opacity:.85;
}

/* =========================
   SPLIT
========================= */
.split{ display:grid; gap:16px; grid-template-columns:1fr; }
@media (min-width:720px){
  .split{ grid-template-columns:1fr 1fr; }
}
.panel{
  border-radius:var(--radius);
  padding:20px;
  border:1px solid rgba(11,31,51,.10);
  background:var(--white);
  box-shadow:var(--shadow);
}
.panel ul{ margin:0; padding-left:18px; }
.panel li{ margin:8px 0; }
.panel.before{ background:linear-gradient(135deg, rgba(20,58,92,.06), rgba(255,255,255,1)); }
.panel.after{ background:linear-gradient(135deg, rgba(201,162,77,.12), rgba(255,255,255,1)); }

/* =========================
   TIMELINE PORTI (mobile-first)
========================= */
.timeline{
  display:grid;
  gap:14px;
  margin-top:18px;
}

.t-item{
  display:grid;
  grid-template-columns: 28px 1fr;
  gap:14px;
  align-items:start;
}

.t-left{
  position:relative;
  display:flex;
  justify-content:center;
}

.t-dot{
  width:12px;height:12px;border-radius:999px;
  background:var(--gold);
  box-shadow: 0 0 0 4px rgba(201,162,77,.22);
  margin-top: 18px;
  z-index: 2;
}

.t-line{
  position:absolute;
  top: 34px;
  bottom: -10px;
  width:2px;
  background: rgba(11,31,51,.12);
}

.t-card{
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(11,31,51,.08);
}

.t-head{
  display:flex;
  justify-content:space-between;
  gap:14px;
  align-items:flex-start;
}

.t-title{ margin-bottom:6px; }
.t-desc{ margin: 10px 0 0; opacity:.92; }

.t-meta{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.pill{
  display:inline-flex;
  align-items:center;
  padding:6px 10px;
  border-radius:999px;
  font-weight:800;
  font-size:.85rem;
  background: rgba(11,31,51,.06);
  border: 1px solid rgba(11,31,51,.10);
}
.pill.gold{
  background: rgba(201,162,77,.18);
  border: 1px solid rgba(201,162,77,.45);
}

.t-foot{ margin-top:10px; }

@media (min-width: 920px){
  .timeline{ gap:18px; }
  .t-card{ padding: 20px 22px; }
}

/* =========================
   FLOAT
========================= */
@media (prefers-reduced-motion: no-preference){
  .floaty{ animation: floaty 5.5s ease-in-out infinite; }
  @keyframes floaty{
    0%,100%{ transform: translateY(0); }
    50%{ transform: translateY(-6px); }
  }
}

/* =========================
   SCROLL REVEAL (with JS)
========================= */
@media (prefers-reduced-motion: no-preference){
  .io{
    opacity:0 !important;
    transform: translateY(14px) scale(.99) !important;
    animation:none !important;
  }
  .io.in{
    opacity:1 !important;
    transform: translateY(0) scale(1) !important;
    transition: opacity .65s ease, transform .65s ease;
  }
}
@media (prefers-reduced-motion: reduce){
  .io{ opacity:1 !important; transform:none !important; }
}
/* =========================
   TIMELINE: colore dinamico per livello (da DB)
   Usa la variabile CSS --porto-color impostata in porti.php
========================= */
.t-item { --porto-color: var(--gold); }

.t-dot{
  background: var(--porto-color);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--porto-color) 25%, transparent);
}

.t-line{
  background: color-mix(in srgb, var(--porto-color) 25%, rgba(11,31,51,.12));
}

/* pill gold coerente col colore livello */
.pill.gold{
  background: color-mix(in srgb, var(--porto-color) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--porto-color) 55%, transparent);
}
/* =========================
   BOTTONI SMALL (per timeline)
========================= */
.btn.small{
  padding:8px 12px;
  font-weight:800;
  font-size:.92rem;
}
.section.light .btn.ghost{
  color: var(--blue-dark);
  border-color: rgba(11,31,51,.18);
}
.section.light .btn.ghost:hover{
  border-color: rgba(11,31,51,.28);
}

/* =========================
   MAPPA (lazy iframe)
========================= */
.map-actions{
  display:flex;
  gap:10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.map-wrap{
  margin-top: 12px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(11,31,51,.10);
  box-shadow: var(--shadow);
  background: rgba(11,31,51,.03);
}

.map-iframe{
  width: 100%;
  height: 280px;
  border: 0;
  display:block;
}

@media (min-width: 720px){
  .map-iframe{ height: 320px; }
}