/* ==================== RESET & BASE ==================== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #f4f5f7;
  --bg-raised: #eaecf0;
  --bg-card: #ffffff;
  --text: #1a1a2e;
  --text-muted: #5c6370;
  --accent: #3a6ea5;
  --accent-hover: #2c5a8a;
  --border: #d1d5db;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --max-width: 900px;
  --section-gap: 6rem;
}

html, body {
  overflow-x: hidden;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
}

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

img, video {
  max-width: 100%;
  display: block;
  border-radius: 8px;
}

.video-container {
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  transition: height 0.4s ease;
}
.video-container video {
  width: 100%;
  display: block;
  transition: opacity 0.3s ease;
}
.video-container video.fade-out {
  opacity: 0;
}

ul { list-style: none; }

/* ==================== HERO ==================== */
#hero {
  display: flex;
  flex-direction: column;
  position: relative;
  height: 100svh;
  height: 100vh; /* fallback for older browsers */
  height: 100svh;
}

.hero-photo {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  background-color: #1a1a1a;
  overflow: hidden;
}

.hero-photo-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: opacity 1s ease;
}

.hero-caption {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 0.3rem 0.6rem;
  border-radius: 3px;
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.5s ease;
  font-style: italic;
}

.hero-content {
  flex: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  background: var(--bg-raised);
}

.hero-content h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 1rem;
}

.hero-tagline {
  font-size: clamp(1rem, 2.5vw, 1.35rem);
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 540px;
  margin-bottom: 2rem;
}

.hero-links {
  display: flex;
  gap: 1rem;
}

.hero-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  transition: background 0.2s, border-color 0.2s;
}
.hero-links a:hover {
  background: var(--border);
  border-color: var(--text-muted);
  color: white;
}
.hero-email {
  width: auto !important;
  height: auto !important;
  padding: 0.5rem 1rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.hero-email:hover {
  background: var(--border);
  border-color: var(--text-muted);
  color: var(--text);
}

.scroll-indicator {
  display: none;
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-muted);
  opacity: 0.6;
  animation: bounce 2s ease infinite;
  text-decoration: none;
  z-index: 2;
}
.scroll-indicator:hover {
  opacity: 1;
  color: var(--text);
}

@keyframes bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(8px); }
}

/* ==================== PROJECTS ==================== */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.project {
  margin-top: var(--section-gap);
}

.project-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.project-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.project-type {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.project-body {
  padding-bottom: 2rem;
}

.project-grid {
  display: grid;
  gap: 2.5rem;
  min-width: 0;
}
.project-grid > * {
  min-width: 0;
}
.project-grid.two-col {
  grid-template-columns: 1fr;
}
.project-grid.single-col {
  grid-template-columns: 1fr;
}
.project-grid.single-col .project-media {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.project-text p {
  margin-bottom: 1rem;
  color: var(--text-muted);
}
.project-text p strong {
  color: var(--text);
}

.project-text .project-problem {
  color: var(--text-muted);
}

.partner-logo {
  margin: 1.5rem 0 0.5rem;
}
.partner-logo img {
  width: 100%;
  height: auto;
  opacity: 0.85;
  transition: opacity 0.2s;
}
.partner-logo img:hover {
  opacity: 1;
}

.feature-video {
  margin-bottom: 2rem;
}
.feature-video video {
  width: 100%;
  display: block;
  border-radius: 8px;
}

.project-tech {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.5rem 0;
}

.project-tech span {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.3rem 0.7rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
}

.project-link {
  display: inline-block;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.6rem 1.4rem;
  background: var(--accent);
  color: var(--bg);
  border-radius: 6px;
  transition: background 0.2s;
}
.project-link:hover {
  background: var(--accent-hover);
  color: var(--bg);
}
.project-link.disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: default;
}

/* Project media */
.project-media { margin-top: 1rem; }

.media-caption {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  font-style: italic;
}

.carousel-wrapper {
  position: relative;
  margin-top: 1rem;
  overflow: hidden;
}

.carousel-wrapper .carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.carousel-wrapper:hover .carousel-arrow {
  opacity: 1;
}
.carousel-wrapper .carousel-arrow:hover {
  background: var(--border);
}
.carousel-arrow.left { left: -12px; }
.carousel-arrow.right { right: -12px; }

.gallery-carousel {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.75rem 0;
  scrollbar-width: none;
  scroll-behavior: smooth;
}
.gallery-carousel::-webkit-scrollbar { display: none; }

.gallery-carousel img {
  height: 100px;
  width: auto;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s, border-color 0.2s;
  border: 2px solid transparent;
}
.gallery-carousel img:hover {
  opacity: 0.8;
}
.gallery-carousel img.active {
  opacity: 1;
  border-color: var(--accent);
}

.thumb-item {
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
}
.thumb-item .play-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.thumb-item .play-badge svg {
  width: 10px;
  height: 10px;
  fill: white;
}

.thumb-video {
  height: 100px;
  width: auto;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s, border-color 0.2s;
  border: 2px solid transparent;
  pointer-events: none;
}
.thumb-video:hover {
  opacity: 0.8;
}
.thumb-video.active {
  opacity: 1;
  border-color: var(--accent);
}

.gallery-photos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}
.gallery-photos-captions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.diagram {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

#apophis-widget {
  width: 100%;
  max-width: 600px;
  min-height: 400px;
  border-radius: 8px;
  overflow: hidden;
  margin-left: auto;
  margin-right: auto;
}
#apophis-widget iframe {
  width: 100% !important;
  height: 400px !important;
  max-width: 100% !important;
}

