/* =========================================================
   THEME VARIABLES — change colors, fonts and spacing here.
   Everything below references these, so editing here
   updates the whole site.
   ========================================================= */
:root {
  /* --- Colors --- */
  --bg:        #F7F8FF;   /* page background: very light lavender-white */
  --surface:   #FFFFFF;   /* card / panel background */
  --border:    #E4E7FA;   /* hairline borders */

  --ink:       #14162B;   /* main text (deep navy, not pure black) */
  --ink-soft:  #5B5F79;   /* secondary / paragraph text */

  --blue:      #4F7CFF;   /* primary accent */
  --purple:    #9B6BFF;   /* secondary accent */
  --cyan:      #38D0F0;   /* tertiary accent, used sparingly */

  --gradient:  linear-gradient(135deg, var(--blue), var(--purple));

  /* --- Fonts --- */
  --font-display: 'Space Grotesk', sans-serif;
  --font-body:    'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* --- Layout --- */
  --max-width: 1120px;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
}

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

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

h2 { font-size: clamp(1.9rem, 3vw, 2.6rem); margin-bottom: 2.5rem; }
h3 { font-size: 1.25rem; margin-bottom: 0.5rem; }

p { color: var(--ink-soft); 
    margin-bottom: 20px;  }

a { color: inherit; text-decoration: none; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.text-gradient {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--blue);
  margin-bottom: 0.75rem;
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 1.6rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  cursor: pointer;
}
.btn:hover { transform: translateY(-2px); }

.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 8px 24px -8px rgba(79, 124, 255, 0.55);
}
.btn-primary:hover { box-shadow: 0 12px 28px -6px rgba(155, 107, 255, 0.55); }

.btn-ghost {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--blue); }

.btn-text {
  background: none;
  border: none;
  padding: 0;
  color: var(--blue);
  font-size: 0.9rem;
}
.btn-text:hover { color: var(--purple); transform: none; }

.hero-actions { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 2rem; }

/* =========================================================
   HEADER / NAV
   ========================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(247, 248, 255, 0.75);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 24px;
}

.logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
}
.logo span { color: var(--blue); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 2rem;
  list-style: none;
}

.nav-links a { font-weight: 500; color: var(--ink-soft); }
.nav-links a:hover { color: var(--ink); }

.nav-cta {
  background: var(--gradient);
  color: #fff !important;
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
}
.nav-toggle span {
  width: 22px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
}

/* =========================================================
   HERO
   ========================================================= */
.hero {
  position: relative;
  overflow: hidden;
  padding: 5rem 0 6rem;
}

.hero-glow {
  position: absolute;
  width: 480px;
  height: 480px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  z-index: 0;
}
.hero-glow--1 { background: var(--blue); top: -120px; left: -140px; }
.hero-glow--2 { background: var(--purple); bottom: -160px; right: -120px; }

.hero-inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 3rem;
  align-items: center;
}

/* Grid items default to min-width:auto, which lets their content's
   intrinsic size push the track wider than the column — this is
   what was clipping the pipeline graphic. min-width:0 fixes it. */
.hero-copy, .hero-visual { min-width: 0; }

.hero-copy h1 {
  font-size: clamp(2.2rem, 4.4vw, 3.4rem);
  margin: 0.75rem 0 1.25rem;
}

.hero-lede { max-width: 46ch; font-size: 1.05rem; }

/* --- pipeline signature graphic --- */
.hero-visual { max-width: 420px; margin: 0 auto; }
.pipeline-svg { display: block; width: 100%; height: auto; overflow: visible; }

.pipe-line {
  fill: none;
  stroke: url(#flowGrad);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 8 8;
  animation: dashFlow 6s linear infinite;
  opacity: 0.7;
}

@keyframes dashFlow {
  to { stroke-dashoffset: -200; }
}

.node-circle {
  fill: var(--surface);
  stroke: var(--border);
  stroke-width: 1.5;
  filter: drop-shadow(0 6px 14px rgba(79, 124, 255, 0.18));
}
.node-circle--center {
  stroke: url(#flowGrad);
  stroke-width: 2;
}

.node-icon {
  font-size: 26px;
  text-anchor: middle;
}
.node-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-anchor: middle;
  fill: var(--ink-soft);
}

.node { animation: float 4s ease-in-out infinite; }
.node:nth-child(4) { animation-delay: 0.3s; }
.node:nth-child(5) { animation-delay: 0.6s; }
.node:nth-child(6) { animation-delay: 0.9s; }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* =========================================================
   SERVICES
   ========================================================= */
.services { padding: 5rem 0; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

.service-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 2rem 1.6rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.service-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 32px -16px rgba(79, 124, 255, 0.28);
}
.service-icon { font-size: 1.8rem; margin-bottom: 1rem; }

/* =========================================================
   PROJECTS
   ========================================================= */
.projects { padding: 5rem 0; }

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.75rem;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.project-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px -20px rgba(79, 124, 255, 0.32);
}

