/* =====================================================================
   Matteo Menardi Ménego — Official Website
   Shared design system + fixes (loaded LAST so it standardises every page)
   --------------------------------------------------------------------
   Ladin flag palette drives every accent.
   Dark mode  -> body text #FFFFFF, "Ménego" accent #87CEEB
   Light mode -> body text #006A4E
   Heidegger quote -> shiny platinum
   ===================================================================== */

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

  /* Default (and only) wallpaper — single static image used everywhere.
     JS no longer swaps; content glides over one consistent photo. */
  --wp-url: url('../images/IMG_0864H.jpg');
}

/* ---------- Typography ------------------------------------------------ */
.font-sentient,
body {
  font-family: 'Sentient', ui-serif, Georgia, 'Times New Roman', serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Wallpaper that every page glides over (Apple.com style) ---- */
html        { background-color: #F4F6F7; color-scheme: light; }
html.dark   { background-color: #05080b; color-scheme: dark; }

/* Cross-platform base: no tap flash on iOS, no auto text inflation, smooth
   momentum scroll, and the canvas matches the theme during overscroll. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
* { -webkit-overflow-scrolling: touch; }

body { background-color: transparent !important; min-height: 100vh; min-height: 100dvh; }

/* ---------------------------------------------------------------------------
   Site wallpaper — a fixed full-viewport layer holding a REAL <img>. Using an
   actual image element (not a CSS background, not a pseudo-element) is the most
   robust way to guarantee the photo paints on every engine, including iOS
   Safari with backdrop-filter glass on the page. All content rides above it at
   z-index:1, so every page looks like the home screen.                     */
.site-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: #c9d6e2;            /* sky-toned fallback while the photo decodes */
}
html.dark .site-bg { background: #0a1622; }
.site-bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;             /* orientation-matched source => natural framing */
  object-position: center;
  display: block;
}
/* A light veil so text stays legible while the photo stays vivid. */
.site-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,0.07) 0%,
    rgba(255,255,255,0.05) 35%,
    rgba(255,255,255,0.11) 100%
  );
  transition: background .35s ease;
}
html.dark .site-bg::after {
  background: linear-gradient(180deg, rgba(4,7,11,.40) 0%, rgba(4,7,11,.32) 55%, rgba(4,7,11,.46) 100%);
}

/* Every page region rides above the wallpaper. (nav already carries z-50.) */
body > header,
body > main,
body > section,
body > footer { position: relative; z-index: 1; }

/* ---------- Per-page photo hero (same proven mechanism as the home hero) -
   A real in-flow header carrying the wallpaper as a direct background image,
   so every page opens on the photo exactly like the home screen.          */
.page-hero {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  min-height: 42vh;
}
@media (min-width: 768px) { .page-hero { min-height: 50vh; } }
@supports (height: 100dvh) {
  .page-hero { min-height: 42dvh; }
  @media (min-width: 768px) { .page-hero { min-height: 50dvh; } }
}
/* Name-page variant: light veil instead of dark, so its dark-green text stays
   legible directly on the photo. */
.page-hero--light { min-height: 100vh; }
@supports (height: 100dvh) { .page-hero--light { min-height: 100dvh; } }

/* ---------- Glassmorphism (iOS 18+ inspired, single source of truth) ------ */
.glass {
  background: rgba(255, 255, 255, 0.40);
  -webkit-backdrop-filter: saturate(185%) blur(28px);
  backdrop-filter: saturate(185%) blur(28px);
  border: 1px solid rgba(0, 106, 78, 0.07);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.12),
              0 4px 6px -4px rgba(0, 0, 0, 0.08);
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
html.dark .glass {
  background: rgba(10, 14, 20, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.45),
              0 4px 6px -4px rgba(0, 0, 0, 0.25);
}
/* graceful fallback where backdrop-filter is unsupported (old browsers) */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .glass          { background: rgba(255,255,255,0.92); }
  html.dark .glass{ background: rgba(12,18,24,0.94); }
}

/* ---------- Apple-rounded + shadows + card lift ----------------------- */
.apple-rounded { border-radius: 1.75rem; }

.minimal-shadow {
  box-shadow: 0 10px 30px -12px rgba(0,0,0,.18),
              0 4px 10px -6px rgba(0,0,0,.12);
}
html.dark .minimal-shadow {
  box-shadow: 0 16px 40px -14px rgba(0,0,0,.55),
              0 6px 14px -8px rgba(0,0,0,.45);
}

.section-card,
.social-card {
  transition: transform .35s cubic-bezier(.4,0,.2,1),
              box-shadow .35s cubic-bezier(.4,0,.2,1);
  will-change: transform;
}
.section-card:hover,
.social-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 26px 48px -16px rgba(0,0,0,.26),
              0 10px 18px -10px rgba(0,0,0,.18);
}
html.dark .section-card:hover,
html.dark .social-card:hover {
  box-shadow: 0 30px 60px -18px rgba(0,0,0,.65),
              0 12px 22px -12px rgba(0,0,0,.5);
}

/* ---------- Long text justified --------------------------------------- */
.content-justified { text-align: justify; text-justify: inter-word; hyphens: auto; }