/* ==================== ABOUT ==================== */
#about {
  margin-top: var(--section-gap);
}

/* ==================== PROJECTS ==================== */
#projects {
  margin-top: var(--section-gap);
}
#projects .section-inner h2 {
  margin-bottom: 0;
}

.section-inner h2 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  padding: 0.75rem 1.25rem;
  background: #4a4a5e;
  color: var(--bg);
  border-radius: 6px;
  margin-bottom: 2rem;
}

.about-photo {
  float: right;
  width: 260px;
  margin: 0 0 1.5rem 2rem;
  border-radius: 8px;
  overflow: hidden;
}
.about-photo img {
  width: 100%;
  display: block;
  border-radius: 8px;
}
.about-photo-caption {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.7;
}

@media (max-width: 600px) {
  .about-photo {
    float: none;
    width: 100%;
    max-width: 300px;
    margin: 0 auto 1.5rem;
  }
}

.about-content p {
  color: var(--text-muted);
  margin-bottom: 1rem;
  max-width: 640px;
}
.about-content a,
.project-text a {
  color: var(--accent);
  text-decoration: underline;
}
.project-text a.project-link {
  color: var(--bg);
  text-decoration: none;
}

/* ==================== TECHNOLOGIES ==================== */
#technologies {
  margin-top: var(--section-gap);
}

.tech-agents {
  margin-bottom: 3rem;
}

.tech-agents h3 {
  font-size: 0.85rem;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.tech-agents > p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  max-width: 640px;
}

.agent-tools {
  display: grid;
  gap: 1rem;
}

.agent-tool {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.agent-tool strong {
  font-size: 1rem;
  color: var(--text);
}

.agent-tool span {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
}

@media (min-width: 768px) {
  .agent-tools {
    grid-template-columns: 1fr 1fr;
  }
}

.tech-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.tech-category h3 {
  font-size: 0.85rem;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.tech-category ul li {
  color: var(--text-muted);
  font-size: 0.95rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
}

/* ==================== FOOTER ==================== */
footer {
  margin-top: var(--section-gap);
  position: relative;
  overflow: hidden;
  padding: 4rem 1.5rem 2rem;
  min-height: 400px;
  background: #1a1a2e;
  color: #eaecf0;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.footer-inner h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.contact-links a {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: #9ca3af;
  display: flex;
  align-items: center;
}
.contact-links a:hover {
  color: #e0e0e0;
}
.contact-links a svg {
  width: 24px;
  height: 24px;
}

#grid {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* ==================== RESPONSIVE ==================== */
@media (min-width: 768px) {
  body { font-size: 17px; }

  #hero {
    flex-direction: row;
    height: auto;
    min-height: 100vh;
  }
  .hero-photo {
    height: auto;
    flex: 0 0 40%;
  }
  .hero-content {
    flex: 1;
    padding: 4rem 3rem;
  }
  .scroll-indicator {
    display: block;
  }

  .project-grid.two-col {
    grid-template-columns: 1fr 1fr;
  }

  .gallery-carousel img,
  .thumb-item img,
  .thumb-video {
    height: 130px;
  }

  .partner-logo img {
    width: auto;
    height: 5rem;
  }

  .tech-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .contact-links {
    gap: 2rem;
  }
}

@media (min-width: 1024px) {
  .hero-content {
    padding: 5rem 4rem;
  }
}

/* ==================== ANIMATION ==================== */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}
