/* =========================================================
   Noah Lim — "Ink & Gold", editorial layout
   One spacing scale (--s-*) drives every gap, margin and padding.
   ========================================================= */

:root {
  /* Ink */
  --ink:        #0e1a2b;
  --ink-2:      #2a3442;
  /* Medal gold: --gold for rules and marks, --accent for gold text on paper,
     --gold-light for gold on ink */
  --gold:       #c9a227;
  --gold-light: #e9c46a;
  --accent:     #8a6a1e;
  /* Paper */
  --paper:      #fbfaf7;
  --paper-2:    #f3efe6;
  --on-ink:     #f4efe4;
  --text:       #16181d;
  --muted:      #5d6370;
  --rule:       #e2dacb;

  --serif: 'Newsreader', 'Iowan Old Style', Georgia, 'Songti SC', 'Noto Serif SC', serif;
  --sans:  'Inter', -apple-system, 'Segoe UI', sans-serif;

  /* Spacing scale */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4rem;
  --s-9: 6rem;
  --section: clamp(4.5rem, 9vw, 8rem);
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --label-col: 13rem;

  --ease: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Base ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 5rem; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
::selection { background: var(--gold-light); color: var(--ink); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

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

.eyebrow {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.link-arrow {
  display: inline-flex;
  align-items: baseline;
  gap: var(--s-2);
  font-weight: 500;
  color: var(--ink);
  border-bottom: 1px solid var(--gold);
  padding-bottom: 2px;
  transition: color var(--ease), border-color var(--ease);
}
.link-arrow::after { content: "\2192"; transition: transform var(--ease); }
.link-arrow:hover { color: var(--accent); }
.link-arrow:hover::after { transform: translateX(3px); }
#download-cv::after { content: "\2193"; }
#download-cv:hover::after { transform: translateY(2px); }

/* =========================================================
   NAVIGATION
   ========================================================= */
.navbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  background: rgba(251, 250, 247, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--ease);
}
.navbar.scrolled { border-bottom-color: var(--rule); }
.nav {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: 4.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-name {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--ink);
}
.nav-menu { display: flex; gap: var(--s-6); }
.nav-link {
  font-size: 0.875rem;
  color: var(--muted);
  padding: var(--s-2) 0;
  border-bottom: 1px solid transparent;
  transition: color var(--ease), border-color var(--ease);
}
.nav-link:hover { color: var(--ink); }
.nav-link.active { color: var(--ink); border-bottom-color: var(--gold); }
.hamburger {
  display: none;
  background: none;
  border: 0;
  width: 2rem; height: 2rem;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}
.bar {
  display: block;
  width: 22px; height: 1.5px;
  background: var(--ink);
  transition: transform var(--ease);
}
.hamburger.active .bar:first-child { transform: translateY(3.75px) rotate(45deg); }
.hamburger.active .bar:last-child  { transform: translateY(-3.75px) rotate(-45deg); }

/* =========================================================
   HERO
   ========================================================= */
.hero { padding: calc(4.25rem + var(--s-9)) 0 var(--s-8); }
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 20rem);
  gap: var(--s-9);
  align-items: end;
}
.hero-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(3.25rem, 8.5vw, 7rem);
  line-height: 0.95;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin: var(--s-5) 0 var(--s-6);
}
.hero-lede {
  font-family: var(--serif);
  font-size: clamp(1.25rem, 2vw, 1.5rem);
  line-height: 1.45;
  color: var(--ink-2);
  max-width: 32rem;
  margin-bottom: var(--s-7);
}
.hero-links { display: flex; flex-wrap: wrap; gap: var(--s-6); }

.hero-figure img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: 50% 30%;
}
.plate figcaption {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--rule);
}

.facts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: var(--s-8);
  border-top: 1px solid var(--ink);
}
.facts > div {
  padding: var(--s-5) var(--s-5) 0 0;
}
.facts > div + div {
  padding-left: var(--s-5);
  border-left: 1px solid var(--rule);
}
.facts dt {
  font-family: var(--serif);
  font-size: 2.25rem;
  line-height: 1;
  color: var(--ink);
  margin-bottom: var(--s-2);
}
.facts dd { font-size: 0.875rem; color: var(--muted); line-height: 1.45; }

/* =========================================================
   SECTIONS — numbered label column + content column
   ========================================================= */
