/* Tokens ---------------------------------------------------------------- */

:root {
  --paper: #F4F6F8;
  --ink: #16213A;
  --slate: #586377;
  --rule: #D3D9E2;
  --cobalt: #2346D1;
  --hl: #FFE45C;

  --serif: "Hahmlet", "Noto Serif KR", "AppleMyungjo", serif;
  --sans: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;

  color-scheme: light;
}

/* Base ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.75;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

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

a:hover { text-decoration-thickness: 2px; }

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

strong { font-weight: 600; }

/* The highlighter: used only on measured results. */
mark {
  color: inherit;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 0 0.14em;
  background: linear-gradient(var(--hl), var(--hl)) 0 78% / 100% 0.66em no-repeat;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -3rem;
  padding: 0.5rem 0.75rem;
  background: var(--ink);
  color: var(--paper);
}

.skip:focus { top: 1rem; }

.wrap {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Hero ------------------------------------------------------------------ */

.hero {
  padding: clamp(4rem, 13vw, 8.5rem) 0 clamp(2.5rem, 6vw, 4rem);
}

.hero h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(3.25rem, 11vw, 6.75rem);
  line-height: 1;
  letter-spacing: -0.025em;
  margin: 0 0 clamp(1.5rem, 4vw, 2.25rem);
}

.lede {
  font-size: clamp(1.125rem, 2.3vw, 1.375rem);
  line-height: 1.75;
  max-width: 33em;
  margin: 0 0 1.25rem;
}

.contact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.75rem;
  margin: 0;
}

/* Project index --------------------------------------------------------- */

.index {
  border-top: 2px solid var(--ink);
}

.index h2 {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--slate);
  margin: 0.9rem 0 0.25rem;
}

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

.index li { border-bottom: 1px solid var(--rule); }

.index a {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 1.5rem;
  align-items: baseline;
  padding: 1.15rem 0;
  color: inherit;
  text-decoration: none;
}

.i-name {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 500;
  line-height: 1.35;
}

.i-kind {
  color: var(--slate);
  font-size: 0.95rem;
}

.i-result { font-size: 0.98rem; }

.index a:hover .i-name {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

@media (prefers-reduced-motion: no-preference) {
  .index mark { animation: swipe 0.7s cubic-bezier(0.3, 0.7, 0.2, 1) both; }
  .index li:nth-child(1) mark { animation-delay: 0.3s; }
  .index li:nth-child(2) mark { animation-delay: 0.45s; }
  .index li:nth-child(3) mark { animation-delay: 0.6s; }
  .index li:nth-child(4) mark { animation-delay: 0.75s; }
  .index li:nth-child(5) mark { animation-delay: 0.9s; }
}

@keyframes swipe {
  from { background-size: 0% 0.66em; }
}

/* Projects -------------------------------------------------------------- */

.project {
  padding-top: clamp(4rem, 9vw, 6.5rem);
  scroll-margin-top: 0.5rem;
}

.p-head {
  border-top: 2px solid var(--ink);
  padding-top: 1.25rem;
  margin-bottom: clamp(1.75rem, 4vw, 2.75rem);
}

.p-head h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.9rem, 4.6vw, 2.75rem);
  line-height: 1.2;
  letter-spacing: -0.012em;
  margin: 0;
  max-width: 18em;
}

.p-kind {
  color: var(--slate);
  font-size: 1.05rem;
  margin: 0.5rem 0 0;
}

.p-grid {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  gap: 3.5rem;
  align-items: start;
}

.p-meta {
  position: sticky;
  top: 2rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.p-meta dl { margin: 0; }

.p-meta dt {
  color: var(--slate);
  margin-top: 1.1rem;
}

.p-meta dt:first-child { margin-top: 0; }

.p-meta dd { margin: 0.15rem 0 0; }

.p-body { max-width: 40rem; }

.p-summary {
  font-size: 1.125rem;
  margin: 0 0 0.5rem;
}

.p-body h3 {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 600;
  margin: 2.25rem 0 0.6rem;
}

.p-body h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.4rem 0 0.35rem;
}

