@font-face {
  font-family: "Noto Sans Local";
  src: url("../fonts/Noto-Sans-regular/Noto-Sans-regular.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 400;
}

@font-face {
  font-family: "Noto Sans Local";
  src: url("../fonts/Noto-Sans-700/Noto-Sans-700.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 700;
}

/* ---------------------------------------------------------------- tokens */

:root {
  --sans: "Noto Sans Local", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --rail: 268px;
  --toc: 196px;
  --col-gap: clamp(36px, 4.4vw, 76px);
  --pad-x: clamp(20px, 3vw, 40px);
  --sticky-top: 34px;
}

:root,
:root[data-theme="dark"] {
  --bg: #0e1117;
  --surface: #161b23;
  --surface-2: #1b212b;
  --ink: #e7e9ee;
  --muted: #9aa4b3;
  --faint: #6d7885;
  --line: #232935;
  --line-strong: #333c4a;
  --accent: #f0a02c;
  --photo-glow: rgba(240, 160, 44, 0.16);
}

:root[data-theme="light"] {
  --bg: #ffffff;
  --surface: #f7f8fa;
  --surface-2: #eef0f4;
  --ink: #13171e;
  --muted: #4d5764;
  --faint: #737d8a;
  --line: #e4e7ec;
  --line-strong: #ccd2da;
  --accent: #a8620a;
  --photo-glow: rgba(168, 98, 10, 0.14);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #ffffff;
    --surface: #f7f8fa;
    --surface-2: #eef0f4;
    --ink: #13171e;
    --muted: #4d5764;
    --faint: #737d8a;
    --line: #e4e7ec;
    --line-strong: #ccd2da;
    --accent: #a8620a;
    --photo-glow: rgba(168, 98, 10, 0.14);
  }
}

/* ------------------------------------------------------------------ base */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, currentColor 32%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: color 130ms ease, text-decoration-color 130ms ease;
}

a:hover,
a:focus-visible {
  color: var(--accent);
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.arrow {
  display: inline-block;
  transition: transform 140ms ease;
}

a:hover .arrow,
a:focus-visible .arrow {
  transform: translate(2px, -2px);
}

.skip-link {
  position: fixed;
  z-index: 60;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--accent);
  color: #0e1117;
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-220%);
}

.skip-link:focus {
  color: #0e1117;
  transform: translateY(0);
}

/* ---------------------------------------------------------------- layout */

.layout {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr) var(--toc);
  gap: 0 var(--col-gap);
  width: min(100% - (2 * var(--pad-x)), 1360px);
  margin: 0 auto;
  padding-block: 0 64px;
}

/* --------------------------------------------------- identity (left rail) */

.identity {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  /* overflow-y forces overflow-x to `auto`, so the photo's glow ring needs
     gutter inside the scroll box or it gets clipped against the left edge. */
  margin-inline: -10px;
  padding-inline: 10px;
  overflow-y: auto;
  scrollbar-width: none;
}

.identity::-webkit-scrollbar {
  display: none;
}

.identity-inner {
  padding-block: calc(var(--sticky-top) + 22px) 32px;
}

.identity-photo {
  position: relative;
  overflow: hidden;
  width: 132px;
  height: 132px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--surface-2);
  box-shadow: 0 0 0 6px var(--photo-glow);
}

.identity-photo img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.identity-photo.photo-missing img {
  display: none;
}

.identity-photo-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  /* letter-spacing trails the last glyph, so nudge back to true optical centre */
  text-indent: 0.08em;
}