.sec { padding: var(--section) 0 0; }
.sec-grid {
  display: grid;
  grid-template-columns: var(--label-col) minmax(0, 1fr);
  gap: var(--s-6);
  border-top: 1px solid var(--ink);
  padding-top: var(--s-5);
}
.sec-head { align-self: start; position: sticky; top: 6rem; }
.sec-num {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: var(--s-2);
  font-variant-numeric: tabular-nums;
}
.sec-head h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.75rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.sec-body { min-width: 0; }

/* About */
.about { max-width: 46rem; }
.about-text {
  font-family: var(--serif);
  font-size: clamp(1.3rem, 2.2vw, 1.65rem);
  line-height: 1.45;
  color: var(--ink);
}

/* Entries: education, experience, research */
.entry {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  gap: var(--s-5);
  padding: var(--s-5) 0;
}
.entry + .entry { border-top: 1px solid var(--rule); }
.entry:first-child { padding-top: 0; }
.entry-when {
  font-size: 0.875rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  padding-top: 0.3rem;
}
.entry-when span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}
.entry-what h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.4rem;
  line-height: 1.3;
  color: var(--ink);
}
.entry-what h3 a {
  background-image: linear-gradient(var(--gold), var(--gold));
  background-size: 0 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size var(--ease), color var(--ease);
}
.entry-what h3 a::after { content: " \2197"; font-size: 0.8em; color: var(--accent); }
.entry-what h3 a:hover { background-size: 100% 1px; }
.entry-org {
  margin-top: var(--s-1);
  font-size: 0.925rem;
  color: var(--muted);
}
.entry-points { margin-top: var(--s-3); }
.entry-points li {
  position: relative;
  line-height: 1.5rem;
  padding-left: var(--s-5);
  font-size: 0.95rem;
  color: var(--ink-2);
}
.entry-points li + li { margin-top: var(--s-1); }
.entry-points li::before {
  content: "";
  position: absolute;
  left: 0; top: 12px;
  width: 0.6rem; height: 1px;
  background: var(--gold);
}

/* Competition record */
.record {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.record th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 var(--s-4) var(--s-3) 0;
  border-bottom: 1px solid var(--ink);
}
.record td {
  padding: var(--s-4) var(--s-4) var(--s-4) 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: baseline;
}
.record td:first-child { width: 6.5rem; font-size: 0.875rem; color: var(--muted); }
.record td:nth-child(2) {
  font-family: var(--serif);
  font-size: 1.15rem;
  color: var(--ink);
}
.record td:last-child { font-size: 0.9rem; color: var(--ink-2); white-space: nowrap; padding-right: 0; text-align: right; }
.record .is-medal td:last-child { color: var(--accent); font-weight: 500; }

.sub-head {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: var(--s-8) 0 var(--s-3);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--ink);
}
.honours li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-5);
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--rule);
}
.honours li span:first-child { font-family: var(--serif); font-size: 1.15rem; color: var(--ink); }
.honours li span:last-child { font-size: 0.875rem; color: var(--muted); text-align: right; }

/* Photo plates */
.plates { padding-top: var(--section); }
.plates-label {
  border-top: 1px solid var(--ink);
  padding-top: var(--s-5);
  margin-bottom: var(--s-5);
}
.plates-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--s-6) var(--s-5);
}
.plate img { width: 100%; height: clamp(14rem, 22vw, 18rem); object-fit: cover; }
.plate-a { grid-column: span 4; }
.plate-b { grid-column: span 2; }
.plate-a img, .plate-b img { height: clamp(18rem, 34vw, 28rem); }
.plate-b img { object-position: 45% 50%; }
.plate-c, .plate-d, .plate-e { grid-column: span 2; }
.plate-e img { object-position: 50% 28%; }
.plate figcaption span {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2px;
}

/* Skills */
.skills > div {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  gap: var(--s-5);
  padding: var(--s-4) 0;
}
.skills > div + div { border-top: 1px solid var(--rule); }
.skills > div:first-child { padding-top: 0; }
.skills dt { font-size: 0.875rem; color: var(--muted); padding-top: 0.2rem; }
.skills dd { font-family: var(--serif); font-size: 1.2rem; color: var(--ink); line-height: 1.5; }

/* =========================================================
   PRESS
   ========================================================= */
