/* ============================================================
   Matteo Menardi Ménego — Official Website · Version 1.1
   Ladin palette · Inter body · Playfair display titles
   Static always-visible wallpaper · mobile-first optimised
   ============================================================ */

:root {
  --ladin-blue:  #87CEEB;
  --ladin-white: #FFFFFF;
  --ladin-green: #006A4E;
  --platinum:    #E5E4E2;

  --font:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --display: "Playfair Display", Georgia, "Times New Roman", serif;

  --r-sm: 16px;
  --r-md: 24px;
  --r-lg: 34px;
  --r-pill: 999px;

  --ease:   cubic-bezier(0.22, 1, 0.36, 1);
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --maxw: 1280px;

  /* One shared size for all longer running text — coherent across pages.
     Was ~1rem; lifted a couple of points and made fluid. */
  --body-size: clamp(1.08rem, 0.6vw + 0.98rem, 1.2rem);
}

/* ---------- Theme tokens ----------
   Both modes are built strictly from the three Ladin flag colours
   (blue #87CEEB · white #FFFFFF · green #006A4E) so dark and light
   read as two faces of the same flag — stark and symmetric. */
:root[data-theme="dark"] {
  --text:        #FFFFFF;                       /* pure Ladin white */
  --text-soft:   rgba(255,255,255,0.88);
  --text-faint:  rgba(255,255,255,0.62);
  --accent:      #87CEEB;                       /* pure Ladin blue  */
  --card-bg:     rgba(4,12,15,0.58);
  --card-bg-2:   rgba(4,12,15,0.74);
  --card-border: rgba(135,206,235,0.34);        /* Ladin-blue hairline */
  --card-shadow: 0 24px 60px -18px rgba(0,0,0,0.62);
  --bar-bg:      rgba(3,9,12,0.56);
  --bar-border:  rgba(135,206,235,0.26);
  --hairline:    rgba(135,206,235,0.22);
  --scrim:       linear-gradient(180deg, rgba(2,7,9,0.46) 0%, rgba(2,7,9,0.24) 42%, rgba(2,7,9,0.52) 100%);
  --chip:        rgba(135,206,235,0.14);
  --table-row:   rgba(255,255,255,0.06);
}
:root[data-theme="light"] {
  --text:        #006A4E;                       /* pure Ladin green */
  --text-soft:   rgba(0,106,78,0.92);
  --text-faint:  rgba(0,106,78,0.66);
  --accent:      #006A4E;                       /* pure Ladin green */
  --card-bg:     rgba(255,255,255,0.82);
  --card-bg-2:   rgba(255,255,255,0.94);
  --card-border: rgba(0,106,78,0.30);           /* Ladin-green hairline */
  --card-shadow: 0 24px 60px -20px rgba(0,60,44,0.30);
  --bar-bg:      rgba(255,255,255,0.74);
  --bar-border:  rgba(0,106,78,0.26);
  --hairline:    rgba(0,106,78,0.22);
  --scrim:       linear-gradient(180deg, rgba(255,255,255,0.40) 0%, rgba(255,255,255,0.18) 42%, rgba(255,255,255,0.44) 100%);
  --chip:        rgba(0,106,78,0.12);
  --table-row:   rgba(255,255,255,0.66);
}

* , *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  background: transparent;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   STATIC WALLPAPER  (always visible, content glides over it)
   No background-attachment:fixed — that breaks on mobile.
   A position:fixed layer keeps the image static instead.
   ============================================================ */
