/* ===== Tokens ===== */
:root {
  --bg: #F3F0E8;
  --surface: #EAE6DB;
  --text: #17191A;
  --muted: #5B5E5A;
  --rule: #CFCABB;
  --rule-strong: #8E8B80;
  --accent: #A8431A;
  --accent-soft: rgba(168, 67, 26, .14);
  --on-accent: #FFFFFF;
  --grid: rgba(23, 25, 26, .07);
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --s1: .5rem;
  --s2: 1rem;
  --s3: 1.5rem;
  --s4: 2.5rem;
  --s5: 4.5rem;
  --wrap: 1120px;
}

@media (prefers-color-scheme:dark) {
  :root:not([data-theme="light"]) {
    --bg: #131615;
    --surface: #1B1F1D;
    --text: #E8E6DF;
    --muted: #A3A69F;
    --rule: #2D322F;
    --rule-strong: #6D726C;
    --accent: #E8935C;
    --accent-soft: rgba(232, 147, 92, .16);
    --on-accent: #131615;
    --grid: rgba(232, 230, 223, .06);
  }
}

:root[data-theme="dark"] {
  --bg: #131615;
  --surface: #1B1F1D;
  --text: #E8E6DF;
  --muted: #A3A69F;
  --rule: #2D322F;
  --rule-strong: #6D726C;
  --accent: #E8935C;
  --accent-soft: rgba(232, 147, 92, .16);
  --on-accent: #131615;
  --grid: rgba(232, 230, 223, .06);
}

/* ===== Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box
}

html {
  scroll-behavior: smooth
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.65 var(--sans);
  -webkit-font-smoothing: antialiased
}

a {
  color: var(--text);
  text-decoration-color: var(--rule-strong);
  text-underline-offset: .2em
}

a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent)
}

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

h1,
h2,
h3 {
  line-height: 1.15;
  margin: 0;
  letter-spacing: -.02em
}

p {
  margin: 0 0 1em
}

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

.mono {
  font-family: var(--mono);
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted)
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--on-accent);
  padding: .5rem 1rem;
  z-index: 99
}

.skip:focus {
  left: 0
}

section {
  padding: var(--s5) 0;
  border-top: 1px solid var(--rule)
}

.sec-head {
  display: flex;
  gap: var(--s2);
  align-items: baseline;
  margin-bottom: var(--s4)
}

.sec-head h2 {
  font-size: clamp(1.5rem, 3vw, 2rem)
}

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--rule)
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  min-height: 3.5rem
}

.brand {
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -.01em
}

.brand span {
  color: var(--accent)
}

.nav {
  display: flex;
  align-items: center;
  gap: var(--s3)
}

.nav ul {
  display: flex;
  gap: var(--s3);
  list-style: none;
  margin: 0;
  padding: 0
}

.nav a {
  text-decoration: none;
  font-size: .92rem;
  color: var(--muted);
  padding: .4rem 0;
  border-bottom: 2px solid transparent
}

.nav a:hover {
  color: var(--text)
}

.nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent)
}

.icon-btn {
  font: inherit;
  font-size: .82rem;
  font-family: var(--mono);
  background: none;
  color: var(--text);
  border: 1px solid var(--rule-strong);
  padding: .45rem .7rem;
  min-height: 2.5rem;
  cursor: pointer
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent)
}

.menu-btn {
  display: none
}

@media (max-width:720px) {
  .js .menu-btn {
    display: inline-block
  }

  .nav {
    flex-wrap: wrap;
    justify-content: flex-end
  }

  .js .nav ul {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
    padding: 0 var(--s3)
  }

  .js .nav ul.open {
    display: flex
  }

  .js .nav ul a {
    display: block;
    padding: .9rem 0;
    border-bottom: 1px solid var(--rule)
  }

  .nav ul {
    flex-wrap: wrap;
    gap: var(--s2)
  }
}

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  font-size: .92rem;
  font-weight: 600;
  padding: .75rem 1.2rem;
  border: 1px solid var(--text);
  text-decoration: none;
  color: var(--text);
  min-height: 2.75rem
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent)
}

.btn.primary {
  background: var(--text);
  color: var(--bg)
}

.btn.primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent)
}

.actions {
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap
}

.arrow-link {
  font-weight: 600
}

/* ===== Hero ===== */
.hero {
  border-top: 0;
  padding: var(--s5) 0;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: -1px -1px
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: var(--s4);
  align-items: end
}

.hero h1 {
  font-size: clamp(2.8rem, 8vw, 5.6rem);
  letter-spacing: -.04em;
  line-height: .95;
  margin: var(--s2) 0 var(--s3)
}

.hero .lede {
  font-size: 1.15rem;
  max-width: 34em;
  color: var(--muted)
}

.spec {
  border: 1px solid var(--rule-strong);
  background: var(--bg);
  margin: 0
}

