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

:root {
  --page: #fafafa;
  --surface: #ffffff;
  --ink: #111827;
  --ink-2: #374151;
  --ink-3: #6b7280;
  --line: #d1d5db;
  --line-soft: #e5e7eb;
  --accent: #2563eb;
  --tint: #eff6ff;
  --fill: #f3f4f6;
  --font: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

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

html {
  -webkit-text-size-adjust: 100%;
}

html:has(dialog[open]) {
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink-2);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

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

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

::selection {
  background: var(--accent);
  color: #fff;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  color: var(--ink);
  font-weight: 600;
}

.wrap {
  max-width: 736px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Intro ---------- */

.intro {
  padding-top: 80px;
  padding-bottom: 56px;
}
.intro img {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  object-fit: cover;
}
.intro h1 {
  margin-top: 24px;
  font-size: 26px;
  line-height: 1.3;
}
.intro .role {
  margin-top: 2px;
}
.social {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}
.social a {
  color: var(--ink-2);
}
.social a:hover {
  color: var(--accent);
}
.social svg {
  display: block;
  width: 20px;
  height: 20px;
}
.intro .bio {
  margin-top: 24px;
}
.intro .bio + .bio {
  margin-top: 12px;
}

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

.section-title {
  font-size: 19px;
}

.cards {
  margin-top: 8px;
  padding-bottom: 72px;
}

.card {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 28px;
  align-items: start;
  padding: 28px 0;
}
.card + .card {
  border-top: 1px solid var(--line-soft);
}

.card-media img {
  width: 100%;
  aspect-ratio: 3 / 2;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  object-fit: cover;
  object-position: top left;
}

.card h3 {
  font-size: 19px;
  line-height: 1.3;
}

.card-blurb {
  margin-top: 6px;
}

.card-open {
  margin-top: 12px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}
.card-open:hover {
  text-decoration: underline;
}

.card-media {
  cursor: pointer;
}

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

.site-footer {
  padding-top: 24px;
  padding-bottom: 40px;
  color: var(--ink-3);
  font-size: 15px;
}

/* ---------- Detail sheet ---------- */

dialog.sheet {
  width: min(760px, 100vw);
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line-soft);
  background: var(--surface);
  color: var(--ink-2);
  overflow-y: auto;
  overscroll-behavior: contain;
}
dialog.sheet:focus {
  outline: none;
}
dialog.sheet::backdrop {
  background: rgba(17, 24, 39, 0.3);
}
dialog.sheet[open] {
  animation: sheet-in 0.18s ease-out;
}
@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
}

.sheet-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  height: 0;
  padding: 0 16px;
}
.sheet-close {
  display: grid;
  width: 36px;
  height: 36px;
  margin-top: 16px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-3);
  cursor: pointer;
}
.sheet-close:hover {
  background: var(--fill);
  color: var(--ink);
}
.sheet-close svg {
  width: 16px;
  height: 16px;
}

.sheet-head {
  padding: 56px 48px 0;
}
.sheet-head h2 {
  font-size: 26px;
  line-height: 1.3;
}
.sheet-sub {
  max-width: 48ch;
  margin-top: 4px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
}
.sheet-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.icon-link {
  color: var(--ink-2);
}
.icon-link:hover {
  color: var(--accent);
}
.icon-link svg {
  display: block;
  width: 20px;
  height: 20px;
}

.sheet-body {
  padding: 0 48px 72px;
}

.stats {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 20px;
  margin-top: 16px;
  padding: 20px 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}
.stat b {
  display: block;
  color: var(--ink);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
}
.stat span {
  display: block;
  margin-top: 4px;
  color: var(--ink-3);
  font-size: 14px;
  line-height: 1.4;
}

.sheet-body section {
  margin-top: 36px;
}
.sheet-body h3 {
  font-size: 19px;
  line-height: 1.3;
}
.sheet-body section > p,
.sheet-body section > ul {
  margin-top: 10px;
}
.sheet-body ul {
  padding-left: 20px;
}
.sheet-body li + li {
  margin-top: 6px;
}
.sheet-body strong {
  color: var(--ink);
  font-weight: 600;
}

