/* =========================================
   COMPONENTS — UI Elements
   ========================================= */

/* --- Section Label --- */
.section-label {
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  font-weight: 500;
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--color-accent);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.section-label::before {
  content: '';
  display: block;
  width: 2rem;
  height: 2px;
  background: var(--color-accent);
}

/* --- Section Title --- */
.section-title {
  margin-bottom: var(--space-10);
}

/* --- Hero Section --- */
.hero {
  min-height: calc(100dvh - var(--header-height));
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}

@supports (height: 100svh) {
  .hero {
    min-height: calc(100svh - var(--header-height));
  }
}

.hero__content {
  position: relative;
  z-index: 2;
  padding-block: var(--space-10) var(--space-12);
}

.hero__title {
  font-size: var(--text-hero);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.92;
  width: max-content;
  max-width: 100%;
  margin-bottom: var(--space-5);
}

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

html[lang="zh"] .hero__title {
  font-size: clamp(3.4rem, 14vw, 9.5rem);
  letter-spacing: 0.14em;
  line-height: 1.12;
}

.hero__slogan {
  font-family: var(--font-display);
  font-size: clamp(1rem, 1.7vw, 1.45rem);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  max-width: 36ch;
  line-height: 1.35;
  margin-bottom: var(--space-3);
}

html[lang="zh"] .hero__slogan {
  letter-spacing: 0.22em;
  text-transform: none;
}

.hero__eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--space-5);
  display: block;
}

.hero__subtitle {
  font-size: clamp(1.05rem, 1.6vw, 1.35rem);
  font-weight: 400;
  color: var(--color-text-secondary);
  max-width: 36ch;
  line-height: var(--leading-normal);
  margin-bottom: var(--space-8);
}

.hero__cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-8);
  background: var(--color-accent);
  color: #14120f;
  font-family: var(--font-display);
  font-size: var(--text-small);
  font-weight: 700;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  border: var(--border-thick) solid var(--color-text-primary);
  box-shadow: var(--shadow-button);
  transition:
    background var(--duration-fast) var(--ease-out-quart),
    transform var(--duration-fast) var(--ease-out-quart),
    box-shadow var(--duration-fast) var(--ease-out-quart);
}

.hero__cta:hover {
  background: var(--color-text-primary);
  color: var(--color-bg);
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 0 var(--color-accent);
}

.hero__cta:active {
  transform: translate(2px, 2px);
  box-shadow: var(--shadow-button-active);
}

/* --- Geometric Decorations --- */
.hero__shapes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.geo-shape {
  position: absolute;
  transition: transform var(--duration-slow) var(--ease-out-expo);
}

.geo-circle {
  width: clamp(180px, 26vw, 360px);
  height: clamp(180px, 26vw, 360px);
  border-radius: 50%;
  border: 3px solid var(--color-blue-border);
  top: 6%;
  right: -6%;
  opacity: 0.55;
}

.geo-square {
  width: clamp(72px, 10vw, 150px);
  height: clamp(72px, 10vw, 150px);
  background: var(--color-blue-deep);
  border: 2px solid var(--color-blue-border);
  top: auto;
  bottom: 12%;
  right: 8%;
  opacity: 0.7;
}

.geo-diamond {
  width: clamp(48px, 6vw, 96px);
  height: clamp(48px, 6vw, 96px);
  background: var(--color-accent);
  top: 16%;
  right: 18%;
  opacity: 0.72;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.geo-line-h {
  width: clamp(64px, 10vw, 160px);
  height: 3px;
  background: var(--color-border-bright);
  top: auto;
  bottom: 18%;
  left: auto;
  right: 22%;
}

.geo-line-v {
  width: 3px;
  height: clamp(48px, 7vw, 100px);
  background: var(--color-border-bright);
  top: 12%;
  left: auto;
  right: 30%;
  opacity: 0.8;
}

.geo-triangle {
  width: 0;
  height: 0;
  border-left: clamp(28px, 4vw, 64px) solid transparent;
  border-right: clamp(28px, 4vw, 64px) solid transparent;
  border-bottom: clamp(48px, 7vw, 110px) solid var(--color-blue-mid);
  bottom: 22%;
  left: auto;
  right: 4%;
  opacity: 0.45;
}

/* --- About Section --- */
.about__name {
  font-family: var(--font-display);
  font-size: var(--text-subheading);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-primary);
  line-height: 1.1;
  margin-bottom: var(--space-5);
}

