/* ===========================
   Julien Alex — Static Site
   Dark polar theme
   =========================== */

:root {
  --bg-body: #0d1b2a;
  --bg-surface: #1b2838;
  --bg-card: #1b2838;
  --bg-input: #0d1b2a;
  --text: #c9d1d9;
  --text-muted: #8b949e;
  --text-heading: #ffffff;
  --accent: #4ca1d9;
  --accent-hover: #7bc0f5;
  --accent-warm: #d4a574;
  --accent-warm-hover: #e0bb91;
  --border: #30363d;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-heading: 'DM Serif Display', 'Georgia', serif;
  --max-width: 1000px;
  --header-height: 70px;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-body);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.11'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; height: auto; display: block; }

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  color: var(--text-heading);
  line-height: 1.3;
  font-weight: 400;
}
h1 { font-size: 2.5rem; }
h2 { font-size: 1.8rem; margin-bottom: 1.5rem; }
h3 { font-size: 1.3rem; margin-bottom: 1rem; }
p  { margin-bottom: 1rem; }

/* --- Layout --- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
}
.section { padding: 2.5rem 0 3.5rem; position: relative; z-index: 1; }
.section + .section { border-top: 1px solid rgba(76, 161, 217, 0.08); }
.section-title { text-align: center; margin-bottom: 3rem; }

/* --- Header --- */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: rgba(13, 27, 42, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
}
.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}
.logo img { height: 40px; width: auto; }
.logo span {
  color: var(--text-heading);
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Navigation */
.nav-toggle { display: none; }
.nav-toggle-label { display: none; cursor: pointer; padding: 0.5rem; }
.nav-toggle-label span,
.nav-toggle-label span::before,
.nav-toggle-label span::after {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text);
  position: relative;
  transition: transform 0.3s;
}
.nav-toggle-label span::before,
.nav-toggle-label span::after {
  content: '';
  position: absolute;
}
.nav-toggle-label span::before { top: -7px; }
.nav-toggle-label span::after  { top:  7px; }

.nav {
  display: flex;
  gap: 2rem;
  list-style: none;
}
.nav a {
  color: var(--text);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
  padding: 0.25rem 0.5rem;
  border-bottom: 2px solid transparent;
  border-radius: 4px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.nav a:hover {
  background: rgba(76, 161, 217, 0.08);
}
.nav a:hover,
.nav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent-warm);
}

/* --- Hero --- */
.hero {
  position: relative;
  z-index: 1;
  height: 100vh;
  min-height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}
.hero-bg {
  position: absolute;
  inset: -20% 0;
  object-fit: cover;
  width: 100%;
  height: 140%;
  z-index: 0;
  will-change: transform;
}
.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(13,27,42,0.3), rgba(13,27,42,0.85));
  z-index: 1;
}
.hero-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 40%, rgba(76,161,217,0.08) 0%, transparent 60%);
  animation: heroGlow 8s ease-in-out infinite alternate;
}
@keyframes heroGlow {
  from { opacity: 0.4; transform: scale(1); }
  to   { opacity: 1; transform: scale(1.15); }
}
.hero-content {
  position: relative;
  z-index: 2;
}
.hero h1 {
  font-size: 3.5rem;
  margin-bottom: 0.75rem;
}
.hero .tagline {
  font-size: 1.15rem;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-family: var(--font-body);
  font-weight: 400;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}

/* --- Cards Grid --- */
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}
.card {
  background: var(--bg-card);
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.3s, box-shadow 0.3s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3), inset 0 2px 0 var(--accent-warm);
  color: inherit;
}
.card-img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}
.card-body {
  padding: 1.5rem;
}
.card-body h3 { margin-bottom: 0.5rem; }
.card-body p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 0;
}

/* --- Gallery --- */
.gallery-section {
  background: rgba(0, 0, 0, 0.2);
  padding: 2.5rem 0 3.5rem;
  position: relative;
  z-index: 1;
}
.gallery-section .section-title { text-align: center; margin-bottom: 2rem; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: auto auto;
  gap: 0.5rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}
.gallery-grid picture {
  cursor: pointer;
  overflow: hidden;
  border-radius: 4px;
  position: relative;
}
.gallery-grid picture:first-child {
  grid-column: 1 / 3;
  grid-row: 1 / 3;
}
.gallery-grid img {
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 4px;
  transition: transform 0.4s ease-out;
}
.gallery-grid picture:first-child img {
  aspect-ratio: auto;
  height: 100%;
}
.gallery-grid picture:hover img { transform: scale(1.05); }
.gallery-grid picture::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.3) 0%, transparent 50%);
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.gallery-grid picture:hover::after { opacity: 1; }
.gallery-credit {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 1.25rem;
  font-style: italic;
}

