/* Papr default theme. Tokens and components from docs/design (Home, Post). */

:root,
.t-light {
  --bg: #FAFAF8;
  --surface: #F1F1EE;
  --text: #1C1C1A;
  --muted: #55554F;
  --rule: #DCDCD6;
  --accent: #1D4ED8;
  --accent-ink: #FFFFFF;
  color-scheme: light;
}

.t-dark {
  --bg: #0B0B0C;
  --surface: #161617;
  --text: #EDEDED;
  --muted: #A1A1A1;
  --rule: #2A2A2B;
  --accent: #7AA2FF;
  --accent-ink: #0B0B0C;
  color-scheme: dark;
}

/* without the script, follow the system setting */
@media (prefers-color-scheme: dark) {
  :root:not(.t-light) {
    --bg: #0B0B0C;
    --surface: #161617;
    --text: #EDEDED;
    --muted: #A1A1A1;
    --rule: #2A2A2B;
    --accent: #7AA2FF;
    --accent-ink: #0B0B0C;
    color-scheme: dark;
  }
}

:root {
  --sans: 'Public Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --gutter: 32px;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
}

a {
  color: var(--accent);
}

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

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

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

.wrap {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.serif {
  font-family: var(--serif);
}

.label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: var(--gutter);
  top: 8px;
  z-index: 1;
  background: var(--bg);
  padding: 8px 12px;
}

/* --- header ------------------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--rule);
}

.site-nav {
  padding-top: 14px;
  padding-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 32px;
}

.wordmark {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

.navlinks {
  display: flex;
  flex-wrap: wrap;
  gap: 0 28px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.navlink {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  gap: 6px;
}

.navlink:hover {
  color: var(--accent);
}

.navlink[aria-current="page"] {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}

.navlink.accent {
  color: var(--accent);
}

.navlink.accent:hover {
  color: var(--text);
}

.toggle {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  visibility: hidden;
}

/* the toggle needs the script, which sets one of these classes */
.t-light .toggle,
.t-dark .toggle {
  visibility: visible;
}

.toggle:hover {
  border-color: var(--muted);
}

/* --- footer ------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--rule);
  margin-top: auto;
}

.site-footer .wrap {
  padding-top: 20px;
  padding-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
}

/* --- home --------------------------------------------------------------- */

.home {
  padding-top: 56px;
  padding-bottom: 64px;
  display: flex;
  flex-wrap: wrap;
  gap: 48px 56px;
  align-items: flex-start;
}

.author {
  flex: 1 1 260px;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.author .photo {
  aspect-ratio: 1 / 1;
  background: var(--surface);
  border: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 0;
}

.author .photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.author h1 {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-size: 44px;
  line-height: 1.05;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.author .bio p {
  margin: 0 0 .6em;
  font-size: 15.5px;
  line-height: 1.6;
}

.author .now p {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--muted);
}

.author .links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 20px;
  padding-top: 4px;
}

.writing {
  flex: 999 1 560px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.section-head {
  border-top: 1px solid var(--rule);
  padding-top: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 16px;
}

.section-head h1,
.section-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 40px 28px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.card:hover {
  color: inherit;
}

.card:hover h3 {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

.card h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.25;
  font-weight: 600;
}

.card p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--muted);
}

.cover {
  aspect-ratio: 4 / 3;
  background: var(--surface);
  border: 1px solid var(--rule);
  overflow: hidden;
  display: block;
}

.cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tags {
  border-top: 1px solid var(--rule);
  padding-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tags h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip {
  font-family: var(--mono);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
}

.chip:hover,
.chip[aria-current="page"] {
  border-color: var(--accent);
  color: var(--accent);
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.pager .next {
  margin-left: auto;
}

.empty {
  margin: 0;
  color: var(--muted);
}

/* --- blog --------------------------------------------------------------- */

.listing {
  padding-top: 56px;
  padding-bottom: 64px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* --- search ------------------------------------------------------------- */

.search {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 640px;
}

.search-row {
  display: flex;
  gap: 8px;
}

.search input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--muted);
  border-radius: 0;
}

.search button {
  min-height: 44px;
  padding: 8px 18px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 0;
  cursor: pointer;
}

.search button:hover {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.results {
  margin: 0;
  padding: 0;
  list-style: none;
  max-width: 760px;
}

.results li {
  border-top: 1px solid var(--rule);
}

.result {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 0;
  color: inherit;
  text-decoration: none;
}

.result:hover {
  color: inherit;
}

.result:hover h2 {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

.result h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.25;
  font-weight: 600;
}

.result p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--muted);
}