#wallpaper {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  background-image: var(--wall-landscape);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  will-change: auto;
}
#wallpaper::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--scrim);
}
:root {
  --wall-landscape: url("assets/img/IMG_0864H.jpg");
  --wall-portrait:  url("assets/img/IMG_0864.jpeg");
}
/* Portrait / vertical-mobile → portrait wallpaper */
@media (orientation: portrait) and (max-width: 900px) {
  #wallpaper { background-image: var(--wall-portrait); background-position: center 28%; }
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
.menego { font-style: italic; font-weight: 500; }

/* ============================================================
   TOP BAR
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  border-bottom: 1px solid var(--bar-border);
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px clamp(16px, 4vw, 36px);
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 13px; flex-shrink: 0; }
.avatar {
  width: 46px; height: 46px;
  border-radius: 16px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--card-bg-2);
  box-shadow: 0 0 0 2px var(--platinum), 0 0 0 4px rgba(229,228,226,0.3), 0 8px 22px -10px rgba(0,0,0,0.6);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center 14%; }
.brand-name {
  font-size: clamp(1.05rem, 1.5vw, 1.32rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: var(--text);
}
.brand-name .menego { color: var(--accent); }

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.nav a {
  position: relative;
  padding: 9px 15px;
  border-radius: var(--r-pill);
  font-size: 0.94rem;
  font-weight: 500;
  color: var(--text-soft);
  transition: background 0.3s var(--ease), color 0.3s var(--ease), transform 0.3s var(--ease);
}
.nav a::after {
  content: "";
  position: absolute;
  left: 15px; right: 15px; bottom: 4px;
  height: 2px;
  background: linear-gradient(90deg, var(--ladin-blue), var(--ladin-green));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.32s var(--ease);
  border-radius: 2px;
}
.nav a:hover { color: var(--text); transform: translateY(-1px); }
.nav a:hover::after { transform: scaleX(1); }
.nav a.active { color: var(--text); font-weight: 650; }
.nav a.active::after { transform: scaleX(1); }
.lookup {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: 6px;
  padding: 9px 18px;
  border-radius: var(--r-pill);
  font-weight: 600;
  color: var(--platinum);
  border: 1px solid var(--platinum);
  transition: background 0.3s var(--ease), color 0.3s var(--ease), transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  box-shadow: 0 0 14px -4px rgba(229,228,226,0.6);
}
.lookup:hover {
  background: var(--platinum);
  color: #0a140f;
  transform: translateY(-1px);
}

/* ============================================================
   LAYOUT
   ============================================================ */
main {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(26px, 5vw, 56px) clamp(16px, 4vw, 36px) 56px;
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 2.6vw, 28px);
}
.page-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.4rem, 6vw, 4.4rem);
  letter-spacing: -0.03em;
  line-height: 1.02;
  color: var(--text);
  margin-bottom: 6px;
}

.reveal { animation: rise 0.7s var(--bounce) both; }
@keyframes rise { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; opacity: 1; transform: none; }
  html { scroll-behavior: auto; }
}