/* --- About page --- */
.page-header--left { text-align: left; }
.section-title--left { text-align: left; }
.about-bio {
  max-width: var(--max-width);
  overflow: hidden; /* contain float */
}
.about-portrait {
  float: left;
  width: 260px;
  margin: 0 2rem 1.5rem 0;
  shape-outside: margin-box;
}
.portrait {
  width: 100%;
  border-radius: 8px;
}
.social-links {
  display: flex;
  gap: 1.5rem;
  margin-top: 1.5rem;
}
.social-links a {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.social-links a:hover { color: var(--accent); }

.lectures {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}
.lecture-card {
  background: var(--bg-surface);
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.3s, box-shadow 0.3s;
}
.lecture-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.25);
}
.lecture-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}
.lecture-card-body {
  padding: 1.25rem;
}
.lecture-card-body h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.lecture-card-body p  { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 0; }

/* --- Contact form --- */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  max-width: 900px;
  margin: 0 auto;
}
.page-contact {
  background: url('/images/backgrounds/sunset.jpg') center/cover no-repeat fixed;
}
.page-contact::before {
  background: rgba(13, 27, 42, 0.45);
}
.page-contact .footer {
  background: rgba(13, 27, 42, 0.4);
}
.contact-info h2 { text-align: left; }
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(13, 27, 42, 0.5);
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(76, 161, 217, 0.2);
}
.form-group textarea {
  min-height: 150px;
  resize: vertical;
}

/* --- Buttons --- */
.btn {
  display: inline-block;
  padding: 0.75rem 2rem;
  background: var(--accent-warm);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  text-decoration: none;
}
.btn:hover {
  background: var(--accent-warm-hover);
  color: #fff;
  transform: translateY(-1px);
}

/* --- Resources page --- */
.resource-section {
  margin-bottom: 2rem;
  background: var(--bg-surface);
  border-radius: 8px;
  padding: 1.5rem 2rem;
  border-left: 3px solid transparent;
  transition: border-color 0.3s;
}
.resource-section:hover {
  border-left-color: var(--accent);
}
.resource-section h3 {
  border-bottom: 1px solid rgba(76, 161, 217, 0.12);
  padding-bottom: 0.75rem;
  margin-bottom: 1.25rem;
}
.resource-list { list-style: none; }
.resource-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(48, 54, 61, 0.5);
}
.resource-list li:last-child { border-bottom: none; }
.resource-list a { font-weight: 500; font-size: 1.05rem; }
.resource-list .resource-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
  margin-bottom: 0;
}

/* --- Article (CO2 page) --- */
.article {
  max-width: var(--max-width);
  margin: 0 auto;
}
.article h2 { margin-top: 3rem; }
.article h3 {
  margin-top: 2.5rem;
  font-size: 1.5rem;
}
.article p {
  font-size: 1.05rem;
  line-height: 1.85;
}
.article img {
  border-radius: 4px;
  margin: 2rem auto;
}
.article .img-caption {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: -1.25rem;
  margin-bottom: 2rem;
  font-style: italic;
}
.article strong { color: var(--text-heading); }
.article > p:first-of-type::first-letter {
  font-family: var(--font-heading);
  font-size: 3.4em;
  float: left;
  line-height: 0.8;
  margin-right: 0.08em;
  margin-top: 0.05em;
  color: var(--accent-warm);
}
.stat-callout {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  color: var(--accent-warm);
  border-left: 3px solid var(--accent-warm);
  padding: 0.75rem 1.25rem;
  margin: 2rem 0;
  background: rgba(212, 165, 116, 0.06);
  border-radius: 0 6px 6px 0;
  line-height: 1.4;
}
.img-fallback {
  background: var(--bg-surface);
  border: 1px dashed var(--border);
  border-radius: 4px;
  padding: 1.5rem 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 2rem auto;
  max-width: 600px;
}
.pull-quote {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-style: italic;
  color: var(--text-heading);
  border-left: 3px solid var(--accent-warm);
  padding: 0.5rem 1.5rem;
  margin: 2.5rem -1rem 2.5rem 0;
  line-height: 1.5;
  background: rgba(212, 165, 116, 0.04);
  border-radius: 0 4px 4px 0;
}
.article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 3rem 0;
}

