/* ============================================================================
   charlesmk.com
   SERVAL palette, one typeface (Geist). Quiet, editorial, flat.
   Red is for years, labels and key words only.
   ========================================================================== */

:root {
  /* core */
  --beige: #F3E6D1;
  --charcoal: #333236;
  --red: #BE4240;
  /* tints */
  --beige-light: #FAF1E2;
  --beige-dark: #E2D3BB;
  --beige-deep: #CFBFA4;
  --charcoal-light: #45444A;
  --charcoal-dark: #222125;
  --red-dark: #8E2E2D;
  --red-light: #C9534F;

  --font: "Geist", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --muted: #5C5A5F;           /* charcoal at reading-friendly contrast on beige */
  --line: 1px solid var(--beige-deep);
  --max: 1080px;
  --gutter: clamp(16px, 5vw, 48px);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  margin: 0;
  background: var(--beige);
  color: var(--charcoal);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

a { color: inherit; text-decoration-color: var(--red); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--red-dark); }
::selection { background: var(--red); color: var(--beige-light); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; border-radius: 2px; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.025em; line-height: 1.12; }
p { margin: 0 0 1em; }

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

/* small red label: the only "label" style on the site */
.label { display: block; color: var(--red); font-size: 0.9rem; font-weight: 500; letter-spacing: 0; margin-bottom: 10px; }
/* chapter marker above each section title: larger than the small red labels inside entries */
.section > .wrap > .label { font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 12px; }
.label .num { font-variant-numeric: tabular-nums; font-weight: 500; opacity: 0.75; margin-right: 10px; }
.key { color: var(--red); }
.muted { color: var(--muted); }

/* --- header -------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--beige) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.site-header.is-scrolled { border-bottom-color: var(--beige-deep); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; }
.brand { white-space: nowrap; font-weight: 600; letter-spacing: -0.02em; text-decoration: none; font-size: 1.05rem; }
.site-nav { display: flex; gap: clamp(14px, 3vw, 28px); font-size: 0.95rem; }
.site-nav a { text-decoration: none; color: var(--muted); }
.site-nav a:hover { color: var(--charcoal); }

/* --- hero ---------------------------------------------------------------- */
.hero { padding: clamp(40px, 7vw, 88px) 0 clamp(48px, 7vw, 80px); }
.hero .wrap { display: grid; grid-template-columns: 1fr minmax(220px, 340px); gap: clamp(32px, 6vw, 80px); align-items: center; }
.hero h1 { font-size: clamp(2.8rem, 7.5vw, 5rem); margin-bottom: 18px; }
.roles { font-size: clamp(1.1rem, 2vw, 1.35rem); font-weight: 500; letter-spacing: -0.01em; margin-bottom: 22px; }
.roles span + span::before { content: " / "; color: var(--red); font-weight: 400; }
.hero .intro { max-width: 52ch; font-size: clamp(1.1rem, 1.8vw, 1.25rem); margin: 0; }

/* at-a-glance grid under the intro */
.glance { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 32px; margin: 28px 0 0; max-width: 640px; }
.glance div { padding: 12px 0; border-top: var(--line); }
.glance dt { color: var(--red); font-weight: 500; font-size: 0.9rem; margin-bottom: 2px; }
.glance dd { margin: 0; font-size: 0.95rem; color: var(--muted); line-height: 1.5; }

.note { font-size: 0.9rem; color: var(--muted); margin: 10px 0 0; }
.portrait { margin: 0; }
.portrait img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: 60% 50%; border-radius: 3px; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.btn {
  display: inline-flex; align-items: center;
  padding: 11px 20px;
  font: 500 0.95rem/1 var(--font);
  text-decoration: none;
  border-radius: 3px;
  border: 1px solid var(--charcoal);
  color: var(--charcoal);
}
.btn:hover { background: var(--charcoal); color: var(--beige); }
.btn.primary { background: var(--charcoal); color: var(--beige); }
.btn.primary:hover { background: var(--charcoal-dark); color: var(--beige-light); }

