/* ============================================================
   Chenlab — Homepage
   Theme: "Laboratory Notebook" — bright, crisp, academic
   ============================================================ */

/* ----------------------------------------------------------
   1. CSS Custom Properties
   ---------------------------------------------------------- */
:root {
  /* Palette */
  --color-bg:           #fafaf7;
  --color-bg-alt:       #f4f4f0;
  --color-surface:      #ffffff;
  --color-card:         #ffffff;
  --color-card-hover:   #fdfdfb;
  --color-border:       #e4e4de;
  --color-border-hover: #d0d0c8;

  --color-text:         #1a1a2e;
  --color-text-secondary:#5c5c72;
  --color-text-muted:   #9494a8;

  --color-primary:      #0d3b66;   /* deep navy */
  --color-accent:       #2a9d8f;   /* teal-green */
  --color-accent-glow:  rgba(42, 157, 143, 0.12);

  /* Typography */
  --font-display:  'Cormorant Garamond', 'Times New Roman', serif;
  --font-body:     system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono:     'Courier New', 'Consolas', monospace;
  --font-size-xs:  0.8rem;
  --font-size-sm:  0.9rem;
  --font-size-base:1rem;
  --font-size-md:  1.15rem;
  --font-size-lg:  1.4rem;
  --font-size-xl:  1.8rem;
  --font-size-2xl: 2.8rem;
  --font-size-3xl: 4rem;

  /* Spacing */
  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  2rem;
  --space-xl:  3.5rem;
  --space-2xl: 5rem;

  /* Layout */
  --max-width:   1140px;
  --radius:      6px;
  --radius-lg:   10px;
  --shadow-sm:   0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.03);
  --shadow-md:   0 2px 8px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg:   0 4px 16px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.04);
  --transition:  0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ----------------------------------------------------------
   2. Reset & Base
   ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  font-weight: 400;
  line-height: 1.7;
  color: var(--color-text);
  background:
    /* Subtle dot-grid — lab notebook paper */
    radial-gradient(circle, rgba(0,0,0,0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

::selection {
  background: rgba(42, 157, 143, 0.18);
  color: var(--color-primary);
}

/* ----------------------------------------------------------
   3. Typography
   ---------------------------------------------------------- */
h1, h2, h3, h4 { font-family: var(--font-display); }

p { margin-bottom: var(--space-md); }

a { color: inherit; text-decoration: none; transition: color var(--transition); }

/* ----------------------------------------------------------
   4. Utility
   ---------------------------------------------------------- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* ----------------------------------------------------------
   5. Skip Link
   ---------------------------------------------------------- */
.skip-link {
  position: fixed;
  top: -100px;
  left: var(--space-md);
  background: var(--color-primary);
  color: #fff;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-xs);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  z-index: 10000;
  border-radius: 0 0 var(--radius) var(--radius);
  transition: top 0.2s;
}
.skip-link:focus { top: 0; }

/* ----------------------------------------------------------
   6. Header
   ---------------------------------------------------------- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 250, 247, 0.88);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  border-bottom: 1px solid var(--color-border);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
}

.header__logo {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  font-style: italic;
  color: var(--color-primary);
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header__logo:hover { color: var(--color-accent); }

.header__nav {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  flex-shrink: 0;
}

.header__nav-link {
  font-size: var(--font-size-xs);
  font-weight: 550;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  padding: var(--space-xs) 0;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}
.header__nav-link:hover,
.header__nav-link:focus-visible {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

/* ----------------------------------------------------------
   7. Buttons
   ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.7rem 1.6rem;
  font-size: var(--font-size-sm);
  font-weight: 550;
  letter-spacing: 0.04em;
  text-align: center;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all var(--transition);
  position: relative;
}

/* Primary — solid navy */
.btn--primary {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
}
.btn--primary:hover {
  background: #153f60;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Outline — for hero secondary */
.btn--outline {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn--outline:hover {
  background: var(--color-primary);
  color: #ffffff;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Download, Launch, Paper — subtle secondary buttons */
.btn--download,
.btn--launch,
.btn--paper {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: var(--color-border);
  justify-content: center;
  font-weight: 450;
  font-size: var(--font-size-xs);
  padding: 0.5rem 1.2rem;
  letter-spacing: 0.05em;
}
.btn--download:hover,
.btn--launch:hover,
.btn--paper:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
  box-shadow: none;
  transform: translateY(-1px);
}

.btn--launch::after { content: ' ↗'; }
.btn--download::after { content: ' ↓'; }
.btn--paper::after { content: ' ↗'; }

/* Disabled */
.btn--disabled {
  background: var(--color-bg-alt);
  color: var(--color-text-muted);
  border-color: var(--color-border);
  cursor: not-allowed;
  pointer-events: none;
}

/* ----------------------------------------------------------
   8. Hero
   ---------------------------------------------------------- */
.hero {
  position: relative;
  padding: var(--space-2xl) 0 var(--space-xl);
  text-align: center;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(13, 59, 102, 0.04) 0%, transparent 55%),
    radial-gradient(ellipse at 70% 60%, rgba(42, 157, 143, 0.05) 0%, transparent 55%),
    var(--color-bg);
}

/* Top accent line */
.hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg,
    var(--color-primary) 0%,
    var(--color-accent) 100%
  );
}

/* Bottom separator */
.hero::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 75%;
  max-width: 760px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-border), transparent);
}