/* --- Placeholder (Coming Soon) --- */
.placeholder {
  text-align: center;
  padding: 10rem 2rem 8rem;
  position: relative;
  z-index: 1;
}
.placeholder h1 { margin-bottom: 1rem; }
.placeholder p {
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* --- Page header (inner pages) --- */
.page-header {
  padding-top: calc(var(--header-height) + 4rem);
  padding-bottom: 3rem;
  text-align: center;
  position: relative;
  z-index: 1;
  background: radial-gradient(ellipse at 50% 0%, rgba(76,161,217,0.12) 0%, transparent 60%);
}
.page-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.3;
}

/* --- Lightbox --- */
.lightbox {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.93);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease-out;
}
.lightbox.active {
  opacity: 1;
  pointer-events: auto;
}
.lightbox-img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 4px;
}
.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 1rem;
  opacity: 0.75;
  transition: opacity 0.2s;
  font-family: sans-serif;
}
.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  opacity: 1;
}
.lightbox-close {
  top: 1rem;
  right: 1.5rem;
  font-size: 2rem;
  line-height: 1;
}
.lightbox-prev,
.lightbox-next {
  top: 50%;
  transform: translateY(-50%);
  font-size: 3rem;
  line-height: 1;
}
.lightbox-prev { left: 1.5rem; }
.lightbox-next { right: 1.5rem; }
.lightbox-counter {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.5);
  font-size: 0.9rem;
  font-family: var(--font-body);
}

/* --- Footer --- */
.footer {
  background: rgba(27, 40, 56, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 2.5rem 0;
  text-align: center;
  margin-top: auto;
  position: relative;
  z-index: 1;
}
.footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.25;
}
.footer p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}
.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.5rem;
}
.footer-links a {
  color: var(--text-muted);
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  transition: color 0.2s;
}
.footer-links a:hover { color: var(--accent); }

/* --- Animations --- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Hero entrance */
.hero-content h1 {
  animation: fadeUp 0.6s ease-out both;
}
.hero-content .tagline {
  animation: fadeUp 0.6s ease-out 0.15s both;
}

/* Staggered card entrance */
.card {
  opacity: 0;
  animation: fadeUp 0.5s ease-out both;
}
.card:nth-child(1) { animation-delay: 0.1s; }
.card:nth-child(2) { animation-delay: 0.2s; }
.card:nth-child(3) { animation-delay: 0.3s; }

/* Scroll-reveal: elements start hidden, JS adds .revealed */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}
.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Gallery items get staggered reveal */
.gallery-grid picture.reveal {
  transition-delay: calc(var(--i, 0) * 0.07s);
}

/* Section titles */
.section-title.reveal {
  transform: translateY(16px);
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .nav-toggle-label { display: block; }
  .nav {
    position: absolute;
    top: var(--header-height);
    left: 0; right: 0;
    background: rgba(27, 40, 56, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    flex-direction: column;
    padding: 1.5rem 2rem;
    gap: 0.75rem;
    transform: scaleY(0);
    transform-origin: top;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    pointer-events: none;
  }
  .nav-toggle:checked ~ .nav {
    transform: scaleY(1);
    opacity: 1;
    pointer-events: auto;
  }
  .hero h1 { font-size: 2.2rem; }
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.4rem; }
  .about-portrait {
    float: none;
    width: 220px;
    margin: 0 auto 1.5rem;
  }
  .about-bio { text-align: center; }
  .about-bio .social-links { justify-content: center; }
  .page-header--left { text-align: center; }
  .section-title--left { text-align: center; }
  .contact-grid { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    padding: 0 1rem;
  }
  .gallery-grid picture:first-child {
    grid-column: 1 / 3;
    grid-row: auto;
  }
  .gallery-grid picture:first-child img {
    aspect-ratio: 21 / 9;
  }
  .section { padding: 2rem 0 2.5rem; }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 1.8rem; }
  .cards { grid-template-columns: 1fr; }
  .gallery-grid {
    grid-template-columns: 1fr;
  }
  .gallery-grid picture:first-child {
    grid-column: auto;
    grid-row: auto;
  }
  .gallery-grid picture:first-child img {
    aspect-ratio: 4 / 3;
  }
  .container { padding: 0 1rem; }
  .lectures { grid-template-columns: 1fr; }
}
