/* ============================================================
   theTouches — design tokens modeled after darioamodei.com
   Light/dark themes are CSS variables flipped by `.u-mode-invert`.
   ============================================================ */

:root {
  --colors--background: #f0eee6;
  --colors--text: #1f1e1d;
  --colors--text-link-hover: #5e5d59;
  --colors--primary-accent: #1f1e1d;
  --colors--border: #d1cfc5;
  --colors--text-secondary: #5e5d59;

  --font-serif: "Newsreader", "Times New Roman", Georgia, serif;
}

/* Dark theme — toggled on <html> by src/main.js */
.u-mode-invert {
  --colors--background: #1f1e1d;
  --colors--text: #f0eee6;
  --colors--text-link-hover: #b0aea5;
  --colors--primary-accent: #1f1e1d;
  --colors--border: #5e5d59;
  --colors--text-secondary: #b0aea5;
}

/* ============================================================
   Base
   ============================================================ */

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

html {
  background-color: var(--colors--background);
}

body {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: 0;
  color: var(--colors--text);
  background-color: var(--colors--background);
  transition: color 0.2s linear, background-color 0.2s linear;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background-color: rgba(0, 100, 255, 0.26);
  color: inherit;
}

a {
  color: var(--colors--text);
  text-decoration: underline;
  text-underline-offset: 0.1em;
  text-decoration-thickness: 0.08em;
  transition: color 0.2s linear;
}

a:hover {
  color: var(--colors--text-link-hover);
}

img {
  max-width: 100%;
  height: auto;
}

code {
  font-size: 0.9em;
  background-color: color-mix(in srgb, var(--colors--text) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--colors--text) 30%, transparent);
  border-radius: 4px;
  padding: 0.1em 0.3em;
}

/* ============================================================
   Type scale
   ============================================================ */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.2;
  text-wrap: balance;
}

h1 {
  font-size: 3.1em;
  line-height: 1.1;
  font-weight: 700;
  margin: 0 0 0.2em;
}

h2 {
  font-size: 1.6em;
  margin: 0 0 0.5em;
}

h3,
.h3 {
  font-size: 1.2em;
  margin: 0 0 0.7em;
}

h4 {
  font-size: 1.1em;
  font-weight: 400;
  margin: 0 0 0.5em;
}

h5 {
  font-size: 1em;
  font-weight: 400;
  margin: 0 0 0.5em;
}

h6 {
  font-size: 0.9em;
  font-weight: 400;
  margin: 0 0 0.5em;
}

p {
  margin: 0 0 1em;
}

@media (max-width: 767px) {
  h1 {
    font-size: 2.4em;
  }
}

/* ============================================================
   Layout
   ============================================================ */

.container {
  width: 100%;
  max-width: 87.5rem; /* 1400px */
  margin: 0 auto;
  padding: 20px;
}

.container.cc-narrow {
  max-width: 54rem;
}

.container.cc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.header-nav { display: flex; align-items: center; gap: 1.5rem; margin-left: auto; margin-right: 1.5rem; }
.header-nav a { text-decoration: none; font-size: .86rem; }

@media (max-width: 991px) {
  .container.cc-narrow {
    width: 80%;
    max-width: none;
    padding: 0 10px;
  }
}

@media (max-width: 479px) {
  .container.cc-narrow {
    width: 95%;
  }
}

/* Spacing utilities */
.u-mt-sm { margin-top: 1.3em; }
.u-mb-sm { margin-bottom: 1.3em; }
.u-mt-md { margin-top: 2em; }
.u-mb-md { margin-bottom: 2em; }
.u-mt-lg { margin-top: 3em; }
.u-mb-lg { margin-bottom: 3em; }

/* ============================================================
   Header
   ============================================================ */

.header {
  position: sticky;
  top: 0;
  z-index: 5;
  margin-top: 15px;
  margin-bottom: 25px;
  padding-top: 15px;
  padding-bottom: 10px;
  background-color: var(--colors--background);
  transition: background-color 0.2s linear;
}

.header-name-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.header-name-link:hover {
  color: var(--colors--text);
}

.header-name {
  font-size: 1.44em;
  font-weight: 600;
  line-height: 1;
  margin: 0;
  color: var(--colors--text);
}

.header-archive-tag {
  margin-left: auto;
  margin-right: 1rem;
}

/* ============================================================
   Dark-mode toggle switch
   ============================================================ */

.toggle-switch {
  width: 40px;
  height: 20px;
  display: inline-block;
  position: relative;
  flex-shrink: 0;
}