/* ---------- Cards with accent border ---------- */
.card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-left: none;
  border-radius: var(--r-lg);
  box-shadow: var(--card-shadow);
  -webkit-backdrop-filter: saturate(160%) blur(26px);
  backdrop-filter: saturate(160%) blur(26px);
  padding: clamp(24px, 4vw, 48px);
  transition: transform 0.45s var(--bounce), box-shadow 0.45s var(--ease), border-color 0.45s var(--ease);
}
.card:hover { transform: translateY(-6px); box-shadow: 0 36px 80px -22px rgba(0,0,0,0.5); }
.card h2.section-title {
  font-family: var(--display);
  font-size: clamp(1.6rem, 3vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: 16px;
}
.card h3 { font-size: clamp(1.05rem, 1.6vw, 1.25rem); font-weight: 650; color: var(--text); }
.card p { color: var(--text-soft); margin-bottom: 13px; font-size: var(--body-size); }
.card p:last-child { margin-bottom: 0; }
.justify p, p.justify {
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  font-size: var(--body-size);
  line-height: 1.7;
}

.grid { display: grid; gap: clamp(16px, 2.2vw, 24px); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 880px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.full-wide {
  text-align: center;
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  font-weight: 600;
  color: var(--text);
}

/* ---------- Hero ---------- */
.hero { text-align: center; align-items: center; }
.hero .profile {
  width: clamp(170px, 24vw, 264px);
  aspect-ratio: 1;
  border-radius: 30%;
  overflow: hidden;
  margin: 0 auto 26px;
  background: var(--card-bg-2);
  box-shadow: 0 0 0 3px var(--platinum), 0 0 0 7px rgba(229,228,226,0.28), 0 22px 50px -18px rgba(0,0,0,0.6);
}
.hero .profile img { width: 100%; height: 100%; object-fit: cover; object-position: center 12%; }
.hero h1 {
  font-family: var(--display);
  font-size: clamp(2.2rem, 6vw, 4.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.05;
}

/* ---------- Platinum quote ---------- */
.quote { text-align: center; margin: 18px auto 0; }
.quote .q {
  display: inline-block;
  font-size: clamp(1.1rem, 2.4vw, 1.7rem);
  font-weight: 600;
  font-style: italic;
  letter-spacing: 0.005em;
  background: linear-gradient(100deg, #9C9C9C 0%, #FFFFFF 26%, #E5E4E2 50%, #FFFFFF 74%, #8F8F8F 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--platinum);
  filter: drop-shadow(0 0 1px rgba(70,70,70,0.85)) drop-shadow(0 2px 10px rgba(40,40,40,0.4));
}
.quote .cite { display: block; margin-top: 11px; font-size: 0.9rem; font-style: normal; color: var(--text-faint); }
.quote .cite .work { font-family: var(--display); font-style: italic; }

/* ---------- Climb ticklist table ---------- */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.modern-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.modern-table th {
  background: linear-gradient(90deg, var(--ladin-green), var(--ladin-blue));
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 12px 18px;
  text-align: left;
  white-space: nowrap;
}
.modern-table th:first-child { border-radius: 12px 0 0 12px; }
.modern-table th:last-child  { border-radius: 0 12px 12px 0; }
.modern-table td {
  background: var(--table-row);
  padding: 14px 18px;
  color: var(--text-soft);
  transition: background 0.2s ease;
  vertical-align: top;
}
.modern-table td:first-child { border-radius: 12px 0 0 12px; font-weight: 700; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.modern-table td:last-child  { border-radius: 0 12px 12px 0; }
.modern-table tr:hover td { background: rgba(135,206,235,0.14); }
.modern-table .route-name { color: var(--text); font-weight: 650; }
.modern-table .grade-pill {
  display: inline-block;
  font-weight: 800;
  color: var(--accent);
  background: var(--chip);
  padding: 3px 12px;
  border-radius: var(--r-pill);
  font-size: 0.86rem;
}

/* ---------- Timeline / lists ---------- */
.timeline { display: flex; flex-direction: column; gap: 22px; }
.tl-item { display: grid; grid-template-columns: 130px 1fr; gap: 20px; }
.tl-item .yr { font-family: var(--display); font-weight: 700; color: var(--accent); font-size: 1.05rem; }
.tl-item .body h3 { margin-bottom: 4px; }
.tl-item .body p { margin: 0; }
@media (max-width: 620px) { .tl-item { grid-template-columns: 1fr; gap: 4px; } }

.li-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.li-list li { color: var(--text-soft); padding-left: 18px; position: relative; }
.li-list li::before {
  content: ""; position: absolute; left: 0; top: 0.7em;
  width: 6px; height: 6px; border-radius: 50%;
  background: linear-gradient(135deg, var(--ladin-blue), var(--ladin-green));
}
.li-list li strong { color: var(--text); }

.cv-block { margin-bottom: 22px; }
.cv-block:last-child { margin-bottom: 0; }
.cv-block h3 { margin-bottom: 5px; }
.cv-block .sub { color: var(--text-faint); font-size: 0.9rem; }
.cv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 32px; }
@media (max-width: 620px) { .cv-grid { grid-template-columns: 1fr; } }
.cv-key { font-weight: 700; color: var(--text); margin-bottom: 3px; }
.cv-val { color: var(--text-soft); }
.divider { height: 1px; background: var(--hairline); margin: 22px 0; border: 0; }

.exp-item { padding: 13px 0; border-bottom: 1px solid var(--hairline); }
.exp-item:last-child { border-bottom: 0; }
.exp-item h3 { margin-bottom: 3px; }
.exp-item .org { color: var(--text-soft); }
.exp-item .when { color: var(--text-faint); font-size: 0.88rem; margin-top: 2px; }

/* ---------- Socials ---------- */
.social-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(14px, 2vw, 22px); }
@media (max-width: 820px) { .social-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .social-grid { grid-template-columns: 1fr; } }
.social-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 13px; padding: clamp(26px, 4vw, 42px);
  text-align: center;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--r-md);
  box-shadow: var(--card-shadow);
  -webkit-backdrop-filter: saturate(160%) blur(24px);
  backdrop-filter: saturate(160%) blur(24px);
  color: var(--text);
  font-weight: 650;
  font-size: 1.08rem;
  transition: transform 0.4s var(--bounce), box-shadow 0.4s var(--ease);
}
.social-card:hover { transform: translateY(-6px) scale(1.015); box-shadow: 0 32px 70px -20px rgba(0,0,0,0.45); }
.social-card .ic { transition: transform 0.35s var(--bounce); }
.social-card:hover .ic { transform: scale(1.16) rotate(5deg); }
.social-card svg { width: 38px; height: 38px; }
.social-card .handle { font-size: 0.88rem; font-weight: 500; color: var(--text-faint); }

.here-card { text-align: center; font-size: clamp(1.2rem, 2.2vw, 1.6rem); font-weight: 700; color: var(--text); }
.here-card .url { display: block; color: var(--accent); font-weight: 600; font-size: 1.02rem; margin: 9px 0 4px; }
.here-card .you { display: block; color: var(--text-faint); font-size: 0.92rem; font-weight: 500; }

/* ---------- Stories ---------- */
.story-text p { margin-bottom: 16px; font-size: var(--body-size); line-height: 1.72; }
.story-date { font-family: var(--display); font-weight: 700; color: var(--text); display: block; margin-bottom: 13px; font-size: 1.1rem; }
.byline { text-align: right; color: var(--text-faint); font-style: italic; margin-top: 6px; }

.photo-stack { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(12px, 2vw, 22px); margin: 28px 0; }
.photo-stack img {
  width: 100%;
  height: auto;            /* original aspect ratio kept, never cropped */
  border-radius: var(--r-sm);
  box-shadow: var(--card-shadow);
}
.photo-stack .span-2 { grid-column: 1 / -1; max-width: 780px; margin-inline: auto; }
@media (max-width: 620px) {
  .photo-stack { grid-template-columns: 1fr; }
  .photo-stack .span-2 { max-width: 100%; }
}

.readmore {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 24px; border-radius: var(--r-pill);
  font-weight: 600; color: var(--text);
  background: var(--chip);
  border: 1px solid var(--card-border);
  transition: transform 0.3s var(--ease), background 0.3s var(--ease);
}
.readmore:hover { transform: translateY(-2px); background: var(--card-bg-2); }

/* ---------- Hidden gem ---------- */
.gem {
  min-height: calc(100vh - 230px);
  min-height: calc(100dvh - 230px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 28px; padding: 50px 0;
}
.gem .big-name {
  font-family: var(--display);
  font-size: clamp(2.4rem, 9vw, 6.4rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.02;
  color: var(--text);
}
.gem .big-name .stack { display: none; }
@media (max-width: 820px) {
  .gem .big-name .inline { display: none; }
  .gem .big-name .stack { display: block; }
  .gem .big-name .stack span { display: block; }
}
.gem .thanks { font-size: 1.2rem; color: var(--text-soft); }
.gem .made { color: var(--text-faint); font-size: 0.94rem; }

/* ============================================================
   BOTTOM BAR
   ============================================================ */
.bottombar {
  margin-top: auto;
  background: var(--bar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  border-top: 1px solid var(--bar-border);
  padding: 24px clamp(16px, 4vw, 36px) 28px;
}
.bottombar .row {
  max-width: var(--maxw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
}
.copyright { font-size: 0.86rem; color: var(--text-faint); justify-self: start; }
.copyright:hover { color: var(--text-soft); }
.socials-mini { display: flex; align-items: center; gap: 12px; justify-self: center; }
.socials-mini a, .partners a {
  display: inline-flex;
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  border-radius: var(--r-pill);
  color: var(--text-soft);
  background: var(--chip);
  transition: transform 0.3s var(--ease), color 0.3s var(--ease), background 0.3s var(--ease);
}
.socials-mini a:hover, .partners a:hover { transform: translateY(-2px); color: var(--text); background: var(--card-bg-2); }
.socials-mini svg { width: 19px; height: 19px; }
.partners { display: flex; align-items: center; gap: 12px; justify-self: end; }
.partners a { width: auto; padding: 0 16px; font-weight: 650; font-size: 0.88rem; }

.bottombar .controls {
  max-width: var(--maxw);
  margin: 18px auto 0;
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
}
.theme-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px;
  border-radius: var(--r-pill);
  background: var(--chip);
  border: 1px solid var(--card-border);
}
.theme-toggle button {
  border: 0; cursor: pointer;
  font-family: var(--font);
  font-size: 1.05rem;
  width: 42px; height: 34px;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-soft);
  transition: background 0.35s var(--ease), transform 0.35s var(--ease);
}
.theme-toggle button.on {
  background: var(--card-bg-2);
  transform: scale(1.05);
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
}
.theme-toggle button:hover { color: var(--text); }

.ladin-flag {
  display: inline-flex;
  width: 46px; height: 30px;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--card-border);
  box-shadow: 0 3px 12px -4px rgba(0,0,0,0.4);
  transition: transform 0.3s var(--ease);
}
.ladin-flag:hover { transform: scale(1.08); }
.ladin-flag span { flex: 1; }
.ladin-flag .b { background: var(--ladin-blue); }
.ladin-flag .w { background: var(--ladin-white); }
.ladin-flag .g { background: var(--ladin-green); }

/* ============================================================
   MOBILE OPTIMISATION
   ============================================================ */
@media (max-width: 900px) {
  .topbar-inner { flex-wrap: wrap; row-gap: 10px; padding: 10px 16px; }
  .brand { width: 100%; }
  /* Two-row menu exactly as specified:
     [Name][space][Home][About Me] / [Climbed Milestones][My Socials][Stories] */
  .nav {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
    gap: 6px 8px;
  }
  .nav a, .lookup {
    padding: 9px 13px;
    font-size: 0.9rem;
    margin-left: 0;
  }
  .nav a::after { left: 13px; right: 13px; }
  .lookup { box-shadow: 0 0 10px -4px rgba(229,228,226,0.6); }

  .card { backdrop-filter: saturate(150%) blur(18px); -webkit-backdrop-filter: saturate(150%) blur(18px); }

  .bottombar .row { grid-template-columns: 1fr; justify-items: center; gap: 16px; text-align: center; }
  .copyright, .socials-mini, .partners { justify-self: center; }
  .bottombar .controls { padding-top: 14px; }
}
@media (max-width: 520px) {
  .nav { gap: 5px 6px; }
  .nav a { padding: 8px 11px; font-size: 0.86rem; }
  .lookup { padding: 8px 14px; }
  .topbar-inner { gap: 10px; }
  main { padding-top: 22px; }
  .modern-table th, .modern-table td { padding: 11px 13px; font-size: 0.9rem; }
}

/* Tap targets & no hover jitter on touch devices */
@media (hover: none) {
  .card:hover, .social-card:hover { transform: none; }
  .nav a, .lookup, .readmore, .social-card { -webkit-tap-highlight-color: transparent; }
}