/* --- sections ------------------------------------------------------------ */
.section { padding: clamp(48px, 7vw, 80px) 0; }
.section-head { display: grid; grid-template-columns: minmax(180px, 280px) 1fr; gap: 10px clamp(24px, 5vw, 64px); }
.section-head .role { margin: 8px 0 0; color: var(--muted); font-size: 0.95rem; }
.section-head h2 { font-size: clamp(1.9rem, 4vw, 2.6rem); }
.section-head .lede { font-size: 1.08rem; max-width: 60ch; color: var(--muted); margin: 6px 0 0; }

/* a chapter can hold several major parts, each with its own header; a rule separates them */
.part + .part { margin-top: clamp(36px, 5vw, 56px); padding-top: clamp(36px, 5vw, 56px); border-top: var(--line); }

/* entry list: roles, papers */
.entries { margin-top: clamp(20px, 3vw, 32px); }
.entry {
  display: grid;
  grid-template-columns: minmax(180px, 280px) 1fr;
  gap: 8px clamp(24px, 5vw, 64px);
  padding: 16px 0;
}
.entry .when { color: var(--red); font-weight: 500; font-size: 0.95rem; padding-top: 3px; }
.entry .when small { display: block; color: var(--muted); font-weight: 400; font-size: 0.9rem; margin-top: 2px; }
.entry h3 { font-size: clamp(1.2rem, 2vw, 1.4rem); margin-bottom: 8px; }
.entry p { max-width: 64ch; color: var(--muted); }
.entry p:last-child { margin-bottom: 0; }
.entry ul { margin: 0; padding-left: 1.1em; max-width: 64ch; color: var(--muted); }
.entry li { margin-bottom: 6px; }
.entry li::marker { color: var(--red); }
.entry .link { font-weight: 500; text-decoration: none; color: var(--charcoal); }
.entry .link::after { content: " \2192"; color: var(--red); }
.entry .link:hover { color: var(--red-dark); }

.tags, .entry .tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding: 0; list-style: none; }
.tags li { font-size: 0.85rem; padding: 3px 10px; border-radius: 999px; background: var(--beige-dark); color: var(--charcoal); margin: 0; }

/* --- employer access ----------------------------------------------------- */
.locked { display: flex; align-items: center; justify-content: space-between; gap: 16px 32px; flex-wrap: wrap; margin-top: 20px; padding: 20px 24px; border: 1px dashed var(--beige-deep); border-radius: 3px; background: var(--beige-light); }
.locked p { margin: 0; max-width: 60ch; color: var(--muted); }
.locked strong { color: var(--charcoal); font-weight: 600; }

.gate > * { max-width: 640px; }
.gate h1 { font-size: clamp(2.4rem, 6vw, 3.6rem); margin-bottom: 16px; }
.gate-form { margin: 32px 0 20px; }
.gate-form label { display: block; font-weight: 500; font-size: 0.95rem; margin-bottom: 8px; }
.gate-row { display: flex; gap: 10px; flex-wrap: wrap; }
.gate-row input {
  flex: 1 1 240px; min-width: 0;
  font: 400 1rem/1.2 var(--font); color: var(--charcoal);
  padding: 11px 14px; border: 1px solid var(--beige-deep); border-radius: 3px; background: var(--beige-light);
}
.gate-row input:focus { outline: 2px solid var(--red); outline-offset: 1px; border-color: transparent; }
.gate-row input[aria-invalid="true"] { border-color: var(--red); }
.gate-row .btn { cursor: pointer; }
.gate-error { color: var(--red-dark); font-size: 0.92rem; margin: 10px 0 0; }

/* --- design gallery ------------------------------------------------------ */
.works { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.work { display: flex; flex-direction: column; gap: 12px; text-decoration: none; color: inherit; }
.work img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 3px; background: var(--beige-dark); transition: opacity 0.2s; }
.work .cap { font-size: 0.92rem; color: var(--muted); line-height: 1.5; }
.work .cap strong { display: block; color: var(--charcoal); font-weight: 600; font-size: 1rem; margin-bottom: 2px; }
.work:hover img { opacity: 0.88; }
.work:hover .cap strong { color: var(--red-dark); }
.section-head .tags { margin-top: 12px; }
.section-head .link { display: inline-block; margin-top: 12px; font-weight: 500; text-decoration: none; }
.section-head .link::after { content: " \2192"; color: var(--red); }