.project-cover {
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
}
.project-cover--1 { background: linear-gradient(135deg, #4F7CFF, #8E7BFF); }
.project-cover--2 { background: linear-gradient(135deg, #7B7CFF, #9B6BFF); }
.project-cover--3 { background: linear-gradient(135deg, #38D0F0, #4F7CFF); }
.project-cover--4 { background: linear-gradient(135deg, #6B7BFF, #38D0F0); }
.project-cover-icon { filter: drop-shadow(0 4px 10px rgba(0,0,0,0.15)); }
.project-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.project-card-body { padding: 1.5rem; }

.tag-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.9rem 0 1.2rem; }
.tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink-soft);
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
}

/* =========================================================
   ABOUT
   ========================================================= */
.about { padding: 5rem 0; }

.about-inner {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 3rem;
  align-items: center;
}

.about-inner p { margin-bottom: 1rem; max-width: 56ch; }

.about-visual { display: flex; justify-content: center; }
.about-blob {
  width: 220px;
  height: 220px;
  border-radius: 42% 58% 63% 37% / 45% 40% 60% 55%;
  background: var(--gradient);
  opacity: 0.85;
  filter: blur(0.5px);
  animation: morph 8s ease-in-out infinite;
}
@keyframes morph {
  0%, 100% { border-radius: 42% 58% 63% 37% / 45% 40% 60% 55%; }
  50% { border-radius: 58% 42% 37% 63% / 55% 60% 40% 45%; }
}

/* =========================================================
   CONTACT
   ========================================================= */
.contact { padding: 5rem 0 6rem; text-align: center; }
.contact-inner { max-width: 640px; margin: 0 auto; }
.contact-lede { margin: 1rem 0 0; }
.contact .hero-actions { justify-content: center; }

/* =========================================================
   FOOTER
   ========================================================= */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  text-align: center;
}
.site-footer p { font-size: 0.85rem; }

/* =========================================================
   MODAL (project detail lightbox)
   ========================================================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 4vh 20px;
  overflow-y: auto;
}
.modal.is-open { display: flex; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 43, 0.55);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  max-width: 720px;
  width: 100%;
  z-index: 1;
}

.modal-close {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 0.9rem;
}

#modalTitle { padding-right: 2rem; }
#modalTagline { margin-top: 0.4rem; margin-bottom: 1.5rem; }
/* when a tagline is a { intro, points } object instead of a plain string */
#modalTagline ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
  color: var(--ink-soft);
}
#modalTagline ul li { margin-bottom: 0.25rem; }
#modalTagline p { margin: 0 0 0.75rem; }
#modalTagline p:last-child { margin-bottom: 0; }

.modal-video {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  background: var(--bg);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 1.75rem;
}

.modal-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* 顶部媒体区：视频 + 截图，横向滚动切换，一次显示一张 */
.modal-media-wrap {
  position: relative;
  margin-bottom: 1.75rem;
}
/* JS sets [hidden] on the wrap when there's no video/screenshots at all */
.modal-media-wrap[hidden] { display: none; }

.modal-media {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.modal-media::-webkit-scrollbar { display: none; }
.modal-media .modal-video { flex: 0 0 100%; scroll-snap-align: start; margin-bottom: 0; }

.modal-media img {
  flex: 0 0 100%;
  scroll-snap-align: start;
  display: block;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  cursor: zoom-in;
}

/* left/right arrows over the media strip hint that more screenshots follow */
.media-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(20, 22, 43, 0.15);
}
.media-prev { left: 0.6rem; }
.media-next { right: 0.6rem; }
/* the [hidden] attribute must win over the display:flex rule above */
.media-nav[hidden] { display: none; }

/* modal 里所有图片：永远不超过容器宽度 */
.modal-panel img {
  max-width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

/* architecture diagram image: shown at its natural size (capped to the
   panel width) and centered, with no filled background behind it */
.modal-arch-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0.9rem auto 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
/* the [hidden] attribute must win over the display:block rule above */
.modal-arch-image[hidden] { display: none; }

.modal-section { margin-bottom: 1.25rem; }
.modal-section h4 {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--blue);
  margin-bottom: 0.35rem;
}

/* tech tags inside the modal sit tighter than the card tag-row */
.modal-section .tag-row { margin: 0.2rem 0 0; }

/* section body text (div so it can contain bullet lists) */
.modal-section .modal-text { color: var(--ink-soft); }
.modal-text p { margin: 0 0 0.75rem; }
.modal-text p:last-child { margin-bottom: 0; }

/* bullet lists inside modal sections */
.modal-section ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
  color: var(--ink-soft);
}
.modal-section ul li { margin-bottom: 0.25rem; }

/* architecture diagram also opens in the lightbox on click */
.modal-arch-image {
  cursor: zoom-in;
}

/* =========================================================
   LIGHTBOX (click-to-enlarge for modal images)
   ========================================================= */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 4vh 20px;
}
.lightbox.is-open { display: flex; }

.lightbox-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 43, 0.85);
}

/* fixed-size viewing box; the image scales down/up to fit inside it */
.lightbox-stage {
  position: relative;
  z-index: 1;
  width: min(900px, 90vw);
  height: min(600px, 82vh);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: zoom-out;
  background: var(--surface);
}

.lightbox-close {
  position: fixed;
  top: 1.2rem;
  right: 1.2rem;
  z-index: 2;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 0.9rem;
}

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox-prev { left: 1.2rem; }
.lightbox-next { right: 1.2rem; }
/* the [hidden] attribute must win over the display:flex rule above */
.lightbox-nav[hidden] { display: none; }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 860px) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero-visual { order: -1; max-width: 340px; margin: 0 auto; }
  .about-inner { grid-template-columns: 1fr; text-align: left; }
  .about-visual { order: -1; }
}

@media (max-width: 720px) {
  .nav-toggle { display: flex; }
  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: flex-start;
    padding: 1.5rem 24px;
    gap: 1.25rem;
    display: none;
  }
  .nav-links.is-open { display: flex; }
}
