/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Theme variables */
:root {
  --bg: #FAF6F1;
  --text: #3C2415;
  --heading: #2A1A0E;
  --link: #8B5E3C;
  --on-link: #fff;
  --link-hover: #6B3F1F;
  --border: #D4B896;
  --code-bg: #F0E8DF;
  --code-text: #5C3D2E;
  --meta: #7A6455;
  --footer-bg: #F3EDE5;
}

[data-theme="dark"] {
  --bg: #1A1210;
  --text: #D4C4B0;
  --heading: #E8DDD0;
  --link: #C49A6C;
  --on-link: #1A1210;
  --link-hover: #DEBD96;
  --border: #3D2E22;
  --code-bg: #241C16;
  --code-text: #C9A882;
  --meta: #9C8A78;
  --footer-bg: #1E1714;
}

/* Base */
html { font-size: 16px; }
body {
  font-family: 'Libre Baskerville', Georgia, serif;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Layout */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

main {
  flex: 1;
  padding: 2rem 0;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 1000;
  padding: 0.5rem 0.75rem;
  color: var(--heading);
  background: var(--bg);
  border: 2px solid var(--link);
  border-radius: 4px;
  transform: translateY(calc(-100% - 1rem));
}
.skip-link:focus {
  transform: translateY(0);
}

/* Typography */
h1, h2, h3, h4 { color: var(--heading); line-height: 1.3; }
h1 { font-size: 1.8rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.4rem; margin: 1.8rem 0 0.6rem; }
h3 { font-size: 1.15rem; margin: 1.4rem 0 0.4rem; }
h4 { font-size: 1rem; margin: 1.2rem 0 0.3rem; }
p { margin-bottom: 1rem; }

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}
a:hover { color: var(--link-hover); }

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

ul, ol { margin: 0 0 1rem 1.5rem; }
li { margin-bottom: 0.3rem; }
li > ul, li > ol { margin-bottom: 0; }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

strong { color: var(--heading); }

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}
.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2.5rem;
}
.site-title {
  font-size: 1.3rem;
  font-weight: bold;
  color: var(--heading);
  text-decoration: none;
  flex-shrink: 0;
}
.site-title:hover { color: var(--link); text-decoration: none; }
.site-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.site-nav a {
  font-size: 0.9rem;
  text-decoration: none;
}
.site-nav a[aria-current="page"] {
  color: var(--heading);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.35rem;
}

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--text);
}
.theme-toggle:hover {
  background: var(--code-bg);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--footer-bg);
  padding: 1.5rem 0;
  font-size: 0.85rem;
  color: var(--meta);
}
.site-footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.footer-links a { margin-left: 1rem; }

/* Home */
.home-page .container {
  max-width: 960px;
}
.home-page main {
  padding: 0;
}
.home-hero {
  padding: 4.5rem 0 4rem;
  max-width: 850px;
}
.home-hero h1 {
  max-width: 780px;
  margin-bottom: 1.25rem;
  font-size: clamp(2.25rem, 6vw, 3.4rem);
  letter-spacing: -0.035em;
}
.home-eyebrow {
  margin-bottom: 0.75rem;
  color: var(--meta);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.home-hero-lede {
  max-width: 720px;
  margin-bottom: 1.75rem;
  font-size: 1.12rem;
}
.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.8rem;
  padding: 0.55rem 1rem;
  border: 1px solid var(--link);
  border-radius: 6px;
  font-weight: 700;
  text-decoration: none;
}
.button-link:hover {
  border-color: var(--link-hover);
  text-decoration: none;
}
.button-link-primary {
  background: var(--link);
  color: var(--bg);
}
.button-link-primary:hover {
  background: var(--link-hover);
  color: var(--bg);
}
.home-section {
  padding: 3.75rem 0;
  border-top: 1px solid var(--border);
}
.home-section-heading {
  max-width: 690px;
  margin-bottom: 1.75rem;
}
.home-section-heading h2 {
  margin: 0;
  font-size: clamp(1.65rem, 4vw, 2.15rem);
}
.proof-grid,
.strength-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}
.proof-card {
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--footer-bg);
}
.proof-card h3,
.strength-grid h3 {
  margin: 0 0 0.5rem;
}
.proof-card p:last-child,
.strength-grid p:last-child,
.home-contact p:last-of-type {
  margin-bottom: 0;
}
.proof-value {
  color: var(--heading);
  font-size: 1.18rem;
  font-weight: 700;
}
.proof-card-link {
  font-weight: 700;
}
.strength-grid article {
  padding-right: 1rem;
}
.home-section-link {
  margin: 1.5rem 0 0;
  font-weight: 700;
}
.home-personal-intro {
  max-width: 700px;
}
.home-personal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-top: 1.5rem;
  font-weight: 700;
}
.home-contact {
  margin: 0 0 3.75rem;
  padding: 1.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--footer-bg);
}
.home-contact h2 {
  margin: 0 0 0.6rem;
}
.home-contact .button-link {
  margin-top: 1rem;
}
.home-page main hr {
  margin: 0;
}
.home-page .latest-posts {
  padding: 3.75rem 0;
}

