/* ═══════════════════════════════════════════════
   UNWHITE / 未白 — Main Stylesheet
   A space yet to be defined.
   ═══════════════════════════════════════════════ */

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

/* ── Custom Properties ── */
:root {
  --white: #fafafa;
  --off-white: #f5f5f4;
  --ghost: #e7e5e4;
  --mist: #d6d3d1;
  --ash: #a8a29e;
  --text-primary: #78716c;
  --text-secondary: #a8a29e;
  --text-tertiary: #d6d3d1;

  --font-sans: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  --weight-hairline: 200;
  --weight-light: 300;
  --weight-regular: 400;

  --delay-short: 50ms;
  --delay-medium: 120ms;
  --delay-long: 200ms;
  --delay-glacial: 400ms;

  --ease-out-soft: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out-drift: cubic-bezier(0.45, 0, 0.55, 1);
}

/* ── Base ── */
html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--white);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-weight: var(--weight-light);
  line-height: 2.2;
  letter-spacing: 0.04em;
  overflow-x: hidden;
  cursor: default;
}

::selection {
  background: var(--ghost);
  color: var(--text-primary);
}

/* ── Geometric Background Layer ── */
.geo-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  animation: geoFadeIn 4s var(--ease-out-soft) 1s forwards;
}

.geo-lines {
  width: 100%;
  height: 100%;
}

@keyframes geoFadeIn {
  to { opacity: 0.6; }
}

/* ── Noise Overlay ── */
.noise-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.018;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* ── Flicker Layer (rare, barely perceptible) ── */
.flicker-layer {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: var(--white);
  opacity: 0;
  animation: flicker 8s ease-in-out 12s infinite;
}

@keyframes flicker {
  0%, 92%, 100% { opacity: 0; }
  94% { opacity: 0.03; }
  95% { opacity: 0; }
  96% { opacity: 0.02; }
  97% { opacity: 0; }
}

/* ── Main Container ── */
.main-container {
  position: relative;
  z-index: 3;
}

/* ═══ HERO ═══ */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.hero-inner {
  text-align: center;
  padding: 2rem;
  position: relative;
}

.hero-title {
  font-weight: var(--weight-hairline);
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  letter-spacing: 0.15em;
  line-height: 1.6;
  color: var(--text-primary);
  opacity: 0;
  transform: translateY(12px);
  animation: heroFadeIn 3s var(--ease-out-soft) 0.8s forwards;
  /* subtle misalignment */
  margin-left: -3px;
}

.hero-title-en {
  display: inline;
}

.hero-title-sep {
  display: inline;
  margin: 0 0.3em;
  opacity: 0.3;
  font-weight: var(--weight-hairline);
}

.hero-title-zh {
  display: inline;
  font-weight: 200;
  letter-spacing: 0.2em;
}

@keyframes heroFadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-subtitle {
  font-weight: var(--weight-hairline);
  font-size: clamp(0.85rem, 1.8vw, 1.1rem);
  letter-spacing: 0.25em;
  text-transform: lowercase;
  color: var(--text-secondary);
  margin-top: 2rem;
  opacity: 0;
  animation: subtitleFadeIn 2.5s var(--ease-out-soft) 2.8s forwards;
}

@keyframes subtitleFadeIn {
  to { opacity: 1; }
}

.hero-line {
  width: 0;
  height: 1px;
  background: var(--ghost);
  margin: 2.5rem auto;
  animation: lineExtend 3s var(--ease-out-soft) forwards;
}

.hero-line--top {
  animation-delay: 4.5s;
}

.hero-line--bottom {
  animation-delay: 5s;
  width: 0;
  max-width: 120px;
}

.hero-line--top {
  max-width: 80px;
}

@keyframes lineExtend {
  to { width: 100%; }
}

/* Scroll hint */
.scroll-hint {
  position: absolute;
  bottom: -80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  opacity: 0;
  animation: scrollHintIn 2s var(--ease-out-soft) 6s forwards;
}

.scroll-hint-text {
  font-size: 0.65rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: var(--weight-light);
}

.scroll-hint-line {
  width: 1px;
  height: 32px;
  background: linear-gradient(to bottom, var(--mist), transparent);
  animation: scrollPulse 2.5s var(--ease-in-out-drift) infinite;
}

@keyframes scrollHintIn {
  to { opacity: 1; }
}

