/* PlugBot portfolio page. Purple = real robot, teal = simulation. */
:root {
  --bg: #fafbfc;
  --ink: #161b26;
  --muted: #586172;
  --rule: #dfe4ea;
  --surface: #eef1f5;
  --real: #6b3fd6;
  --sim: #1d7686;
  --sim-pale: #a9d3da;
  --off: #b9c1cc;
  --link: #5a33c4;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1522; --ink: #e7ebf1; --muted: #9ba5b4; --rule: #24304a; --surface: #152036;
    --real: #a68bff; --sim: #5cb8c8; --sim-pale: #2b5560; --off: #46526a; --link: #b9a4ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1522; --ink: #e7ebf1; --muted: #9ba5b4; --rule: #24304a; --surface: #152036;
  --real: #a68bff; --sim: #5cb8c8; --sim-pale: #2b5560; --off: #46526a; --link: #b9a4ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans KR", "IBM Plex Sans", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.75;
  word-break: keep-all;
  overflow-wrap: break-word;
}
html:lang(en) body { line-height: 1.65; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--real); outline-offset: 3px; border-radius: 2px; }
code { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.86em; background: var(--surface); padding: 0.1em 0.35em; border-radius: 4px; white-space: nowrap; }
strong { font-weight: 700; }

/* layout: one reading column, figures may run wider */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.col { max-width: 680px; }
section { padding: 56px 0 8px; }
h1, h2, h3 { line-height: 1.3; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 28px; font-weight: 700; margin-bottom: 20px; }
h3 { font-size: 20px; font-weight: 700; margin: 36px 0 10px; }
p { margin: 0 0 16px; }
ul { margin: 0 0 16px; padding-left: 1.2em; }
li { margin-bottom: 8px; }
.muted { color: var(--muted); }
.nw { white-space: nowrap; }
.small { font-size: 14px; line-height: 1.6; }

/* top bar */
.bar { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--rule); }
.bar .wrap { display: flex; align-items: center; gap: 20px; height: 56px; }
.bar .name { font-weight: 700; color: var(--ink); text-decoration: none; margin-right: auto; }
.bar nav { display: flex; gap: 18px; font-size: 15px; }
.bar nav a { color: var(--muted); text-decoration: none; }
.bar nav a:hover { color: var(--ink); }
.tools { display: flex; gap: 10px; align-items: center; font-size: 15px; }
.tools a { color: var(--ink); }
.theme { border: 1px solid var(--rule); background: transparent; color: var(--ink); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; padding: 0; }
.theme svg { width: 16px; height: 16px; }
@media screen and (max-width: 860px) { .bar nav { display: none; } }

/* hero */
.hero { padding: 64px 0 28px; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 48px; align-items: end; }
.hero h1 { font-size: clamp(34px, 5.4vw, 56px); font-weight: 700; line-height: 1.18; letter-spacing: -0.025em; margin-bottom: 20px; }
.hero .lede { font-size: 19px; color: var(--muted); margin: 0; max-width: 30em; }
.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: 15px; line-height: 1.55; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
@media screen and (max-width: 760px) { .hero { grid-template-columns: 1fr; gap: 28px; padding-top: 40px; } }
.links { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 4px 0 28px; font-size: 15px; }

figure { margin: 0 0 8px; }
figcaption { color: var(--muted); font-size: 14px; line-height: 1.6; margin-top: 10px; max-width: 680px; }
.hero-media img { width: 100%; border-radius: 6px; background: var(--surface); }

