:root {
  --paper: #f2f4f7;
  --surface: #ffffff;
  --ink: #1b2333;
  --muted: #5b6577;
  --line: #d9dee6;
  --marker: #ffe14d;
  --bar-strong: #2d4f9e;

  --font-display: "Bai Jamjuree", "Anuphan", system-ui, sans-serif;
  --font-body: "Anuphan", system-ui, sans-serif;

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.625rem;
  --step-3: 2.25rem;
  --step-4: clamp(2.25rem, 4.2vw, 3.5rem);

  --gutter: clamp(16px, 4vw, 48px);
  --max: 1160px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
}

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.2;
  margin: 0;
}

h2 { font-size: var(--step-3); font-weight: 700; }
h3 { font-size: var(--step-1); font-weight: 600; }

p { margin: 0; }

a { color: inherit; }

:focus-visible {
  outline: 3px solid var(--bar-strong);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: var(--gutter);
  top: 8px;
  background: var(--surface);
  padding: 8px 12px;
  z-index: 10;
}

/* Header */
.site-head {
  max-width: var(--max);
  margin: 0 auto;
  padding: 20px var(--gutter);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--step-1);
  text-decoration: none;
}
.site-head nav {
  display: flex;
  gap: 4px 20px;
  flex-wrap: wrap;
}
.site-head nav a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
}
.site-head nav a:hover { color: var(--ink); }

main > section {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(56px, 8vw, 104px) var(--gutter);
}