.shot {
  margin: 20px 0 0;
}
.shot img {
  width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.sheet-body section > p.caption,
.caption {
  margin-top: 14px;
  color: var(--ink-3);
  font-size: 14.5px;
  line-height: 1.5;
}
.caption b {
  font-weight: 600;
}

/* ---------- Architecture diagram ---------- */

.diagram {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}
.diagram.two {
  grid-template-columns: 1fr 1fr;
  align-items: start;
}
.diagram:not(.two) {
  max-width: 500px;
  margin-right: auto;
  margin-left: auto;
}

.lane {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 10px;
}
.lane-label {
  margin-bottom: 12px;
  color: var(--ink-3);
  font-size: 13.5px;
}

.flow {
  display: flex;
  flex-direction: column;
}
.flow > * + * {
  position: relative;
  margin-top: 26px;
}
.flow > * + *::before {
  content: "";
  position: absolute;
  top: -23px;
  left: 50%;
  width: 12px;
  height: 20px;
  transform: translateX(-50%);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='20' viewBox='0 0 12 20' fill='none' stroke='%239ca3af' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 1v17M2 14l4 4 4-4'/%3E%3C/svg%3E")
    no-repeat center;
}

.flow > .no-arrow {
  margin-top: 14px;
}
.flow > .no-arrow::before {
  display: none;
}
.lane .lane {
  padding: 10px;
}

.node {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
}
.node small {
  display: block;
  margin-top: 1px;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 400;
}
.node.model {
  border-color: #93c5fd;
  background: var(--tint);
}
.node.api {
  border: 1px dashed #60a5fa;
}
.node.client {
  border-color: var(--ink-2);
  border-radius: 999px;
}
.node.store {
  border-radius: 999px;
  background: var(--fill);
}
.node .reads {
  display: block;
  margin-top: 2px;
  color: var(--ink-3);
  font-size: 12.5px;
  font-style: italic;
  font-weight: 400;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.loop {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fcfcfd;
}
.loop-label {
  margin-bottom: 10px;
  color: var(--ink-3);
  font-size: 13.5px;
  text-align: center;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 16px;
  color: var(--ink-3);
  font-size: 13.5px;
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.legend i {
  width: 18px;
  height: 11px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
}
.legend .k-model {
  border-color: #93c5fd;
  background: var(--tint);
}
.legend .k-api {
  border: 1px dashed #60a5fa;
}
.legend .k-client {
  border-color: var(--ink-2);
  border-radius: 999px;
}
.legend .k-store {
  border-radius: 999px;
  background: var(--fill);
}

/* ---------- Tables and stack ---------- */

.table-wrap {
  margin-top: 16px;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15.5px;
}
th,
td {
  padding: 8px 12px 8px 0;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--ink-3);
  font-size: 14px;
  font-weight: 400;
}
td.num,
th.num {
  padding-right: 0;
  padding-left: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
tr.best td {
  color: var(--ink);
  font-weight: 600;
}

.stack {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 24px;
  margin: 12px 0 0;
}
.stack dt {
  color: var(--ink-3);
}
.stack dd {
  margin: 0;
}
.stack dd span + span::before {
  content: ", ";
}

/* ---------- Responsive ---------- */

@media (max-width: 680px) {
  .intro {
    padding-top: 56px;
  }
  .card {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .sheet-head {
    padding: 64px 24px 0;
  }
  .sheet-body {
    padding: 0 24px 56px;
  }
  .stats {
    grid-auto-flow: row;
    grid-template-columns: 1fr 1fr;
  }
  .diagram.two {
    grid-template-columns: 1fr;
  }
  .stack {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .stack dd {
    margin-bottom: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  dialog.sheet[open] {
    animation: none;
  }
}

.sheet-body section > .legend + p {
  margin-top: 28px;
}