/* judged-run ledger: one dot per run */
.ledger { display: grid; grid-template-columns: 170px max-content max-content 1fr; gap: 12px 20px; align-items: center; margin: 8px 0 12px; }
.ledger .grp { font-weight: 700; }
.ledger .grp small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.ledger .cond { color: var(--muted); font-size: 15px; }
.ledger .n { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 17px; white-space: nowrap; }
.ledger .n small { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 10px; }
.ledger .gap { grid-column: 1 / -1; height: 6px; }
.dots { display: grid; grid-template-columns: repeat(20, 14px); gap: 5px; }
.dot { width: 14px; height: 14px; border-radius: 50%; }
.dot.ok { background: var(--real); }
.dot.no { box-shadow: inset 0 0 0 2px var(--off); }
.sim .dot.ok { background: var(--sim); }
.dot.pale { background: var(--sim-pale); }
.dot.ring { box-shadow: inset 0 0 0 2px var(--sim); }
@media screen and (max-width: 760px) {
  .ledger { grid-template-columns: 1fr max-content; grid-auto-flow: row dense; gap: 6px 14px; }
  .ledger .grp { grid-column: 1 / -1; margin-top: 10px; }
  .ledger .sp { display: none; }
  .ledger .dots { grid-column: 1 / -1; margin-bottom: 6px; }
  .ledger .n { text-align: right; }
  .dots { grid-template-columns: repeat(20, minmax(0, 1fr)); gap: 4px; max-width: 420px; }
  .dots .dot { width: 100%; height: auto; aspect-ratio: 1; }
}
@media (prefers-reduced-motion: no-preference) {
  .js .ledger .dot { animation: land 260ms ease-out both; animation-delay: calc(var(--i) * 11ms); }
  @keyframes land { from { transform: scale(0.3); opacity: 0; } }
}
.paired { display: grid; grid-template-columns: max-content 1fr; gap: 18px 28px; align-items: start; margin: 18px 0 8px; }
.legend { list-style: none; padding: 0; margin: 0; font-size: 15px; }
.legend li { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.legend .dot { flex: none; }
.legend b { font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
@media screen and (max-width: 760px) { .paired { grid-template-columns: 1fr; } }

/* tables */
.tbl { width: auto; max-width: 680px; border-collapse: collapse; font-size: 15px; margin: 8px 0 16px; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { white-space: nowrap; text-align: left; padding: 8px 28px 8px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 500; white-space: normal; }
.tbl td.r, .tbl th.r { text-align: right; }
.scroll { overflow-x: auto; }

/* same-wave strip with labels in page language */
.strip { position: relative; }
.strip img { border-radius: 6px; }
.strip-labels { display: grid; grid-template-columns: repeat(3, 1fr); font-size: 15px; margin-bottom: 8px; }
.strip-labels b { display: block; }
.strip-labels .fail { color: var(--muted); }
.strip-labels .win { color: var(--sim); font-weight: 700; }

/* diagrams: swap light and dark versions */
.lt { display: block; }
.dk { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lt { display: none; } :root:not([data-theme="light"]) .dk { display: block; } }
:root[data-theme="dark"] .lt { display: none; }
:root[data-theme="dark"] .dk { display: block; }
.diagram { margin: 12px 0 28px; }
.diagram img { border-radius: 6px; }

/* problem stories */
.story { border-left: 3px solid var(--real); padding-left: 20px; margin: 28px 0; }
.story h3 { margin-top: 0; }
.story.sim { border-left-color: var(--sim); }
.decisions li strong { display: inline; }

/* timeline: a real sequence, so dates lead */
.timeline { list-style: none; padding: 0; margin: 0; max-width: 680px; }
.timeline li { display: grid; grid-template-columns: 88px 1fr; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--rule); margin: 0; }
.timeline time { font-variant-numeric: tabular-nums; color: var(--muted); }
.timeline li.end { border-bottom: 0; font-weight: 700; }

.team { list-style: none; padding: 0; }
/* award: three photos share one height, widths follow their aspect ratios */
.award-photos { display: grid; grid-template-columns: 1.678fr 1.132fr 0.694fr; gap: 10px; margin: 8px 0 4px; }
.award-photos img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; background: var(--surface); }
@media screen and (max-width: 760px) { .award-photos { grid-template-columns: 1fr 1fr; } .award-photos a:first-child { grid-column: 1 / -1; } }
.team li { margin-bottom: 10px; }

footer { border-top: 1px solid var(--rule); margin-top: 64px; padding: 28px 0 48px; font-size: 14px; color: var(--muted); }
footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 24px; }

@media screen and (max-width: 480px) {
  body { font-size: 16px; }
  .wrap { padding: 0 16px; }
  h2 { font-size: 24px; }
  .tbl th, .tbl td { padding-right: 16px; }
  section { padding-top: 44px; }
}

.print-only { display: none !important; }

@media print {
  @page { size: A4; margin: 13mm 14mm 15mm; }
  :root, :root[data-theme="dark"] {
    --bg: #ffffff; --ink: #161b26; --muted: #586172; --rule: #dfe4ea; --surface: #eef1f5;
    --real: #6b3fd6; --sim: #1d7686; --sim-pale: #a9d3da; --off: #b9c1cc; --link: #161b26;
  }
  body { background: #fff; font-size: 9.6pt; line-height: 1.62; }
  .bar, .theme, footer, .links, .screen-only { display: none !important; }
  .print-only { display: block !important; }
  .print-links.print-only { display: flex !important; }
  .wrap { max-width: none; padding: 0; }
  .col, figcaption, .tbl { max-width: none; }
  a { color: inherit; text-decoration: none; }
  section { padding: 14pt 0 0; }
  h2 { font-size: 15pt; margin-bottom: 8pt; }
  h3 { font-size: 11.5pt; margin: 12pt 0 4pt; }
  p, ul { margin-bottom: 7pt; }
  li { margin-bottom: 3pt; }
  .hero { padding: 0 0 8pt; grid-template-columns: 1.25fr 1fr; gap: 16pt; }
  .hero h1 { font-size: 25pt; margin-bottom: 8pt; }
  .hero .lede { font-size: 11pt; }
  .facts { font-size: 8.6pt; gap: 3pt 10pt; }
  .print-links { display: flex; gap: 10pt; align-items: center; font-size: 8.6pt; color: var(--muted); margin: 0 0 8pt; }
  .print-links img { width: 56pt; height: 56pt; }
  figcaption { font-size: 8pt; margin-top: 4pt; }
  .js .ledger .dot { animation: none; }
  .ledger { gap: 6pt 14pt; grid-template-columns: 130pt max-content max-content 1fr; }
  .dots { grid-template-columns: repeat(20, 9pt); gap: 3.5pt; }
  .dot, .legend .dot { width: 9pt; height: 9pt; }
  .tbl { font-size: 8.8pt; }
  .tbl th, .tbl td { padding: 3pt 18pt 3pt 0; }
  .strip-labels { font-size: 8.8pt; margin-bottom: 4pt; }
  .lt { display: block !important; } .dk { display: none !important; }
  .diagram { margin: 4pt 0 8pt; }
  .diagram img { max-height: 112mm; width: auto; max-width: 100%; margin: 0 auto; }
  .story { padding-left: 12pt; margin: 10pt 0; }
  .story figure img { max-height: 60mm; width: auto; }
  .timeline li { padding: 3pt 0; grid-template-columns: 60pt 1fr; }
  .award-photos { gap: 6pt; }
  #approach, #architecture, #problems, #method, #role { break-before: page; }
  #results h3 { break-before: page; margin-top: 0; }
  .story, figure, .ledger, .paired, .tbl, .timeline li, .award-photos { break-inside: avoid; }
  h2, h3 { break-after: avoid; }
}