.hero .container { position: relative; z-index: 1; }

.hero__title {
  font-family: var(--font-display);
  font-size: var(--font-size-3xl);
  font-weight: 700;
  font-style: italic;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--color-primary);
  margin-bottom: var(--space-sm);
  animation: fadeUp 0.7s ease-out both;
}

.hero__title .accent {
  color: var(--color-accent);
}

.hero__tagline {
  font-family: var(--font-display);
  font-size: 2rem;
  font-style: italic;
  color: var(--color-accent);
  margin-bottom: var(--space-lg);
  animation: fadeUp 0.7s ease-out 150ms both;
}

.hero__note {
  font-size: var(--font-size-md);
  color: var(--color-text-muted);
  margin-bottom: var(--space-lg);
  font-style: italic;
  line-height: 1.6;
  white-space: nowrap;
}

.hero__actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
  animation: fadeUp 0.7s ease-out 300ms both;
}

/* Scroll hint */
.hero__scroll-hint {
  margin-top: var(--space-xl);
  animation: fadeUp 0.7s ease-out 400ms both;
}
.hero__scroll-hint span {
  display: block;
  width: 1px;
  height: 28px;
  margin: 0 auto;
  background: linear-gradient(to bottom, var(--color-accent), transparent);
  animation: bounceDown 2s ease-in-out infinite;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes bounceDown {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(5px); }
}

/* ----------------------------------------------------------
   9. Section Base
   ---------------------------------------------------------- */
.section {
  padding: var(--space-2xl) 0;
  position: relative;
}

.section--alt {
  background: var(--color-bg);
}

.section__number {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  font-weight: 500;
  letter-spacing: 0.10em;
  color: var(--color-accent);
  text-transform: uppercase;
  margin-bottom: var(--space-sm);
}

.section__title {
  font-family: var(--font-display);
  font-size: var(--font-size-2xl);
  font-weight: 700;
  font-style: italic;
  color: var(--color-primary);
  margin-bottom: var(--space-sm);
  line-height: 1.1;
}

.section__description {
  font-size: var(--font-size-md);
  color: var(--color-text-secondary);
  max-width: 600px;
  margin-bottom: var(--space-xl);
  line-height: 1.7;
}

/* ----------------------------------------------------------
   10. Dataset Gallery (full-width cards, future carousel)
   ---------------------------------------------------------- */
.dataset-gallery,
.tool-gallery {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}


/* ----------------------------------------------------------
   11. Cards
   ---------------------------------------------------------- */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  transition: all var(--transition);
  position: relative;
  box-shadow: var(--shadow-sm);

  opacity: 0;
  animation: cardReveal 0.55s ease-out forwards;
}

/* Top accent bar — invisible until hover */
.card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: var(--radius-lg);
  right: var(--radius-lg);
  height: 2px;
  background: var(--color-accent);
  border-radius: 0 0 2px 2px;
  opacity: 0;
  transform: scaleX(0.6);
  transition: all var(--transition);
}

