/* ── Design Tokens ── */
:root {
  --bg: #eef1f4;
  --bg-deep: #e2e7ed;
  --surface: #f7f9fb;
  --ink: #15202b;
  --ink-soft: #3d4a57;
  --muted: #667582;
  --accent: #1f6f8b;
  --accent-hover: #185a70;
  --accent-soft: rgba(31, 111, 139, 0.12);
  --line: rgba(21, 32, 43, 0.12);
  --white: #ffffff;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --danger-border: #fecdca;
  --header-h: 64px;
  --max-w: 880px;
  --radius: 10px;
  --radius-sm: 8px;
  --font: "Noto Sans TC", sans-serif;
  --display: "Noto Sans TC", sans-serif;
  --ease: 0.28s ease;
  --shadow: 0 18px 50px rgba(21, 32, 43, 0.08);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

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

body.modal-open { overflow: hidden; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--ease);
}

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

ul { list-style: none; }

.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}

.section {
  padding: 96px 0;
}

.section-tone {
  background:
    linear-gradient(180deg, rgba(226, 231, 237, 0.9), rgba(238, 241, 244, 0.4)),
    radial-gradient(ellipse 80% 60% at 100% 0%, rgba(31, 111, 139, 0.08), transparent 55%);
}

.section-label {
  display: inline-block;
  font-family: var(--display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}

.section-title {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.section-desc {
  color: var(--muted);
  max-width: 540px;
  margin-bottom: 40px;
}

/* ── Header ── */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(238, 241, 244, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}

.site-header.scrolled {
  border-bottom-color: var(--line);
  background: rgba(247, 249, 251, 0.92);
  box-shadow: 0 8px 24px rgba(21, 32, 43, 0.04);
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
  color: var(--ink);
}

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

.site-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-nav a {
  color: var(--ink-soft);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 10px;
  border-radius: 6px;
}

.site-nav a:hover {
  color: var(--ink);
  background: rgba(21, 32, 43, 0.04);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--ink);
}

.nav-toggle svg {
  width: 22px;
  height: 22px;
  display: block;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--ease), color var(--ease), border-color var(--ease), transform var(--ease);
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: var(--white);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: rgba(21, 32, 43, 0.22);
}

.btn-ghost:hover {
  border-color: var(--ink);
  color: var(--ink);
  background: rgba(21, 32, 43, 0.03);
}

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

.hero-atmosphere {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 55% at 12% 20%, rgba(31, 111, 139, 0.22), transparent 60%),
    radial-gradient(ellipse 55% 50% at 88% 70%, rgba(21, 32, 43, 0.1), transparent 55%),
    linear-gradient(160deg, #d9e2ea 0%, #eef1f4 42%, #e7ecef 100%);
  animation: atmosphere-shift 14s ease-in-out infinite alternate;
}

.hero-atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(21, 32, 43, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 32, 43, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black, transparent 75%);
  pointer-events: none;
}

@keyframes atmosphere-shift {
  from { filter: hue-rotate(0deg) saturate(1); }
  to { filter: hue-rotate(-8deg) saturate(1.08); }
}

.hero-inner {
  position: relative;
  z-index: 1;
}

.hero-greeting {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 16px;
}

.hero-title {
  font-size: clamp(2rem, 5.5vw, 3.25rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 12px;
}

.hero-role {
  font-size: clamp(1.05rem, 2.2vw, 1.2rem);
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 20px;
}

.hero-lead {
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 34em;
  margin-bottom: 36px;
  line-height: 1.8;
}

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

/* ── About ── */
.about-highlights {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 40px 0 36px;
}

.highlight {
  padding: 20px 0;
  border-top: 1px solid var(--line);
}

.highlight-value {
  display: block;
  font-family: var(--display);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 6px;
}

.highlight-label {
  font-size: 0.875rem;
  color: var(--muted);
}

.bio {
  display: flex;
  flex-direction: column;
  gap: 18px;
  color: var(--ink-soft);
  max-width: 44em;
}

.bio p { text-wrap: pretty; }

/* ── Skills ── */
.skills-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.skill-block {
  padding: 28px 0;
  border-top: 1px solid var(--line);
}

.skill-block:last-child {
  border-bottom: 1px solid var(--line);
}

.skill-block h3 {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}

.skill-block p {
  color: var(--ink-soft);
  margin-bottom: 14px;
  max-width: 42em;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tags li {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
}

/* ── Timeline ── */
.timeline {
  list-style: none;
  position: relative;
  margin-top: 8px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: linear-gradient(180deg, var(--accent), rgba(31, 111, 139, 0.15));
}

.timeline-item {
  position: relative;
  padding: 0 0 40px 28px;
}

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

.timeline-item::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 10px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--bg);
}

.timeline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 8px;
  font-size: 0.8125rem;
  color: var(--muted);
}

.timeline-meta time {
  font-weight: 600;
  color: var(--accent);
}

.timeline-body h3 {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.company {
  font-size: 0.9375rem;
  color: var(--ink-soft);
  margin-bottom: 12px;
}

.timeline-body > ul:not(.tags) {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--ink-soft);
}