/* Shared card list (used in collection listings, homepage previews) */
.post-list { list-style: none; margin-left: 0; }
.post-item { margin-bottom: 1.5rem; }
.post-item h2 { margin: 0 0 0.2rem; font-size: 1.2rem; }
.post-item h3 { margin: 0 0 0.2rem; font-size: 1.2rem; }
.post-item h2 a,
.post-item h3 a,
.post-item-thumb,
.section-link {
  text-decoration: none;
}
.post-item .post-date {
  font-size: 0.85rem;
  color: var(--meta);
}
.post-item p {
  margin: 0.3rem 0 0;
  font-size: 0.95rem;
}
.post-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}
.post-item-tag {
  background: var(--code-bg);
  color: var(--meta);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
}
.post-item-has-thumb {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  padding: 0;
  background: var(--footer-bg);
}
.post-item-thumb {
  display: block;
}
.post-item-thumb img {
  width: 100%;
  height: 160px;
  object-fit: contain;
  display: block;
  background: var(--code-bg);
  padding: 1rem;
}
.post-item-body {
  padding: 1rem 1.25rem 1.25rem;
}

.latest-posts h2 {
  margin: 0;
  margin-bottom: 1rem;
}
.section-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}
.section-link {
  font-size: 0.92rem;
  font-weight: 700;
}

/* Collection listing page */
.collection-intro p:last-child {
  margin-bottom: 0;
}
.collection-controls-panel {
  margin: 1.75rem 0 1.25rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--footer-bg);
}
.collection-controls-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1.25rem;
  cursor: pointer;
  list-style: none;
}
.collection-controls-toggle::-webkit-details-marker {
  display: none;
}
.collection-controls-toggle::after {
  content: "+";
  flex-shrink: 0;
  color: var(--meta);
  font-size: 1.2rem;
  line-height: 1;
}
.collection-controls-panel[open] .collection-controls-toggle::after {
  content: "\2212";
}
.collection-controls-heading {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.collection-controls-title {
  color: var(--heading);
  font-size: 1rem;
  font-weight: 700;
}
.collection-controls-status {
  color: var(--meta);
  font-size: 0.85rem;
}
.collection-controls-body {
  padding: 0 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
}
.collection-controls {
  padding-top: 1rem;
}
.collection-search-field,
.collection-filter-group {
  display: block;
}
.collection-filter-group {
  margin-top: 1rem;
}
.collection-control-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--meta);
}
.collection-search-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  padding: 0.75rem 0.9rem;
  font: inherit;
}
.collection-search-input:focus,
.collection-controls-toggle:focus,
.collection-tag-filter:focus,
.collection-clear-filters:focus,
.collection-pagination-link:focus {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}
.collection-filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.collection-filter-header .collection-control-label {
  margin-bottom: 0;
}
.collection-tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.collection-tag-filter,
.collection-clear-filters,
.collection-pagination-link {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.collection-tag-filter,
.collection-pagination-link {
  padding: 0.4rem 0.75rem;
}
.collection-clear-filters {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}
.collection-tag-filter.is-active,
.collection-pagination-link.is-current {
  background: var(--link);
  border-color: var(--link);
  color: var(--on-link);
}
.collection-results-summary,
.collection-empty-state,
.collection-noscript-note {
  color: var(--meta);
  font-size: 0.92rem;
}
.collection-empty-state {
  padding: 1rem 1.1rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--footer-bg);
}
.collection-list {
  margin-top: 1rem;
}
.collection-pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.5rem;
}
.collection-pagination-link[disabled] {
  cursor: not-allowed;
  opacity: 0.5;
}

