:root {
  --paper: #f4efe6;
  --paper-2: #ece5d8;
  --ink: #17150f;
  --muted: #6f6857;
  --line: rgba(23, 21, 15, 0.14);
  --accent: #ff4d1c;
  --accent-2: #1f4734;
  --card: #fbf8f2;
  --shadow: 0 24px 60px -28px rgba(23, 21, 15, 0.35);
  --nav-bg: rgba(244, 239, 230, 0.72);
  --nav-bg-mobile: rgba(244, 239, 230, 0.97);
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", monospace;
}

:root[data-theme="dark"] {
  --paper: #141210;
  --paper-2: #1c1915;
  --ink: #f1ece1;
  --muted: #9d9484;
  --line: rgba(241, 236, 225, 0.14);
  --accent: #ff5e30;
  --accent-2: #5fae86;
  --card: #1e1b16;
  --shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.6);
  --nav-bg: rgba(20, 18, 16, 0.72);
  --nav-bg-mobile: rgba(20, 18, 16, 0.97);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s ease, color 0.4s ease;
}

/* ---------- background layers ---------- */
#grid {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  opacity: 0.5;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.cursor-glow {
  position: fixed;
  top: 0; left: 0;
  width: 460px; height: 460px;
  margin: -230px 0 0 -230px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 77, 28, 0.16), transparent 60%);
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.4s ease;
  opacity: 0;
}

/* click ripple / splash */
.ripple {
  position: fixed;
  width: 18px; height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0%, rgba(255, 77, 28, 0.35) 45%, transparent 70%);
  pointer-events: none;
  z-index: 9999;
  opacity: 0.5;
  transform: scale(0);
  animation: ripple-out 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes ripple-out {
  to { transform: scale(16); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ripple { display: none; }
}

/* USYD Quadrangle clock tower backdrop */
.quad-bg {
  position: fixed;
  right: 0;
  bottom: 0;
  width: min(440px, 44%);
  height: 88vh;
  opacity: 0.16;
  z-index: -1;
  pointer-events: none;
}
/* transparent building cutout — no rectangle, blends on any background */
.quad-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("quad-cutout.png") no-repeat bottom right;
  background-size: contain;
  filter: grayscale(1) sepia(0.4) contrast(1.05) brightness(1.02);
}

/* ---------- nav ---------- */
nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 40px;
  background: var(--nav-bg);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease;
}

nav.scrolled { border-color: var(--line); }

.brand {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}

.nav-links { display: flex; gap: 28px; }

.nav-links a {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.25s ease;
  position: relative;
}

.nav-links a span { color: var(--accent); opacity: 0.7; margin-right: 4px; }
.nav-links a:hover,
.nav-links a.active { color: var(--ink); }

/* hamburger */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px; height: 42px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
}
.nav-toggle span {
  display: block;
  width: 18px; height: 2px;
  margin: 0 auto;
  background: var(--ink);
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.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); }

/* right-side nav cluster */
.nav-right {
  display: flex;
  align-items: center;
  gap: 24px;
}
.nav-icons {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* circular icon buttons (social links + theme toggle) */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  text-decoration: none;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}
.icon-btn:hover { background: var(--ink); color: var(--paper); transform: translateY(-2px); }
.icon-btn svg { width: 18px; height: 18px; }

/* dark mode toggle sun/moon swap */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- hero ---------- */
.hero {
  position: relative;
  max-width: 1100px;
  margin: 0 auto;
  padding: 130px 40px 60px;
}

.eyeline {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 26px;
}

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(255, 77, 28, 0.6);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 77, 28, 0.5); }
  70% { box-shadow: 0 0 0 9px rgba(255, 77, 28, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 77, 28, 0); }
}

.hero h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(72px, 17vw, 220px);
  line-height: 0.86;
  letter-spacing: -0.04em;
  margin: 0;
}

.hero h1 .line { display: block; }
.hero h1 .accent { color: var(--accent); font-style: italic; }

.role {
  font-family: var(--serif);
  font-size: clamp(22px, 3.4vw, 38px);
  font-weight: 400;
  margin: 30px 0 0;
  color: var(--ink);
}

.role-rotate {
  color: var(--accent-2);
  font-style: italic;
  border-bottom: 3px solid rgba(31, 71, 52, 0.25);
  transition: opacity 0.3s ease;
}

