/* ─── Design Tokens ─── */
:root {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #888888;
  --accent: #e63946;
  --border: #e8e8e8;
  --surface: #f6f6f6;

  --c-spotch:  #1B4332;
  --c-inlife:  #BF4E30;
  --c-koselig: #5C4033;
  --c-aight:   #1A1A2E;

  --sans: 'DM Sans', 'Noto Sans TC', sans-serif;
  --section-v: clamp(5rem, 9vw, 9rem);
  --radius: 16px;
  --radius-lg: 24px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --t: 0.3s var(--ease);
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.7;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }

/* ─── Container ─── */
.container { max-width: 1140px; margin: 0 auto; padding: 0 2rem; }

/* ─── Typography ─── */
h1 { font-size: clamp(3.5rem, 8vw, 7rem); letter-spacing: -0.03em; line-height: 1.05; font-weight: 800; }
h2 { font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -0.02em; line-height: 1.15; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; line-height: 1.3; }
.muted { color: var(--muted); }

/* ─── Scroll Animations ─── */
.animate {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
.animate.visible { opacity: 1; transform: none; }
.animate-delay-1 { transition-delay: 0.1s; }
.animate-delay-2 { transition-delay: 0.2s; }
.animate-delay-3 { transition-delay: 0.3s; }
.animate-delay-4 { transition-delay: 0.4s; }

/* ─── Buttons ─── */
.btn-primary, .btn-secondary {
  display: inline-block;
  padding: 0.85rem 2rem;
  border-radius: 100px;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background var(--t), color var(--t), border-color var(--t), transform var(--t);
  cursor: pointer;
}
.btn-primary { background: var(--fg); color: var(--bg); }
.btn-primary:hover { background: var(--accent); transform: translateY(-2px); }
.btn-secondary { border: 1.5px solid var(--border); color: var(--fg); }
.btn-secondary:hover { border-color: var(--fg); transform: translateY(-2px); }

/* ─── Section Headers ─── */
.section-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}
.section-header { margin-bottom: 3.5rem; }

/* ══════════════════════════════════
   NAV
══════════════════════════════════ */
#nav {
  position: fixed;
  inset: 0 0 auto;
  z-index: 100;
  padding: 1.5rem 2.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background var(--t), box-shadow var(--t), padding var(--t);
}
#nav.scrolled {
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 1px 0 var(--border);
  padding-top: 1rem;
  padding-bottom: 1rem;
}
.nav-logo { font-size: 1rem; font-weight: 800; letter-spacing: 0.06em; }
.nav-links {
  list-style: none;
  display: flex;
  gap: 2.5rem;
  align-items: center;
}
.nav-links a {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
  transition: color var(--t);
  position: relative;
}
.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -3px; left: 0; right: 0;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--t);
}
.nav-links a:hover,
.nav-links a.active { color: var(--fg); }
.nav-links a:hover::after,
.nav-links a.active::after { transform: scaleX(1); }

.nav-cta {
  background: var(--fg) !important;
  color: var(--bg) !important;
  padding: 0.5rem 1.25rem;
  border-radius: 100px;
}
.nav-cta::after { display: none !important; }
.nav-cta:hover { background: var(--accent) !important; color: var(--bg) !important; }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  z-index: 101;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 1.5px;
  background: var(--fg);
  transition: var(--t);
}

/* ══════════════════════════════════
   HERO
══════════════════════════════════ */
#hero {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  padding: 0 2rem;
  position: relative;
}
.hero-inner {
  max-width: 1140px;
  margin: 0 auto;
  width: 100%;
  padding-top: 5rem;
}
.hero-tags {
  display: flex;
  gap: 0.65rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.tag {
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.35rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  color: var(--muted);
  transition: border-color var(--t), color var(--t);
}
.tag:hover { border-color: var(--accent); color: var(--accent); }
.hero-name { margin-bottom: 1.5rem; }
.hero-en {
  font-size: clamp(0.9rem, 2vw, 1.4rem);
  font-weight: 300;
  letter-spacing: 0.28em;
  color: var(--muted);
  margin-top: 0.3rem;
}
.hero-tagline {
  font-size: clamp(1rem, 1.8vw, 1.2rem);
  margin-bottom: 2.5rem;
  line-height: 1.9;
}
.hero-tagline .muted { font-size: 0.9em; display: block; margin-top: 0.25rem; }

.hero-scroll {
  position: absolute;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.63rem;
  letter-spacing: 0.18em;
  font-weight: 600;
}
.scroll-line {
  width: 1px;
  height: 44px;
  background: linear-gradient(to bottom, var(--muted), transparent);
  animation: scrollPulse 2s ease-in-out infinite;
}
@keyframes scrollPulse {
  0%, 100% { opacity: 0.3; transform: scaleY(0.9); }
  50% { opacity: 1; transform: scaleY(1.1); }
}

/* ══════════════════════════════════
   ABOUT
══════════════════════════════════ */
#about {
  padding: var(--section-v) 0;
  border-top: 1px solid var(--border);
}
.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 1fr);
  gap: clamp(2.5rem, 5vw, 5.5rem);
  align-items: start;
}
.about-intro {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
.about-figure {
  margin: 0;
  max-width: min(100%, 340px);
}
.about-profile-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
.about-bio p {
  font-size: 1.02rem;
  line-height: 1.92;
  color: var(--muted);
  margin-bottom: 1.1rem;
  max-width: 40em;
}
.about-bio p:last-child { margin-bottom: 0; }
.about-lead {
  font-size: 1.08rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--fg);
  line-height: 1.88;
}

