/* =========================================================================
   Loh Kah Meng -- Portfolio site design system
   Palette follows the validated dataviz reference (references/palette.md):
   fixed categorical hue order, navy-on-cream chrome, accessible contrast.
   ========================================================================= */

:root {
  --surface-1: #fcfcfb;
  --surface-2: #f9f9f7;
  --surface-3: #f2f2f0;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --hairline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);

  --blue: #2a78d6;
  --aqua: #1baf7a;
  --yellow: #eda100;
  --green: #008300;
  --violet: #4a3aa7;
  --red: #e34948;
  --magenta: #e87ba4;
  --orange: #eb6834;
  --gold: #ab8a3f;

  --good: #0ca30c;

  --font: system-ui, -apple-system, "Segoe UI", sans-serif;

  --container: 1120px;
  --radius: 14px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--surface-1);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

a { color: inherit; text-decoration: none; }

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

/* ---------------------------------------------------------------------- */
/* Nav                                                                     */
/* ---------------------------------------------------------------------- */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface-1);
  border-bottom: 1px solid var(--hairline);
}

.site-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.brand .dot { color: var(--blue); }

.brand-mark {
  height: 26px;
  width: auto;
  display: block;
}

.nav-links {
  display: flex;
  gap: 32px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.15s ease;
}

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

.nav-toggle { display: none; }

@media (max-width: 760px) {
  .nav-links {
    position: fixed;
    inset: 68px 0 0 0;
    background: var(--surface-1);
    flex-direction: column;
    padding: 28px 24px;
    gap: 22px;
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
  }
  .nav-links.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
  .nav-links a { font-size: 18px; }
  .nav-toggle {
    display: block;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
  }
  .nav-toggle svg { display: block; }
}

/* ---------------------------------------------------------------------- */
/* Hero                                                                    */
/* ---------------------------------------------------------------------- */

.hero {
  padding: 96px 0 64px;
  border-bottom: 1px solid var(--hairline);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 20px;
}

.eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
}

h1 {
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 22px;
  max-width: 16ch;
}

.lede {
  font-size: clamp(17px, 2vw, 20px);
  color: var(--text-secondary);
  max-width: 62ch;
  margin: 0 0 32px;
}

.button-row { display: flex; gap: 14px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover { transform: translateY(-1px); }

.btn-primary { background: var(--text-primary); color: #fff; }
.btn-primary:hover { box-shadow: 0 8px 20px rgba(11,11,11,0.18); }

.btn-secondary { background: transparent; color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }

/* ---------------------------------------------------------------------- */
/* Section scaffolding                                                     */
/* ---------------------------------------------------------------------- */

section { padding: 88px 0; }
section + section { border-top: 1px solid var(--hairline); }

.section-head { max-width: 62ch; margin-bottom: 48px; }

.section-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

h2 {
  font-size: clamp(26px, 3.4vw, 36px);
  letter-spacing: -0.015em;
  margin: 0 0 14px;
}

.section-head p { color: var(--text-secondary); font-size: 17px; margin: 0; }

/* ---------------------------------------------------------------------- */
/* Philosophy pillars                                                      */
/* ---------------------------------------------------------------------- */

.pillars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

@media (max-width: 820px) { .pillars { grid-template-columns: 1fr; } }

.pillar {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 28px 26px;
}

.pillar-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 14px;
}

.pillar h3 { font-size: 18px; margin: 0 0 10px; letter-spacing: -0.01em; }
.pillar p { font-size: 15px; color: var(--text-secondary); margin: 0; }

/* ---------------------------------------------------------------------- */
/* Pento-Helix framework                                                   */
/* ---------------------------------------------------------------------- */

.helix-block { margin-top: 40px; padding-top: 40px; border-top: 1px solid var(--hairline); }
.helix-head h3 { font-size: 20px; margin: 0 0 10px; letter-spacing: -0.01em; }
.helix-head p { font-size: 15.5px; color: var(--text-secondary); max-width: 68ch; margin: 0 0 24px; }

.helix-pillars { display: flex; flex-direction: column; gap: 10px; }

.helix-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  font-size: 15px;
  color: var(--text-secondary);
}

.helix-num { font-size: 13px; font-weight: 700; color: var(--blue); flex-shrink: 0; min-width: 20px; }

.helix-row.constant {
  background: color-mix(in srgb, var(--gold) 10%, var(--surface-2));
  border-color: color-mix(in srgb, var(--gold) 35%, var(--hairline));
  color: var(--text-primary);
}
.helix-row.constant .helix-num { color: var(--gold); }

.helix-note { font-size: 13.5px; color: var(--text-muted); margin-top: 16px; max-width: 68ch; }

/* ---------------------------------------------------------------------- */
/* Project cards                                                           */
/* ---------------------------------------------------------------------- */

.project-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

@media (max-width: 820px) { .project-grid { grid-template-columns: 1fr; } }