.lede {
  max-width: 560px;
  margin: 26px 0 0;
  font-size: 17px;
  line-height: 1.6;
  color: var(--muted);
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 38px;
}

.btn {
  font-family: var(--mono);
  font-size: 14px;
  padding: 14px 24px;
  border-radius: 100px;
  text-decoration: none;
  transition: transform 0.25s ease, background 0.25s ease, color 0.25s ease;
  border: 1px solid var(--ink);
}

.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); }
.btn.ghost { color: var(--ink); background: transparent; }
.btn.ghost:hover { background: var(--ink); color: var(--paper); }
.btn span { transition: transform 0.25s ease; display: inline-block; }
.btn.primary:hover span { transform: translateX(4px); }

/* ---------- marquee ---------- */
.marquee {
  margin-top: 80px;
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}

.marquee-track {
  display: inline-flex;
  gap: 26px;
  white-space: nowrap;
  font-family: var(--serif);
  font-size: 26px;
  font-style: italic;
  color: var(--ink);
  animation: scroll 26s linear infinite;
}
.marquee-track span:nth-child(even) { color: var(--accent); font-style: normal; }

@keyframes scroll {
  to { transform: translateX(-50%); }
}

/* ---------- stats ---------- */
.stats {
  max-width: 1100px;
  margin: 60px auto;
  padding: 0 40px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 30px;
}

.stat { border-top: 2px solid var(--ink); padding-top: 18px; }
.stat .num {
  display: block;
  font-family: var(--serif);
  font-size: clamp(40px, 5vw, 64px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.03em;
}
.stat .label {
  display: block;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- sections ---------- */
section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 90px 40px;
}

.section-tag {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  margin: 0 0 24px;
  letter-spacing: 0.04em;
}

.section-head {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(34px, 5vw, 58px);
  letter-spacing: -0.03em;
  margin: 0 0 50px;
  line-height: 1;
}

/* ---------- about ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 50px;
}
.about-grid h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(32px, 4vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0;
}
.about-grid h2 em { color: var(--accent); }
.about-body p {
  font-size: 17px;
  line-height: 1.7;
  color: var(--muted);
  margin: 0 0 20px;
}
.about-body p:last-child { margin-bottom: 0; }

/* ---------- timeline ---------- */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--line);
}
.tl-item {
  position: relative;
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 30px;
  padding: 0 0 50px 36px;
}
.tl-item::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 6px;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--accent);
}
.tl-time {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  padding-top: 4px;
}
.tl-card h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 24px;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.tl-card h3 .org {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--paper);
  background: var(--accent);
  padding: 3px 9px;
  border-radius: 100px;
  vertical-align: middle;
  margin-left: 6px;
  font-weight: 400;
}
.tl-card.edu h3 .org { background: var(--accent-2); }
.place {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 14px;
}
.tl-card ul { margin: 0; padding-left: 18px; }
.tl-card li {
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted);
  margin-bottom: 8px;
}

/* ---------- skills ---------- */
.skill-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.skill-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.skill-card:hover { transform: translateY(-6px); box-shadow: var(--shadow); }
.skill-card h3 {
  font-family: var(--mono);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin: 0 0 16px;
}
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags span {
  font-size: 14px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 100px;
  color: var(--ink);
  transition: background 0.2s ease, color 0.2s ease;
}
.skill-card:hover .tags span { background: var(--paper-2); }

/* ---------- beyond ---------- */
.beyond-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.beyond-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 30px;
  background: var(--card);
  transition: transform 0.3s ease, background 0.3s ease;
}
.beyond-card:hover { transform: translateY(-6px); background: var(--ink); }
.beyond-card:hover h3,
.beyond-card:hover p { color: var(--paper); }
.beyond-card:hover .bk-no { color: var(--accent); }
.bk-no {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
}
.beyond-card h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 24px;
  margin: 14px 0 10px;
}
.beyond-card p {
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0;
}

/* ---------- contact ---------- */
#contact { text-align: center; padding-bottom: 60px; }
.contact-head {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(40px, 7vw, 96px);
  line-height: 0.95;
  letter-spacing: -0.04em;
  margin: 0 auto 24px;
}
.contact-head em { color: var(--accent); }
.contact-sub {
  max-width: 540px;
  margin: 0 auto 40px;
  font-size: 17px;
  line-height: 1.6;
  color: var(--muted);
}
.mail-link {
  display: inline-block;
  font-family: var(--serif);
  font-size: clamp(24px, 4vw, 42px);
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 4px;
  transition: color 0.25s ease;
}
.mail-link:hover { color: var(--accent); }
.contact-links {
  margin-top: 36px;
  display: flex;
  gap: 24px;
  justify-content: center;
}
.contact-links a {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.25s ease;
}
.contact-links a:hover { color: var(--ink); }