.card:hover {
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.card:hover::before {
  opacity: 1;
  transform: scaleX(1);
}

/* Staggered reveal */
.card:nth-child(1) { animation-delay: 0ms; }
.card:nth-child(2) { animation-delay: 80ms; }
.card:nth-child(3) { animation-delay: 160ms; }
.card:nth-child(4) { animation-delay: 240ms; }
.card:nth-child(5) { animation-delay: 320ms; }
.card:nth-child(6) { animation-delay: 400ms; }

@keyframes cardReveal {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Card internals */
.card__figure {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: var(--space-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
}

.card__title {
  font-family: var(--font-display);
  font-size: var(--font-size-xl);
  font-weight: 650;
  font-style: italic;
  color: var(--color-primary);
  margin-bottom: var(--space-sm);
  line-height: 1.2;
}

.card__meta-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
  letter-spacing: 0.03em;
}

.card__description {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-md);
  line-height: 1.7;
  flex-shrink: 0;
}

.card__actions {
  margin-top: auto;
  padding-top: var(--space-sm);
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* --- Horizontal card modifier (after base .card to override) --- */
.card--horizontal {
  flex-direction: row;
  gap: var(--space-lg);
  align-items: stretch;
  padding: 0;
  overflow: hidden;
}

.card__figure-wrap {
  flex: 0 0 42%;
  min-width: 280px;
  overflow: hidden;
  background: var(--color-bg);
}

.card__figure-wrap .card__figure {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  margin: 0;
  border: none;
  border-radius: 0;
}

.card__body {
  flex: 1;
  padding: var(--space-lg) 0 var(--space-lg) var(--space-lg);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ----------------------------------------------------------
   12. About Us
   ---------------------------------------------------------- */
.about__content {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.footer__affiliation {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
  line-height: 1.5;
}

.about__text {
  font-size: var(--font-size-md);
  line-height: 1.75;
  color: var(--color-text-secondary);
}

.about__text strong {
  color: var(--color-primary);
  font-weight: 600;
}

.about__photo {
  max-width: 560px;
  width: 100%;
  align-self: center;
}

.about__photo img {
  width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

/* ----------------------------------------------------------
   13. Status Badge
   ---------------------------------------------------------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  font-size: var(--font-size-xs);
  font-weight: 550;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.2em 0.75em;
  border-radius: 999px;
  margin-bottom: var(--space-md);
  width: fit-content;
}

.status-badge--coming-soon {
  background: var(--color-bg-alt);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

/* ----------------------------------------------------------
   14. Footer
   ---------------------------------------------------------- */
.footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  text-align: center;
  padding: var(--space-xl) 0;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
}

.footer__brand {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-style: italic;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
}

/* ----------------------------------------------------------
   14. Focus styles
   ---------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ----------------------------------------------------------
   15. Tablet (≤768px)
   ---------------------------------------------------------- */
@media (max-width: 768px) {
  :root {
    --space-2xl: 3.5rem;
    --font-size-3xl: 3rem;
    --font-size-2xl: 2.2rem;
  }

  .header__inner { height: 52px; padding: 0 var(--space-md); }
  .header__logo { font-size: 1rem; }
  .header__nav { gap: var(--space-md); }

  .hero { padding: var(--space-xl) 0; }
  .hero__description { font-size: var(--font-size-base); }

  .section { padding: var(--space-xl) 0; }
  .section__title { font-size: var(--font-size-xl); }

  .card--horizontal {
    flex-direction: column;
  }
  .card__figure-wrap {
    flex: 0 0 auto;
    min-width: unset;
    aspect-ratio: 16 / 9;
  }
  .card__body {
    padding: var(--space-lg) var(--space-lg);
  }

  .about__photo { max-width: 100%; }

  .card-grid { grid-template-columns: 1fr; gap: var(--space-md); }
}

/* ----------------------------------------------------------
   16. Phone (≤480px)
   ---------------------------------------------------------- */
@media (max-width: 480px) {
  .container { padding: 0 var(--space-md); }

  .header__inner { height: 48px; }
  .header__logo { font-size: 0.85rem; max-width: 160px; }
  .header__nav-link { font-size: 0.7rem; letter-spacing: 0.04em; }

  .hero__title { font-size: 2.4rem; }
  .hero__note { white-space: normal; }
  .hero__actions { flex-direction: column; align-items: stretch; }

  .section__title { font-size: var(--font-size-lg); }
  .section__description { font-size: var(--font-size-sm); }
}