.about__name::after {
  content: '.';
  color: var(--color-accent);
}

html[lang="zh"] .about__name {
  letter-spacing: 0.2em;
  text-transform: none;
}

.about__text {
  font-size: clamp(1.125rem, 1.5vw, 1.5rem);
  line-height: var(--leading-snug);
  color: var(--color-text-secondary);
}

.about__text--lead {
  margin-bottom: var(--space-6);
}

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

.about__geo-block {
  width: min(100%, 280px);
  aspect-ratio: 1;
  margin-left: auto;
  background: var(--color-blue-deep);
  position: relative;
  border: var(--border-thick) solid var(--color-blue-border);
}

.about__geo-frame {
  position: absolute;
  inset: var(--space-6);
  border: 2px solid var(--color-border-bright);
}

.about__geo-diamond {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  background: var(--color-accent);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  opacity: 0.6;
}

.about__geo-block::before {
  content: '';
  position: absolute;
  inset: var(--space-4);
  border: 2px solid var(--color-border-bright);
}

.about__geo-block::after {
  content: '';
  position: absolute;
  width: 46%;
  height: 46%;
  bottom: -14px;
  right: -14px;
  background: var(--color-accent);
  opacity: 0.28;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

#about .reveal-scale {
  padding: 0 var(--space-4) var(--space-5) 0;
}

/* --- Skills Section --- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: var(--space-3);
}

.skill-tag {
  display: flex;
  width: 100%;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: var(--border-thin) solid var(--color-border);
  font-family: var(--font-display);
  font-size: var(--text-small);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  transition:
    border-color var(--duration-fast),
    background var(--duration-fast),
    transform var(--duration-fast);
  cursor: default;
}

.skill-tag:hover {
  border-color: var(--color-accent);
  background: rgba(255, 69, 0, 0.08);
  transform: translateX(4px);
}

.skill-tag__shape {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  background: var(--color-blue-border);
}

.skill-tag:nth-child(3n+1) .skill-tag__shape { border-radius: 0; }
.skill-tag:nth-child(3n+2) .skill-tag__shape { border-radius: 50%; }
.skill-tag:nth-child(3n) .skill-tag__shape {
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

/* --- Projects Section (Bento) --- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: minmax(180px, auto);
  gap: var(--grid-gap);
  align-items: stretch;
}

.project-card {
  background: var(--color-surface);
  border: var(--border-thin) solid var(--color-border);
  padding: var(--space-6);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 240px;
  transition:
    transform var(--duration-normal) var(--ease-out-quart),
    box-shadow var(--duration-normal) var(--ease-out-quart),
    border-color var(--duration-normal);
}

.project-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--color-accent);
  z-index: 2;
}

.project-card:hover .project-card__geo {
  opacity: 0.2;
  transform: scale(1.04) rotate(6deg);
}

.project-card__geo {
  position: absolute;
  top: -20%;
  right: -10%;
  width: 70%;
  height: 70%;
  background: var(--color-blue-deep);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  transition:
    opacity var(--duration-slow) var(--ease-out-expo),
    transform var(--duration-slow) var(--ease-out-expo);
  opacity: 0.16;
}

.project-card__tag {
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  color: var(--color-accent);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}

.project-card__title {
  font-family: var(--font-display);
  font-size: var(--text-subheading);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-tight);
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.project-card__desc {
  font-size: var(--text-small);
  color: var(--color-text-secondary);
  line-height: var(--leading-normal);
  max-width: unset;
}

.project-card > div:not(.project-card__geo) {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.project-card__link {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: var(--space-2);
  margin-top: auto;
  padding-top: var(--space-5);
  font-family: var(--font-display);
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  transition: gap var(--duration-fast);
}

.project-card__link:hover {
  gap: var(--space-4);
}

/* Project card sizes — explicit cells so the bento closes without holes */
.project-card--large {
  grid-column: 1 / span 7;
  grid-row: 1 / span 2;
  min-height: 100%;
}

