/* ========================================
   David Ye — Personal Website
   Editorial / Literary Aesthetic
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Cormorant:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400;1,500&family=Karla:ital,wght@0,300;0,400;0,500;0,600;1,400&display=swap');

/* --- CSS Variables --- */
:root {
  --bg: #FAF6F0;
  --bg-alt: #F2ECE3;
  --text: #2C2825;
  --text-muted: #6B6560;
  --text-light: #9A938D;
  --accent: #C45D3E;
  --accent-hover: #A84B30;
  --accent-light: rgba(196, 93, 62, 0.08);
  --sage: #7A8B6F;
  --sage-light: rgba(122, 139, 111, 0.1);
  --border: rgba(44, 40, 37, 0.1);
  --border-strong: rgba(44, 40, 37, 0.2);

  --font-display: 'Cormorant', Georgia, 'Times New Roman', serif;
  --font-body: 'Karla', 'Helvetica Neue', sans-serif;

  --max-width: 1100px;
  --content-width: 720px;
  --nav-height: 72px;
  --side-padding: clamp(1.5rem, 5vw, 4rem);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

::selection {
  background-color: var(--accent);
  color: var(--bg);
}

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

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

img {
  max-width: 100%;
  display: block;
}

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

/* --- Navigation --- */
nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--side-padding);
  background: rgba(250, 246, 240, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 100;
  border-bottom: 1px solid var(--border);
}

.nav-name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.nav-name:hover {
  opacity: 0.7;
  color: var(--text);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2rem;
  list-style: none;
}

.nav-links a {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  position: relative;
  padding-bottom: 2px;
  transition: color 0.2s ease;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1.5px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
}

.nav-links a:hover::after,
.nav-links a.active::after {
  width: 100%;
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  margin: 5px 0;
  transition: all 0.3s ease;
}

/* --- Main Content --- */
main {
  flex: 1;
  margin-top: var(--nav-height);
}

/* --- Page Hero (About page) --- */
.hero {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: clamp(3rem, 6vh, 5rem) var(--side-padding);
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
  min-height: calc(100vh - var(--nav-height));
}

.hero-text {
  opacity: 0;
  animation: fadeSlideUp 0.8s ease forwards;
  padding-top: clamp(1rem, 3vh, 2.5rem);
}

.hero-greeting {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 4.5vw, 3.5rem);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 1.2rem;
  color: var(--text);
}

.hero-greeting em {
  font-style: italic;
  color: var(--accent);
}

.hero-about p {
  margin-bottom: 1em;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
}

.hero-about p:last-child {
  margin-bottom: 0;
}

.hero-about a {
  border-bottom: 1px solid var(--accent);
  padding-bottom: 1px;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.hero-about a:hover {
  border-color: transparent;
}

.hero-image-wrap {
  position: relative;
  opacity: 0;
  animation: fadeSlideUp 0.8s ease 0.2s forwards;
}


.hero-image {
  width: 100%;
  max-width: 440px;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: center 20%;
  border-radius: 6px;
  filter: saturate(0.9) contrast(1.02);
}

/* --- About Content --- */
.about-section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--side-padding) clamp(4rem, 10vh, 8rem);
}

.about-content {
  max-width: var(--content-width);
  margin: 0 auto;
  opacity: 0;
  animation: fadeSlideUp 0.8s ease 0.4s forwards;
}

.about-content p {
  margin-bottom: 1.4em;
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text);
}

.about-content p:last-child {
  margin-bottom: 0;
}