.project-card {
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 28px;
  background: var(--surface-1);
  transition: border-color 0.15s ease, transform 0.15s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.project-card:hover { border-color: var(--border); transform: translateY(-2px); }

.project-card.featured {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 32px;
  padding: 36px;
  background: var(--surface-2);
}

@media (max-width: 760px) { .project-card.featured { grid-template-columns: 1fr; } }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: 999px;
  width: fit-content;
  margin-bottom: 14px;
}

.tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.tag-blue    { color: var(--blue);    background: color-mix(in srgb, var(--blue) 12%, transparent); }
.tag-aqua    { color: var(--aqua);    background: color-mix(in srgb, var(--aqua) 14%, transparent); }
.tag-yellow  { color: #9a6f00;        background: color-mix(in srgb, var(--yellow) 18%, transparent); }
.tag-magenta { color: #b0517a;        background: color-mix(in srgb, var(--magenta) 18%, transparent); }
.tag-muted   { color: var(--text-muted); background: var(--surface-3); }

.project-card h3 { font-size: 19px; margin: 0 0 10px; letter-spacing: -0.01em; }
.project-card.featured h3 { font-size: 26px; }

.project-card p { font-size: 14.5px; color: var(--text-secondary); margin: 0 0 18px; flex-grow: 1; }
.project-card.featured p { font-size: 16px; }

.stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.chip {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-3);
  border: 1px solid var(--hairline);
  padding: 4px 10px;
  border-radius: 999px;
}

.card-link {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.card-link svg { transition: transform 0.15s ease; }
.project-card:hover .card-link svg { transform: translateX(3px); }

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.stat-box {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.stat-value.good { color: var(--good); }
.stat-label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

/* ---------------------------------------------------------------------- */
/* Case-study page                                                         */
/* ---------------------------------------------------------------------- */

.page-header {
  padding: 64px 0 48px;
  border-bottom: 1px solid var(--hairline);
}

.breadcrumb {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.breadcrumb a { color: var(--text-muted); font-weight: 600; }
.breadcrumb a:hover { color: var(--text-primary); }

.page-header h1 { max-width: 26ch; }

.meta-row {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  margin-top: 28px;
  padding-top: 28px;
  border-top: 1px solid var(--hairline);
}

.meta-item .k { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 4px; }
.meta-item .v { font-size: 14.5px; font-weight: 600; }

.prose { max-width: 72ch; }
.prose p { color: var(--text-secondary); font-size: 16.5px; margin: 0 0 18px; }
.prose h3 { font-size: 20px; margin: 36px 0 14px; letter-spacing: -0.01em; }
.prose ul { color: var(--text-secondary); font-size: 16px; padding-left: 22px; }
.prose li { margin-bottom: 8px; }
.prose strong { color: var(--text-primary); }

.callout {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--blue);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  font-size: 15px;
  color: var(--text-secondary);
  margin: 24px 0;
}
.callout strong { color: var(--text-primary); }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  margin: 20px 0 28px;
}
table.data-table th, table.data-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
}
table.data-table th {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}
table.data-table td.num { font-variant-numeric: tabular-nums; }
table.data-table tr.best td { font-weight: 700; color: var(--text-primary); }

.bar-list { margin: 24px 0; }
.bar-row { display: grid; grid-template-columns: 160px 1fr 52px; gap: 12px; align-items: center; margin-bottom: 10px; }
.bar-row .label { font-size: 13.5px; color: var(--text-secondary); }
.bar-track { background: var(--surface-3); border-radius: 999px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--blue); }
.bar-row .val { font-size: 13px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------------- */
/* Coming soon                                                             */
/* ---------------------------------------------------------------------- */

.soon-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}
@media (max-width: 820px) { .soon-grid { grid-template-columns: 1fr; } }

.soon-card {
  border: 1px dashed var(--hairline);
  border-radius: var(--radius);
  padding: 28px;
  background: var(--surface-2);
}
.soon-card h3 { font-size: 19px; margin: 0 0 10px; }
.soon-card p { font-size: 14.5px; color: var(--text-secondary); margin: 0; }

/* ---------------------------------------------------------------------- */
/* Footer                                                                   */
/* ---------------------------------------------------------------------- */

footer {
  padding: 56px 0;
  border-top: 1px solid var(--hairline);
  background: var(--surface-2);
}

.footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.footer-links { display: flex; gap: 24px; list-style: none; margin: 0; padding: 0; }
.footer-links a { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.footer-links a:hover { color: var(--text-primary); }

.footer-brand { display: flex; flex-direction: column; gap: 12px; }
.footer-mark { height: 34px; width: auto; }

.copyright { font-size: 13px; color: var(--text-muted); }

/* ---------------------------------------------------------------------- */
/* Reveal-on-scroll                                                        */
/* ---------------------------------------------------------------------- */

.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.5s ease, transform 0.5s ease; }
.reveal.in { opacity: 1; transform: translateY(0); }
