/* ============================================
   TaigiSpeech Website — Styles
   Design: Matcha-green theme (following TaigiTube)
   ============================================ */

/* ---------- Font ---------- */
@font-face {
  font-family: "jf-openhuninn";
  src: url("../assets/fonts/jf-openhuninn-2.1.ttf") format("truetype");
  font-display: swap;
}

/* ---------- CSS Variables ---------- */
:root {
  --primary: #94b46f;
  --primary-hover: #7fa05a;
  --primary-light: #d4e4c0;
  --bg: #f4f1e9;
  --bg-alt: #eae6da;
  --text: #4a4a4a;
  --text-light: #6b6b6b;
  --card-bg: #ffffff;
  --tag-bg: #e0d8b0;
  --tag-text: #6b6246;
  --accent-teal: #2c7a7b;
  --emergency-bg: #fff0f0;
  --emergency-border: #e8a0a0;
  --functional-bg: #f0f7ff;
  --functional-border: #a0c4e8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
  --font-zh: "jf-openhuninn", "PingFang TC", "Microsoft JhengHei UI", sans-serif;
  --font-en: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --max-w: 960px;
  --transition: 0.3s ease;
}

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

html {
  scroll-behavior: smooth;
}

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

[data-lang="en"] body {
  font-family: var(--font-en);
}

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

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

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

/* ---------- Language Toggle ---------- */
[data-lang="zh"] .en-only { display: none !important; }
[data-lang="en"] .zh-only { display: none !important; }

.lang-toggle {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(148, 180, 111, 0.4);
  border-radius: 24px;
  padding: 8px 18px;
  cursor: pointer;
  font-family: var(--font-en);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.lang-toggle:hover {
  background: rgba(255, 255, 255, 1);
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.lang-sep {
  color: #ccc;
}

.lang-opt {
  transition: color var(--transition);
}

[data-lang="zh"] .lang-opt[data-l="zh"] {
  color: var(--primary-hover);
  font-weight: 700;
}

[data-lang="en"] .lang-opt[data-l="en"] {
  color: var(--primary-hover);
  font-weight: 700;
}

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

.section {
  padding: 5rem 0;
}

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

.section-title {
  text-align: center;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  color: var(--accent-teal);
  margin-bottom: 2.5rem;
  font-weight: 700;
}

.subsection-title {
  text-align: center;
  font-size: 1.2rem;
  color: var(--text);
  margin: 3rem 0 1.5rem;
  font-weight: 600;
}

/* ---------- Hero ---------- */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--bg) 0%, #e8e4d6 50%, var(--primary-light) 100%);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  top: -40%;
  right: -20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(148, 180, 111, 0.15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.hero-inner {
  text-align: center;
  padding: 2rem 24px;
  position: relative;
  z-index: 1;
}

.hero-title {
  margin-bottom: 1rem;
}

.hero-title-main {
  display: block;
  font-size: clamp(2.8rem, 6vw, 4.5rem);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
  font-family: var(--font-en);
  line-height: 1.1;
}

.hero-title-main .T {
  color: var(--primary);
}

.hero-title-sub {
  display: block;
  font-size: clamp(1.4rem, 3vw, 2rem);
  color: var(--text-light);
  margin-top: 0.3rem;
  font-weight: 500;
}

.hero-desc {
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: var(--text-light);
  max-width: 600px;
  margin: 0 auto 1.5rem;
  line-height: 1.8;
}

.hero-badges {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: 5px 16px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.hero-buttons {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition);
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(148, 180, 111, 0.3);
}

.btn-primary:hover {
  background: var(--primary-hover);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(148, 180, 111, 0.4);
}

.btn-icon {
  font-size: 1.15em;
}

.btn-sm {
  padding: 8px 18px;
  font-size: 0.85rem;
  border-radius: 20px;
  background: var(--primary);
  color: #fff;
}

.btn-sm:hover {
  background: var(--primary-hover);
  color: #fff;
  transform: translateY(-1px);
}

/* ---------- Hero Nav ---------- */
.hero-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2rem;
}

.hero-nav a {
  color: var(--text-light);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 16px;
  border-radius: 20px;
  border: 1.5px solid rgba(74, 74, 74, 0.2);
  transition: all var(--transition);
  text-decoration: none;
}

.hero-nav a:hover {
  color: var(--primary-hover);
  border-color: var(--primary);
  background: rgba(148, 180, 111, 0.1);
}

/* ---------- Scroll Hint ---------- */
.scroll-hint {
  margin-top: 3rem;
}

.scroll-arrow {
  display: inline-block;
  font-size: 1.5rem;
  color: var(--text-light);
  opacity: 0.5;
  animation: bounce 2s ease infinite;
}

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

/* ---------- About ---------- */
.about-text p {
  font-size: 1.05rem;
  line-height: 1.9;
  margin-bottom: 1rem;
  text-align: justify;
}

/* ---------- Intent Grid ---------- */
.intent-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.intent-group-label {
  text-align: center;
  font-size: 1.1rem;
  margin-bottom: 1.2rem;
  padding: 10px 0;
  border-radius: var(--radius-sm);
  font-weight: 700;
}

.intent-group-label.emergency {
  background: var(--emergency-bg);
  color: #b44040;
}

.intent-group-label.functional {
  background: var(--functional-bg);
  color: #4070b4;
}

.intent-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.intent-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
  border: 1.5px solid transparent;
  border-top: 3px solid transparent;
}

.intent-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.intent-card.emergency {
  border-color: var(--emergency-border);
  border-top-color: #d06060;
}

.intent-card.functional {
  border-color: var(--functional-border);
  border-top-color: #6090d0;
}

.intent-name {
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-en);
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