.about-content a {
  border-bottom: 1px solid var(--accent);
  padding-bottom: 1px;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.about-content a:hover {
  border-color: transparent;
}

.section-divider {
  max-width: var(--content-width);
  margin: 0 auto 3rem;
  border: none;
  border-top: 1px solid var(--border);
}

.section-label {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 2rem;
}

/* --- Resume Page --- */
.resume-page {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: clamp(3rem, 6vh, 5rem) var(--side-padding) clamp(4rem, 10vh, 8rem);
}

.resume-header {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 2px solid var(--text);
  opacity: 0;
  animation: fadeSlideUp 0.8s ease forwards;
}

.resume-name {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 4vw, 3rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.resume-tagline {
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 540px;
}

.resume-contact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.resume-contact-row span {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.resume-section {
  margin-bottom: 2.5rem;
  opacity: 0;
  animation: fadeSlideUp 0.8s ease forwards;
}

.resume-section:nth-child(2) { animation-delay: 0.1s; }
.resume-section:nth-child(3) { animation-delay: 0.2s; }
.resume-section:nth-child(4) { animation-delay: 0.3s; }
.resume-section:nth-child(5) { animation-delay: 0.4s; }

.resume-section-title {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.resume-entry {
  margin-bottom: 2rem;
}

.resume-entry:last-child {
  margin-bottom: 0;
}

.resume-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.resume-entry-company {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text);
}

.resume-entry-date {
  font-size: 0.85rem;
  color: var(--text-light);
  font-weight: 400;
  white-space: nowrap;
}

.resume-entry-role {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-style: italic;
}

.resume-entry-location {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 0.75rem;
}

.resume-entry ul {
  list-style: none;
  padding: 0;
}

.resume-entry li {
  position: relative;
  padding-left: 1.2rem;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text);
}

.resume-entry li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.5;
}

.resume-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.resume-skill-tag {
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.35rem 0.85rem;
  border-radius: 100px;
  border: 1px solid rgba(196, 93, 62, 0.15);
}

.resume-download {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2rem;
  padding: 0.75rem 1.5rem;
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  border-radius: 6px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.resume-download:hover {
  color: var(--bg);
  opacity: 0.85;
  transform: translateY(-1px);
}

.resume-download svg {
  width: 16px;
  height: 16px;
}

/* --- Contact Page --- */
.contact-page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: clamp(4rem, 10vh, 8rem) var(--side-padding);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--nav-height));
  text-align: center;
}

.contact-content {
  max-width: 560px;
  opacity: 0;
  animation: fadeSlideUp 0.8s ease forwards;
}

.contact-heading {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
  line-height: 1.2;
}

.contact-text {
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
}

.contact-email-link {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--accent);
  padding: 1rem 2rem;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  transition: all 0.3s ease;
  cursor: pointer;
  background: none;
  letter-spacing: -0.01em;
  opacity: 0;
  animation: fadeSlideUp 0.6s ease 0.3s forwards;
}

.contact-email-link:hover {
  background: var(--accent);
  color: var(--bg);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(196, 93, 62, 0.2);
}

.contact-email-link svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
}

.contact-alt {
  margin-top: 2rem;
  font-size: 0.9rem;
  color: var(--text-light);
  opacity: 0;
  animation: fadeSlideUp 0.6s ease 0.5s forwards;
}

.contact-alt a {
  border-bottom: 1px solid var(--accent);
  padding-bottom: 1px;
}

/* --- Footer --- */
footer {
  padding: 2rem var(--side-padding);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-light);
  border-top: 1px solid var(--border);
}

/* --- Animations --- */
@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- Responsive --- */
@media (max-width: 768px) {
  :root {
    --nav-height: 64px;
  }

  .nav-links {
    display: none;
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    flex-direction: column;
    background: rgba(250, 246, 240, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 2rem var(--side-padding);
    gap: 1.5rem;
    border-bottom: 1px solid var(--border);
  }

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

  .nav-toggle {
    display: block;
  }

  .nav-toggle.open span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }

  .nav-toggle.open span:nth-child(2) {
    opacity: 0;
  }

  .nav-toggle.open span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding-top: clamp(1.5rem, 4vh, 3rem);
    padding-bottom: 2rem;
  }

  .hero-text {
    padding-top: 0;
  }

  .hero-image-wrap {
    order: -1;
    max-width: 260px;
    margin: 0 auto;
  }

  .hero-image {
    max-width: 100%;
  }

  .resume-entry-header {
    flex-direction: column;
    gap: 0.15rem;
  }

  .contact-email-link {
    font-size: 1.2rem;
    padding: 0.85rem 1.5rem;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 16px;
  }

  .hero-greeting {
    font-size: 2rem;
  }

  .nav-name {
    font-size: 1.25rem;
  }
}