.about-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.65rem 1.45rem 1.5rem;
  position: sticky;
  top: 5.75rem;
}
.about-panel + .about-panel {
  margin-top: 1.65rem;
  padding-top: 1.65rem;
  border-top: 1px solid var(--border);
}
.about-panel-title {
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1.1rem;
  font-weight: 700;
}

.edu-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.edu-item {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1.05rem;
  align-items: flex-start;
}
.edu-item:last-child { margin-bottom: 0; }
.edu-year {
  flex: 0 0 auto;
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 600;
  padding-top: 0.2rem;
  min-width: 5.5rem;
  font-variant-numeric: tabular-nums;
}
.edu-body strong {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
}
.edu-body p {
  font-size: 0.84rem;
  color: var(--muted);
  margin: 0.2rem 0 0;
  line-height: 1.55;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.timeline-year {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr);
  column-gap: 0.85rem;
  align-items: start;
  padding-bottom: 1.35rem;
  list-style: none;
}
.timeline-year:last-child { padding-bottom: 0; }
.timeline-year-label {
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.35;
  text-align: right;
  padding-top: 0.15rem;
  font-variant-numeric: tabular-nums;
}
.timeline-items {
  list-style: none;
  margin: 0;
  padding: 0 0 0 0.85rem;
  border-left: 1px solid var(--border);
}
.timeline-items li {
  font-size: 0.87rem;
  color: #444;
  line-height: 1.62;
  padding-bottom: 0.42rem;
}
.timeline-items li:last-child { padding-bottom: 0; }

/* ══════════════════════════════════
   SKILLS
══════════════════════════════════ */
#skills {
  padding: var(--section-v) 0;
  background: var(--surface);
}
.skills-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3rem;
}
.skill-group h3 {
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.25rem;
  font-weight: 700;
}
.skill-tags { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.skill-tag {
  font-size: 0.84rem;
  padding: 0.4rem 0.95rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-weight: 500;
  transition: border-color var(--t), transform var(--t), box-shadow var(--t);
  cursor: default;
}
.skill-tag:hover {
  border-color: var(--fg);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.07);
}

/* ══════════════════════════════════
   WORKS
══════════════════════════════════ */
#works {
  padding: var(--section-v) 0;
  border-top: 1px solid var(--border);
}
.works-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}
.work-card {
  display: block;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform var(--t), box-shadow var(--t);
  background: var(--bg);
  cursor: pointer;
}
.work-card:hover {
  transform: translateY(-7px);
  box-shadow: 0 24px 60px rgba(0,0,0,0.10);
}
.card-visual {
  background: var(--card-color, #111);
  height: 230px;
  display: flex;
  align-items: flex-end;
  padding: 2rem;
  position: relative;
  overflow: hidden;
  transition: height var(--t);
}
.card-visual-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 0;
}
.card-visual::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(135deg, transparent 30%, rgba(0,0,0,0.4));
}
.card-visual::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--card-color, #111);
  opacity: 0;
  transition: opacity var(--t);
}
.work-card:hover .card-visual::after { opacity: 0.12; }
.card-project-name {
  font-size: clamp(2.2rem, 4vw, 3.5rem);
  font-weight: 900;
  color: rgba(255,255,255,0.9);
  letter-spacing: -0.03em;
  line-height: 1;
  position: relative;
  z-index: 2;
  transition: transform var(--t);
}
.work-card:hover .card-project-name { transform: translateX(4px); }
.card-info { padding: 1.75rem; }
.card-tags {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.card-tags span {
  font-size: 0.7rem;
  padding: 0.2rem 0.65rem;
  background: var(--surface);
  border-radius: 100px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}
.card-desc {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.75;
  margin-bottom: 1.25rem;
}
.card-link {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: gap var(--t), color var(--t);
  letter-spacing: 0.01em;
}
.work-card:hover .card-link { gap: 0.7rem; color: var(--accent); }

/* ══════════════════════════════════
   CONTACT
══════════════════════════════════ */
#contact {
  padding: var(--section-v) 0;
  background: var(--fg);
  color: var(--bg);
}
#contact .section-label { color: var(--accent); }
#contact h2 { color: var(--bg); }
.contact-inner { max-width: 640px; }
.contact-inner > p {
  color: rgba(255,255,255,0.55);
  margin: 1rem 0 2.25rem;
  font-size: 1.05rem;
}
.contact-links { display: flex; gap: 0.9rem; flex-wrap: wrap; margin-bottom: 2rem; }
#contact .btn-primary { background: var(--bg); color: var(--fg); }
#contact .btn-primary:hover { background: var(--accent); color: var(--bg); }
#contact .btn-secondary { border-color: rgba(255,255,255,0.25); color: rgba(255,255,255,0.75); }
#contact .btn-secondary:hover { border-color: var(--bg); color: var(--bg); }
.contact-meta { display: flex; gap: 2rem; font-size: 0.85rem; color: rgba(255,255,255,0.35); }