/* --- dark section -------------------------------------------------------- */
.section.dark { background: var(--charcoal); color: var(--beige); }
.section.dark .label, .section.dark .key, .section.dark .entry .when { color: var(--red-light); }
.section.dark .section-head .lede, .section.dark .entry p, .section.dark .entry ul, .section.dark .muted { color: var(--beige-dark); }
.section.dark .entry .when small { color: var(--beige-deep); }
.section.dark .section-head .role { color: var(--beige-dark); }
.section.dark .part + .part { border-top-color: var(--charcoal-light); }
.section.dark .tags li { background: var(--charcoal-light); color: var(--beige); }
.section.dark a { color: var(--beige); text-decoration-color: var(--red-light); }
.section.dark .entry .link { color: var(--beige); }
.section.dark .entry .link::after { color: var(--red-light); }
.section.dark .section-head .link::after { color: var(--red-light); }
.section.dark .section-head .link:hover, .section.dark .entry .link:hover { color: var(--red-light); }
.section.dark .btn { border-color: var(--beige); color: var(--beige); }
.section.dark .btn:hover { background: var(--beige); color: var(--charcoal); }
.section.dark .btn.primary { background: var(--beige); color: var(--charcoal); }
.section.dark .btn.primary:hover { background: var(--beige-light); color: var(--charcoal-dark); }
.section.dark .locked { background: var(--charcoal-light); border-color: #5E5D63; }
.section.dark .locked p { color: var(--beige-dark); }
.section.dark .locked strong { color: var(--beige); }
.section.dark .block .k { color: var(--red-light); }
.section.dark .award { background: var(--charcoal-light); border-color: var(--charcoal-light); border-top-color: var(--red-light); }
.section.dark .award .kind, .section.dark .award p { color: var(--beige-dark); }
.section.dark .work img { background: var(--charcoal-light); }
.section.dark .work .cap { color: var(--beige-dark); }
.section.dark .work .cap strong { color: var(--beige); }
.section.dark .work:hover .cap strong { color: var(--red-light); }
.section.dark .section-head .link { color: var(--beige); }

/* --- recognition: award cards, a different shape from the role list ----- */
.block { display: grid; grid-template-columns: minmax(180px, 280px) 1fr; gap: 12px clamp(24px, 5vw, 64px); padding: 16px 0; }
.block .k { color: var(--red); font-weight: 500; font-size: 0.95rem; padding-top: 3px; }
.awards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.award { padding: 22px 22px 20px; background: var(--beige-light); border: var(--line); border-top: 3px solid var(--red); border-radius: 3px; }
.award .kind { display: block; font-size: 0.8rem; font-weight: 500; color: var(--muted); margin-bottom: 8px; }
.award h3 { font-size: 1.15rem; margin-bottom: 8px; }
.award p { margin: 0; font-size: 0.92rem; color: var(--muted); line-height: 1.5; }

/* --- contact ------------------------------------------------------------- */
.contact h2 { font-size: clamp(2.2rem, 6vw, 4rem); margin-bottom: 18px; }
.contact .mail { font-size: clamp(1.2rem, 3vw, 1.7rem); font-weight: 500; letter-spacing: -0.01em; }
.contact p { max-width: 52ch; color: var(--muted); }
.section.dark.contact p { color: var(--beige-dark); }
.section.dark.contact .mail:hover { color: var(--red-light); }

/* --- footer -------------------------------------------------------------- */
.site-footer { background: var(--charcoal-dark); color: var(--beige-deep); font-size: 0.9rem; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 24px; padding-bottom: 24px; }

/* --- responsive ---------------------------------------------------------- */
@media (max-width: 820px) {
  .hero .wrap { grid-template-columns: 1fr; }
  .portrait { order: -1; max-width: 260px; }
  .section-head, .entry, .block { grid-template-columns: 1fr; }
  .section-head .lede { margin-top: 0; }
  .works { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  body { font-size: 16px; }
  .glance { grid-template-columns: 1fr; }
  .works, .awards { grid-template-columns: 1fr; }
}
/* two-row header: name, then a swipeable row with every chapter */
@media (max-width: 760px) {
  html { scroll-padding-top: 100px; }
  .site-header .wrap { height: auto; flex-direction: column; align-items: flex-start; gap: 4px; padding-top: 12px; padding-bottom: 10px; }
  .site-nav { width: 100%; gap: 18px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .site-nav::-webkit-scrollbar { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