@keyframes scrollPulse {
  0%, 100% { opacity: 0.4; transform: scaleY(1); }
  50% { opacity: 0.8; transform: scaleY(1.2); }
}

/* ═══ SECTIONS (shared) ═══ */
.section {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8rem 2rem;
  position: relative;
}

.section-inner {
  max-width: 640px;
  width: 100%;
  /* subtle misalignment */
  transform: translateX(4px);
}

.section-label {
  font-size: 0.6rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: var(--weight-light);
  margin-bottom: 3rem;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 1.5s var(--ease-out-soft), transform 1.5s var(--ease-out-soft);
}

.section.is-visible .section-label {
  opacity: 1;
  transform: translateY(0);
}

/* ═══ ABOUT ═══ */
.line-reveal .line-text {
  font-weight: var(--weight-light);
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  line-height: 2.8;
  color: var(--text-primary);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 1.8s var(--ease-out-soft), transform 1.8s var(--ease-out-soft);
}

.section.is-visible .line-reveal .line-text {
  opacity: 1;
  transform: translateY(0);
}

/* staggered line-by-line reveal */
.section.is-visible .line-reveal .line-text:nth-child(1) { transition-delay: 0.3s; }
.section.is-visible .line-reveal .line-text:nth-child(2) { transition-delay: 0.8s; }
.section.is-visible .line-reveal .line-text:nth-child(3) { transition-delay: 1.3s; }
.section.is-visible .line-reveal .line-text:nth-child(4) { transition-delay: 1.8s; }
.section.is-visible .line-reveal .line-text:nth-child(5) { transition-delay: 2.3s; }
.section.is-visible .line-reveal .line-text:nth-child(6) { transition-delay: 2.8s; }

/* ═══ CONCEPT ═══ */
.fragment-group {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.fragment {
  font-weight: var(--weight-hairline);
  font-size: clamp(1rem, 2.2vw, 1.3rem);
  line-height: 3;
  color: var(--text-secondary);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 2s var(--ease-out-soft), transform 2s var(--ease-out-soft);
}

.section.is-visible .fragment {
  opacity: 1;
  transform: translateX(0);
}

.section.is-visible .fragment:nth-child(1) { transition-delay: 0.4s; }
.section.is-visible .fragment:nth-child(2) { transition-delay: 1s; }
.section.is-visible .fragment:nth-child(3) { transition-delay: 1.6s; }
.section.is-visible .fragment:nth-child(4) { transition-delay: 2.2s; }

/* ═══ EXPERIENCE ═══ */
.experience-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.experience-item {
  display: flex;
  align-items: baseline;
  gap: 1.2rem;
  font-weight: var(--weight-light);
  font-size: clamp(0.9rem, 1.8vw, 1.05rem);
  line-height: 3.2;
  color: var(--text-secondary);
  opacity: 0;
  transition: opacity 2s var(--ease-out-soft);
}

.section.is-visible .experience-item {
  opacity: 1;
}

.section.is-visible .experience-item:nth-child(1) { transition-delay: 0.5s; }
.section.is-visible .experience-item:nth-child(2) { transition-delay: 1.4s; }
.section.is-visible .experience-item:nth-child(3) { transition-delay: 2.3s; }

.experience-dash {
  color: var(--text-tertiary);
  font-weight: var(--weight-hairline);
  letter-spacing: 0.1em;
  flex-shrink: 0;
}

.experience-text {
  /* occasional subtle text shift */
  animation: textShift 12s ease-in-out infinite;
}

.experience-item:nth-child(2) .experience-text {
  animation-delay: 4s;
}

.experience-item:nth-child(3) .experience-text {
  animation-delay: 8s;
}

@keyframes textShift {
  0%, 88%, 100% { transform: translateX(0); }
  90% { transform: translateX(2px); }
  92% { transform: translateX(-1px); }
  94% { transform: translateX(0); }
}

/* ═══ CONTACT ═══ */
.contact-text {
  font-weight: var(--weight-light);
  font-size: clamp(0.9rem, 1.8vw, 1.05rem);
  line-height: 2.8;
  color: var(--text-secondary);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 1.8s var(--ease-out-soft), transform 1.8s var(--ease-out-soft);
}

.section.is-visible .contact-text {
  opacity: 1;
  transform: translateY(0);
}

.section.is-visible .contact-text:nth-child(2) { transition-delay: 0.6s; }
.section.is-visible .contact-text:nth-child(3) { transition-delay: 1.2s; }

.contact-email {
  display: inline-block;
  margin-top: 2.5rem;
  font-weight: var(--weight-light);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  color: var(--text-tertiary);
  text-decoration: none;
  border-bottom: 1px solid var(--ghost);
  padding-bottom: 2px;
  transition: color var(--delay-glacial) var(--ease-out-soft), border-color var(--delay-glacial) var(--ease-out-soft);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 1.8s var(--ease-out-soft) 1.6s, transform 1.8s var(--ease-out-soft) 1.6s, color var(--delay-glacial) var(--ease-out-soft), border-color var(--delay-glacial) var(--ease-out-soft);
}

.section.is-visible .contact-email {
  opacity: 1;
  transform: translateY(0);
}

.contact-email:hover {
  color: var(--text-secondary);
  border-color: var(--ash);
  transition-delay: 150ms;
}

/* ═══ DOWNLOAD ═══ */
.download .section-inner {
  text-align: center;
  transform: translateX(0);
}

.download-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.btn-download {
  display: inline-block;
  background: transparent;
  border: 1px solid var(--ghost);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-weight: var(--weight-light);
  font-size: 0.85rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 1rem 3.5rem;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition:
    border-color var(--delay-glacial) var(--ease-out-soft),
    color var(--delay-glacial) var(--ease-out-soft);
  opacity: 0;
  animation: downloadBtnIn 2s var(--ease-out-soft) 0.5s forwards;
}

/* Ghost variant — even more minimal */
.btn-download--ghost {
  border-color: var(--text-tertiary);
  color: var(--text-tertiary);
  padding: 1rem 2.8rem;
  font-size: 0.75rem;
}

/* delayed hover — the button feels slightly unresponsive */
.btn-download:hover {
  border-color: var(--ash);
  color: var(--text-primary);
  transition-delay: 150ms;
}

.btn-download--ghost:hover {
  border-color: var(--mist);
  color: var(--text-secondary);
  transition-delay: 150ms;
}

.btn-download:active {
  border-color: var(--text-tertiary);
}

.btn-line {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--text-secondary);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 600ms var(--ease-out-soft) 150ms;
}