/* Buttons */
.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 28px;
}
.btn {
  display: inline-block;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  border: 2px solid var(--ink);
}
.btn-primary { background: var(--ink); color: var(--surface); }
.btn-primary:hover { background: #2c3850; border-color: #2c3850; }
.btn-ghost:hover { background: var(--surface); }

/* Hero */
.hero {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: clamp(32px, 5vw, 72px);
  align-items: center;
}
.hero .name {
  font-size: var(--step-4);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.hero .name span {
  display: block;
  margin-top: 6px;
  font-family: var(--font-body);
  font-size: var(--step-1);
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}
.hero .role {
  display: inline-block;
  margin-top: 20px;
  font-weight: 600;
  background: var(--marker);
  padding: 2px 8px;
  border-radius: 3px;
}
.hero .headline {
  margin-top: 28px;
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-weight: 600;
  line-height: 1.3;
  max-width: 22ch;
}

/* The portrait stands on the line that opens the next section */
main > .hero { padding-bottom: 0; }

/* Portrait: cut-out photo standing on a soft panel, head rising above it */
.portrait {
  margin: 0;
  position: relative;
  align-self: end;
  justify-self: center;
  width: min(100%, 440px);
}
.portrait::before {
  content: "";
  position: absolute;
  inset: 18% 0 0 0;
  background: #d5dff0;
  border-radius: 220px 220px 14px 14px;
}
.portrait img {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0 0 14px 14px;
}
.hero .lede {
  margin-top: 20px;
  font-size: var(--step-1);
  color: var(--muted);
  max-width: 34em;
  line-height: 1.55;
}

/* Projects */
.projects { border-top: 1px solid var(--line); }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 32px;
  flex-wrap: wrap;
  margin-bottom: 40px;
}
.section-head p { color: var(--muted); }

/* Project cards: the whole card opens the project page */
.project-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(24px, 3vw, 40px);
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.card:hover { border-color: var(--ink); }
.card:focus-within { outline: 3px solid var(--bar-strong); outline-offset: 3px; }
.card h3 { font-size: var(--step-1); margin-top: 12px; }
.card h3 a { text-decoration: none; }
.card h3 a:focus-visible { outline: none; }
.card h3 a::after {
  content: "";
  position: absolute;
  inset: 0;
}
.card-body { padding: 20px 24px 24px; display: flex; flex-direction: column; flex: 1; }
.card-body > p { margin-top: 8px; color: var(--muted); }
.card-more {
  margin-top: auto;
  padding-top: 16px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 2px;
}
.card:hover .card-more { text-decoration-color: var(--marker); }

.card-lead {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
}
.card-lead h3 { font-size: var(--step-2); }
.card-lead .card-body { padding: clamp(24px, 3vw, 40px); }

.thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top left;
  background: #e6e9ef;
  border-bottom: 1px solid var(--line);
}
.card-lead .thumb { height: 100%; border-bottom: 0; border-right: 1px solid var(--line); }
.thumb-empty {
  display: grid;
  place-items: center;
  background: repeating-linear-gradient(135deg, #e9edf2 0 12px, #e2e7ee 12px 24px);
  color: var(--muted);
  font-weight: 600;
  font-size: var(--step--1);
}
.thumb-empty span {
  background: var(--surface);
  padding: 4px 12px;
  border-radius: 6px;
}

.tags {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tags li {
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
}

/* Project page */
main > .project-page {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(32px, 5vw, 64px) var(--gutter) clamp(56px, 8vw, 104px);
}
.project-page .back {
  display: inline-block;
  margin-bottom: 32px;
  color: var(--muted);
  font-weight: 500;
  text-underline-offset: 4px;
}
.project-page h1 {
  margin-top: 16px;
  font-size: var(--step-4);
  font-weight: 700;
  max-width: 20ch;
}
.project-page .lede {
  margin-top: 16px;
  font-size: var(--step-1);
  color: var(--muted);
  max-width: 36em;
}
.embed {
  margin: 40px 0 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.embed iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  border: 0;
}
.embed .thumb-empty { aspect-ratio: 16 / 9; }
.embed figcaption {
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  font-size: var(--step--1);
  color: var(--muted);
}
.case-study {
  margin-top: clamp(48px, 6vw, 72px);
  max-width: 46em;
}
.case-study h2 { font-size: var(--step-2); }
.brief {
  margin: 24px 0 0;
  display: grid;
  gap: 18px;
}
.brief div {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 16px;
}
.brief dt { font-weight: 600; }
.brief dd { margin: 0; }
.todo { color: var(--muted); font-style: italic; }
.next-project {
  margin-top: clamp(48px, 6vw, 72px);
  padding-top: 24px;
  border-top: 2px solid var(--ink);
}
.next-project p { color: var(--muted); font-size: var(--step--1); }
.next-project a {
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 600;
  text-underline-offset: 4px;
}

/* Skills */
.skills { border-top: 1px solid var(--line); }
.sub-h {
  margin-top: 40px;
  font-size: var(--step-0);
  color: var(--muted);
  font-weight: 600;
}
.tools {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.tools li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.tool-logo {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  object-fit: contain;
}
.tools strong {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.3;
}
.tools li span:last-child { font-size: var(--step--1); color: var(--muted); line-height: 1.4; }

.skill-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px;
  margin-top: 16px;
}
.skill-grid h4 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 600;
}
.skill-grid p { color: var(--muted); }

/* Experience */
.experience { border-top: 1px solid var(--line); }
.timeline {
  list-style: none;
  margin: 32px 0 0;
  padding: 0;
}
.timeline li {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 24px;
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}
.timeline li:last-child { border-bottom: 0; }
.timeline .when {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.timeline .where { color: var(--muted); margin-bottom: 8px; }
.timeline li p:last-child { max-width: 40em; }

/* Contact */
main > .contact {
  background: var(--ink);
  color: var(--surface);
  border-radius: 14px;
  margin: 0 var(--gutter) 40px;
  padding: clamp(40px, 6vw, 72px) clamp(24px, 5vw, 64px);
}
@media (min-width: 1160px) {
  main > .contact { margin: 0 auto 40px; max-width: calc(var(--max) - 2 * 48px); }
}
.contact h2 { max-width: 20ch; }
.contact p { margin-top: 12px; color: #c4cad6; }
.contact .btn-primary { background: var(--marker); color: var(--ink); border-color: var(--marker); }
.contact .btn-primary:hover { background: #ffea80; border-color: #ffea80; }
.contact .btn-ghost { border-color: var(--surface); }
.contact .btn-ghost:hover { background: #2c3850; }
.contact :focus-visible { outline-color: var(--marker); }

.site-foot {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter) 40px;
  font-size: var(--step--1);
  color: var(--muted);
}

/* Responsive */
@media (max-width: 900px) {
  .hero,
  .card-lead { grid-template-columns: 1fr; }
  .card-lead .thumb { height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  main > .hero { padding-bottom: clamp(56px, 8vw, 104px); }
  .portrait {
    order: -1;
    justify-self: start;
    width: min(70%, 280px);
  }
  .skill-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .skill-grid { grid-template-columns: 1fr; }
  .timeline li { grid-template-columns: 1fr; gap: 4px; }
  .project-grid { grid-template-columns: 1fr; }
  .tools { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tools li { flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px; }
  .brief div { grid-template-columns: 1fr; gap: 2px; }
}
