/* ============================================================
   Portfolio Valentin Agnano — éditorial finance, marine & or
   Serif display + sans body, hairlines dorées, zéro dépendance
   ============================================================ */

:root {
  --navy-900: #0d1626;
  --navy-800: #152238;
  --navy-700: #1c2e4a;
  --navy-600: #2a4066;
  --gold-500: #c9a24b;
  --gold-400: #d8b568;
  --gold-300: #e8d3a3;
  --paper:    #faf7f1;
  --paper-2:  #f2ede3;
  --ink:      #1a2233;
  --ink-soft: #4a5468;
  --line:     rgba(21, 34, 56, .14);
  --gold-line: rgba(201, 162, 75, .45);
  --card:     #ffffff;
  --shadow:   0 18px 50px -18px rgba(13, 22, 38, .22);

  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;

  --bg: var(--paper);
  --bg-alt: var(--paper-2);
  --fg: var(--ink);
  --fg-soft: var(--ink-soft);
}

[data-theme="dark"] {
  --bg:      #0d1626;
  --bg-alt:  #111d31;
  --card:    #16253d;
  --fg:      #eef0f4;
  --fg-soft: #a8b2c4;
  --line:    rgba(232, 211, 163, .14);
  --gold-line: rgba(201, 162, 75, .5);
  --shadow:  0 18px 50px -18px rgba(0, 0, 0, .55);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.65;
  font-size: 16.5px;
  -webkit-font-smoothing: antialiased;
  transition: background .35s ease, color .35s ease;
}

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

.container { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--gold-500);
  color: var(--navy-900); padding: 8px 16px; z-index: 100;
}
.skip-link:focus { left: 12px; top: 12px; }

/* ---------- Typographie ---------- */
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; }
h2 { font-size: clamp(1.7rem, 3.4vw, 2.5rem); letter-spacing: -.01em; }
h3 { font-size: 1.25rem; }
.gold { color: var(--gold-500); font-style: italic; }

.kicker {
  font-size: .74rem; font-weight: 600; letter-spacing: .22em;
  text-transform: uppercase; color: var(--gold-500);
  display: flex; align-items: center; gap: 12px;
}
.kicker::before { content: ""; width: 34px; height: 1px; background: var(--gold-line); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; align-items: center; gap: 28px; height: 64px; }
.nav-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); margin-right: auto; }
.brand-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  object-fit: cover; border: 1px solid var(--gold-line);
}
.brand-name { font-family: var(--font-display); font-size: 1.02rem; }
.nav-links { display: flex; gap: 22px; }
.nav-links a {
  text-decoration: none; color: var(--fg-soft); font-size: .9rem; font-weight: 500;
  padding: 4px 0; border-bottom: 1px solid transparent; transition: color .2s, border-color .2s;
}
.nav-links a:hover { color: var(--fg); border-bottom-color: var(--gold-500); }
.nav-actions { display: flex; align-items: center; gap: 12px; }

.theme-toggle {
  background: none; border: 1px solid var(--line); color: var(--fg-soft);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer;
  display: grid; place-items: center; transition: border-color .2s, color .2s;
}
.theme-toggle:hover { border-color: var(--gold-500); color: var(--gold-500); }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-block; text-decoration: none; font-weight: 600; font-size: .92rem;
  padding: 12px 22px; border-radius: 8px; border: 1px solid transparent;
  transition: background .2s, color .2s, border-color .2s, opacity .2s;
}
.btn:hover { opacity: .92; }
.btn-sm { padding: 7px 14px; font-size: .82rem; border-radius: 8px; }
.btn-navy { background: var(--navy-800); color: var(--gold-300); }
.btn-navy:hover { box-shadow: var(--shadow); }
[data-theme="dark"] .btn-navy { background: var(--gold-500); color: var(--navy-900); }
.btn-gold { background: var(--gold-500); color: var(--navy-900); }
.btn-gold:hover { background: var(--gold-400); box-shadow: 0 10px 30px -12px rgba(201,162,75,.6); }
.btn-outline { border-color: var(--gold-line); color: var(--fg); }
.btn-outline:hover { border-color: var(--gold-500); color: var(--gold-500); }
.btn-ghost { color: var(--fg-soft); }
.btn-ghost:hover { color: var(--gold-500); }

