/* ==========================================================================
   Taylor Tang — portfolio stylesheet
   Colors & fonts are defined once in :root / [data-theme="dark"] below.
   Everything else builds on the original cream/navy, serif+sans identity.
   ========================================================================== */

:root {
  --bg:        #f5f0e6;   /* cream page background */
  --card:      #fcfaf4;   /* publication/award cards */
  --navy:      #17233d;   /* headings & dark text */
  --muted:     #5b6675;   /* secondary/body text */
  --blue:      #2c4fe0;   /* links, numbers, buttons */
  --blue-soft: #e7e9fb;   /* tag pill background */
  --border:    #e7e1d2;   /* hairline borders */
  --radius:    18px;
  --max:       960px;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans:  "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg:        #131a2c;
  --card:      #1b2440;
  --navy:      #f3efe4;
  --muted:     #a9b0c4;
  --blue:      #8ea0ff;
  --blue-soft: #232c4d;
  --border:    #2c3559;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--navy);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
  border-radius: 4px;
}

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 28px; }

/* skip link (accessibility) */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--navy); color: var(--bg);
  padding: 12px 18px; border-radius: 0 0 8px 0; font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ---------- NAV ---------- */
nav {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--max); margin: 0 auto; padding: 18px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.nav-name { font-weight: 700; font-size: 18px; color: var(--navy); }
.nav-links { display: flex; align-items: center; gap: 26px; }
.nav-links a { font-weight: 500; font-size: 15px; color: var(--muted); transition: color 0.15s ease; }
.nav-links a.plain { color: var(--muted); }
.nav-links a.plain:hover, .nav-links a.plain[aria-current="true"] { color: var(--blue); text-decoration: none; }

/* small pill button used in the nav for LinkedIn */
.btn-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card);
  color: var(--blue); font-weight: 600; font-size: 14px;
}
.btn-pill:hover { text-decoration: none; border-color: var(--blue); }
.btn-pill svg { width: 16px; height: 16px; }

/* theme toggle */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card);
  color: var(--navy); cursor: pointer; flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--blue); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* ---------- HERO ---------- */
.hero { padding: 90px 0 70px; }
.hero-grid { display: flex; align-items: center; gap: 56px; }
.hero-copy { flex: 1 1 auto; min-width: 0; }

.eyebrow {
  display: flex; align-items: center; gap: 10px;
  text-transform: uppercase; letter-spacing: 0.12em;
  font-size: 13px; font-weight: 600; color: var(--muted);
  margin-bottom: 26px;
}
.eyebrow .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); flex-shrink: 0; aspect-ratio: 1 / 1; }

.hero h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(34px, 6vw, 62px);
  line-height: 1.08;
  letter-spacing: -0.015em;
  color: var(--navy);
  max-width: 15ch;
  margin-bottom: 28px;
}
.hero .lead {
  font-size: 19px; color: var(--muted);
  max-width: 60ch; margin-bottom: 22px;
}

.hero-meta {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 14px; margin-bottom: 30px;
}
.meta-item { font-size: 14.5px; color: var(--muted); }
.meta-item strong { color: var(--navy); font-weight: 600; }
.lang-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--blue-soft); color: var(--blue);
  font-weight: 600; font-size: 13px;
  padding: 6px 13px; border-radius: 999px;
}
.lang-badge .lang-level { font-size: 12px; }

.btn-row { display: flex; gap: 14px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 13px 22px; border-radius: 999px;
  font-weight: 600; font-size: 15px;
}
.btn svg { width: 17px; height: 17px; }
.btn-solid { background: var(--navy); color: var(--bg); }
.btn-solid:hover { text-decoration: none; opacity: 0.92; }
.btn-ghost { background: var(--card); color: var(--blue); border: 1px solid var(--border); }
.btn-ghost:hover { text-decoration: none; border-color: var(--blue); }

/* ---------- HEADSHOT ---------- */
.hero-portrait { flex: 0 0 auto; }
.portrait-frame {
  position: relative;
  width: 220px; height: 220px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  padding: 8px;
  box-shadow: 0 18px 40px -20px rgba(23, 35, 61, 0.35);
}
.portrait-frame::before {
  content: "";
  position: absolute; inset: -10px;
  border-radius: 50%;
  border: 1px solid var(--border);
  opacity: 0.6;
}
.portrait-frame img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
/* fallback monogram shown until img/headshot.jpg is added */
.portrait-frame .avatar-fallback {
  width: 100%; height: 100%;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--blue-soft), var(--card));
  font-family: var(--serif);
  font-size: 64px; font-weight: 600; color: var(--blue);
}
.portrait-frame img.has-error { display: none; }
.portrait-frame:not(.no-image) .avatar-fallback { display: none; }