.press-quote {
  margin-bottom: var(--s-7);
  padding-left: var(--s-5);
  border-left: 2px solid var(--gold);
}
.press-quote blockquote p {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.35rem, 2.4vw, 1.75rem);
  line-height: 1.4;
  color: var(--ink);
  margin-bottom: var(--s-4);
}
.press-quote figcaption { font-size: 0.875rem; color: var(--muted); }
.press-quote cite { font-style: italic; }
.press-quote figcaption a {
  margin-left: var(--s-1);
  color: var(--ink);
  font-weight: 500;
  border-bottom: 1px solid var(--gold);
}
.press-quote figcaption a:hover { color: var(--accent); }

.press-outlets { font-size: 0.925rem; color: var(--muted); margin-bottom: var(--s-5); }

.press-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0 var(--s-6);
  border-bottom: 1px solid var(--ink);
}
.press-filters { display: flex; flex-wrap: wrap; gap: 0 var(--s-5); }
.press-filter,
.press-lang {
  font: inherit;
  font-size: 0.85rem;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: var(--s-3) 0;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color var(--ease), border-color var(--ease);
}
.press-filter:hover, .press-lang:hover { color: var(--ink); }
.press-filter.active, .press-lang.active { color: var(--ink); border-bottom-color: var(--gold); }
.press-langs { gap: 0 var(--s-4); }

.press-year {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr);
  gap: 0 var(--s-5);
  border-bottom: 1px solid var(--rule);
}
.press-year[hidden], .press-item[hidden] { display: none; }
.press-year-label {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.35rem;
  color: var(--ink);
  padding-top: var(--s-4);
  line-height: 1.2;
}
.press-item + .press-item { border-top: 1px solid var(--rule); }
.press-item a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "outlet meta" "headline headline" "gloss gloss";
  gap: var(--s-1) var(--s-4);
  padding: var(--s-4) 0;
}
.press-outlet {
  grid-area: outlet;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.press-meta { grid-area: meta; font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.press-headline {
  grid-area: headline;
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.35;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color var(--ease);
}
.press-headline[lang="zh"] { font-weight: 500; letter-spacing: 0.02em; }
.press-item a:hover .press-headline { text-decoration-color: var(--gold); }
.press-gloss { grid-area: gloss; font-size: 0.875rem; color: var(--muted); }
.press-empty { color: var(--muted); padding: var(--s-6) 0; }
.press-profile { margin-top: var(--s-5); font-size: 0.875rem; }
.press-profile a { border-bottom: 1px solid var(--gold); }
.press-profile a::after { content: " \2192"; }
.press-profile a:hover { color: var(--accent); }

/* =========================================================
   CONTACT / FOOTER
   ========================================================= */
.contact {
  margin-top: var(--section);
  background: var(--ink);
  color: var(--on-ink);
  padding: var(--s-9) 0 var(--s-6);
}
.contact .eyebrow { color: var(--gold-light); }
.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s-7);
  align-items: end;
}
.contact-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.75rem, 6vw, 4.5rem);
  line-height: 1;
  letter-spacing: -0.02em;
  margin-top: var(--s-4);
}
.contact-body { display: flex; flex-direction: column; gap: var(--s-3); }
.contact-email {
  font-family: var(--serif);
  font-size: clamp(1.4rem, 2.6vw, 2rem);
  border-bottom: 1px solid rgba(233, 196, 106, 0.5);
  align-self: flex-start;
  transition: color var(--ease), border-color var(--ease);
}
.contact-email:hover { color: var(--gold-light); border-color: var(--gold-light); }
.contact-phone { color: rgba(244, 239, 228, 0.7); }
.contact-phone:hover { color: var(--on-ink); }
.contact-social { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); margin-top: var(--s-4); font-size: 0.9rem; }
.contact-social a { color: rgba(244, 239, 228, 0.7); transition: color var(--ease); }
.contact-social a:hover { color: var(--gold-light); }
.contact-foot {
  display: flex;
  justify-content: space-between;
  margin-top: var(--s-9);
  padding-top: var(--s-5);
  border-top: 1px solid rgba(244, 239, 228, 0.15);
  font-size: 0.8rem;
  color: rgba(244, 239, 228, 0.5);
}
.contact-foot a:hover { color: var(--gold-light); }