/* ---------- Hero ---------- */
.hero { position: relative; padding: 84px 0 56px; }
.hero-inner { position: relative; }
.hero-title { margin: 18px 0 4px; }
.hero-name {
  display: block; font-size: clamp(2.6rem, 7vw, 4.6rem);
  letter-spacing: -.02em;
}
.hero-fields {
  display: flex; align-items: baseline; gap: 14px; margin-top: 6px;
  font-size: clamp(1.1rem, 2.4vw, 1.5rem); color: var(--fg-soft); font-weight: 400;
  letter-spacing: .01em;
}
.hero-fields .dot { color: var(--gold-500); }
.hero-tagline {
  font-size: clamp(1.05rem, 2vw, 1.2rem); color: var(--fg);
  font-weight: 500; margin: 22px 0 12px; max-width: 620px;
}
.hero-intro { max-width: 640px; color: var(--fg-soft); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 30px 0 0; align-items: center; }

.hero-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px;
  margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line);
}
.stat-value {
  font-family: var(--font-display); font-size: clamp(1.35rem, 2.6vw, 1.7rem);
  color: var(--gold-500); display: block; line-height: 1;
}
.stat-label { font-size: .8rem; color: var(--fg-soft); display: block; margin-top: 5px; }

/* ---------- Sections ---------- */
.section { padding: 84px 0; }
.section-alt { background: var(--bg-alt); border-block: 1px solid var(--line); }
.section-head { max-width: 720px; margin-bottom: 44px; }
.section-head h2 { margin: 14px 0 12px; }
.section-sub { color: var(--fg-soft); }

/* ---------- Réalisations ---------- */
.projects-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.project-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; display: flex; flex-direction: column;
  transition: box-shadow .25s ease, border-color .25s;
}
.project-card:hover { box-shadow: var(--shadow); border-color: var(--gold-line); }

.project-cover { position: relative; display: block; overflow: hidden; aspect-ratio: 16 / 10; }
.project-cover img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.cover-veil {
  position: absolute; inset: 0;
  background: linear-gradient(200deg, rgba(21,34,56,0) 40%, rgba(21,34,56,.55));
}
.cover-cta {
  position: absolute; left: 18px; bottom: 14px; color: #fff; font-size: .85rem; font-weight: 600;
  letter-spacing: .04em; opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s;
}
.project-card:hover .cover-cta { opacity: 1; transform: translateY(0); }

.project-body { padding: 26px 26px 24px; display: flex; flex-direction: column; gap: 12px; }
.project-body h3 a { color: var(--fg); text-decoration: none; }
.project-body h3 a:hover { color: var(--gold-500); }
.project-summary { color: var(--fg-soft); font-size: .95rem; }

.tag-list { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 6px; }
.tag-list li {
  font-size: .74rem; font-weight: 600; letter-spacing: .03em;
  padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--gold-line); color: var(--gold-500); background: transparent;
}

/* ---------- Timeline ---------- */
.timeline { position: relative; max-width: 780px; }
.timeline::before {
  content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px;
  width: 1px; background: linear-gradient(var(--gold-line), transparent);
}
.tl-item { position: relative; padding-left: 40px; margin-bottom: 14px; }
.tl-marker {
  position: absolute; left: 0; top: 20px; width: 15px; height: 15px;
  border-radius: 50%; background: var(--bg); border: 2px solid var(--gold-500);
}
.tl-content { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.tl-head {
  width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  display: grid; grid-template-columns: 120px 1fr auto; gap: 4px 18px; align-items: center;
  padding: 16px 20px; color: var(--fg); font: inherit;
}
.tl-head:hover .tl-role { color: var(--gold-500); }
.tl-period { font-size: .78rem; font-weight: 700; letter-spacing: .08em; color: var(--gold-500); text-transform: uppercase; }
.tl-role { font-family: var(--font-display); font-size: 1.08rem; font-weight: 600; transition: color .2s; }
.tl-org { grid-column: 2; font-size: .85rem; color: var(--fg-soft); }
.tl-chevron { grid-row: 1 / span 2; grid-column: 3; color: var(--gold-500); font-size: 1.2rem; transition: transform .25s; }
.tl-head[aria-expanded="true"] .tl-chevron { transform: rotate(180deg); }
.tl-details { padding: 0 20px 18px 158px; }
.tl-details ul:not(.tag-list) { padding-left: 18px; color: var(--fg-soft); font-size: .93rem; display: grid; gap: 5px; }
.tl-details .tag-list { margin-top: 14px; }

.education { margin-top: 56px; }
.edu-title { font-size: 1.15rem; margin-bottom: 18px; color: var(--fg); }
.edu-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; max-width: 780px; }
.edu-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px; display: grid; gap: 6px;
}
.edu-card strong { font-family: var(--font-display); font-size: 1.02rem; }
.edu-org { font-size: .86rem; color: var(--fg-soft); }
.edu-note { font-size: .82rem; color: var(--fg-soft); }