/* ---------- GENERIC SECTION ---------- */
section { padding: 40px 0; }
.section-head { margin-bottom: 34px; }
.section-head h2 {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(28px, 4vw, 40px);
  color: var(--navy); letter-spacing: -0.01em; margin-bottom: 12px;
}
.section-head p { color: var(--muted); font-size: 18px; max-width: 60ch; }

/* ---------- ABOUT ---------- */
.about p { font-size: 19px; color: var(--muted); max-width: 68ch; margin-bottom: 18px; }
.about p strong { color: var(--navy); font-weight: 600; }

/* ---------- FOCUS CARDS (01 / 02 / 03) ---------- */
.focus-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.focus-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 26px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.focus-card:hover, .focus-card:focus-within {
  transform: translateY(-4px);
  border-color: var(--blue);
  box-shadow: 0 16px 30px -20px rgba(23, 35, 61, 0.35);
}
.focus-card .num { color: var(--blue); font-weight: 700; font-size: 14px; margin-bottom: 16px; }
.focus-card h3 { font-size: 20px; color: var(--navy); margin-bottom: 10px; }
.focus-card p { color: var(--muted); font-size: 15.5px; }

/* ---------- TIMELINE (experience) ---------- */
.timeline { position: relative; }
.timeline-item {
  position: relative;
  padding: 0 0 32px 32px;
  border-left: 2px solid var(--border);
}
.timeline-item:last-child { padding-bottom: 4px; }
.timeline-item::before {
  content: "";
  position: absolute; left: -7px; top: 4px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--blue); border: 3px solid var(--bg);
}
.timeline-item .role-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.timeline-item h3 { font-family: var(--serif); font-weight: 600; font-size: 22px; color: var(--navy); }
.timeline-item .dates { color: var(--muted); font-weight: 600; font-size: 14px; }
.timeline-item .org { color: var(--blue); font-weight: 600; font-size: 15px; margin-bottom: 10px; }
.timeline-item p { color: var(--muted); font-size: 16px; max-width: 68ch; }

/* ---------- EDUCATION ---------- */
.edu-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.edu-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px 26px;
}
.edu-card h3 { font-family: var(--serif); font-size: 19px; color: var(--navy); margin-bottom: 4px; }
.edu-card .dates { color: var(--muted); font-weight: 600; font-size: 13.5px; margin-bottom: 8px; display: block; }
.edu-card p { color: var(--muted); font-size: 15px; }

/* ---------- SKILLS & LANGUAGES ---------- */
.skills-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.skill-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px 26px;
}
.skill-card h3 { font-size: 16px; color: var(--navy); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.skill-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.skill-list li { color: var(--muted); font-size: 15.5px; padding-left: 18px; position: relative; }
.skill-list li::before { content: "—"; position: absolute; left: 0; color: var(--blue); }
.lang-row { display: flex; justify-content: space-between; align-items: center; }
.lang-level { color: var(--blue); font-weight: 600; font-size: 13.5px; }

/* ---------- FILTER BAR ---------- */
.filter-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 28px;
}
.filter-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-btn {
  font-family: var(--sans); cursor: pointer;
  background: var(--card); border: 1px solid var(--border);
  color: var(--muted); font-weight: 600; font-size: 13.5px;
  padding: 8px 15px; border-radius: 999px;
  transition: all 0.15s ease;
}
.filter-btn:hover { border-color: var(--blue); color: var(--blue); }
.filter-btn[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }
.filter-year {
  font-family: var(--sans); font-size: 13.5px; font-weight: 600;
  color: var(--muted); background: var(--card);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 34px 8px 15px;
}
.filter-empty { color: var(--muted); font-style: italic; padding: 20px 0; display: none; }

