:root {
  color-scheme: light;
  --background: #fff;
  --text: #202124;
  --muted: #6b6f73;
  --line: #e7e8e9;
  --link: #34383c;
  --focus: #1769aa;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --background: #151617;
  --text: #f0f0ef;
  --muted: #a4a7aa;
  --line: #343638;
  --link: #e2e4e5;
  --focus: #9dcfff;
}

html::view-transition-group(root) {
  animation: none;
}

html::view-transition-image-pair(root) {
  isolation: isolate;
}

html::view-transition-old(root),
html::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

html[data-theme="dark"]::view-transition-old(root) {
  z-index: 1;
}

html[data-theme="dark"]::view-transition-new(root) {
  z-index: 2;
  clip-path: circle(0 at var(--theme-origin-x) var(--theme-origin-y));
  animation: theme-reveal 800ms cubic-bezier(0.23, 1, 0.32, 1) both;
}

html[data-theme="light"]::view-transition-old(root) {
  z-index: 2;
  clip-path: circle(var(--theme-reveal-radius) at var(--theme-origin-x) var(--theme-origin-y));
  animation: theme-conceal 500ms cubic-bezier(0.23, 1, 0.32, 1) both;
}

html[data-theme="light"]::view-transition-new(root) {
  z-index: 1;
}

@keyframes theme-reveal {
  to { clip-path: circle(var(--theme-reveal-radius) at var(--theme-origin-x) var(--theme-origin-y)); }
}

@keyframes theme-conceal {
  to { clip-path: circle(0 at var(--theme-origin-x) var(--theme-origin-y)); }
}

* { box-sizing: border-box; }

