:root {
  --bg: #050505;
  --text: #f2f2f2;
  --muted: #9a9a9a;
  --line: #242424;
  --section-title-size: clamp(1.2rem, calc(0.95vw + 8px), 1.45rem);
  --section-body-size: clamp(1.06rem, calc(0.72vw + 7px), 1.22rem);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16.5px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
  line-height: 1.45;
}

.layout {
  width: min(1180px, 92vw);
  margin: 0 auto;
  min-height: 100svh;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  column-gap: 44px;
  padding: 192px 0 96px;
  align-content: start;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 52px;
  align-self: start;
  border-right: 1px solid var(--line);
  padding-right: 26px;
}

.portrait {
  width: 118px;
  height: 118px;
  border-radius: 2px;
  margin: 0 0 28px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  filter: grayscale(100%) contrast(112%) brightness(82%);
}

.toc {
  display: grid;
  gap: 8px;
}

.toc-link {
  color: var(--muted);
  text-decoration: none;
  text-transform: lowercase;
  font-style: italic;
  font-size: 1.12rem;
  line-height: 1.05;
  opacity: 0.9;
  transition: color 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.nav-full {
  display: inline;
}

.nav-short {
  display: none;
}

.toc-link:hover,
.toc-link.active {
  color: var(--text);
  opacity: 1;
  transform: translateX(2px);
}

.content {
  max-width: 920px;
}

.bio {
  padding: 4px 0 24px;
  margin-bottom: 24px;
}

.section {
  padding: 6px 0 42px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.section:last-child,
.section-last {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.label {
  margin: 0 0 14px;
  color: var(--muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: var(--section-body-size);
}

h1,
h2 {
  margin: 0 0 20px;
  font-weight: 700;
}

h1 {
  font-size: clamp(1.58rem, 2.2vw, 2.2rem);
  letter-spacing: 0.01em;
}

h2 {
  font-size: var(--section-title-size);
}

p,
.links a,
.course-name,
.course-meta,
.text-link,
.row-links a {
  font-size: var(--section-body-size);
}

p {
  margin: 0 0 18px;
  color: #d7d7d7;
  max-width: 68ch;
}

.about-contact {
  margin-top: 8px;
}

a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: #fff;
}

.links {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.writing-note {
  display: block;
  margin-top: 4px;
  font-size: 0.88rem;
  font-style: italic;
  color: var(--muted);
}

.courses {
  margin: 0;
  padding: 0;
  list-style: none;
}

.course-intro {
  margin: -6px 0 16px;
  color: var(--muted);
  max-width: 70ch;
}

.courses li {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.courses.no-flags li {
  grid-template-columns: 26px minmax(0, 1fr);
}

.courses li:last-child {
  border-bottom: none;
}

.course-rank {
  color: var(--muted);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  font-style: italic;
}

.course-rank::after {
  content: ".";
}

.course-details {
  min-width: 0;
}

.course-name {
  display: block;
  color: #ececec;
}

.course-meta {
  margin: 4px 0 0;
  color: var(--muted);
}

.course-flags {
  display: inline-flex;
  gap: 3px;
  font-size: 0.88rem;
  line-height: 1;
  justify-self: end;
}

.flag {
  color: #0f0f0f;
  -webkit-text-stroke: 0.45px #2b2b2b;
}

.flag.active {
  color: #c9ad67;
  -webkit-text-stroke: 0;
}

.row-links {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
    row-gap: 12px;
    min-height: auto;
    padding: 20px 0 24px;
    align-items: start;
  }

  .sidebar {
    position: static;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 8px;
    background: var(--bg);
    border-right: none;
    border-bottom: none;
    padding-right: 0;
    padding-bottom: 8px;
    width: 100%;
    max-width: none;
    margin: 0;
  }

  .portrait {
    width: 94px;
    height: 94px;
    margin-bottom: 2px;
    flex-shrink: 0;
  }

  .toc {
    display: flex;
    flex-direction: column;
    row-gap: 6px;
    justify-content: flex-start;
    padding-top: 0;
  }

  .toc-link {
    text-transform: lowercase;
    font-size: 1rem;
    line-height: 1.08;
    padding: 2px 0;
    min-height: 0;
    display: inline-block;
  }

  .nav-full {
    display: none;
  }

  .nav-short {
    display: inline;
  }

  .bio {
    text-align: left;
  }

  .bio p {
    margin-left: 0;
    margin-right: 0;
  }

  .about-contact {
    justify-content: flex-start;
  }

  .section {
    padding-bottom: 34px;
  }
}

@media (max-width: 700px) {
  .courses li {
    grid-template-columns: 24px minmax(0, 1fr);
    row-gap: 4px;
    align-items: start;
  }

  .course-flags {
    grid-column: 2;
    justify-self: start;
    margin-top: 2px;
  }

  .row-links {
    gap: 14px;
  }
}
