/* ============================================================
   Sean Chen — Resume Site
   Design System: 黑白灰極簡（Linear / Vercel / Stripe inspired）
   Mobile First
   ============================================================ */

:root {
  /* Color tokens */
  --bg: #0a0a0a;
  --bg-alt: #0f0f10;
  --surface: #141416;
  --surface-hover: #1a1a1d;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;
  --accent: #ffffff;

  /* Typography */
  --font-sans: "Inter", "Noto Sans TC", -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;

  /* Layout */
  --container: 1080px;
  --nav-h: 64px;
  --radius: 12px;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

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

img, svg { display: inline-block; vertical-align: middle; }
ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; }

::selection { background: rgba(255, 255, 255, 0.9); color: #0a0a0a; }

.mono { font-family: var(--font-mono); letter-spacing: 0.08em; }

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 20px;
}

/* ---------- Accessibility ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--text);
  color: var(--bg);
  padding: 8px 16px;
  z-index: 1000;
}
.skip-link:focus { left: 0; }

/* ---------- Navigation ---------- */
.site-nav {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--nav-h);
  z-index: 100;
  border-bottom: 1px solid transparent;
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease);
}

.site-nav.scrolled {
  background: rgba(10, 10, 10, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom-color: var(--border);
}

.nav-inner {
  max-width: var(--container);
  height: 100%;
  margin-inline: auto;
  padding-inline: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  width: 8px;
  height: 8px;
  background: var(--text);
  border-radius: 2px;
}

.brand-dot { color: var(--text-tertiary); }

.nav-toggle {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: none;
  border: 0;
  padding: 8px;
  cursor: pointer;
}
.nav-toggle span {
  width: 22px;
  height: 1.5px;
  background: var(--text);
  transition: transform 0.3s var(--ease), opacity 0.3s;
}
.nav-toggle[aria-expanded="true"] span:first-child { transform: translateY(3.75px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:last-child { transform: translateY(-3.75px) rotate(-45deg); }

.nav-menu {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  right: 0;
  background: rgba(10, 10, 10, 0.96);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px 20px 20px;
  gap: 4px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease), visibility 0.25s;
}
.nav-menu.open { opacity: 1; visibility: visible; transform: translateY(0); }

.nav-menu a {
  display: block;
  padding: 10px 4px;
  font-size: 15px;
  color: var(--text-secondary);
  transition: color 0.2s;
}
.nav-menu a:hover { color: var(--text); }

.nav-cta { color: var(--text) !important; font-weight: 600; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: calc(var(--nav-h) + 48px) 0 64px;
  overflow: hidden;
}

.hero-glow {
  position: absolute;
  top: -30%;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 600px;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.06), transparent 60%);
  pointer-events: none;
}

.hero-inner { position: relative; }

.hero-eyebrow {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 20px;
}

.hero-title {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.05;
  background: linear-gradient(180deg, #ffffff 30%, #8a8a8e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 16px;
  min-height: 1.05em;
}

.hero-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 28px;
}
.role-sep { color: var(--text-tertiary); }

.hero-tagline {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.25;
  margin-bottom: 12px;
  min-height: 1.25em;
}

.hero-sub {
  max-width: 560px;
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 36px;
  min-height: 3.4em;
}

.code-type {
  position: relative;
  font-variant-ligatures: none;
}

.hero-roles.code-type {
  display: block;
  font-family: var(--font-mono);
  font-size: 14px;
  min-height: 1.7em;
}

.hero .code-type.is-typing {
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.14);
}

.hero .code-type.is-typing::after,
.hero .code-type.is-terminal-caret::after {
  content: "";
  display: inline-block;
  width: 0.56ch;
  height: 0.92em;
  margin-left: 0.14ch;
  background: #7dd3fc;
  box-shadow: 0 0 16px rgba(125, 211, 252, 0.52);
  transform: translateY(0.1em);
  animation: caretBlink 0.9s steps(1, end) infinite;
}

.hero-title.code-type::after {
  -webkit-text-fill-color: #7dd3fc;
}

@keyframes caretBlink {
  0%, 48% { opacity: 1; }
  49%, 100% { opacity: 0; }
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.25s var(--ease);
}