.intent-desc {
  font-size: 1rem;
  color: var(--text-light);
  line-height: 1.5;
}

/* ---------- Method ---------- */
.method-block {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
  margin-bottom: 3.5rem;
}

.method-block.reverse {
  direction: rtl;
}

.method-block.reverse > * {
  direction: ltr;
}

.method-text h3 {
  font-size: 1.3rem;
  color: var(--accent-teal);
  margin-bottom: 0.8rem;
  font-weight: 700;
}

.method-text p {
  font-size: 0.95rem;
  line-height: 1.8;
  text-align: justify;
}

.method-img {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--card-bg);
  padding: 8px;
}

.method-img img {
  border-radius: var(--radius-sm);
}

.pipeline-figure {
  text-align: center;
  margin-top: 1rem;
}

.pipeline-figure img {
  max-width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 0 auto;
  background: var(--card-bg);
  padding: 12px;
}

.figure-caption {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 0.8rem;
  font-style: italic;
}

/* ---------- Stats ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 3rem;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
  border-top: 3px solid var(--primary);
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.stat-number {
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  font-weight: 800;
  color: var(--primary-hover);
  font-family: var(--font-en);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 4px;
}

.stat-detail {
  font-size: 0.75rem;
  color: var(--text-light);
  opacity: 0.8;
  margin-top: 2px;
  font-family: var(--font-en);
}

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

.chart-container {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.chart-container img {
  margin: 0 auto;
  border-radius: var(--radius-sm);
}

/* ---------- Photos ---------- */
.photos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.photo-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
}

.photo-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.photo-card img {
  width: 100%;
  height: 280px;
  object-fit: cover;
}

.photo-caption {
  padding: 1rem;
  font-size: 0.9rem;
  color: var(--text-light);
  text-align: center;
}

/* ---------- Acknowledgments ---------- */
.special-thanks {
  display: flex;
  align-items: center;
  gap: 2rem;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  margin-bottom: 2.5rem;
  border-left: 4px solid var(--primary);
}

.special-thanks-logo {
  width: 100px;
  min-width: 100px;
  min-height: 100px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  align-self: center;
}

.special-thanks-text p {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text);
}

.special-thanks-text a {
  color: var(--accent-teal);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.special-thanks-text a:hover {
  color: var(--primary-hover);
}

@media (max-width: 480px) {
  .special-thanks {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
    padding: 1.5rem;
  }

  .special-thanks-logo {
    width: 80px;
    height: 80px;
  }
}

.ack-text {
  text-align: center;
  font-size: 1.05rem;
  line-height: 1.8;
  margin-bottom: 2rem;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

.inst-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

.inst-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform var(--transition);
}

.inst-card:hover {
  transform: translateY(-2px);
}

.inst-logo {
  width: 60px;
  height: 60px;
  object-fit: contain;
  margin: 0 auto 10px;
}

.inst-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-teal);
  margin-bottom: 6px;
  font-family: var(--font-en);
}

.inst-full {
  font-size: 0.78rem;
  color: var(--text-light);
  line-height: 1.4;
}

/* ---------- Citation ---------- */
.citation-block {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  box-shadow: var(--shadow);
  position: relative;
}

.citation-block .btn-sm {
  position: absolute;
  top: 12px;
  right: 12px;
}

.bibtex {
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
  background: transparent;
}

/* ---------- Footer ---------- */
.footer {
  background: var(--text);
  color: #d4d4d4;
  padding: 2.5rem 0;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--primary-light);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition);
}

.footer-links a:hover {
  color: #fff;
}

.footer-copy {
  font-size: 0.8rem;
  opacity: 0.6;
}

.footer-font {
  font-size: 0.75rem;
  opacity: 0.4;
  margin-top: 6px;
}

.footer-font a {
  color: var(--primary-light);
}

.footer-font a:hover {
  color: #fff;
}

/* ---------- Animations (scroll reveal) ---------- */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- RWD: Tablet ---------- */
@media (max-width: 1023px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .inst-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------- RWD: Tablet small ---------- */
@media (max-width: 768px) {
  .section {
    padding: 3.5rem 0;
  }

  .hero-title-main {
    font-size: clamp(2rem, 8vw, 3rem);
  }

  .method-block,
  .method-block.reverse {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    direction: ltr;
  }

  .intent-grid {
    grid-template-columns: 1fr;
  }

  .charts-row {
    grid-template-columns: 1fr;
  }

  .photos-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .inst-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero-buttons {
    gap: 10px;
  }

  .btn {
    padding: 10px 20px;
    font-size: 0.9rem;
  }
}

/* ---------- RWD: Mobile ---------- */
@media (max-width: 480px) {
  .section {
    padding: 2.5rem 0;
  }

  .container {
    padding: 0 16px;
  }

  .hero-title-main {
    font-size: clamp(1.8rem, 10vw, 2.5rem);
  }

  .hero-desc {
    font-size: 0.95rem;
  }

  .hero-buttons {
    flex-direction: column;
    align-items: center;
  }

  .btn {
    width: 80%;
    justify-content: center;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .intent-cards {
    grid-template-columns: 1fr;
  }

  .inst-grid {
    grid-template-columns: 1fr;
  }

  .lang-toggle {
    top: 12px;
    right: 12px;
    padding: 6px 14px;
    font-size: 0.8rem;
  }

  .photo-card img {
    height: 200px;
  }

  .citation-block {
    padding: 1rem;
  }

  .citation-block .btn-sm {
    position: static;
    margin-bottom: 1rem;
    display: inline-flex;
  }

  .bibtex {
    font-size: 0.7rem;
  }

  .about-text p {
    text-align: left;
  }

  .method-text p {
    text-align: left;
  }
}

/* ---------- Accessibility: Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .scroll-arrow {
    animation: none;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