/* ---------- Compétences ---------- */
.skills-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.skill-col {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px 26px; display: flex; flex-direction: column; gap: 16px;
  transition: transform .25s, box-shadow .25s, border-color .25s;
}
.skill-col:hover { box-shadow: var(--shadow); border-color: var(--gold-line); }
.skill-col h3 { padding-bottom: 12px; border-bottom: 1px solid var(--gold-line); }
.skill-col:first-child h3 { color: var(--gold-500); }
.skill-items { list-style: none; display: grid; gap: 9px; font-size: .93rem; color: var(--fg-soft); }
.skill-items li { padding-left: 20px; position: relative; }
.skill-items li::before { content: "▸"; position: absolute; left: 0; color: var(--gold-500); font-size: .8rem; }
.tools { margin-top: auto; }

/* ---------- Contact ---------- */
.section-contact { padding-bottom: 110px; }
.contact-inner { text-align: center; max-width: 640px; }
.contact-inner .kicker { justify-content: center; }
.contact-inner .kicker::after { content: ""; width: 34px; height: 1px; background: var(--gold-line); }
.contact-inner h2 { margin: 14px 0 12px; font-size: clamp(2rem, 4.5vw, 3rem); }
.contact-inner .hero-actions { justify-content: center; margin-top: 26px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 26px 0; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: .84rem; color: var(--fg-soft); }
.footer-note { font-style: italic; }

/* ---------- Page projet ---------- */
.project-page .backlink { color: var(--fg-soft); text-decoration: none; font-size: .9rem; }
.project-page .backlink:hover { color: var(--gold-500); }
.project-hero {
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  box-shadow: var(--shadow); margin: 10px 0 40px;
}
.project-hero img { width: 100%; max-height: 480px; object-fit: cover; object-position: top; }
.project-hero figcaption, .gallery-item figcaption {
  font-size: .8rem; color: var(--fg-soft); font-style: italic; padding: 10px 16px;
  border-top: 1px solid var(--line); background: var(--card);
}
.project-cols { display: grid; grid-template-columns: 1.7fr 1fr; gap: 36px; margin-bottom: 48px; }
.project-main { display: grid; gap: 30px; }
.block-title {
  font-size: 1.2rem; margin-bottom: 12px;
  display: flex; align-items: center; gap: 12px;
}
.block-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.project-main p { color: var(--fg-soft); }
.built-list { list-style: none; display: grid; gap: 10px; }
.built-list li {
  padding: 12px 16px 12px 38px; position: relative;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  font-size: .94rem; color: var(--fg-soft);
}
.built-list li::before { content: "→"; position: absolute; left: 14px; color: var(--gold-500); }
.side-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 24px; position: sticky; top: 90px; display: grid; gap: 10px;
}
.side-card h4 {
  font-size: .74rem; letter-spacing: .18em; text-transform: uppercase; color: var(--gold-500);
}
.side-card p { font-size: .92rem; color: var(--fg-soft); }
.side-card .stack { font-family: var(--font-display); font-style: italic; }
.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; margin-bottom: 48px; }
.gallery-item { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--card); }
.gallery-item img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; }
.next-links { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.next-card {
  text-decoration: none; color: var(--fg); background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; padding: 22px; display: grid; gap: 8px;
  transition: transform .22s, border-color .22s, box-shadow .22s;
}
.next-card:hover { border-color: var(--gold-line); box-shadow: var(--shadow); }
.next-card strong { font-family: var(--font-display); font-size: 1.05rem; }
.next-card .cover-cta { position: static; opacity: 1; transform: none; color: var(--gold-500); }

/* ---------- Animations 3D ---------- */
#scroll-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 100;
  background: linear-gradient(90deg, var(--gold-500), var(--gold-300));
  box-shadow: 0 0 12px rgba(201, 162, 75, .5);
}