/* --- post --------------------------------------------------------------- */

.post-head {
  padding-top: 64px;
  padding-bottom: 44px;
  display: flex;
  flex-wrap: wrap;
  gap: 0 56px;
}

.post-head .spacer {
  flex: 0 1 220px;
}

.post-head .intro {
  flex: 999 1 560px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.post-head .back {
  align-self: flex-start;
}

.post-head h1 {
  margin: 0;
  max-width: 820px;
  font-family: var(--serif);
  font-size: 50px;
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.post-head .summary {
  margin: 0;
  max-width: 660px;
  font-size: 20px;
  line-height: 1.5;
  color: var(--muted);
}

.meta {
  margin: 14px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 16px 56px;
}

.meta dt {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.meta dd {
  margin: 4px 0 0;
  font-size: 15px;
}

.tree {
  font-family: var(--mono);
  color: var(--muted);
  margin-right: 8px;
}

.rule {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 0;
}

.post-body {
  padding-top: 48px;
  padding-bottom: 96px;
  display: flex;
  flex-wrap: wrap;
  gap: 32px 56px;
  align-items: flex-start;
}

.toc {
  flex: 0 1 220px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 24px;
}

.toc .label {
  margin-bottom: 8px;
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc a {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
  text-decoration: none;
  display: flex;
  gap: 8px;
  padding: 5px 0;
}

.toc a:hover,
.toc a[aria-current="true"] {
  color: var(--text);
}

.toc a[aria-current="true"] .tree {
  color: var(--accent);
}

.toc .sub a {
  padding-left: 18px;
}

.toc-spacer {
  flex: 0 1 220px;
}

/* --- prose -------------------------------------------------------------- */

.prose {
  flex: 999 1 560px;
  min-width: 0;
  max-width: 900px;
  font-size: 18px;
  line-height: 1.7;
}

.prose > * {
  max-width: 660px;
}

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

.prose p {
  margin: 0 0 1.2em;
}

.prose h2 {
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1.25;
  font-weight: 600;
  margin: 1.8em 0 .6em;
}

.prose h3 {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--muted);
  margin: 1.6em 0 .6em;
}

.prose h2,
.prose h3 {
  scroll-margin-top: 24px;
}

.prose a {
  color: var(--text);
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

.prose a:hover {
  color: var(--accent);
}

.prose ul,
.prose ol {
  margin: 0 0 1.2em;
  padding-left: 1.3em;
}

.prose li {
  margin: .2em 0;
}

.prose code {
  font-family: var(--mono);
  font-size: .82em;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1px 5px;
}

.prose pre {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 18px 20px;
  margin: 0 0 1.4em;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.7;
}

.prose pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}

.prose blockquote {
  margin: 1.6em 0;
  padding: 2px 0 2px 24px;
  border-left: 2px solid var(--rule);
  font-family: var(--serif);
  font-style: italic;
  font-size: 23px;
  line-height: 1.45;
}

.prose blockquote p {
  margin: 0;
}

.prose blockquote footer {
  margin-top: .5em;
  font-family: var(--sans);
  font-style: normal;
  font-size: 15px;
  color: var(--muted);
}

.prose figure {
  margin: 2em 0;
}

.prose figure.wide {
  max-width: none;
}

.prose figure img {
  display: block;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--rule);
}

.prose figcaption {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.4em 0;
}

.prose table {
  border-collapse: collapse;
  margin: 0 0 1.4em;
  font-size: 16px;
}

.prose th,
.prose td {
  border-bottom: 1px solid var(--rule);
  padding: 8px 14px 8px 0;
  text-align: left;
}

.prose th {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--muted);
}

.prose .video {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--surface);
}

.prose .video iframe,
.prose .video video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.prose .gallery ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* --- phone width -------------------------------------------------------- */

@media (max-width: 640px) {
  :root {
    --gutter: 20px;
  }

  .home,
  .post-head {
    padding-top: 36px;
  }

  .author {
    max-width: none;
  }

  .author .photo {
    width: 160px;
  }

  .author h1 {
    font-size: 36px;
  }

  .post-head h1 {
    font-size: 36px;
  }

  .post-head .spacer,
  .toc-spacer {
    display: none;
  }

  .toc {
    position: static;
  }

  .prose {
    font-size: 17px;
  }

  .prose blockquote {
    font-size: 20px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}