.toggle-checkbox {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-label {
  position: absolute;
  inset: 0;
  width: 40px;
  height: 20px;
  border: 1px solid var(--colors--primary-accent);
  background-color: var(--colors--background);
  border-radius: 2rem;
  cursor: pointer;
  margin: 0;
  padding: 0;
}

.toggle-label::before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: var(--colors--primary-accent);
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-checkbox:checked + .toggle-label {
  background-color: var(--colors--text);
}

.toggle-checkbox:checked + .toggle-label::before {
  transform: translateX(20px);
  background-color: var(--colors--background);
}

.toggle-checkbox:focus-visible + .toggle-label {
  outline: 2px solid var(--colors--text);
  outline-offset: 2px;
}

/* ============================================================
   Homepage
   ============================================================ */

.home-intro p:first-child {
  margin-top: 0;
}

.hero { padding: 5.2rem 0 4.4rem; border-bottom: 1px solid var(--colors--border); }
.eyebrow, .section-index { color: var(--colors--text-secondary); font-family: Arial, sans-serif; font-size: .72rem; letter-spacing: .09em; text-transform: uppercase; }
.hero h1 { font-size: clamp(3.5rem, 10vw, 7rem); letter-spacing: -.045em; margin: .25rem 0 .45rem; }
.hero-copy { font-size: clamp(1.35rem, 3vw, 2rem); line-height: 1.35; max-width: 36rem; color: var(--colors--text-secondary); }
.hero-links { display: flex; gap: 1.8rem; margin-top: 2rem; font-size: 1rem; }
.portfolio-section { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: 2rem; padding: 2.8rem 0; border-bottom: 1px solid var(--colors--border); }
.section-index { margin: .35rem 0 0; }
.section-body { max-width: 42rem; }
.section-body > :first-child { margin-top: 0; }
.section-body h2 { display: none; }
.section-body p:last-child, .section-body ul:last-child { margin-bottom: 0; }
.section-body ul { padding-left: 1.2rem; }
.section-body li { margin-bottom: .55rem; }
.section-lede { color: var(--colors--text-secondary); margin: 0 0 1.2rem; }
.project-list { border-top: 1px solid var(--colors--border); }
.project-card { min-height: 5rem; display: grid; grid-template-columns: 2.5rem 1fr auto 1.2rem; align-items: center; gap: .8rem; padding: .9rem .2rem; border-bottom: 1px solid var(--colors--border); text-decoration: none; }
.project-number, .project-tag, .project-info > span, .blog-item time, .section-footnote { color: var(--colors--text-secondary); font-size: .82rem; }
.project-info { display: grid; gap: .15rem; }
.project-info strong { font-size: 1.12rem; font-weight: 500; }
.project-arrow { transition: transform .2s ease; }
.project-card:hover .project-arrow { transform: translate(3px,-3px); }
.section-footnote { margin-top: 1rem; }
.blog-list { list-style: none; padding: 0 !important; margin: 0 0 1.2rem; border-top: 1px solid var(--colors--border); }
.blog-item { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--colors--border); margin: 0 !important; }
.blog-item a { text-decoration: none; }
.blog-source { color: var(--colors--text-secondary); font-size: .82rem; white-space: nowrap; }
.text-link { font-size: .95rem; }
.contact-links { display: flex; gap: 1.5rem; font-size: .95rem; }
.skills-list { border-top: 1px solid var(--colors--border); margin-top: 1.5rem; }
.skills-list p { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--colors--border); padding: .65rem 0; margin: 0; font-size: .88rem; }
.skills-list strong { font-weight: 500; }
.skills-list span { color: var(--colors--text-secondary); text-align: right; }
.site-footer { display: flex; justify-content: space-between; padding: 1.6rem 0 2.5rem; color: var(--colors--text-secondary); font-size: .86rem; }
.site-footer a { color: inherit; }

@media (max-width: 640px) {
  .header-nav { gap: .8rem; margin-right: .75rem; }
  .header-nav a { font-size: .76rem; }
  .header-name { font-size: 1.1em; }
  .hero { padding: 3.5rem 0 3rem; }
  .hero-links { flex-wrap: wrap; gap: .7rem 1.3rem; }
  .portfolio-section { grid-template-columns: 1fr; gap: .7rem; padding: 2rem 0; }
  .project-card { grid-template-columns: 1.8rem 1fr auto 1rem; gap: .45rem; }
  .project-info strong { font-size: 1rem; }
  .project-info > span { font-size: .75rem; }
  .blog-item { align-items: flex-start; }
}

/* Bulleted link lists (post listings) */
.bullet-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.bullet-list_item {
  padding-left: 0.7em;
}

.bullet-list_item::before {
  content: "\2022";
  display: inline-block;
  margin-right: 0.3em;
  margin-left: -0.7em;
}

.bullet-list_link {
  margin-right: 0.25em;
}

.bullet-list_year {
  display: inline;
  color: var(--colors--text-secondary);
}

/* ============================================================
   Post page
   ============================================================ */

.post-back-link {
  display: inline-block;
  margin: 0 0 2rem;
  color: var(--colors--text-secondary);
  text-decoration: none;
}

.post-back-link:hover {
  color: var(--colors--text-primary);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.post-date {
  font-size: 0.9em;
  color: var(--colors--text-secondary);
  margin: 2em 0 1em;
}

.post-subtitle {
  color: var(--colors--text-secondary);
  font-size: 1em;
  margin: 0 0 0.5em;
}

.rich-text > :first-child {
  margin-top: 0;
}

.rich-text > :last-child {
  margin-bottom: 0;
}

.rich-text h1,
.rich-text h2,
.rich-text h3,
.rich-text h4 {
  margin-top: 1.5em;
}

.rich-text ul,
.rich-text ol {
  padding-left: 1.5em;
  margin: 1em 0;
}

.rich-text li {
  margin-bottom: 0.4em;
}

.rich-text blockquote {
  border-left: 1px solid var(--colors--border);
  font-style: italic;
  font-weight: 400;
  line-height: 1.5;
  padding: 0.25em 0 0.1em 1.25em;
  margin: 2em 0;
}

.rich-text blockquote p:last-child {
  margin-bottom: 0;
}

.rich-text pre {
  overflow-x: auto;
  padding: 1em;
  background-color: color-mix(in srgb, var(--colors--text) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--colors--text) 15%, transparent);
  border-radius: 4px;
}

.rich-text pre code {
  background-color: transparent;
  border: 0;
  padding: 0;
  border-radius: 0;
}

.rich-text hr {
  border: 0;
  border-top: 1px solid var(--colors--border);
  margin: 2em 0;
}

.rich-text table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
}

.rich-text th,
.rich-text td {
  border: 1px solid var(--colors--border);
  padding: 0.4em 0.6em;
  text-align: left;
}

.rich-text sup {
  font-size: 0.75em;
}

/* ============================================================
   Archive
   ============================================================ */

.archive-year {
  margin-top: 2em;
}

.archive-year:first-of-type {
  margin-top: 0;
}