/* Révélation : bascule depuis la profondeur */
.reveal {
  opacity: 0;
  transform: perspective(1000px) rotateX(7deg) translateY(38px);
  transform-origin: top center;
  transition: opacity .85s cubic-bezier(.16, 1, .3, 1), transform .85s cubic-bezier(.16, 1, .3, 1);
}
.reveal.in { opacity: 1; transform: perspective(1000px) rotateX(0) translateY(0); }
.reveal:nth-child(2) { transition-delay: .08s; }
.reveal:nth-child(3) { transition-delay: .16s; }
.reveal:nth-child(4) { transition-delay: .24s; }

/* Scène 3D du hero : sol en grille perspective + orbes dorés */
.hero { position: relative; overflow: hidden; }
.hero-scene { position: absolute; inset: 0; pointer-events: none; perspective: 900px; }
.grid-floor {
  position: absolute; left: -25%; right: -25%; bottom: -18%; height: 62%;
  transform: rotateX(63deg); transform-origin: 50% 0;
  overflow: hidden;
  mask-image: linear-gradient(180deg, transparent, #000 30%);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 30%);
  opacity: .5;
}
.grid-lines {
  position: absolute; inset: 0; width: calc(100% + 96px);
  background:
    repeating-linear-gradient(90deg, var(--gold-line) 0 1px, transparent 1px 96px),
    repeating-linear-gradient(0deg, var(--line) 0 1px, transparent 1px 72px);
  animation: gridSlide 14s linear infinite;
}
@keyframes gridSlide { to { transform: translateX(-96px); } }
.orb {
  position: absolute; border-radius: 50%; filter: blur(26px);
  background: radial-gradient(circle, rgba(201, 162, 75, .35), transparent 70%);
  will-change: transform;
}
.orb-1 { width: 260px; height: 260px; top: 8%; right: 6%; animation: orbFloat 9s ease-in-out infinite; }
.orb-2 { width: 140px; height: 140px; top: 55%; right: 26%; animation: orbFloat 12s ease-in-out infinite reverse; }
.orb-3 { width: 200px; height: 200px; top: 22%; left: -4%; opacity: .5; animation: orbFloat 15s ease-in-out infinite; }
@keyframes orbFloat { 50% { transform: translateY(-26px); } }
[data-theme="dark"] .orb { background: radial-gradient(circle, rgba(201, 162, 75, .22), transparent 70%); }

/* Tilt 3D des cartes (souris) + reflet doré */
.tilt { position: relative; will-change: transform; }
.tilt::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: radial-gradient(460px circle at var(--mx, 50%) var(--my, 50%), rgba(201, 162, 75, .14), transparent 55%);
  opacity: 0; transition: opacity .35s ease;
}
.tilt:hover::after { opacity: 1; }
.tilt.tilting { transition: none; }
.tilt:not(.tilting) { transition: transform .5s cubic-bezier(.16, 1, .3, 1), box-shadow .25s ease, border-color .25s; }

/* Effet deck : screenshots inclinés qui se redressent au scroll */
.deck3d { will-change: transform, opacity; transform-origin: 50% 100%; }

/* Timeline : la ligne se dessine au scroll */
.timeline::before { transform: scaleY(var(--tl-progress, 0)); transform-origin: top; transition: transform .1s linear; }
.tl-marker { transform: scale(0); transition: transform .5s cubic-bezier(.34, 1.56, .64, 1) .15s; }
.tl-item.in .tl-marker { transform: scale(1); }