.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:hover { background: #d4d4d8; transform: translateY(-1px); }

.btn-ghost { border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { border-color: var(--text-secondary); background: rgba(255, 255, 255, 0.04); }

.hero-scroll {
  display: none;
  align-items: center;
  gap: 12px;
  margin-top: 72px;
  color: var(--text-tertiary);
  font-size: 10px;
}
.scroll-line {
  width: 56px;
  height: 1px;
  background: linear-gradient(90deg, var(--text-tertiary), transparent);
}

/* ---------- Sections ---------- */
.section { padding: 88px 0; }
.section-alt { background: var(--bg-alt); border-block: 1px solid var(--border); }

.section-eyebrow {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.section-title {
  font-size: clamp(28px, 6vw, 40px);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}

.section-desc {
  color: var(--text-secondary);
  max-width: 640px;
  margin-bottom: 40px;
  font-size: 15px;
}

/* ---------- About ---------- */
.about-grid { display: grid; gap: 32px; margin-top: 32px; }

.about-text p {
  color: var(--text-secondary);
  font-size: 16px;
  margin-bottom: 16px;
}
.about-text p:last-child { margin-bottom: 0; }

.about-side {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  height: fit-content;
}

.side-label {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-bottom: 16px;
}

/* ---------- Tags ---------- */
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }

.tag {
  font-size: 13px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.2s, color 0.2s;
}
.tag:hover { border-color: var(--border-strong); color: var(--text); }
.tag-sm { font-size: 12px; padding: 3px 10px; }

/* ---------- Experience ---------- */
.exp-list { display: grid; gap: 20px; margin-top: 16px; }

.exp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  transition: border-color 0.3s var(--ease), transform 0.3s var(--ease), background 0.3s;
}
.exp-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  transform: translateY(-2px);
}

.exp-current { border-color: rgba(255, 255, 255, 0.22); }

.exp-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.exp-title { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.exp-company { color: var(--text-secondary); font-size: 14px; margin-top: 2px; }

.exp-period {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.badge-current {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  letter-spacing: 0.08em;
}

.exp-points { margin-bottom: 18px; display: grid; gap: 6px; }
.exp-points li {
  position: relative;
  padding-left: 18px;
  color: var(--text-secondary);
  font-size: 14px;
}
.exp-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 6px;
  height: 1.5px;
  background: var(--text-tertiary);
}

/* ---------- Projects ---------- */
.project-grid { display: grid; gap: 20px; }

.project-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color 0.3s var(--ease), transform 0.3s var(--ease), background 0.3s;
}
.project-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  transform: translateY(-3px);
}

.project-number { font-size: 12px; color: var(--text-tertiary); }

.project-name { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }

.project-outcome { color: var(--text-secondary); font-size: 14px; flex-grow: 1; }

.project-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-top: 4px;
  transition: gap 0.25s var(--ease);
}
.project-link:hover { gap: 10px; }
.project-link svg { transition: transform 0.25s var(--ease); }
.project-link:hover svg { transform: translate(1px, -1px); }

/* ---------- Skills ---------- */
.skills-grid { display: grid; gap: 16px; margin-top: 16px; }

.skill-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color 0.3s var(--ease);
}
.skill-group:hover { border-color: var(--border-strong); }

.skill-group-name {
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.skill-items { display: grid; gap: 8px; }
.skill-items li { font-size: 14px; color: var(--text-secondary); }

/* ---------- Timeline ---------- */
.timeline {
  position: relative;
  margin-top: 40px;
  padding-left: 24px;
  display: grid;
  gap: 40px;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 3.5px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: linear-gradient(180deg, var(--border-strong), var(--border) 80%, transparent);
}

.timeline-item { position: relative; }

.timeline-dot {
  position: absolute;
  left: -24px;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.08);
}

.timeline-future .timeline-dot {
  background: var(--bg);
  border: 1px solid var(--text-secondary);
  animation: pulse 2.4s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.08); }
  50% { box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.04); }
}

.timeline-year { font-size: 12px; color: var(--text-tertiary); margin-bottom: 4px; }
.timeline-title { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.timeline-note { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }
.timeline-future .timeline-title { color: var(--text-secondary); }

/* ---------- Exploring ---------- */
.exploring-grid { display: grid; gap: 12px; margin-top: 8px; }

.exploring-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 15px;
  font-weight: 500;
  transition: border-color 0.3s var(--ease), transform 0.3s var(--ease);
}
.exploring-card:hover { border-color: var(--border-strong); transform: translateX(4px); }

.exploring-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text);
  animation: pulse 2.4s infinite;
  flex-shrink: 0;
}

/* ---------- Contact ---------- */
.contact-grid { display: grid; gap: 16px; }

.contact-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color 0.3s var(--ease), transform 0.3s var(--ease), background 0.3s;
}
.contact-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  transform: translateY(-2px);
}

.contact-label { font-size: 11px; color: var(--text-tertiary); margin-bottom: 8px; }
.contact-value { font-size: 16px; font-weight: 600; word-break: break-all; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 48px 0;
  text-align: center;
}
.footer-inner { padding-inline: 20px; }
.footer-name { font-weight: 700; margin-bottom: 4px; }
.footer-meta { color: var(--text-secondary); font-size: 14px; margin-bottom: 16px; }
.footer-copy { color: var(--text-tertiary); font-size: 12px; }

/* ============================================================
   Scroll Reveal（IntersectionObserver 配合 site.js）
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* Stagger delays */
.d-1 { transition-delay: 0.08s; }
.d-2 { transition-delay: 0.16s; }
.d-3 { transition-delay: 0.24s; }
.d-4 { transition-delay: 0.32s; }
.d-5 { transition-delay: 0.4s; }
.d-6 { transition-delay: 0.48s; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .hero .code-type::after { display: none; }
  .exploring-pulse, .timeline-future .timeline-dot { animation: none; }
}