.p-body h3 + h4 { margin-top: 0.75rem; }

.p-body ul {
  margin: 0;
  padding-left: 1.15rem;
}

.p-body li { margin: 0.5rem 0; }

.p-body li::marker { color: var(--slate); }

.p-body ul ul { margin-top: 0.3rem; }

.p-body ul ul li {
  margin: 0.3rem 0;
  font-size: 0.97rem;
}

/* Images, for later: <figure><img src="images/..." alt="..."><figcaption>...</figcaption></figure> */
.p-body figure { margin: 2rem 0; }

.p-body figure img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--rule);
}

.p-body figcaption {
  color: var(--slate);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* Banner header: the title panel overlaps the image and blurs what sits behind it. */
.p-banner {
  position: relative;
  border-top: 0;
  padding-top: 0;
}

.p-banner-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1916 / 821;
  object-fit: cover;
  object-position: 50% 35%;
  -webkit-mask-image: linear-gradient(to bottom, #000 62%, transparent);
  mask-image: linear-gradient(to bottom, #000 62%, transparent);
}

.p-banner-text {
  position: absolute;
  left: clamp(0.75rem, 3vw, 2rem);
  bottom: clamp(0.25rem, 1.5vw, 1rem);
  padding: 0.9rem 1.5rem 1rem;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.75);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
}

.p-banner .p-kind { color: #3B4661; }

/* Chart banner: the whole chart sits on the page color, right-aligned, with the title over its empty top-left. */
.p-banner--chart { padding-top: 2.5rem; }

.p-banner--chart .p-banner-img {
  width: 64%;
  margin-left: auto;
  aspect-ratio: auto;
  -webkit-mask-image: none;
  mask-image: none;
}

.p-banner--chart .p-banner-text {
  top: 0;
  bottom: auto;
  left: 0;
  max-width: 34rem;
}

/* Full-width screenshot strip above a project's details; scrolls sideways on phones. */
.shots { margin: 0 0 clamp(2.5rem, 5vw, 3.5rem); }

.shots-scroll { overflow-x: auto; }

.shots-scroll:focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 4px;
}

.shots img {
  display: block;
  width: 100%;
  min-width: 46rem;
  height: auto;
}

.shots figcaption {
  color: var(--slate);
  font-size: 0.9rem;
  margin-top: 0.75rem;
}

/* Looping video clips shown side by side, each with a small label. */
.clips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.clip { position: relative; }

.clip video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 8px;
}

.clip-label {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.15rem 0.6rem;
  font-size: 0.875rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 4px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* Footer ---------------------------------------------------------------- */

.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: clamp(5rem, 10vw, 7rem);
  padding: 1.25rem 0 3rem;
  border-top: 1px solid var(--rule);
  color: var(--slate);
  font-size: 0.9rem;
}

.foot p { margin: 0; }

.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
}

/* Narrow screens -------------------------------------------------------- */

@media (max-width: 52rem) {
  .p-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 2rem;
  }

  .p-meta {
    position: static;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--rule);
  }

  .p-meta dl {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 1.25rem;
    row-gap: 0.5rem;
  }

  .p-meta dt, .p-meta dd { margin: 0; }

  .p-banner-img { aspect-ratio: 1 / 1; object-position: 50% 30%; }

  .p-banner-text { padding: 0.65rem 1rem 0.75rem; }

  .p-banner--chart {
    display: flex;
    flex-direction: column;
  }

  .p-banner--chart { padding-top: 0; }

  .p-banner--chart .p-banner-img {
    width: 100%;
    margin: 0;
  }

  .p-banner--chart .p-banner-text {
    position: static;
    order: -1;
    max-width: none;
    padding: 0 0 1rem;
    background: none;
    border: 0;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

@media (max-width: 44rem) {
  .clips { grid-template-columns: minmax(0, 1fr); }

  .index a {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.2rem;
  }

  .i-result { margin-top: 0.35rem; }
}