.btn-download--ghost .btn-line {
  background: var(--text-tertiary);
}

.btn-download:hover .btn-line {
  transform: scaleX(1);
}

/* Visual "delayed" press state — brief opacity dip on click */
.btn--pressed {
  opacity: 0.55 !important;
  transition: opacity 50ms ease !important;
}

@keyframes downloadBtnIn {
  to { opacity: 1; }
}

.download-note {
  margin-top: 2.5rem;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--text-tertiary);
  font-weight: var(--weight-light);
  opacity: 0;
  animation: noteFadeIn 2s var(--ease-out-soft) 1.5s forwards;
}

@keyframes noteFadeIn {
  to { opacity: 1; }
}

/* ═══ FOOTER ═══ */
.footer {
  padding: 6rem 2rem 4rem;
  text-align: center;
}

.footer-text {
  font-size: 0.6rem;
  letter-spacing: 0.35em;
  color: var(--text-tertiary);
  font-weight: var(--weight-light);
  text-transform: uppercase;
  opacity: 0;
  animation: footerIn 3s var(--ease-out-soft) 1s forwards;
}

@keyframes footerIn {
  to { opacity: 0.7; }
}

/* ═══ GLOBAL ANIMATION — Opacity Flicker (rare) ═══ */
@keyframes subtleFlicker {
  0%, 96%, 100% { opacity: 1; }
  97% { opacity: 0.92; }
  98% { opacity: 1; }
  99% { opacity: 0.95; }
}

/* Applied to specific elements via JS randomly */

/* ═══ RESPONSIVE ═══ */
@media (max-width: 640px) {
  .hero-title {
    font-size: 2rem;
    letter-spacing: 0.1em;
  }

  .hero-subtitle {
    font-size: 0.75rem;
  }

  .section {
    padding: 5rem 1.5rem;
    min-height: 70vh;
  }

  .section-inner {
    transform: translateX(2px);
  }

  .line-reveal .line-text {
    line-height: 2.4;
    font-size: 0.9rem;
  }

  .fragment {
    font-size: 0.95rem;
    line-height: 2.6;
  }

  .experience-item {
    font-size: 0.85rem;
  }

  .media-grid {
    gap: 3rem;
  }
}