@font-face {
  font-family: "Nunito";
  src: url("/public/fonts/nunito-variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font: 16px/1.6 "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

main { width: min(100% - 40px, 650px); margin: 80px auto 40px; }

.skip-link { position: absolute; top: 8px; left: 8px; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }

.intro { display: flex; align-items: flex-start; gap: 20px; padding-bottom: 30px; }
.intro img { display: block; width: 68px; height: 68px; margin-bottom: 12px; border-radius: 10px; object-fit: cover; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: 23px; font-weight: 600; line-height: 1.35; }
.intro-about { max-width: 520px; margin: 0 0 16px; padding-left: 14px; border-left: 1px solid var(--line); font-size: 22px; font-weight: 400; line-height: 1.5; }
.intro-about-link { color: var(--text); }
.intro-about-link strong { font-weight: 500; }
.intro-about-link .intro-muted { color: var(--muted); font-weight: 400; }
.intro nav { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; font-size: 14px; }

.list-section { padding: 22px 0; border-top: 1px solid var(--line); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; }
h2 { margin-bottom: 15px; font-size: 17px; font-weight: 600; }

.section-title a, footer, .project-kind, .article-date { color: var(--muted); font-size: 13px; }
.project-list, .article-list { margin: 0; padding: 0; list-style: none; }
.project-row { display: grid; grid-template-columns: 120px 1fr; gap: 12px; padding: 10px 0; }
.project-kind { padding-right: 12px; text-align: right; white-space: nowrap; }
.project-main { padding-left: 14px; border-left: 1px solid var(--line); }
.project-heading { display: flex; align-items: center; gap: 10px; }
.project-icon { width: 32px; height: 32px; object-fit: contain; }
.project-icon-openkey { width: 44px; height: 44px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--background); }
.project-name { font-size: 16px; }
.project-subtitle { margin: 0; color: var(--muted); font-size: 13px; }
.project-links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.project-link { font-size: 13px; }

.article-row { display: grid; grid-template-columns: 100px 1fr; gap: 12px; padding: 7px 0; }
.article-link span { display: block; }
.article-description { color: var(--muted); }
.article-description { font-size: 13px; }
.article-date { font-variant-numeric: tabular-nums; }

footer { display: flex; justify-content: space-between; padding-top: 18px; border-top: 1px solid var(--line); }
.theme-toggle {
  position: fixed;
  z-index: 10;
  top: 12px;
  right: 14px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  opacity: 0;
  cursor: pointer;
  transition: opacity 160ms ease;
}
.theme-toggle.is-visible { opacity: 0.75; }
.theme-toggle:hover,
.theme-toggle:focus-visible { opacity: 1; }
.theme-icon { display: none; width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
html[data-theme="light"] .theme-icon-moon,
html[data-theme="dark"] .theme-icon-sun { display: block; }

@media (prefers-reduced-motion: reduce) {
  .theme-toggle { transition: none; }
}

.post-page { width: min(100% - 40px, 650px); margin: 60px auto; }
.post-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.post-header nav { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; font-size: 13px; }
.postItem { margin: 0; }
.back-link, .post-eyebrow, .post-byline { color: var(--muted); font-size: 14px; }
.post-eyebrow { margin: 38px 0 8px; }
.post-title { margin-bottom: 8px; font-size: clamp(30px, 6vw, 42px); line-height: 1.2; }
.postContent { margin-top: 32px; color: var(--text); line-height: 1.8; }
.postContent h1, .postContent h2, .postContent h3, .postContent h4, .postContent h5 { margin: 1.6em 0 0.5em; }
.postContent p { margin-bottom: 1.2em; }
.postContent img { max-width: 100%; height: auto; }
.postContent pre { overflow: auto; padding: 14px; background: var(--line); }
.postContent code, .postContent pre { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.9em; }
.postContent ul, .postContent ol { padding-left: 24px; }

.project-page { margin-top: 40px; }
.project-page-header { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.project-page-header nav { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; font-size: 13px; }
.project-page > .back-link { display: inline-block; margin-top: 28px; }
.project-page-intro, .project-page-section { margin-left: 0; padding-left: 0; border-left: 0; }
.project-page-intro { margin-top: 30px; padding-bottom: 24px; }
.project-page-kind { color: var(--muted); font-size: 13px; }
.project-page-heading { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.project-page-icon { width: 48px; height: 48px; object-fit: contain; }
.project-page-icon.project-icon-openkey { width: 64px; height: 64px; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: var(--background); }
.project-page-heading h1 { margin: 0; font-size: 28px; }
.project-page-heading p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.project-page-summary { margin: 16px 0 0; font-size: 17px; }
.project-gallery-section { margin: 0 0 12px; }
.project-gallery-section h2 { margin: 0 0 10px; }
.project-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.project-gallery-item { min-width: 0; margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--line); }
.project-gallery-item-wide { grid-column: 1 / -1; }
.project-gallery-item img { display: block; width: 100%; height: 300px; object-fit: contain; }
.project-gallery-item-wide img { height: auto; aspect-ratio: 1.75; }
.project-gallery-item figcaption { padding: 9px 11px; background: var(--background); color: var(--muted); font-size: 13px; }
.project-page-section { padding: 18px 0; }
.project-page-section h2 { margin: 0 0 8px; }
.project-page-section p { margin: 0; color: var(--muted); }
.project-page-section p + p { margin-top: 10px; }
.project-feature-list { margin: 0; padding-left: 20px; color: var(--muted); }
.project-feature-list li + li { margin-top: 5px; }
.project-page-section p + .project-feature-list { margin-top: 10px; }
.project-resource-list { margin: 0; padding: 0; list-style: none; }
.project-resource-list li { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-top: 1px solid var(--line); }
.project-resource-list li > span { color: var(--muted); font-size: 13px; }

.writing-page { margin-top: 60px; }
.writing-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.writing-header nav { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; font-size: 13px; }
.writing-page > .back-link { display: inline-block; margin-top: 28px; }
.writing-list-section { margin-top: 24px; }
.writing-list-section h1 { font-size: 28px; }
.writing-intro { color: var(--muted); }
.writing-list-section .article-row { padding: 10px 0; }

@media (max-width: 520px) {
  main { margin-top: 40px; }
  .intro { gap: 14px; }
  .intro img { width: 54px; height: 54px; }
  .project-row { grid-template-columns: 112px 1fr; gap: 8px; }
  .project-kind { padding-right: 4px; }
  .project-main { padding-left: 10px; }
  .article-row { grid-template-columns: 82px 1fr; gap: 8px; font-size: 14px; }
  .project-page-header nav { gap: 9px; }
  .project-gallery { gap: 8px; }
  .project-gallery-item img { height: 220px; }
  .project-gallery-item-wide img { height: auto; aspect-ratio: 1.35; }
  .project-gallery-item figcaption { padding: 8px; font-size: 12px; }
  .project-resource-list li { flex-direction: column; gap: 0; }
  .writing-header nav { gap: 9px; }
}