/* Scroll reveal (added by script.js, so content stays visible without JS) */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.is-visible { opacity: 1; transform: none; }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 960px) {
  :root { --label-col: 1fr; }
  .sec-grid { grid-template-columns: 1fr; gap: var(--s-5); }
  .sec-head { position: static; display: flex; align-items: baseline; gap: var(--s-4); }
  .sec-num { margin-bottom: 0; }
  .hero-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 17rem); gap: var(--s-7); }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .facts > div:nth-child(3) { padding-left: 0; border-left: 0; }
  .facts > div:nth-child(n+3) { margin-top: var(--s-5); border-top: 1px solid var(--rule); }
}

@media (max-width: 720px) {
  .nav-menu {
    position: fixed;
    top: 4.25rem; left: 0; right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    padding: var(--s-2) var(--gutter) var(--s-5);
    transform: translateY(-120%);
    transition: transform var(--ease);
    z-index: -1;
  }
  .nav-menu.active { transform: translateY(0); }
  .nav-link { display: block; padding: var(--s-3) 0; font-size: 1rem; border-bottom: 1px solid var(--rule); }
  .nav-link.active { border-bottom-color: var(--rule); }
  .hamburger { display: flex; }

  :root { --section: 3.75rem; }
  .hero { padding: calc(4.25rem + var(--s-6)) 0 var(--s-6); }
  .hero-grid { grid-template-columns: 1fr; gap: var(--s-5); }
  .hero-title { margin: var(--s-4) 0 var(--s-5); }
  .hero-lede { margin-bottom: var(--s-6); }
  .facts { margin-top: var(--s-7); }
  .facts > div { padding: var(--s-4) var(--s-4) 0 0; }
  .facts > div + div { padding-left: var(--s-4); }
  .facts > div:nth-child(n+3) { margin-top: var(--s-4); }
  .facts dt { font-size: 1.75rem; }
  .facts dd { font-size: 0.8rem; }
  .entry, .skills > div { grid-template-columns: 1fr; gap: var(--s-1); }
  .entry-when { padding-top: 0; }
  .entry-when span { display: inline; margin-left: var(--s-2); }
  .record thead { display: none; }
  .record tr { display: grid; grid-template-columns: auto 1fr; gap: 0 var(--s-4); padding: var(--s-4) 0; border-bottom: 1px solid var(--rule); }
  .record td { border: 0; padding: 0; }
  .record td:first-child { width: auto; grid-row: span 2; padding-top: 0.2rem; }
  .record td:last-child { text-align: left; white-space: normal; }
  .honours li { flex-direction: column; gap: var(--s-1); }
  .honours li span:last-child { text-align: left; }
  /* Small round portrait with a gold ring, echoing the favicon */
  .hero-figure { order: -1; width: 5.5rem; }
  .hero-figure img {
    border-radius: 50%;
    outline: 1px solid var(--gold);
    outline-offset: 4px;
  }
  .plates-grid { grid-template-columns: 1fr 1fr; gap: var(--s-5) var(--s-4); }
  .plate-a { grid-column: 1 / -1; }
  .plate-b, .plate-c, .plate-d, .plate-e { grid-column: span 1; }
  .plate img, .plate-a img, .plate-b img { height: auto; aspect-ratio: 4 / 5; }
  .plate-a img { aspect-ratio: 3 / 2; }
  .press-year { grid-template-columns: 1fr; }
  .press-year-label { padding-top: var(--s-5); }
  .press-toolbar { gap: 0; }
  .press-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    max-width: 100%;
    gap: 0 var(--s-4);
  }
  .press-filters::-webkit-scrollbar { display: none; }
  .press-filters:not(.press-langs) {
    -webkit-mask-image: linear-gradient(to right, #000 82%, transparent);
    mask-image: linear-gradient(to right, #000 82%, transparent);
    padding-right: var(--s-6);
  }
  .press-filter, .press-lang { white-space: nowrap; flex-shrink: 0; }
  .contact-grid { grid-template-columns: 1fr; }
  .contact-foot { margin-top: var(--s-8); }
}

/* =========================================================
   PRINT — the page itself; the formatted CV is Noah-Lim-CV.pdf
   ========================================================= */
@media print {
  .navbar, .hero-links, .press-toolbar, .press-profile, .plates, .contact-foot { display: none !important; }
  .reveal { opacity: 1 !important; transform: none !important; }
  .hero { padding-top: 0; }
  .sec-head { position: static; }
  .contact { background: none; color: var(--ink); padding-top: var(--s-6); }
  .contact .eyebrow, .contact-email, .contact-social a { color: var(--ink); }
  body { background: #fff; }
}
