/* ============================================
   Stefan Ilic — Personal Website
   ============================================ */

/* --- CSS Reset & Variables --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #FAF9F6;
  --bg-secondary: #F0EBE3;
  --bg-dark: #2C2C34;
  --text-primary: #2D2D2D;
  --text-secondary: #6B6B6B;
  --text-on-dark: #F5F0EB;
  --accent: #5B8A72;
  --accent-hover: #4A7360;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --border: #E5E0D8;
  --radius: 10px;
  --nav-height: 55px;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', 'Helvetica Neue', sans-serif;
  font-size: 17px;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Inter', 'Helvetica Neue', sans-serif;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent-hover);
}

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

/* --- Navbar --- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: #1a1a1f;
  z-index: 1000;
  transition: box-shadow 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.navbar.scrolled {
  box-shadow: 0 2px 20px rgba(0,0,0,0.15);
}

.navbar-inner {
  width: 100%;
  max-width: 1100px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-brand {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-on-dark);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.navbar-brand:hover {
  color: #fff;
}

.navbar-links {
  display: flex;
  gap: 28px;
  list-style: none;
}

.navbar-links a {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-on-dark);
  text-decoration: none;
  padding: 4px 0;
  position: relative;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.navbar-links a:hover,
.navbar-links a.active {
  opacity: 1;
}

.navbar-links a.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
}

.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-on-dark);
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.hamburger.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger.open span:nth-child(2) {
  opacity: 0;
}

.hamburger.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* --- Main Content --- */
main {
  margin-top: var(--nav-height);
  flex: 1;
}

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

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

/* --- Hero Section (Karpathy-style) --- */
.hero {
  padding: 40px 24px 30px;
  max-width: 750px;
  margin: 0 auto;
}

.hero-inner {
  display: flex;
  align-items: center;
  gap: 48px;
}

.hero-photo {
  width: 250px;
  height: 250px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 55% center;
  border: 4px solid var(--bg-secondary);
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
}

.hero-text {
  flex: 1;
}

.hero-name {
  font-size: 2.6rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.hero-tagline {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 1.05rem;
  color: var(--text-primary);
  line-height: 1.7;
  margin-bottom: 18px;
  opacity: 0.7;
}

.hero-socials {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.hero-socials a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.hero-socials a:hover {
  color: var(--text-primary);
  transform: translateY(-2px);
}

.hero-socials svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

.hero-socials a:last-child svg {
  width: 34px;
  height: 34px;
}

/* --- What I'm Building --- */
.building-section {
  padding: 40px 24px 35px;
  background: var(--bg-secondary);
}

.building-section h2 {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 40px;
  color: var(--text-primary);
}

.building-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
}

.building-card {
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  text-decoration: none;
  display: block;
}

.building-card:hover {
  transform: translateY(-7px);
  box-shadow: var(--shadow-md);
}

.building-card-img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  display: block;
}

.building-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 20px 24px 8px;
}

.building-card p {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 0.85rem;
  color: #4a4a4a;
  line-height: 1.7;
  margin: 0 24px 24px;
}

.building-more {
  text-align: center;
  margin-top: 20px;
}

.building-more a {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--accent);
}

.building-more a:hover {
  color: var(--accent-hover);
}

/* --- Timeline --- */
.timeline-section {
  padding: 60px 24px 80px;
}

.timeline {
  position: relative;
  max-width: 1100px;
}

.timeline-entry {
  display: grid;
  grid-template-columns: 200px 20px 1fr;
  gap: 0 10px;
  padding-bottom: 56px;
  position: relative;
}

.timeline-year {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  text-align: right;
  padding-top: 0;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.timeline-marker {
  position: relative;
  display: flex;
  justify-content: center;
}

.timeline-marker::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: -56px;
  width: 2px;
  background: var(--border);
}

.timeline-entry:last-child .timeline-marker::before {
  bottom: 0;
}

.timeline-marker::after {
  content: '';
  position: relative;
  top: 6px;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border: 3px solid var(--bg-primary);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  z-index: 1;
  flex-shrink: 0;
}

.timeline-content {
  padding-top: 0;
}