/* ---------- PUBLICATION / AWARD CARDS ---------- */
.pub {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 30px 32px; margin-bottom: 20px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.pub:hover, .pub:focus-within {
  transform: translateY(-3px);
  border-color: var(--blue);
  box-shadow: 0 16px 30px -20px rgba(23, 35, 61, 0.35);
}
.pub[hidden] { display: none; }
.pub-meta { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.tag {
  background: var(--blue-soft); color: var(--blue);
  font-weight: 600; font-size: 13px; padding: 5px 12px; border-radius: 999px;
}
.year { color: var(--muted); font-weight: 600; font-size: 15px; }
.pub h3 { font-family: var(--serif); font-weight: 600; font-size: 26px; color: var(--navy); margin-bottom: 6px; }
.pub h3 a { color: inherit; text-decoration: none; }
.pub h3 a:hover { text-decoration: underline; }
.venue { color: var(--muted); font-weight: 600; font-size: 15px; margin-bottom: 14px; }
.pub .desc { color: var(--muted); font-size: 16.5px; max-width: 72ch; margin-bottom: 16px; }
.citation { color: var(--muted); opacity: 0.75; font-size: 14.5px; margin-bottom: 20px; }

.pub-links { display: flex; gap: 12px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px; font-weight: 600; font-size: 14px;
}
.chip svg { width: 15px; height: 15px; }
.chip.source { background: var(--card); color: var(--blue); border: 1px solid var(--border); }
.chip.source:hover { text-decoration: none; border-color: var(--blue); }
.chip.pdf { background: var(--blue-soft); color: var(--blue); }
.chip.pdf:hover { text-decoration: none; opacity: 0.9; }

/* ---------- LONG-FORM WRITING ---------- */
.post-body-wrap { padding-bottom: 70px; }
.post-body { max-width: 65ch; }
.post-body p {
  color: var(--muted); font-size: 18px; line-height: 1.8;
  margin-bottom: 24px; max-width: none;
}
.post-body p:last-child { margin-bottom: 0; }

.post-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 70px; max-width: 65ch;
  border-top: 1px solid var(--border); padding-top: 28px;
}
.post-nav a { font-weight: 600; font-size: 15px; color: var(--navy); }
.post-nav a:hover { color: var(--blue); text-decoration: none; }

/* ---------- SCROLL REVEAL ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.is-visible { opacity: 1; transform: translateY(0); }

/* ---------- FOOTER ---------- */
footer { padding: 60px 0 80px; border-top: 1px solid var(--border); margin-top: 40px; }
footer .foot-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
footer p { color: var(--muted); font-size: 15px; }
.foot-links { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- DETAIL PAGE (in-site PDF viewer) ---------- */
.detail-header { padding-top: 48px; padding-bottom: 20px; }
.back-link {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--muted); font-weight: 600; font-size: 14px; margin-bottom: 28px;
}
.back-link:hover { color: var(--blue); text-decoration: none; }
.back-link svg { width: 16px; height: 16px; }
.detail-header h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(28px, 4.5vw, 42px); color: var(--navy); margin-bottom: 14px; letter-spacing: -0.01em; }
.detail-header .desc { color: var(--muted); font-size: 17.5px; max-width: 68ch; margin: 18px 0 26px; }

.pdf-viewer-wrap { padding-bottom: 60px; }
.pdf-viewer {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--card);
  box-shadow: 0 20px 45px -30px rgba(23, 35, 61, 0.4);
}
.pdf-viewer iframe, .pdf-viewer object { width: 100%; height: 82vh; min-height: 480px; border: 0; display: block; }
.pdf-fallback { padding: 40px; text-align: center; color: var(--muted); }

@media (max-width: 640px) {
  .pdf-viewer iframe, .pdf-viewer object { height: 60vh; }
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 760px) {
  .wrap { padding: 0 20px; }
  .nav-links { gap: 14px; }
  .nav-links a.plain:not(.keep) { display: none; } /* hide text links on small screens, keep LinkedIn */
  .focus-grid { grid-template-columns: 1fr; }
  .edu-grid { grid-template-columns: 1fr; }
  .skills-grid { grid-template-columns: 1fr; }
  .hero { padding: 60px 0 50px; }
  .hero-grid { flex-direction: column-reverse; gap: 32px; text-align: left; }
  .portrait-frame { width: 150px; height: 150px; }
  .pub { padding: 24px 22px; }
  .filter-bar { flex-direction: column; align-items: flex-start; }
  .detail-header { padding-top: 32px; }
}

/* ---------- PAGE TRANSITION (progressive enhancement) ---------- */
@view-transition { navigation: auto; }
body { animation: page-fade-in 0.35s ease; }
@keyframes page-fade-in { from { opacity: 0; } to { opacity: 1; } }
