:root {
  --paper: #ffffff;
  --ink: #1b1b1b;
  --ink-2: #555350;
  --ink-3: #8c8984;
  --rule: #1b1b1b;
  --rule-soft: #dcdad5;
  --mark: #b8432f;
  --serif: "Gowun Batang", "Nanum Myeongjo", "AppleMyungjo", serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.8;
  word-break: keep-all;
}

a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--mark); }
img { display: block; max-width: 100%; }

.container {
  width: calc(100% - 64px);
  max-width: 1056px;
  margin: 0 auto;
}

/* ---------- Top bar ---------- */
.nav .container {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-top: 28px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}
.brand {
  font-weight: 700;
  font-size: 17px;
  text-decoration: none;
}
.brand span { font-family: var(--mono); font-weight: 400; font-size: 12px; color: var(--ink-3); margin-left: 6px; }
.nav ul { display: flex; gap: 24px; list-style: none; margin: 0; padding: 0; }
.nav ul a {
  font-family: var(--mono);
  font-size: 13px;
  text-decoration: none;
}
.nav ul a:hover { text-decoration: underline; color: var(--ink); }

/* ---------- Intro ---------- */
.hero { padding: 88px 0 40px; }
.hero h1 {
  font-size: clamp(30px, 4.6vw, 46px);
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 0 0 28px;
}
.hero .lead {
  max-width: 600px;
  font-size: 17px;
  color: var(--ink-2);
  margin: 0;
}

/* ---------- Tags (plain, comma separated) ---------- */
.tags {
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-3);
}
.tags li { display: inline; }
.tags li + li::before { content: ", "; }

/* ---------- Sections ---------- */
section { padding: 56px 0; }
.works + .works { padding-top: 40px; }
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px 24px;
  padding-bottom: 10px;
  margin-bottom: 36px;
  border-bottom: 1px solid var(--rule);
}
.section-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}

.section-count { font-family: var(--mono); font-size: 13px; color: var(--ink-3); }

/* ---------- Works ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 56px 40px;
}
@media (max-width: 680px) { .grid { grid-template-columns: 1fr; gap: 44px; } }


.work-card {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.work-card:focus-visible { outline: 1px solid var(--ink); outline-offset: 6px; }

.thumb {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #f1f0ec;
  border: 1px solid var(--rule-soft);
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(.35);
  transition: filter .4s ease, transform .8s cubic-bezier(.2, .7, .2, 1);
}
.work-card:hover .thumb img,
.work-card:focus-visible .thumb img { filter: none; transform: scale(1.035); }
@media (hover: none) { .thumb img { filter: none; } }

.work-body { padding-top: 14px; }
.work-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule-soft);
  margin-bottom: 10px;
}
/* Rule under the caption is drawn in ink from left to right on hover */
.work .work-meta { position: relative; }
.work .work-meta::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .5s cubic-bezier(.2, .7, .2, 1);
}
.work-card:hover .work-meta::after,
.work-card:focus-visible .work-meta::after { transform: scaleX(1); }
.work-body h3 { transition: transform .5s cubic-bezier(.2, .7, .2, 1); }
.work-card:hover h3,
.work-card:focus-visible h3 { transform: translateX(6px); }
.badge { order: 1; }
/* Section already names the category; badge text is only used by the detail sheet */
.work .badge { display: none; }
.year, .modal-year { order: 2; }
.work-body h3 {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.4;
  margin: 0;
}
/* Main view shows title and tags; summary appears in the detail sheet */
.work-body p { display: none; }
.work-body .tags { margin-top: 4px; }
.work-body p {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-2);
}

.work-detail { display: none; }

/* ---------- Detail sheet ---------- */
dialog.modal {
  width: min(1240px, calc(100% - 48px));
  max-width: none;
  max-height: calc(100% - 48px);
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}
dialog.modal[open] { display: flex; flex-direction: column; }
dialog.modal::backdrop { background: rgba(255, 255, 255, .88); }
.modal-scroll { overflow-y: auto; padding: 56px 48px 48px; }
.modal-image { border: 1px solid var(--rule-soft); }
.modal-image img { width: 100%; height: auto; }
/* Single column; text width capped for readable line length */
.modal-body { max-width: 760px; padding-top: 28px; }
.modal-body .work-meta { justify-content: flex-start; }
.modal-body h2 {
  font-size: 26px;
  line-height: 1.4;
  margin: 0 0 8px;
}
.modal-summary { font-size: 17px; color: var(--ink-2); margin: 0 0 6px; }
.modal-head .tags { margin: 0 0 28px; }
.modal-body .points { margin: 0 0 24px; padding: 0; list-style: none; }
.modal-body .points li {
  padding: 8px 0;
  border-top: 1px dotted var(--rule-soft);
}
.modal-body .points li:last-child { border-bottom: 1px dotted var(--rule-soft); }
.modal-body .desc { margin: 0 0 20px; }
.modal-body .role { margin: 0 0 24px; font-size: 15px; color: var(--ink-2); }
.modal-body .role strong {
  display: block;
  font-family: var(--mono);
  font-weight: 400;
  font-size: 12px;
  color: var(--ink);
}
.modal-links { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.btn { font-family: var(--mono); font-size: 13px; }
.modal-close {
  position: absolute;
  top: 16px;
  right: 20px;
  border: 0;
  padding: 0;
  background: none;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}
.modal-close:hover { color: var(--mark); }
.modal-close:focus { outline: none; }
.modal-close:focus-visible { text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 560px) {
  .modal-scroll { padding: 48px 20px 28px; }
  dialog.modal { width: calc(100% - 24px); max-height: calc(100% - 24px); }
  .modal-body h2 { font-size: 22px; }
}

/* ---------- About ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 56px;
}
@media (max-width: 800px) { .about-grid { grid-template-columns: 1fr; gap: 32px; } }
.about-text p { margin: 0 0 16px; font-size: 16px; }
.skills { display: grid; gap: 18px; align-content: start; }
.skills h3 {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  margin: 0 0 2px;
}
.skills .tags { font-size: 13px; color: var(--ink-2); }

/* ---------- Contact ---------- */
.contact-lead { margin: 0 0 20px; }
.contact-list { margin: 0; }
.contact-list div {
  display: flex;
  gap: 24px;
  padding: 8px 0;
  border-top: 1px dotted var(--rule-soft);
}
.contact-list div:last-child { border-bottom: 1px dotted var(--rule-soft); }
.contact-list dt { width: 72px; font-family: var(--mono); font-size: 13px; color: var(--ink-3); padding-top: 2px; }
.contact-list dd { margin: 0; }

footer { margin-top: 24px; }
footer .container {
  padding-top: 14px;
  padding-bottom: 48px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
}

@media (max-width: 560px) {
  .container { width: calc(100% - 40px); }
  .nav .container { padding-top: 20px; }
  .brand span { display: none; }
  .nav ul { gap: 14px; }
  .hero { padding: 56px 0 24px; }
  .hero .lead { font-size: 16px; }
  section { padding: 40px 0; }
}

@media (prefers-reduced-motion: reduce) {
  .thumb img, .work .work-meta::after, .work-body h3 { transition: filter .4s ease; }
  .work-card:hover .thumb img, .work-card:hover h3 { transform: none; }
}