.spec div {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: var(--s2);
  padding: .7rem var(--s2);
  border-bottom: 1px solid var(--rule)
}

.spec div:last-child {
  border-bottom: 0
}

.spec dt {
  font-family: var(--mono);
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted)
}

.spec dd {
  margin: 0;
  font-size: .92rem
}

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

  .hero {
    padding: var(--s4) 0
  }
}

/* ===== Projects ===== */
.media {
  margin: 0;
  aspect-ratio: 16/9;
  background: var(--surface);
  border: 1px solid var(--rule);
  position: relative;
  overflow: hidden
}

.media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block
}

.media-ph {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--s2);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px
}

.media-ph b {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  letter-spacing: -.03em;
  line-height: 1;
  color: var(--text);
  font-weight: 700
}

.media-ph .mono {
  font-size: .68rem
}

.media-ph i {
  position: absolute;
  right: var(--s2);
  bottom: var(--s2);
  width: 2.4rem;
  height: 2.4rem;
  border: 2px solid var(--accent);
  border-radius: 50%;
  opacity: .8
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem .9rem;
  list-style: none;
  padding: 0;
  margin: 0 0 var(--s2);
  font-family: var(--mono);
  font-size: .76rem;
  color: var(--muted)
}

.tags li::before {
  content: "/ ";
  color: var(--accent)
}

.status {
  display: inline-block;
  font-family: var(--mono);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border: 1px solid var(--rule-strong);
  padding: .1rem .45rem;
  margin-bottom: .6rem
}

.feature {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: var(--s4);
  padding: var(--s4) 0;
  border-top: 1px solid var(--rule);
  align-items: center
}

.feature:first-of-type {
  border-top: 0;
  padding-top: 0
}

.feature:nth-of-type(even) .media {
  order: 2
}

.feature h3 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin: .3rem 0 var(--s2)
}

.note {
  font-size: .9rem;
  color: var(--muted);
  border-left: 2px solid var(--accent);
  padding-left: var(--s2)
}

@media (max-width:820px) {
  .feature {
    grid-template-columns: 1fr;
    gap: var(--s2)
  }

  .feature:nth-of-type(even) .media {
    order: 0
  }
}

.compact-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule-strong)
}

.compact {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) minmax(0, 1.6fr);
  gap: var(--s3);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--rule)
}

.compact h3 {
  font-size: 1.2rem
}

.compact p {
  margin-bottom: .6rem;
  font-size: .95rem
}

.compact .tags {
  margin: 0
}

.compact[hidden] {
  display: none
}

@media (max-width:820px) {
  .compact {
    grid-template-columns: 1fr;
    gap: .4rem
  }
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 0 0 var(--s3);
  padding: 0;
  border: 0
}

.filters legend {
  font-family: var(--mono);
  font-size: .76rem;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0;
  margin-bottom: .5rem
}

.filters button {
  font: inherit;
  font-size: .85rem;
  background: none;
  color: var(--text);
  border: 1px solid var(--rule-strong);
  padding: .45rem .9rem;
  min-height: 2.5rem;
  cursor: pointer
}

.filters button[aria-pressed="true"] {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text)
}

.eng {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s4)
}

.eng article {
  border-top: 2px solid var(--text);
  padding-top: var(--s2)
}

.eng h3 {
  font-size: 1.4rem;
  margin: .3rem 0 .8rem
}

.eng .media {
  aspect-ratio: 21/9;
  margin-top: var(--s2)
}

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

/* ===== Home blocks ===== */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: var(--s4)
}

@media (max-width:820px) {
  .split {
    grid-template-columns: 1fr;
    gap: var(--s2)
  }
}

.mini-list {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--s2);
  border-top: 1px solid var(--rule)
}

.mini-list li {
  display: flex;
  justify-content: space-between;
  gap: var(--s2);
  padding: .7rem 0;
  border-bottom: 1px solid var(--rule)
}

.mini-list span:last-child {
  color: var(--muted);
  font-family: var(--mono);
  font-size: .78rem;
  white-space: nowrap
}

/* ===== About ===== */
.prose {
  max-width: 38em
}

.skills {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 var(--s4);
  margin: 0
}

.skills div {
  padding: var(--s2) 0;
  border-top: 1px solid var(--rule)
}

.skills dt {
  font-family: var(--mono);
  font-size: .76rem;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .3rem
}

.skills dd {
  margin: 0
}

.skills .lead {
  font-weight: 600
}

@media (max-width:720px) {
  .skills {
    grid-template-columns: 1fr
  }
}

/* Timeline: axis in the centre; each entry hangs from its own node by a connector that
   continues into the card's top rule. Duration bars sit on the axis on the entry's own side. */
.tl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 8px 2px 8px minmax(0, 1fr);
  padding: 2.4rem 0 .5rem;
  position: relative
}

.tl-spine {
  grid-column: 3;
  grid-row: 1/-1;
  background: var(--rule-strong);
  pointer-events: none;
  opacity: .6
}