/* ---------- footer ---------- */
footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 30px 40px 50px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
footer .credit { opacity: 0.7; }
footer .credit a { color: inherit; }

/* ---------- to top ---------- */
.to-top {
  position: fixed;
  bottom: 28px; right: 28px;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-size: 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.25s ease;
  z-index: 900;
}
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:hover { background: var(--ink); color: var(--paper); transform: translateY(-3px); }

/* ---------- projects page ---------- */
.proj-hero {
  max-width: 1100px;
  margin: 0 auto;
  padding: 120px 40px 40px;
}
.proj-hero h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(56px, 11vw, 132px);
  line-height: 0.9;
  letter-spacing: -0.04em;
  margin: 18px 0 0;
}
.proj-hero h1 .accent { color: var(--accent); font-style: italic; }
.proj-hero .lede { max-width: 600px; }

.proj-section { max-width: 1100px; margin: 0 auto; padding: 40px 40px 90px; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 24px;
}
.filter {
  font-family: var(--mono);
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 100px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}
.filter:hover { color: var(--ink); border-color: var(--ink); }
.filter.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.proj-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}
.proj-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 30px;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
}
.proj-card:hover { transform: translateY(-6px); box-shadow: var(--shadow); }
.proj-card.hide { display: none; }
.pc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.pc-cat {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--paper);
  background: var(--accent);
  padding: 4px 10px;
  border-radius: 100px;
}
.pc-year { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.proj-card h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 26px;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
}
.proj-card > p {
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 20px;
}
.pc-links { margin-top: auto; }
.pc-links a {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 2px;
  transition: color 0.2s ease;
}
.pc-links a:hover { color: var(--accent); }
.proj-note {
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  margin-top: 50px;
}

@media (max-width: 760px) {
  .proj-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .proj-hero { padding: 90px 22px 30px; }
  .proj-section { padding: 30px 22px 70px; }
}

/* ---------- reveal animation ---------- */
[data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}
[data-reveal].in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; scroll-behavior: auto; }
  [data-reveal] { opacity: 1; transform: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 880px) {
  .about-grid { grid-template-columns: 1fr; gap: 24px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .skill-grid, .beyond-grid { grid-template-columns: 1fr; }
  .tl-item { grid-template-columns: 1fr; gap: 8px; }
}

@media (max-width: 760px) {
  .nav-toggle { display: flex; }
  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--nav-bg-mobile);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
    padding: 8px 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: max-height 0.35s ease, opacity 0.25s ease;
  }
  .nav-links.open {
    max-height: 420px;
    opacity: 1;
    pointer-events: auto;
  }
  .nav-links a {
    padding: 14px 24px;
    font-size: 15px;
    border-bottom: 1px solid var(--line);
  }
  .nav-links a:last-child { border-bottom: none; }
}

@media (max-width: 640px) {
  nav { padding: 14px 20px; }
  .nav-right { gap: 10px; }
  .nav-icons { gap: 6px; }
  .icon-btn { width: 34px; height: 34px; }
  .icon-btn svg { width: 16px; height: 16px; }
  /* let the Quadrangle tower carry the background on phones */
  #grid { opacity: 0.2; }
  .quad-bg {
    right: 0;
    transform: none;
    width: 70%;
    height: 60vh;
    opacity: 0.08;
  }
  .quad-bg::before {
    background-position: bottom right;
    filter: grayscale(1) sepia(0.2) contrast(0.9) brightness(1.1);
  }
  .hero { padding: 90px 22px 40px; }
  .hero h1 { font-size: clamp(58px, 20vw, 100px); }
  section { padding: 70px 22px; }
  .stats { padding: 0 22px; gap: 26px 18px; }
  .stat .num { font-size: clamp(36px, 11vw, 52px); }
  footer { padding: 30px 22px 40px; flex-direction: column; gap: 8px; }
  .marquee-track { font-size: 20px; }
  .buttons { gap: 10px; }
  .btn { padding: 12px 20px; font-size: 13px; }
  .to-top { bottom: 18px; right: 18px; }
}