/* Projects */
.projects-page .container {
  max-width: 960px;
}
.projects-intro {
  max-width: 720px;
  padding: 1rem 0 2.5rem;
}
.projects-intro h1 {
  margin-bottom: 0.75rem;
}
.projects-intro p:last-child,
.project-card p:last-child,
.projects-games-link p:last-child {
  margin-bottom: 0;
}
.projects-section {
  padding: 2.75rem 0;
  border-top: 1px solid var(--border);
}
.projects-section-heading {
  max-width: 720px;
  margin-bottom: 1.5rem;
}
.projects-section-heading h2 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 1.9rem);
}
.projects-eyebrow {
  margin-bottom: 0.35rem;
  color: var(--meta);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.project-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.project-card {
  padding: 1.35rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--footer-bg);
}
.project-card h3 {
  margin: 0 0 0.65rem;
}
.project-card-link {
  font-weight: bold;
}
.project-list {
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
  list-style: none;
}
.project-list li {
  display: grid;
  grid-template-columns: minmax(9rem, 0.35fr) 1fr;
  gap: 1.5rem;
  margin: 0;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
}
.project-list h3,
.project-list p {
  margin: 0;
}
.project-list-kind {
  color: var(--meta);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.projects-games-link {
  margin: 2.75rem 0 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.projects-games-link h2 {
  margin: 0 0 0.5rem;
}

.project-detail-intro {
  padding: 1rem 0 2rem;
  border-bottom: 1px solid var(--border);
}
.project-detail-intro h1 {
  margin: 0 0 0.9rem;
  font-size: clamp(2rem, 7vw, 3rem);
}
.project-detail-lede {
  margin-bottom: 0;
  font-size: 1.08rem;
}
.project-detail section {
  margin-top: 2.5rem;
}
.project-detail section h2 {
  margin-top: 0;
}
.project-detail-back {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* Item detail page */
.item-detail {
  max-width: 46rem;
  margin: 0 auto;
}
.item-meta {
  color: var(--meta);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}
.item-toc {
  margin: 0 0 2rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--code-bg);
}
.item-toc-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  list-style: none;
}
.item-toc-summary::-webkit-details-marker {
  display: none;
}
.item-toc-summary::after {
  content: "+";
  flex-shrink: 0;
  color: var(--meta);
  font-size: 1.2rem;
  line-height: 1;
}
.item-toc[open] .item-toc-summary::after {
  content: "\2212";
}
.item-toc-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--heading);
}
.item-toc-meta {
  color: var(--meta);
  font-size: 0.85rem;
  margin-left: auto;
  padding-right: 0.25rem;
}
.item-toc nav {
  padding: 0 1.25rem 1rem;
  border-top: 1px solid var(--border);
}
.item-toc ol {
  margin: 0;
  padding-top: 0.9rem;
  padding-left: 1.1rem;
}
.item-toc li + li {
  margin-top: 0.35rem;
}
.item-toc-subitem {
  margin-left: 1rem;
  font-size: 0.95rem;
}
.item-content h2,
.item-content h3 {
  scroll-margin-top: 5rem;
}
.item-content h2:first-child { margin-top: 0; }
.item-tags {
  margin-top: 2rem;
  font-size: 0.85rem;
  color: var(--meta);
}
.item-tags span {
  background: var(--code-bg);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  margin-right: 0.4rem;
}
.item-play-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.5rem;
}
.item-play-link {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--code-bg);
  font-size: 0.9rem;
  font-weight: 700;
}
.item-play-link:hover {
  background: var(--link);
  border-color: var(--link);
  color: var(--on-link);
  text-decoration: none;
}
.item-discuss {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

/* About page */
.profile-pic {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto 1.5rem;
  border: 3px solid var(--border);
}

/* Code: inline */
code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.85em;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

/* Code: blocks */
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 1rem;
  line-height: 1.5;
}
pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.82em;
}