.timeline-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.timeline-subtitle {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.timeline-text {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 0.92rem;
  color: var(--text-primary);
  line-height: 1.8;
}

.timeline-lead {
  font-size: 1.15rem;
  font-style: italic;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.timeline-text + .timeline-text {
  margin-top: 10px;
}

.timeline-text a {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 2px;
}

/* --- Portfolio Gallery --- */
.portfolio-section {
  padding: 80px 24px 100px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.portfolio-header {
  text-align: center;
  max-width: 600px;
  margin: 0 auto 48px;
}

.portfolio-header h2 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.portfolio-header p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto;
}

.portfolio-item {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-dark);
  aspect-ratio: 4 / 3;
  cursor: pointer;
}

.portfolio-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.portfolio-item:hover img {
  transform: scale(1.05);
}

.portfolio-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: #fff;
  font-size: 0.82rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.portfolio-item:hover .portfolio-caption {
  opacity: 1;
}

/* --- Page Header (Projects / Papers) --- */
.page-header {
  text-align: center;
  padding: 60px 24px 40px;
}

.page-header h1 {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.page-header p {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 550px;
  margin: 0 auto;
}

.page-header--compact {
  text-align: center;
  max-width: none;
  padding: 14px 24px 12px;
  background: var(--bg-secondary);
}

.page-header--compact > .page-header-accent {
  max-width: 800px;
  margin: 0 auto;
}

.page-header--compact h1 {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.page-header--compact h1::after {
  content: '';
  display: block;
  width: 40px;
  height: 2px;
  background: var(--accent);
  margin: 10px auto 0;
  border-radius: 2px;
}

.page-header--compact p {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 1rem;
  line-height: 1.7;
  margin: 0;
  max-width: none;
}


/* --- Project Sections (scrollable, alternating) --- */
.project-section {
  padding: 40px 24px;
  scroll-margin-top: var(--nav-height);
}

.project-section--light {
  background: var(--bg-primary);
}

.project-section--dark {
  background: var(--bg-secondary);
}

.project-section-inner {
  max-width: 800px;
  margin: 0 auto;
}

.project-section h2 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
  text-align: center;
}

.project-video {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  margin-bottom: 20px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  background: var(--bg-dark);
}

.project-video iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.video-lazy {
  cursor: pointer;
}

.video-lazy img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 72px;
  height: 72px;
  background: url('images/yticon.png') center / contain no-repeat;
  border: none;
  cursor: pointer;
  z-index: 1;
  transition: opacity 0.2s ease;
  opacity: 0.9;
}

.video-lazy:hover .video-play {
  opacity: 1;
}

.project-desc {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 0.90rem;
  color: var(--text-primary);
  line-height: 1.8;
  margin-bottom: 14px;
  text-align: left;
}

.project-bullets {
  list-style: none;
  padding-left: 25px;
}

.project-bullets li {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 0.90rem;
  color: var(--text-primary);
  padding: 6px 0 6px 20px;
  position: relative;
  line-height: 1.7;
}

.project-bullets li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 13px;
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
}

/* --- Papers --- */
.papers-section {
  padding: 20px 24px 100px;
}

.papers-year-group {
  margin-bottom: 48px;
}

.papers-year {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}