/* Constellation (canvas) */
#constellation { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Entrée 3D du nom, lettre par lettre */
.hero-name .ch {
  display: inline-block; opacity: 0;
  transform: translateY(.55em) rotateX(-70deg);
  transform-origin: 50% 100%;
  transition: opacity .7s cubic-bezier(.16, 1, .3, 1), transform .7s cubic-bezier(.16, 1, .3, 1);
  transition-delay: var(--d, 0s);
}
.hero-name.in .ch { opacity: 1; transform: none; }
.hero-title { perspective: 700px; }

/* Le hero s'éloigne en profondeur au scroll */
.hero-inner, .hero-stats { will-change: transform, opacity; }

/* Sparklines sous les stats */
.sparkline { display: block; width: 92px; height: 26px; margin: 8px 0 2px; overflow: visible; }
.sparkline polyline {
  stroke: var(--gold-500); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 220; stroke-dashoffset: 220;
}
.stat.in .sparkline polyline { animation: sparkDraw 1.4s cubic-bezier(.4, 0, .2, 1) .3s forwards; }
@keyframes sparkDraw { to { stroke-dashoffset: 0; } }

/* Ticker financier */
.ticker {
  background: var(--navy-800); border-block: 1px solid var(--gold-line);
  overflow: hidden; padding: 13px 0; position: relative;
}
[data-theme="dark"] .ticker { background: var(--navy-900); }
.ticker::before, .ticker::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 90px; z-index: 1; pointer-events: none;
}
.ticker::before { left: 0; background: linear-gradient(90deg, var(--navy-800), transparent); }
.ticker::after { right: 0; background: linear-gradient(270deg, var(--navy-800), transparent); }
[data-theme="dark"] .ticker::before { background: linear-gradient(90deg, var(--navy-900), transparent); }
[data-theme="dark"] .ticker::after { background: linear-gradient(270deg, var(--navy-900), transparent); }
.ticker-track {
  display: inline-flex; align-items: center; gap: 26px; white-space: nowrap;
  animation: tickerScroll 36s linear infinite; will-change: transform; padding-left: 26px;
}
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker-item {
  color: var(--gold-300); font-size: .8rem; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase;
}
.ticker-sep { color: var(--gold-500); font-size: .5rem; opacity: .7; }
@keyframes tickerScroll { to { transform: translateX(-50%); } }

/* Reflet balayant sur les screenshots */
.project-cover::before, .project-hero::before {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .28) 48%, rgba(201, 162, 75, .18) 52%, transparent 70%);
  transform: translateX(-120%) skewX(-8deg);
}
.project-hero { position: relative; }
.project-card:hover .project-cover::before, .project-hero:hover::before {
  animation: sheen 1s cubic-bezier(.4, 0, .2, 1) forwards;
}
@keyframes sheen { to { transform: translateX(120%) skewX(-8deg); } }

/* Boutons magnétiques */
.btn-magnet { will-change: transform; transition: transform .35s cubic-bezier(.16, 1, .3, 1); }

/* Transitions de page (fondu) */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation-duration: .25s; }
::view-transition-new(root) { animation-duration: .35s; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal, .deck3d { opacity: 1 !important; transform: none !important; transition: none !important; }
  .hero-name .ch { opacity: 1; transform: none; transition: none; }
  .sparkline polyline { stroke-dashoffset: 0; }
  .tl-marker { transform: scale(1); }
  .timeline::before { transform: scaleY(1); }
  #scroll-progress, #constellation { display: none; }
  .ticker-track { animation: none; }
  * { animation: none !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .projects-grid, .skills-grid, .gallery, .next-links, .edu-grid { grid-template-columns: 1fr; }
  .project-cols { grid-template-columns: 1fr; }
  .side-card { position: static; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); gap: 26px; }
  .nav-links { display: none; }
  .tl-head { grid-template-columns: 1fr auto; }
  .tl-period { grid-column: 1; }
  .tl-org { grid-column: 1; }
  .tl-details { padding-left: 20px; }
}