.projects-grid .project-card:nth-child(2) {
  grid-column: 8 / span 5;
  grid-row: 1;
}

.projects-grid .project-card:nth-child(3) {
  grid-column: 8 / span 5;
  grid-row: 2;
}

.projects-grid .project-card:nth-child(4) {
  grid-column: 1 / span 6;
  grid-row: 3;
}

.projects-grid .project-card:nth-child(5) {
  grid-column: 7 / span 6;
  grid-row: 3;
}

.project-card--large .project-card__title {
  font-size: clamp(1.5rem, 2.2vw, 2.05rem);
}

/* --- Experience / Timeline --- */
.timeline {
  position: relative;
  padding-left: var(--space-10);
}

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

.timeline-item {
  position: relative;
  padding-bottom: var(--space-10);
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: calc(-1 * var(--space-10) - 5px);
  top: 6px;
  width: 12px;
  height: 12px;
  background: var(--color-accent);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.timeline-item__year {
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  color: var(--color-accent);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}

.timeline-item__role {
  font-family: var(--font-display);
  font-size: var(--text-subheading);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-tight);
  color: var(--color-text-primary);
  margin-bottom: var(--space-1);
}

.timeline-item__company {
  font-size: var(--text-small);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-3);
}

.timeline-item__desc {
  font-size: var(--text-small);
  color: var(--color-text-muted);
  line-height: var(--leading-relaxed);
  max-width: 60ch;
}

/* --- Contact Section --- */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--grid-gap);
}

.contact-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-6);
  background: var(--color-surface);
  border: var(--border-thin) solid var(--color-border);
  transition:
    border-color var(--duration-fast),
    transform var(--duration-fast);
}

.contact-item:hover {
  border-color: var(--color-accent);
  transform: translateX(4px);
}

.contact-item__icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: var(--color-blue-deep);
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  letter-spacing: 0;
}

.contact-item__label {
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--space-1);
}

.contact-item__value {
  font-family: var(--font-display);
  font-size: var(--text-body);
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: var(--tracking-tight);
  overflow-wrap: anywhere;
}

/* --- Footer --- */
.footer {
  border-top: 1px solid var(--color-border);
  padding-block: var(--space-8);
}

.footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.footer__copy {
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  letter-spacing: var(--tracking-wide);
}

.footer__mark {
  width: 32px;
  height: 32px;
  background: var(--color-blue-deep);
  border: 2px solid var(--color-border);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: var(--text-small);
  font-weight: 700;
  color: var(--color-text-secondary);
  transition: border-color var(--duration-fast);
}

.footer__mark:hover {
  border-color: var(--color-accent);
}

/* --- Lang Toggle --- */
.lang-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  border: var(--border-thin) solid var(--color-border);
  padding: var(--space-1);
}

.lang-toggle__btn {
  min-width: 2.25rem;
  min-height: 1.85rem;
  padding: var(--space-1) var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  font-weight: 500;
  letter-spacing: var(--tracking-wide);
  line-height: 1;
  color: var(--color-text-muted);
  transition:
    background var(--duration-fast),
    color var(--duration-fast);
  text-transform: uppercase;
}

.lang-toggle__btn.active {
  background: var(--color-blue-deep);
  color: var(--color-text-primary);
}

.lang-toggle__btn:hover:not(.active) {
  color: var(--color-text-primary);
}