/* ============================================================
   Responsive — Tablet (≥ 640px)
   ============================================================ */
@media (min-width: 640px) {
  .container { padding-inline: 32px; }
  .nav-inner { padding-inline: 32px; }

  .hero-title { font-size: 64px; }
  .hero-tagline { font-size: 28px; }

  .exp-head { flex-direction: row; justify-content: space-between; align-items: flex-start; }

  .project-grid { grid-template-columns: repeat(2, 1fr); }
  .skills-grid { grid-template-columns: repeat(2, 1fr); }
  .contact-grid { grid-template-columns: repeat(3, 1fr); }
  .exploring-grid { grid-template-columns: repeat(2, 1fr); }

  .hero-scroll { display: inline-flex; }
}

/* ============================================================
   Responsive — Desktop (≥ 960px)
   ============================================================ */
@media (min-width: 960px) {
  .section { padding: 120px 0; }
  .hero-title { font-size: 88px; }
  .hero-tagline { font-size: 32px; }

  /* Desktop nav：水平選單 */
  .nav-toggle { display: none; }
  .nav-menu {
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 28px;
    background: none;
    border: 0;
    padding: 0;
    opacity: 1;
    visibility: visible;
    transform: none;
    backdrop-filter: none;
  }
  .nav-menu a { padding: 4px 0; font-size: 14px; }

  .about-grid { grid-template-columns: 1.6fr 1fr; gap: 48px; }
  .skills-grid { grid-template-columns: repeat(3, 1fr); }
  .exploring-grid { grid-template-columns: repeat(3, 1fr); }

  .timeline {
    padding-left: 0;
    grid-template-columns: repeat(5, 1fr);
    gap: 24px;
  }
  .timeline::before {
    left: 4px;
    right: 4px;
    top: 3.5px;
    bottom: auto;
    width: auto;
    height: 1px;
    background: linear-gradient(90deg, var(--border-strong), var(--border) 80%, transparent);
  }
  .timeline-dot { left: 0; top: 0; }
  .timeline-item { padding-top: 28px; }
}

/* ============================================================
   低調互動效果（v2）
   ============================================================ */

/* ---------- 頂部閱讀進度條 ---------- */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 200;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.35));
  transform: scaleX(0);
  transform-origin: left;
  pointer-events: none;
}

/* ---------- Nav Scrollspy：目前區塊高亮 ---------- */
.nav-menu a { position: relative; }
.nav-menu a.active { color: var(--text); }

@media (min-width: 960px) {
  .nav-menu a::after {
    content: "";
    position: absolute;
    left: 0;
    right: 100%;
    bottom: -2px;
    height: 1px;
    background: var(--text);
    transition: right 0.3s var(--ease);
  }
  .nav-menu a:hover::after,
  .nav-menu a.active::after { right: 0; }
}

/* ---------- 卡片 Spotlight（滑鼠跟隨微光） ---------- */
.spot {
  position: relative;
  overflow: hidden;
}
.spot::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    280px circle at var(--mx, 50%) var(--my, 50%),
    rgba(255, 255, 255, 0.055),
    transparent 65%
  );
  opacity: 0;
  transition: opacity 0.4s var(--ease);
  pointer-events: none;
}
.spot:hover::before { opacity: 1; }

/* ---------- Hero 光暈微視差 ---------- */
.hero-glow {
  transition: transform 0.6s var(--ease);
  will-change: transform;
}

/* ---------- Hero scroll 指示線呼吸 ---------- */
.scroll-line {
  animation: scrollBreath 2.8s ease-in-out infinite;
}
@keyframes scrollBreath {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ---------- Contact 卡片：依數量自適應 ---------- */
@media (min-width: 640px) {
  .contact-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .scroll-line { animation: none; }
  .spot::before { display: none; }
  .hero-glow { transition: none; }
}

/* ============================================================
   Video Lightbox（頁內播放 YouTube Demo）
   ============================================================ */
.js-play {
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}

.video-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.video-modal[hidden] { display: none; }

.video-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: vmFade 0.3s var(--ease);
}

.video-dialog {
  position: relative;
  width: min(1280px, 100%, calc((100vh - 140px) * 16 / 9));
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6);
  animation: vmIn 0.35s var(--ease);
}

@keyframes vmFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes vmIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.video-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.video-title {
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, transform 0.2s var(--ease);
}
.video-close:hover { color: var(--text); border-color: var(--border-strong); transform: rotate(90deg); }

.video-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
}
.video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-external {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  font-size: 11px;
  color: var(--text-tertiary);
  transition: color 0.2s;
}
.video-external:hover { color: var(--text); }

body.modal-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .video-backdrop, .video-dialog { animation: none; }
}
