/* ==========================================================================
   Personal site — Apple HIG-inspired, dark mode
   Design tokens follow Apple's dark system palette & SF type scale.
   Edit values here; every page shares this file.
   ========================================================================== */

:root {
  /* Backgrounds (Apple dark: base black, elevated grays) */
  --bg:            #000000;
  --bg-elevated:   #1c1c1e;
  --bg-elevated-2: #2c2c2e;
  --hairline:      rgba(255, 255, 255, 0.10);

  /* Text (label colors per HIG) */
  --label:           #f5f5f7;
  --label-secondary: rgba(235, 235, 245, 0.60);
  --label-tertiary:  rgba(235, 235, 245, 0.30);

  /* Accent — system blue (dark) */
  --accent:       #0a84ff;
  --accent-hover: #409cff;

  /* Type — San Francisco with graceful fallbacks */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "Helvetica Neue", "Inter", system-ui, sans-serif;

  /* Rhythm */
  --radius:     18px;
  --radius-lg:  24px;
  --maxw:       1180px;
  --nav-h:      48px;
  --ease:       cubic-bezier(0.28, 0.11, 0.32, 1);
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--label);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

::selection { background: rgba(10, 132, 255, 0.35); }

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

/* ---------- Navigation ------------------------------------------------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  padding: 0 22px;
  background: rgba(22, 22, 24, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}

.nav a {
  color: var(--label-secondary);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: -0.01em;
  transition: color 0.2s var(--ease);
}
.nav a:hover { color: var(--label); }
.nav a.brand { color: var(--label); font-weight: 600; margin-right: auto; }
.nav a.active { color: var(--label); }

.nav-menu { display: flex; align-items: center; gap: clamp(20px, 4vw, 44px); }

/* Hamburger button (hidden on desktop) */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  margin-left: 8px;
  padding: 8px;
  background: none;
  border: 0;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: var(--label-secondary);
  transition: transform 0.25s var(--ease), opacity 0.25s var(--ease);
}
/* Morph to an X when open */
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 640px) {
  .nav-toggle { display: flex; }
  .nav-menu {
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 6px 22px 14px;
    background: #161618;
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--hairline);
  }
  .nav-menu.open { display: flex; }
  .nav-menu a { padding: 13px 0; font-size: 17px; border-bottom: 1px solid var(--hairline); }
  .nav-menu a:last-child { border-bottom: 0; }
}

/* ---------- Layout ----------------------------------------------------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }

.section { padding: clamp(56px, 12vw, 130px) 0; }

/* ---------- Hero (full-width top block) ------------------------------- */
.hero-top {
  padding: clamp(72px, 15vh, 156px) 0 clamp(44px, 8vh, 88px);
}
.hero-top h1 {
  font-size: clamp(42px, 7vw, 82px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.03;
  max-width: 16ch;
}
.hero-top p {
  font-size: clamp(18px, 2.3vw, 22px);
  color: var(--label-secondary);
  max-width: 560px;
  margin-top: 24px;
}
.hero-top .btn-row { justify-content: flex-start; margin-top: 34px; }

/* gradient name + waving hand (reusable) */
.grad {
  background: linear-gradient(180deg, #ffffff 0%, #b8b8bd 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.wave { display: inline-block; transform-origin: 70% 80%; }
@media (prefers-reduced-motion: no-preference) {
  .wave { animation: wave 2.8s ease-in-out 0.8s infinite; }
  @keyframes wave {
    0%, 55%, 100% { transform: rotate(0deg); }
    62% { transform: rotate(9deg); }
    72% { transform: rotate(-5deg); }
    82% { transform: rotate(7deg); }
    92% { transform: rotate(-2deg); }
  }
}

/* ---------- Section head (title + see-all link) ---------------------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}
.section-head h2 {
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 600;
  letter-spacing: -0.025em;
}
.see-all { font-size: 15px; font-weight: 500; white-space: nowrap; }

/* ---------- Project cards -------------------------------------------- */
.proj-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.proj-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 26px 28px 24px;
  transition: transform 0.35s var(--ease), background 0.35s var(--ease), border-color 0.35s var(--ease);
}
.proj-card:hover {
  transform: translateY(-4px);
  background: var(--bg-elevated-2);
  border-color: rgba(255, 255, 255, 0.18);
}
.proj-card .year {
  color: var(--label-tertiary);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.proj-card h3 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--accent);
  margin-top: 6px;
  transition: color 0.2s var(--ease);
}
.proj-card:hover h3 { color: var(--accent-hover); }
.proj-card p {
  color: var(--label-secondary);
  font-size: 16px;
  margin-top: 10px;
  flex: 1;
}
.proj-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.proj-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 10px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--hairline);
  color: var(--label);
  font-size: 14px;
  font-weight: 500;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.proj-btn:hover {
  background: #3a3a3c;
  color: var(--label);
  border-color: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

@media (max-width: 640px) {
  .hero-top { padding-top: clamp(56px, 12vh, 96px); }
}

/* ---------- Buttons ---------------------------------------------------- */
.btn-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 980px;
  font-size: 16px;
  font-weight: 500;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease), opacity 0.2s var(--ease);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; transform: scale(1.02); }