.paper-entry {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.paper-entry:last-child {
  border-bottom: none;
}

.paper-title {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 6px;
  line-height: 1.4;
}

.paper-title a {
  color: var(--text-primary);
}

.paper-title a:hover {
  color: var(--accent);
}

.paper-authors {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.paper-authors strong {
  color: var(--text-primary);
}

.paper-venue {
  font-size: 0.88rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 8px;
}

.paper-links {
  display: flex;
  gap: 14px;
}

.paper-links a {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  padding: 3px 10px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  transition: all 0.2s ease;
}

.paper-links a:hover {
  background: var(--accent);
  color: #fff;
}

/* --- Bio Page --- */
.bio-section {
  padding: 10px 24px 40px;
}

.bio-intro {
  display: flex;
  gap: 40px;
  align-items: center;
  margin-bottom: 30px;
}

.bio-photo {
  width: 280px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
}

.bio-prose p {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 0.92rem;
  color: var(--text-primary);
  line-height: 1.8;
  margin-bottom: 16px;
}

.bio-prose p:last-child {
  margin-bottom: 0;
}

.bio-fun {
  border-top: 1.7px solid #aaa;
  padding-top: 30px;
}

.bio-fun h2 {
  font-size: 1.5rem;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.bio-fun p {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 0.92rem;
  color: var(--text-primary);
  line-height: 1.8;
  margin-bottom: 16px;
}

.bio-fun p:last-child {
  margin-bottom: 0;
}

@media (max-width: 768px) {
  .bio-intro {
    flex-direction: column;
    gap: 28px;
  }

  .bio-photo {
    width: 100%;
    max-width: 300px;
  }
}

.paper-preprint {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 8px;
}

.scholar-link {
  text-align: center;
  margin-top: -20px;
  margin-bottom: 40px;
}

.scholar-link a {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent);
  padding: 10px 24px;
  border: 2px solid var(--accent);
  border-radius: 30px;
  transition: all 0.2s ease;
  display: inline-block;
}

.scholar-link a:hover {
  background: var(--accent);
  color: #fff;
}

/* --- Footer --- */
.footer {
  background: #1a1a1f;
  padding: 24px 24px;
  text-align: center;
}

.footer-socials {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
}

.footer-socials a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--text-on-dark);
  opacity: 0.7;
  transition: all 0.2s ease;
}

.footer-socials a:hover {
  opacity: 1;
  color: var(--accent);
  transform: translateY(-2px);
}

.footer-socials svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.footer-socials a:last-child svg {
  width: 28px;
  height: 28px;
}

.footer-copy {
  font-size: 0.95rem;
  color: var(--text-on-dark);
  opacity: 0.5;
  margin-bottom: 8px;
}

.footer-tagline {
  font-size: 0.82rem;
  font-style: italic;
  color: var(--text-on-dark);
  opacity: 0.4;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
  .navbar-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--bg-dark);
    padding: 16px 24px;
    gap: 12px;
    box-shadow: var(--shadow-md);
  }

  .navbar-links.open {
    display: flex;
  }

  .hamburger {
    display: flex;
  }

  .hero {
    padding: 70px 20px 50px;
  }

  .hero-inner {
    flex-direction: column;
    text-align: center;
    gap: 28px;
  }

  .hero-photo {
    width: 140px;
    height: 140px;
  }

  .hero-name {
    font-size: 2.2rem;
  }

  .hero-socials {
    justify-content: center;
  }

  /* Mobile building grid */
  .building-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .building-section {
    padding: 50px 20px 60px;
  }

  /* Mobile timeline */
  .timeline-entry {
    grid-template-columns: 16px 1fr;
    gap: 0 16px;
  }

  .timeline-year {
    grid-column: 1 / -1;
    text-align: left;
    margin-bottom: 8px;
    font-size: 1rem;
  }

  .timeline-marker {
    grid-column: 1;
    grid-row: 2;
  }

  .timeline-content {
    grid-column: 2;
    grid-row: 2;
  }

  /* Project sections */
  .project-section {
    padding: 60px 20px;
  }

  .project-section h2 {
    font-size: 1.4rem;
  }

  /* Portfolio grid */
  .portfolio-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .portfolio-section {
    padding: 60px 20px 80px;
  }

  .portfolio-caption {
    opacity: 1;
  }

  .page-header {
    padding: 60px 20px 30px;
  }

  .page-header h1 {
    font-size: 2rem;
  }

}

@media (max-width: 480px) {
  body {
    font-size: 16px;
  }

  .hero-name {
    font-size: 1.8rem;
  }

  .hero-tagline {
    font-size: 1rem;
  }
}

/* --- Print Styles (Papers) --- */
@media print {
  .navbar, .footer, .hamburger {
    display: none !important;
  }

  main {
    margin-top: 0;
  }

  .paper-entry {
    opacity: 1 !important;
    transform: none !important;
  }

  .paper-links a {
    border: none;
    padding: 0;
    color: var(--text-secondary);
  }

  .paper-links a::after {
    content: " (" attr(href) ")";
    font-size: 0.75rem;
  }
}

/* --- Focus States for Accessibility --- */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Utility --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