.tl-item {
  grid-row: var(--r);
  padding: .85rem 1.3rem 1.7rem;
  border-top: 1px solid var(--rule-strong);
  min-width: 0
}

.tl-item[data-side="L"] {
  grid-column: 1;
  text-align: right
}

.tl-item[data-side="R"] {
  grid-column: 5
}

.tl-item h3 {
  font-size: 1.1rem;
  margin: .2rem 0
}

.tl-item p {
  margin: 0 0 .35rem;
  font-size: .92rem;
  color: var(--muted)
}

.tl-item .org {
  color: var(--text);
  font-size: .95rem
}

.tl-item .when {
  font-family: var(--mono);
  font-size: .76rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .03em
}

.tl-item[data-kind="end"] h3 {
  font-size: .95rem;
  font-weight: 500
}

.tl-conn {
  grid-row: var(--r);
  align-self: start;
  height: 1px;
  background: var(--rule-strong);
  pointer-events: none
}

.tl-conn[data-side="L"] {
  grid-column: 2/4
}

.tl-conn[data-side="R"] {
  grid-column: 3/5
}

.tl-node {
  grid-row: var(--r);
  grid-column: 3;
  align-self: start;
  justify-self: center;
  width: 0;
  height: 0;
  z-index: 2;
  pointer-events: none
}

.tl-node::before {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent)
}

.tl-node[data-kind="point"]::before {
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  background: var(--bg);
  box-shadow: 0 0 0 2px var(--rule-strong)
}

.tl-node[data-kind="end"]::before {
  background: var(--bg);
  box-shadow: 0 0 0 2px var(--accent)
}

.tl-bar {
  grid-row: var(--a)/var(--b);
  width: 6px;
  border-radius: 3px;
  background: var(--accent);
  opacity: .5;
  pointer-events: none
}

.tl-bar[data-side="L"] {
  grid-column: 2;
  justify-self: end
}

.tl-bar[data-side="R"] {
  grid-column: 4;
  justify-self: start
}

.tl-bar[data-open] {
  -webkit-mask-image: linear-gradient(#000 60%, transparent);
  mask-image: linear-gradient(#000 60%, transparent);
  border-radius: 3px 3px 0 0
}

.tl-year {
  grid-row: var(--r);
  grid-column: 2/5;
  justify-self: center;
  align-self: start;
  transform: translateY(-2.1rem);
  z-index: 3;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--rule-strong);
  font-family: var(--mono);
  font-size: .74rem;
  letter-spacing: .06em;
  padding: .1rem .6rem;
  line-height: 1.5
}

.tl-now {
  transform: translateY(-.2rem);
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  text-transform: uppercase
}

@media (max-width:760px) {
  .tl {
    grid-template-columns: 2px 8px 8px minmax(0, 1fr);
    padding-left: 8px
  }

  .tl-spine,
  .tl-node {
    grid-column: 1
  }

  .tl-item[data-side] {
    grid-column: 4;
    text-align: left;
    padding-left: 1rem
  }

  .tl-conn[data-side="L"] {
    grid-column: 1/3
  }

  .tl-conn[data-side="R"] {
    grid-column: 1/4
  }

  .tl-bar[data-side="L"] {
    grid-column: 2;
    justify-self: start
  }

  .tl-bar[data-side="R"] {
    grid-column: 3;
    justify-self: start
  }

  .tl-year {
    grid-column: 1/4;
    justify-self: start;
    margin-left: -4px
  }
}

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--rule);
  padding: var(--s4) 0;
  font-size: .9rem;
  color: var(--muted)
}

.foot {
  display: flex;
  justify-content: space-between;
  gap: var(--s3);
  flex-wrap: wrap
}

.foot ul {
  display: flex;
  gap: var(--s3);
  list-style: none;
  padding: 0;
  margin: 0;
  flex-wrap: wrap
}

.foot a {
  color: var(--muted)
}

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

  * {
    transition: none !important;
    animation: none !important
  }
}

.avatar {
  aspect-ratio: 1/1;
  max-width: 15rem
}

.mini-list b {
  font-weight: 600
}

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

.avatar {
  aspect-ratio: 1/1;
  max-width: 15rem;
  width: 100%
}

.avatar img,
img.avatar {
  width: 100%;
  height: 100%;
  max-width: 15rem;
  aspect-ratio: 1/1;
  object-fit: cover;
  border: 1px solid var(--rule)
}

.hero-grid>div:last-child {
  min-width: 0
}
/* Round profile photo above the name */
.portrait {
  width: 8.5rem;
  height: 8.5rem;
  max-width: none;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--rule-strong), 0 0 0 7px var(--bg), 0 0 0 8px var(--accent);
  margin: 0 0 var(--s3) 8px
}

@media (max-width:820px) {
  .portrait {
    width: 7rem;
    height: 7rem
  }
}