/* --- Nav Links --- */
.nav-links {
  grid-column: 2;
  justify-self: center;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: var(--space-6);
}

.nav-link {
  font-family: var(--font-display);
  font-size: var(--text-small);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-text-secondary);
  position: relative;
  white-space: nowrap;
  transition: color var(--duration-fast);
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--color-accent);
  transition: width var(--duration-normal) var(--ease-out-expo);
}

.nav-link:hover,
.nav-link.is-active {
  color: var(--color-text-primary);
}

.nav-link:hover::after,
.nav-link.is-active::after {
  width: 100%;
}

/* --- Mobile Nav --- */
.mobile-menu-btn {
  display: none;
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
}

.mobile-menu-btn span {
  position: absolute;
  left: 11px;
  top: 21px;
  width: 22px;
  height: 2px;
  background: var(--color-text-primary);
  transform-origin: center;
  transition:
    transform var(--duration-normal) var(--ease-out-quart),
    opacity var(--duration-fast);
}

.mobile-menu-btn span:nth-child(1) {
  transform: translateY(-7px);
}

.mobile-menu-btn span:nth-child(3) {
  transform: translateY(7px);
}

.mobile-menu-btn[aria-expanded="true"] span:nth-child(1) {
  transform: rotate(45deg);
}

.mobile-menu-btn[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-btn[aria-expanded="true"] span:nth-child(3) {
  transform: rotate(-45deg);
}

@media (max-width: 1100px) {
  .nav-links {
    gap: var(--space-4);
  }

  .nav-link {
    font-size: 0.8125rem;
  }
}

@media (max-width: 1024px) {
  .about__geo-block {
    margin-inline: auto;
  }

  #about .reveal-scale {
    padding: 0;
    display: flex;
    justify-content: center;
  }
}

@media (max-width: 960px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 90;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0;
    padding: var(--space-2) clamp(1.25rem, 5vw, 4rem) var(--space-4);
    background: #121212;
    border-bottom: 1px solid var(--color-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .nav-links.is-open {
    display: flex;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: auto;
    height: calc(100dvh - var(--header-height));
    grid-column: 1 / -1;
    justify-self: stretch;
    align-self: stretch;
    padding-top: var(--space-5);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #121212;
    z-index: 2;
  }

  .nav-link {
    padding-block: 0.9rem;
    border-bottom: 1px solid var(--color-border);
  }

  .nav-link:last-child {
    border-bottom: 0;
  }

  .mobile-menu-btn {
    display: flex;
  }

  body.nav-open {
    overflow: hidden;
  }

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

  .projects-grid .project-card:nth-child(n) {
    grid-column: auto;
    grid-row: auto;
    min-height: 220px;
  }

  .projects-grid .project-card--large:nth-child(n) {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .contact-grid {
    grid-template-columns: 1fr;
  }

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

  .projects-grid .project-card:nth-child(n),
  .projects-grid .project-card--large {
    grid-column: 1 / -1;
    min-height: 0;
  }

  .hero__title {
    max-width: 100%;
  }

  .geo-circle,
  .geo-line-v,
  .geo-diamond {
    display: none;
  }

  .geo-square {
    right: -6%;
    bottom: 8%;
    opacity: 0.45;
  }

  .geo-triangle {
    right: 8%;
    bottom: 14%;
    opacity: 0.35;
  }

  .geo-line-h {
    left: clamp(1.25rem, 5vw, 4rem);
    right: auto;
    bottom: 10%;
  }
}

@media (max-width: 380px) {
  .header__logo {
    font-size: 0.78rem;
    letter-spacing: 0.08em;
  }

  html[lang="zh"] .header__logo {
    font-size: 0.95rem;
    letter-spacing: 0.1em;
  }
}

@media (hover: none) {
  .project-card:hover,
  .contact-item:hover,
  .bento-item:hover,
  .skill-tag:hover {
    transform: none;
    box-shadow: none;
  }
}