/* ---------- "Ménego" accent (blue in dark, green in light) ------------ */
.monego-italic { font-style: italic; font-family: 'Sentient', ui-serif, Georgia, serif; }
html.dark .monego-italic { color: var(--ladin-blue); }

/* hidden-gem stacked name: green in light, white in dark (Ménego stays blue in dark) */
.name-stacked { color: #fff; }
html:not(.dark) .name-stacked { color: var(--ladin-green); }

/* ---------- Heidegger Quote — elegant & highly readable in both modes -- */
.quote-platinum {
  color: #d4d2cc;
  background: linear-gradient(145deg, #f8f7f4 0%, #e8e6e0 25%, #d4d1c9 50%, #e6e4de 75%, #f4f2ed 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.3));
  text-shadow: 0 0 1px rgba(255,255,255,0.5);
}

/* Dark mode: clean, high-contrast, elegant treatment that actually works beautifully */
html.dark .quote-platinum {
  color: #f1f0eb;
  background: none;
  -webkit-text-fill-color: #f1f0eb;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.75));
  text-shadow: 0 1px 5px rgba(0,0,0,.65);
}

/* ---------- Platinum ring (profile photo + Lookup button) ------------- */
.platinum-ring {
  box-shadow: 0 0 0 3px var(--platinum),
              0 0 0 6px rgba(229,228,226,.35),
              0 14px 26px -10px rgba(0,0,0,.35);
  transition: box-shadow .35s ease;
}
.platinum-ring:hover {
  box-shadow: 0 0 0 3px #f1f0ee,
              0 0 0 7px rgba(229,228,226,.5),
              0 20px 32px -10px rgba(0,0,0,.4);
}

/* ---------- Navigation underline -------------------------------------- */
.nav-link { position: relative; transition: color .2s ease; }
.nav-link:hover { color: var(--ladin-blue); }
html.dark .nav-link.active { color: var(--ladin-blue); }
html:not(.dark) .nav-link.active { color: var(--ladin-green); }
.nav-link.active::after {
  content: "";
  position: absolute; left: 0; bottom: -3px;
  width: 100%; height: 2px; border-radius: 2px;
  background: linear-gradient(to right, var(--ladin-blue), var(--ladin-green));
}

/* ---------- Profile imagery ------------------------------------------- */
.profile-hero {                 /* big home portrait: full body, no crop (3:4) */
  aspect-ratio: 3 / 4;
  width: 15rem;
  object-fit: cover;            /* frame matches image ratio => nothing cropped */
  object-position: center;
}
@media (min-width: 768px){ .profile-hero { width: 17rem; } }

.nav-avatar { object-fit: cover; object-position: center 22%; }

/* gallery photos always show full, original aspect (no crop) */
.story-image { display: block; width: 100%; height: auto; }

/* ---------- Elegant table (9a ascents) -------------------------------- */
.elegant-table { border-collapse: separate; border-spacing: 0; }
.elegant-table th, .elegant-table td {
  padding: 14px 18px; text-align: left;
  border-bottom: 1px solid rgba(0,106,78,.14);
}
html.dark .elegant-table th, html.dark .elegant-table td {
  border-bottom-color: rgba(255,255,255,.08);
}
.elegant-table tr:last-child td { border-bottom: none; }
.elegant-table tbody tr { transition: background .2s ease; }
.elegant-table tbody tr:hover { background: rgba(0,106,78,.05); }
html.dark .elegant-table tbody tr:hover { background: rgba(255,255,255,.05); }

/* ---------- Ladin flag (proportions 2:3, drawn wide like 🇦🇹 / 🇭🇺) ---- */
.ladin-flag {
  width: 54px; height: 36px;     /* 3:2 box => a 2:3 flag */
  border-radius: 5px; overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  border: 1px solid rgba(255,255,255,.35);
  flex-shrink: 0;
}
html.dark .ladin-flag { border-color: rgba(255,255,255,.18); }

/* ---------- Ménego logo (top bar + bottom bar) ------------------------
   Transparent-PNG enamel pin on an adaptive tile: WHITE in light mode,
   BLACK in dark mode (the transparent margins let the tile colour show).  */
.nav-logo {
  display: block;
  height: 40px; width: auto;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 1px 5px rgba(0,0,0,.22);
  border: 1px solid rgba(0,0,0,.10);
  transition: transform .25s ease, box-shadow .25s ease, background .3s ease, border-color .3s ease;
}
html.dark .nav-logo { background: #000000; border-color: rgba(255,255,255,.16); }
a:hover > .nav-logo {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,.28);
}
@media (max-width: 380px) { .nav-logo { height: 34px; } }

/* Footer mark: deliberately larger than the 36px-tall flag, links to the name page. */
.footer-logo {
  display: block;
  height: 52px; width: auto;
  border-radius: 11px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0,0,0,.26);
  border: 1px solid rgba(0,0,0,.10);
  transition: transform .25s ease, box-shadow .25s ease, background .3s ease, border-color .3s ease;
}
html.dark .footer-logo { background: #000000; border-color: rgba(255,255,255,.16); }
a:hover > .footer-logo {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0,0,0,.32);
}

/* ---------- Name page: legible text directly on the wallpaper ---------
   No card behind it — shadows lift the text off the photo in both modes. */
.readable-on-wp {
  text-shadow: 
    0 1px 3px rgba(255,255,255,.85), 
    0 2px 8px rgba(255,255,255,.6), 
    0 4px 18px rgba(255,255,255,.35);
}
html.dark .readable-on-wp {
  text-shadow: 
    0 1px 2px rgba(0,0,0,.75), 
    0 3px 12px rgba(0,0,0,.65), 
    0 6px 24px rgba(0,0,0,.45);
}
/* Stronger, multi-layer lift for the big stacked name on name.html — keeps full wallpaper visibility */
.readable-on-wp-strong {
  text-shadow: 
    0 1px 4px rgba(255,255,255,.9), 
    0 3px 10px rgba(255,255,255,.7), 
    0 6px 24px rgba(255,255,255,.4),
    0 10px 32px rgba(255,255,255,.25);
}
html.dark .readable-on-wp-strong {
  text-shadow: 
    0 2px 6px rgba(0,0,0,.8), 
    0 4px 16px rgba(0,0,0,.7), 
    0 8px 28px rgba(0,0,0,.5),
    0 12px 40px rgba(0,0,0,.3);
}

/* =====================================================================
   macOS-style dark / light toggle
   Sliding pill · white knob translates · Sun pinned LEFT · Moon pinned RIGHT
   Active mode's icon is emphasised (sun bright = light on, moon bright = dark on)
   ===================================================================== */
.theme-pill {
  appearance: none; -webkit-appearance: none;
  background: transparent; border: 0; padding: 0; margin: 0;
  cursor: pointer; line-height: 0; display: inline-flex; align-items: center;
}
.pill-track {
  position: relative; display: inline-block;
  width: 64px; height: 32px; border-radius: 9999px;
  background: #dfe3e1;
  border: 1px solid rgba(0,106,78,.18);
  box-shadow: inset 0 1px 3px rgba(0,0,0,.18);
  transition: background .3s ease, border-color .3s ease;
}
html.dark .pill-track {
  background: #2e3a44;
  border-color: rgba(255,255,255,.12);
}
/* The knob (pin) carries the icon and slides; Sun centred when light, Moon centred when dark. */
.pill-knob {
  position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px; border-radius: 9999px;
  background: #ffffff; z-index: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,.32), 0 1px 2px rgba(0,0,0,.2);
  transition: transform .32s cubic-bezier(.4,0,.2,1), background .3s ease;
}
html.dark .pill-knob { transform: translateX(32px); background: #f6f7f9; }
/* Both icons sit dead-centre on the knob; only the active mode's icon is shown. */
.pill-ic {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1; pointer-events: none;
  transition: opacity .25s ease;
}
.pill-sun  { opacity: 1; }
.pill-moon { opacity: 0; }
html.dark .pill-sun  { opacity: 0; }
html.dark .pill-moon { opacity: 1; }

/* ---------- Footer social icons: keep them visible on hover ----------- */
footer .text-xl a { transition: color .2s ease, transform .2s ease; }
footer .text-xl a:hover { color: var(--ladin-blue) !important; transform: translateY(-1px); }

/* ---------- Accessibility: focus states ------------------------------- */
:focus-visible {
  outline: 2px solid var(--ladin-blue);
  outline-offset: 3px;
  border-radius: 6px;
}
.theme-pill:focus-visible .pill-track {
  outline: 2px solid var(--ladin-blue);
  outline-offset: 3px;
}

/* ---------- Smooth scroll + reduced motion ---------------------------- */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

/* ---------- Safe-area insets for notched devices (viewport-fit=cover) -- */
/* !important so the insets win over Tailwind padding utilities; on devices
   without a notch env() is 0, so the max() keeps the original padding. */
@supports (padding: max(0px)) {
  nav > div { padding-left: max(1.5rem, env(safe-area-inset-left)) !important;
              padding-right: max(1.5rem, env(safe-area-inset-right)) !important; }
  footer    { padding-bottom: max(2rem, env(safe-area-inset-bottom)) !important;
              padding-left: max(0px, env(safe-area-inset-left));
              padding-right: max(0px, env(safe-area-inset-right)); }
}

/* ---------- Home hero: use the dynamic viewport where supported -------- */
/* Tailwind sets a vh fallback; dvh avoids the mobile URL-bar height jump. */
@supports (height: 100dvh) {
  #hero { min-height: 92dvh; }
  @media (min-width: 768px) { #hero { min-height: 88dvh; } }
}

/* ---------- Print-friendly ------------------------------------------- */
@media print {
  .site-bg { display: none !important; }
  html, body { background: #fff !important; color: #000 !important; }
  nav, footer, .theme-pill, #mobile-menu-btn { display: none !important; }
  .glass {
    background: #fff !important;
    border: 1px solid #ddd !important;
    -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
    box-shadow: none !important;
  }
  .quote-platinum {
    -webkit-text-fill-color: #555 !important; color: #555 !important;
    background: none !important; filter: none !important;
  }
  a { color: #000 !important; text-decoration: underline; }
}