.btn-secondary { background: var(--bg-elevated-2); color: var(--label); }
.btn-secondary:hover { color: var(--label); background: #3a3a3c; transform: scale(1.02); }

/* ---------- Page headers ---------------------------------------------- */
.page-head { padding: clamp(48px, 9vw, 96px) 0 8px; }
.page-head .eyebrow {
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.page-head h1 {
  font-size: clamp(34px, 6vw, 56px);
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-top: 8px;
}
.page-head p {
  color: var(--label-secondary);
  font-size: clamp(17px, 2.2vw, 21px);
  max-width: 640px;
  margin-top: 14px;
}

/* ---------- Cards / grid ---------------------------------------------- */
.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 28px;
  transition: transform 0.35s var(--ease), background 0.35s var(--ease), border-color 0.35s var(--ease);
}
.card:hover { transform: translateY(-4px); background: var(--bg-elevated-2); border-color: rgba(255,255,255,0.18); }

.card .tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--label-tertiary);
  margin-bottom: 14px;
}
.card h3 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 8px; }
.card p { color: var(--label-secondary); font-size: 16px; }
.card .arrow { color: var(--accent); font-size: 15px; font-weight: 500; margin-top: 18px; display: inline-block; }

/* ---------- Blog list -------------------------------------------------- */
.post-list { display: flex; flex-direction: column; }
.post {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  padding: 26px 4px;
  border-bottom: 1px solid var(--hairline);
  transition: padding-left 0.3s var(--ease);
}
.post:hover { padding-left: 12px; }
.post:first-child { border-top: 1px solid var(--hairline); }
.post .meta { color: var(--label-tertiary); font-size: 14px; white-space: nowrap; }
.post h3 { font-size: 21px; font-weight: 500; letter-spacing: -0.02em; color: var(--label); }
.post p { color: var(--label-secondary); font-size: 16px; margin-top: 6px; }

/* ---------- About ------------------------------------------------------ */
.about-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: clamp(32px, 5vw, 68px);
  align-items: start;
}
.about-photo { position: sticky; top: calc(var(--nav-h) + 32px); }
.about-photo img {
  width: 100%;
  display: block;
  border-radius: var(--radius-lg);
  border: 1px solid var(--hairline);
}
@media (max-width: 820px) {
  .about-layout { grid-template-columns: 1fr; }
  .about-photo { position: static; order: -1; max-width: 340px; }
}

.prose { max-width: 680px; }
.prose p { font-size: clamp(17px, 2.1vw, 20px); color: var(--label-secondary); margin-bottom: 22px; }
.prose p strong { color: var(--label); font-weight: 500; }

.detail-list { list-style: none; margin-top: 40px; border-top: 1px solid var(--hairline); }
.detail-list li {
  display: flex;
  gap: 24px;
  padding: 18px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 17px;
}
.detail-list li span { color: var(--label-tertiary); min-width: 120px; }
.detail-list li div { color: var(--label); }

/* ---------- Video lightbox --------------------------------------------- */
.vid-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.vid-modal.open { display: flex; }
.vid-frame {
  position: relative;
  width: min(960px, 100%);
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--hairline);
}
.vid-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.vid-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-elevated-2);
  border: 1px solid var(--hairline);
  color: var(--label);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s var(--ease);
}
.vid-close:hover { background: #3a3a3c; }

/* ---------- Footer ----------------------------------------------------- */
footer {
  border-top: 1px solid var(--hairline);
  margin-top: 40px;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 22px;
  color: var(--label-tertiary);
  font-size: 13px;
}

/* ---------- Entrance animation ---------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .reveal { opacity: 0; transform: translateY(16px); animation: rise 0.8s var(--ease) forwards; }
  .reveal:nth-child(2) { animation-delay: 0.06s; }
  .reveal:nth-child(3) { animation-delay: 0.12s; }
  .reveal:nth-child(4) { animation-delay: 0.18s; }
  @keyframes rise { to { opacity: 1; transform: none; } }
}