/* ─── Footer ─── */
footer {
  padding: 1.75rem 2rem;
  background: var(--fg);
  border-top: 1px solid rgba(255,255,255,0.07);
  text-align: center;
}
footer p { font-size: 0.78rem; color: rgba(255,255,255,0.25); }

/* ══════════════════════════════════
   WORK PAGES
══════════════════════════════════ */
.work-page-hero {
  min-height: 60vh;
  background: var(--project-color, #111);
  display: flex;
  align-items: flex-end;
  padding: 0 2rem 3.5rem;
  position: relative;
  overflow: hidden;
}
.work-page-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 0;
}
.work-page-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.2) 0%,
    transparent 35%,
    rgba(0, 0, 0, 0.5) 100%
  );
}
.work-page-hero .container { position: relative; z-index: 2; }

.work-back {
  position: fixed;
  top: 5.5rem;
  left: 2rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(255,255,255,0.75);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: color var(--t);
  z-index: 50;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.work-back:hover { color: #fff; }

.work-page-hero h1 {
  color: #fff;
  font-size: clamp(2.5rem, 7vw, 5.5rem);
  margin-bottom: 0.4rem;
}
.work-page-hero .work-subtitle {
  color: rgba(255,255,255,0.65);
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  font-weight: 300;
}
.work-meta {
  display: flex;
  gap: 2.5rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}
.work-meta-item { display: flex; flex-direction: column; gap: 0.2rem; }
.work-meta-item .label {
  font-size: 0.63rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
  font-weight: 600;
}
.work-meta-item .value {
  font-size: 0.88rem;
  color: rgba(255,255,255,0.88);
  font-weight: 500;
}

.work-body {
  max-width: 780px;
  margin: 0 auto;
  padding: 5rem 2rem 4rem;
}
.work-section { margin-bottom: 4rem; }
.work-section-label {
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.25rem;
  font-weight: 700;
  display: block;
}
.work-section h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 2rem 0 0.6rem;
  letter-spacing: -0.01em;
}
.work-section h3:first-child { margin-top: 0; }
.work-section p {
  font-size: 1rem;
  line-height: 1.95;
  color: #333;
  margin-bottom: 0.9rem;
}
.work-section strong { color: var(--fg); }
.work-section ul {
  margin: 0.5rem 0 1rem 1.4rem;
}
.work-section li {
  font-size: 0.95rem;
  line-height: 1.85;
  color: #444;
  margin-bottom: 0.2rem;
}
hr.work-divider {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 4rem 0;
}

.work-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0 1.5rem;
  font-size: 0.9rem;
}
.work-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.work-table td {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  color: #444;
  line-height: 1.6;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.15rem;
  margin: 1.5rem 0;
}
.result-card {
  padding: 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.result-card .result-num {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.4rem;
  letter-spacing: -0.02em;
}
.result-card p { font-size: 0.86rem; color: var(--muted); margin: 0; line-height: 1.5; }

.highlight-box {
  padding: 1.5rem 2rem;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 1.5rem 0;
  font-size: 1rem;
  color: #333;
  line-height: 1.8;
  font-style: italic;
}

.work-page-nav {
  border-top: 1px solid var(--border);
  padding: 2.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1140px;
  margin: 0 auto;
}
.work-page-nav a {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: color var(--t);
}
.work-page-nav a:hover { color: var(--accent); }

/* ══════════════════════════════════
   RESPONSIVE
══════════════════════════════════ */
@media (max-width: 900px) {
  .about-grid { grid-template-columns: 1fr; gap: 2.75rem; }
  .about-sidebar { position: static; }
  .skills-grid { grid-template-columns: 1fr 1fr; gap: 2rem; }
  .works-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  #nav { padding: 1.1rem 1.25rem; }
  #nav.scrolled { padding: 0.9rem 1.25rem; }
  .nav-links { display: none; }
  .nav-toggle { display: flex; }

  .nav-links.nav-open {
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0;
    background: var(--bg);
    align-items: center;
    justify-content: center;
    gap: 2.5rem;
    z-index: 99;
  }
  .nav-links.nav-open a {
    font-size: 1.4rem;
    color: var(--fg);
  }
  .nav-links.nav-open .nav-cta {
    font-size: 1rem;
    padding: 0.65rem 1.5rem;
  }

  .hero-inner { padding-top: 4.5rem; }
  .skills-grid { grid-template-columns: 1fr; }
  .card-visual { height: 170px; }
  .contact-meta { flex-direction: column; gap: 0.5rem; }
  .work-back { position: absolute; top: auto; bottom: calc(100% + 1rem); left: 0; }
  .work-meta { gap: 1.5rem; }
}