.identity-name {
  max-width: 12ch;
  margin: 26px 0 0;
  font-size: clamp(1.72rem, 2.1vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.06;
}

.identity-role {
  max-width: 24ch;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.identity-place {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 14px 0 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.identity-place span {
  color: var(--accent);
  font-size: 0.55rem;
}

.identity-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.identity-links a {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 5px 0;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.identity-links a .arrow {
  color: var(--faint);
  font-size: 0.75rem;
}

.identity-links a:hover .arrow,
.identity-links a:focus-visible .arrow {
  color: var(--accent);
}

.identity-foot {
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.theme-toggle {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  padding: 7px 13px 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.theme-toggle-icon {
  width: 11px;
  height: 11px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(90deg, currentColor 0 50%, transparent 50% 100%);
}

.identity-updated {
  margin: 16px 0 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ------------------------------------------------- toc (right rail) */

.toc {
  position: sticky;
  top: 0;
  grid-column: 3;
  grid-row: 1;
  align-self: start;
  padding-block: calc(var(--sticky-top) + 26px) 24px;
}

.toc-title {
  margin: 0 0 16px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.toc-list {
  margin: 0;
  padding: 0 0 0 1px;
  border-left: 1px solid var(--line);
  list-style: none;
}

.toc-list a {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding: 8px 0 8px 15px;
  color: var(--faint);
  font-size: 0.79rem;
  line-height: 1.35;
  text-decoration: none;
  transition: color 140ms ease;
}

.toc-list a::before {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: -1px;
  width: 2px;
  background: transparent;
  content: "";
  transition: background 140ms ease;
}

.toc-num {
  color: var(--line-strong);
  font-family: var(--mono);
  font-size: 0.68rem;
  transition: color 140ms ease;
}

.toc-list a:hover,
.toc-list a:focus-visible {
  color: var(--ink);
}

.toc-list a:hover::before,
.toc-list a:focus-visible::before {
  background: var(--line-strong);
}

.toc-list a[aria-current="true"] {
  color: var(--ink);
  font-weight: 700;
}

.toc-list a[aria-current="true"]::before {
  background: var(--accent);
}

.toc-list a[aria-current="true"] .toc-num {
  color: var(--accent);
}

/* --------------------------------------------------------------- content */

.content {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  padding-block: calc(var(--sticky-top) + 22px) 0;
}

.section {
  padding-bottom: 68px;
  scroll-margin-top: 28px;
}

.section:last-of-type {
  padding-bottom: 40px;
}

.section-head {
  display: flex;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 30px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-strong);
}

.section-num {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.section-head h2 {
  margin: 0;
  font-size: clamp(1.5rem, 2.4vw, 1.95rem);
  font-weight: 700;
  letter-spacing: -0.032em;
  line-height: 1.15;
}

.intro-copy {
  max-width: 68ch;
}

.intro-copy p {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.1rem);
  line-height: 1.76;
}

.intro-copy p:first-child {
  color: var(--ink);
}

.intro-copy p:last-child {
  margin-bottom: 0;
}

.intro-copy a {
  color: var(--accent);
  font-weight: 700;
}

/* --------------------------------------------------------------- records */

.record-list {
  border-top: 1px solid var(--line);
}

.record {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 26px;
  padding: 22px 0 24px;
  border-bottom: 1px solid var(--line);
  transition: background 140ms ease;
}

.record:hover {
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  box-shadow: -14px 0 0 color-mix(in srgb, var(--surface) 55%, transparent),
    14px 0 0 color-mix(in srgb, var(--surface) 55%, transparent);
}

.record-date {
  display: flex;
  flex-direction: column;
  margin: 4px 0 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.71rem;
  letter-spacing: 0.02em;
  line-height: 1.62;
  text-transform: uppercase;
}

.record-date span + span {
  color: var(--line-strong);
}

.record h3 {
  margin: 0;
  font-size: clamp(1.02rem, 1.5vw, 1.14rem);
  font-weight: 700;
  letter-spacing: -0.012em;
  line-height: 1.42;
}

.record h3 a {
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.record p:not(.record-date) {
  max-width: 70ch;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.66;
}

.record .record-org {
  margin-top: 5px;
  color: var(--accent);
  font-size: 0.81rem;
  font-weight: 700;
  letter-spacing: 0.015em;
}

.publication h3 {
  font-size: clamp(0.97rem, 1.4vw, 1.06rem);
  font-weight: 400;
  line-height: 1.5;
}

.publication h3 a {
  font-weight: 700;
}

.publication .record-date {
  margin-top: 3px;
}

.section-footnote {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.section-footnote a {
  color: var(--accent);
  font-weight: 700;
}

/* ---------------------------------------------------------- competitions */

.comp-group + .comp-group {
  margin-top: 44px;
}

.comp-group-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
}

.comp-group-head h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.comp-group-head p {
  margin: 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.comp-list {
  margin: 14px 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.comp-item {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
  transition: background 140ms ease;
}

.comp-item:hover {
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  box-shadow: -14px 0 0 color-mix(in srgb, var(--surface) 55%, transparent),
    14px 0 0 color-mix(in srgb, var(--surface) 55%, transparent);
}

/* Other Competitions: the finishing position is the highlight. */
.place {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  text-align: center;
}

.place sup {
  font-size: 0.5em;
  font-weight: 700;
  letter-spacing: 0;
}

/* Kaggle Competitions: the medal is the highlight. */
.medal {
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
  font-size: 1.55rem;
  line-height: 1;
  text-align: center;
}

.comp-body a,
.comp-body .entry-title {
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.4;
}

.comp-body a {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.comp-body small {
  display: block;
  margin-top: 5px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.01em;
  line-height: 1.55;
}

/* ---------------------------------------------------------------- footer */

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding-top: 26px;
  border-top: 1px solid var(--line-strong);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  text-decoration: none;
}

/* ----------------------------------------------------------- responsive */

/* Below three columns: identity becomes a banner, TOC becomes a sticky strip. */
@media (max-width: 1160px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding-bottom: 48px;
  }

  .identity,
  .toc,
  .content {
    grid-column: 1;
    grid-row: auto;
  }

  .identity {
    position: static;
    order: 1;
    max-height: none;
    margin-inline: 0;
    padding-inline: 0;
    overflow: visible;
  }

  .identity-inner {
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr);
    gap: 8px 28px;
    padding-block: 40px 26px;
  }

  .identity-photo {
    grid-row: span 4;
  }

  .identity-name {
    max-width: none;
    align-self: end;
    margin-top: 0;
  }

  .identity-role,
  .identity-place {
    max-width: none;
    margin-top: 8px;
  }

  .identity-links {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px 24px;
    margin-top: 16px;
    padding-top: 16px;
  }

  .identity-foot {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    grid-column: 1 / -1;
    margin-top: 24px;
    padding-top: 18px;
  }

  .identity-updated {
    margin: 0;
  }

  .toc {
    z-index: 40;
    top: 0;
    order: 2;
    margin-inline: calc(var(--pad-x) * -1);
    padding: 0;
    border-bottom: 1px solid var(--line);
    /* Solid, opaque bar. A translucent bg + backdrop-filter:blur here renders
       as grainy noise over dark content in Chrome on Windows, so avoid both. */
    background: var(--surface);
  }

  .toc-title {
    display: none;
  }

  .toc-list {
    display: flex;
    overflow-x: auto;
    gap: 2px;
    padding-inline: var(--pad-x);
    border-left: 0;
    scrollbar-width: none;
  }

  .toc-list::-webkit-scrollbar {
    display: none;
  }

  .toc-list li {
    flex: 0 0 auto;
  }

  .toc-list a {
    grid-template-columns: auto auto;
    gap: 7px;
    align-items: center;
    padding: 13px 12px;
    white-space: nowrap;
  }

  .toc-list a::before {
    top: auto;
    right: 6px;
    bottom: 0;
    left: 6px;
    width: auto;
    height: 2px;
  }

  .content {
    order: 3;
    padding-top: 34px;
  }

  .section {
    scroll-margin-top: 62px;
  }
}

@media (max-width: 700px) {
  .identity-inner {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding-block: 32px 22px;
  }

  .identity-photo {
    width: 104px;
    height: 104px;
    grid-row: auto;
  }

  .identity-name {
    margin-top: 20px;
  }

  .identity-foot {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .section {
    padding-bottom: 52px;
  }

  .record {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .record:hover {
    background: transparent;
    box-shadow: none;
  }

  .record-date {
    flex-direction: row;
    gap: 8px;
    margin-top: 0;
  }

  .record-date span + span::before {
    content: "\2013\00a0";
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .toc,
  .theme-toggle,
  .skip-link {
    display: none;
  }

  .layout {
    display: block;
  }

  body {
    background: #fff;
    color: #000;
  }
}