/* Professional pages (resume, about) */
.professional-font {
  font-family: 'Inter', system-ui, sans-serif;
}

.resume-page main {
  padding-top: 1.5rem;
}

.resume-core-expertise {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  list-style: none;
  margin-left: 0;
}

.resume-core-expertise li {
  margin-bottom: 0;
}

@media print {
  @page {
    size: A4;
    margin: 0.45in;
  }

  .resume-page {
    --bg: #fff;
    --text: #111;
    --heading: #111;
    --link: #111;
    --border: #ccc;
    background: #fff;
  }

  .resume-page .site-header,
  .resume-page .site-footer,
  .resume-page .resume-download,
  .resume-page .skip-link {
    display: none;
  }

  .resume-page main {
    padding: 0;
  }

  .resume-page .container {
    max-width: none;
    padding: 0;
  }

  .resume-page .professional-font {
    font-size: 9.8pt;
    line-height: 1.3;
  }

  .resume-page h1 {
    font-size: 18pt;
    margin-bottom: 2pt;
  }

  .resume-page .resume-headline {
    font-size: 11pt;
    margin-bottom: 4pt;
  }

  .resume-page .resume-contact {
    margin-bottom: 8pt;
  }

  .resume-page h2 {
    font-size: 12pt;
    margin: 12pt 0 4pt;
  }

  .resume-page h3 {
    font-size: 10.5pt;
    margin: 8pt 0 3pt;
    break-after: avoid;
    page-break-after: avoid;
  }

  .resume-page .resume-page-break {
    break-before: page;
    page-break-before: always;
  }

  .resume-page p,
  .resume-page ul {
    margin-bottom: 6pt;
  }

  .resume-page .resume-core-expertise {
    gap: 2pt 12pt;
  }

  .resume-page h3 + p {
    break-after: avoid;
    page-break-after: avoid;
  }

  .resume-page h3 + p + ul {
    break-inside: auto;
    page-break-inside: auto;
  }

  .resume-page li {
    margin-bottom: 2pt;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .resume-page hr {
    margin: 12pt 0;
  }
}

/* Responsive */
@media (max-width: 760px) {
  .proof-grid,
  .strength-grid,
  .project-grid {
    grid-template-columns: 1fr;
  }
  .project-list li {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  .strength-grid {
    gap: 0.25rem;
  }
  .strength-grid article {
    padding-right: 0;
  }
}

@media (max-width: 600px) {
  html { font-size: 14px; }
  .site-header .container {
    flex-direction: column;
    gap: 1rem;
  }
  .site-nav { gap: 1rem; }
  .site-nav a { font-size: 1rem; }
  .home-hero {
    padding: 3rem 0;
  }
  .home-section,
  .home-page .latest-posts {
    padding: 3rem 0;
  }
  .home-actions {
    align-items: stretch;
    flex-direction: column;
  }
  .button-link {
    width: 100%;
  }
  .home-contact {
    margin-bottom: 3rem;
    padding: 1.4rem;
  }
  .site-footer .container {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }
  .footer-links a { margin: 0 0.5rem; }
  .post-item-thumb img {
    height: 140px;
  }
  .collection-filter-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .collection-controls {
    padding-top: 1rem;
  }
  .collection-controls-toggle,
  .collection-controls-body {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}