.timeline-body > ul:not(.tags) li {
  position: relative;
  padding-left: 14px;
  font-size: 0.9375rem;
}

.timeline-body > ul:not(.tags) li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.7em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(31, 111, 139, 0.45);
}

.compact-text {
  color: var(--ink-soft);
  font-size: 0.9375rem;
  max-width: 40em;
}

.timeline-item--compact .timeline-body h3 {
  font-size: 1.05rem;
}

/* ── Education ── */
.edu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px 32px;
}

.edu-school,
.gh-link {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--ink);
}

.gh-link {
  display: inline-block;
  color: var(--accent);
  border-bottom: 1px solid transparent;
  transition: border-color var(--ease);
}

.gh-link:hover {
  border-bottom-color: var(--accent);
}

.edu-meta {
  margin-top: 8px;
  font-size: 0.875rem;
  color: var(--muted);
}

/* ── Contact ── */
.contact-panel {
  text-align: left;
  padding-top: 48px;
  padding-bottom: 8px;
  border-top: 1px solid var(--line);
}

.contact-desc { margin-bottom: 28px; }

.contact-action { margin-top: 4px; }

.contact-note {
  margin-top: 18px;
  font-size: 0.875rem;
  color: var(--muted);
}

.contact-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.contact-modal[hidden] { display: none; }

.contact-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(21, 32, 43, 0.48);
  backdrop-filter: blur(3px);
}

.contact-modal-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  max-height: min(92vh, 860px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
}

.contact-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.contact-modal-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

.contact-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.contact-modal-close:hover {
  color: var(--ink);
  background: var(--bg-deep);
}

.contact-modal-body { min-height: 120px; }

.contact-modal-body.is-success {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-field label,
.form-field legend {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--ink);
}

fieldset.form-field {
  border: none;
  padding: 0;
  margin: 0;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.form-field legend {
  margin-bottom: 10px;
  padding: 0;
}

.radio-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.form-field input[type="text"],
.form-field select,
.form-field textarea {
  width: 100%;
  font-family: var(--font);
  font-size: 0.9375rem;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color var(--ease), box-shadow var(--ease);
}

.form-field textarea {
  min-height: 120px;
  resize: vertical;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-hint {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.875rem;
  cursor: pointer;
}

.radio-option:has(input:checked) {
  color: var(--accent);
  font-weight: 500;
}

.radio-option input { accent-color: var(--accent); }

.captcha-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.captcha-row input {
  flex: 1;
  min-width: 0;
}

.captcha-row img {
  width: 120px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--bg-deep);
  flex-shrink: 0;
}

.form-error {
  font-size: 0.875rem;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.contact-success {
  text-align: center;
  padding: 24px 12px;
  width: 100%;
}

.contact-success[hidden],
.contact-form[hidden] {
  display: none !important;
}

.contact-success p {
  font-size: 1rem;
  margin-bottom: 8px;
}

.contact-success small {
  color: var(--muted);
  font-size: 0.875rem;
}

.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.contact-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.contact-form-actions .btn { min-width: 96px; }

/* ── Portfolio ── */
.portfolio-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.portfolio-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow var(--ease), transform var(--ease);
}

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

.portfolio-thumb {
  height: 200px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.portfolio-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.portfolio-body {
  padding: 20px 22px 22px;
}

.portfolio-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 10px;
}

.portfolio-body h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.portfolio-body > p {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 14px;
}

.portfolio-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.portfolio-tags span {
  font-size: 0.75rem;
  color: var(--ink-soft);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 3px 8px;
  border-radius: 4px;
}

.portfolio-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 10px 18px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--white);
  background: var(--accent);
  border-radius: var(--radius-sm);
  transition: background var(--ease), color var(--ease), transform var(--ease);
}

.portfolio-link:hover {
  color: var(--white);
  background: var(--accent-hover);
}

.portfolio-link::after {
  content: "→";
  transition: transform var(--ease);
}

.portfolio-link:hover::after {
  transform: translateX(3px);
}

.portfolio-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.portfolio-link-secondary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 9px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}

.portfolio-link-secondary:hover {
  color: var(--accent-hover);
  border-color: var(--accent);
  background: var(--white);
}

.portfolio-footnote {
  margin-top: 28px;
  max-width: 720px;
  font-size: 0.8125rem;
  line-height: 1.75;
  color: var(--muted);
}

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px 0;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted);
}

/* ── Motion ── */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

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

.hero .reveal {
  transition-duration: 0.85s;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .section { padding: 72px 0; }

  .nav-toggle { display: block; }

  .site-nav {
    display: none;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 12px 16px 20px;
    box-shadow: var(--shadow);
  }

  .site-nav.open { display: flex; }

  .site-nav a {
    padding: 12px;
    font-size: 1rem;
  }

  .about-highlights,
  .edu-grid {
    grid-template-columns: 1fr;
  }

  .about-highlights { gap: 0; }

  .radio-group { grid-template-columns: 1fr; }

  .br-desktop { display: none; }

  .hero {
    min-height: auto;
    padding: calc(var(--header-h) + 56px) 0 72px;
  }

  .contact-modal-panel {
    padding: 22px 16px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .hero-atmosphere { animation: none; }
}
