/* CSS Variables for theming */
:root {
  --color-bg: #fcfcfb;
  --color-surface: #ffffff;
  --color-text: #1f2937;
  --color-text-light: #6b7280;
  --color-border: #e5e7eb;
  --color-accent: #2563eb;
  --color-link: #2563eb;
  --color-link-hover: #1d4ed8;
  --color-header-bg: transparent;
  --font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  --max-width: 72ch;
  --spacing-unit: 1.5rem;
  --radius: 10px;
  --color-grid: rgba(115, 122, 133, 0.85);
  --footer-height: 44px;
  --header-height: 72px;
  --header-height-scrolled: 48px;
  --header-title-size: 1.45rem;
  --header-title-size-scrolled: 1.02rem;
}

/* Dark mode variables */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0b0f17;
    --color-surface: #0f172a;
    --color-text: #e5e7eb;
    --color-text-light: #9ca3af;
    --color-border: #1f2937;
    --color-accent: #60a5fa;
    --color-link: #60a5fa;
    --color-link-hover: #93c5fd;
    --color-header-bg: transparent;
    --color-grid: rgba(128, 153, 204, 0.65);
  }
}

/* Reset and base styles */
* {
  box-sizing: border-box;
}

html {
  background-color: var(--color-bg);
  overflow-x: hidden;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  font-size: 17px;
  line-height: 1.75;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Reserve space for fixed header + floating footer */
  padding-top: calc(var(--header-height) + 16px);
  padding-bottom: calc(var(--footer-height) + env(safe-area-inset-bottom, 0px) + 24px);
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.2;
  margin-top: 2rem;
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }

p {
  margin-bottom: 1rem;
}

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

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

a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: 4px;
}

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

/* Container and layout */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing-unit);
}

/* Header */
.site-header {
  background-color: var(--color-header-bg);
  border-bottom: none;
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: var(--header-height);
  z-index: 60;
  background: var(--color-bg);
  backdrop-filter: blur(8px);
  transition: height 160ms ease, box-shadow 160ms ease;
  overflow: hidden;
}

.grid-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.site-header .container,
.site-footer .container {
  position: relative;
  z-index: 1;
}

.site-header .container {
  height: 100%;
}

.site-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
}

.site-title {
  font-size: var(--header-title-size);
  font-weight: 700;
  margin: 0;
  text-decoration: none;
  transition: font-size 160ms ease;
}

.header-quote {
  min-width: 0;
  max-width: 55%;
  margin: 0 0 0 1.5rem;
  font-size: 0.8rem;
  line-height: 1.3;
  font-style: italic;
  text-align: right;
  text-wrap: balance;
  color: var(--color-text-light);
}

.header-quote[hidden] {
  display: none;
}

@media (max-width: 600px) {
  .header-quote {
    display: none;
  }
}

.nav-links {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 1.1rem;
}

.nav-links a {
  padding: 0.5rem 0;
  text-decoration: none;
  color: var(--color-text-light);
}

.nav-links a:hover {
  color: var(--color-text);
  text-decoration: underline;
}

/* Header shrinks after scrolling */
html.is-scrolled .site-header {
  height: var(--header-height-scrolled);
}

html.is-scrolled .site-title {
  font-size: var(--header-title-size-scrolled);
}

@media (prefers-reduced-motion: reduce) {
  .site-header,
  .site-title {
    transition: none;
  }
}

/* Main content */
.site-main {
  min-height: calc(100vh - 200px);
  padding: 2.25rem 0 3rem;
}

/* Footer */
.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--footer-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--color-bg) 10%, transparent);
  border-top: none;
  padding-left: 0;
  padding-right: 0;
  padding-top: 0;
  text-align: center;
  color: var(--color-text-light);
  z-index: 50;
  backdrop-filter: blur(8px);
  overflow: hidden;
}

.site-footer p {
  margin: 0;
    font-size: 0.85rem;
}

.site-footer a {
  color: inherit;
}

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

.site-footer .container {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

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

/* Post styles */
.post {
  max-width: 100%;
}

.post-header {
  margin-bottom: 2rem;
}

.post-title {
  margin-bottom: 0.5rem;
}

.post-date {
  color: var(--color-text-light);
  font-size: 0.9rem;
}

.post-categories,
.post-tags {
  margin-top: 1rem;
}

.category-link,
.tag-link {
  display: inline-block;
  background-color: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.85rem;
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
  text-decoration: none;
}

.category-link:hover,
.tag-link:hover {
  border-color: var(--color-accent);
  color: var(--color-link-hover);
  text-decoration: none;
}

.tags-label {
  font-size: 0.9rem;
  color: var(--color-text-light);
  margin-right: 0.5rem;
}

/* List page styles */
.list-page {
  max-width: 100%;
}

.archive-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}

.archive-item:first-child {
  border-top: 1px solid var(--color-border);
}

.archive-item-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.archive-item-title {
  font-weight: 600;
  text-decoration: none;
  color: var(--color-text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archive-item-title:hover {
  color: var(--color-accent);
}

.archive-item-header .post-date {
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 0.85rem;
}

.archive-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.35rem;
}

.archive-item-tags .category-link,
.archive-item-tags .tag-link {
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  margin: 0;
}

/* Posts list: one row per post — title | tags | date */
.post-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: 0.5rem;
  padding: 0.3rem 0;
}

.post-row-title {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
  text-decoration: none;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-row-title:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.post-row-tags {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 0.3rem;
  margin-left: 0.5rem;
}

.post-row-tags .category-link,
.post-row-tags .tag-link {
  font-size: 0.72rem;
  padding: 0.05rem 0.45rem;
  margin: 0;
  color: var(--color-text-light);
  white-space: nowrap;
}

.post-row-date {
  font-size: 0.8rem;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 720px) {
  .post-row {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 0.2rem;
  }

  .post-row-title {
    grid-column: 1 / -1;
    white-space: normal;
  }

  .post-row-tags {
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-left: 0;
  }
}

.tags-index {
  --tags-row-gap: 0.6rem;
  --tags-col-gap: 0.15rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--tags-row-gap);
  margin-top: 1.25rem;
}

.tags-index .tags-row {
  display: flex;
  justify-content: center;
  gap: var(--tags-col-gap);
  max-width: 100%;
}

.tags-index .tag-name {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tags-index .tag-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.35rem 0.8rem; /* larger pills on /tags/ only */
  font-size: 0.95rem;
  max-width: 100%;
}

.tags-index .tag-pill.is-current {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.tag-page-tags {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.tags-index .tag-count {
  border-left: 1px solid var(--color-border);
  padding-left: 0.6rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
}

@media (max-width: 720px) {
  .tags-index .tags-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: center;
    justify-items: center;
    column-gap: var(--tags-col-gap);
    row-gap: var(--tags-row-gap);
  }
}

@media (max-width: 420px) {
  .tags-index .tags-row {
    grid-template-columns: 1fr;
  }
}

.archive-excerpt {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.posts-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 0 0 1.25rem;
}

.posts-actions a {
  white-space: nowrap;
}

.page-header {
  text-align: center;
  /* margin-bottom: 3rem; */
}
/* 
.page-title {
  margin-bottom: 0.5rem;
} */

.page-description {
  color: var(--color-text-light);
  font-size: 1.1rem;
}

/* Content formatting */
.post-content,
.page-content {
  line-height: 1.6;
  letter-spacing: -0.008em;
}

.post-content h2,
.post-content h3,
.post-content h4 {
  margin-top: 2.5rem;
}

.post-content ul,
.post-content ol {
  margin-bottom: 1rem;
  padding-left: 2rem;
}

.post-content li {
  margin-bottom: 0.5rem;
}

.post-content blockquote {
  border-left: 4px solid var(--color-accent);
  padding-left: 1rem;
  margin: 1.5rem 0;
  color: var(--color-text-light);
  font-style: italic;
}

.post-content code {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.post-content pre {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.5rem 0;
}

.post-content pre code {
  background-color: transparent;
  border: 0;
  padding: 0;
  display: block;
}

/* Highlight.js fallback palette (light/dark friendly) */
.hljs {
  color: #24292e;
  background: transparent;
}
@media (prefers-color-scheme: dark) {
  .hljs {
    color: #e6edf3;
  }
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-subst {
  color: #cf222e;
}
.hljs-string,
.hljs-title,
.hljs-name,
.hljs-attr {
  color: #0a7aca;
}
.hljs-number,
.hljs-literal,
.hljs-symbol {
  color: #b47cff;
}
.hljs-comment,
.hljs-quote {
  color: #6e7781;
}
.hljs-built_in,
.hljs-builtin-name,
.hljs-type,
.hljs-class {
  color: #1f6feb;
}

/* Tables */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

.post-content th,
.post-content td {
  border: 1px solid var(--color-border);
  padding: 0.65rem 0.75rem;
  text-align: left;
}

.post-content thead th {
  background: var(--color-surface);
  font-weight: 600;
}

.post-content tbody tr:nth-child(odd) {
  background: rgba(0, 0, 0, 0.015);
}

.post-content table code {
  font-size: 0.93em;
}

.post-content p,
.page-content p {
  margin: 0 0 1.1rem;
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
}

.post-content p + ul,
.post-content p + ol,
.page-content p + ul,
.page-content p + ol {
  margin-top: -0.25rem;
}

/* Links category cards */
.links-categories {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 1.5rem;
}

.links-category-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
  text-decoration: none;
  color: var(--color-text);
  font-size: 0.95rem;
  transition: color 150ms ease;
}

.links-category-card:first-child {
  border-top: 1px solid var(--color-border);
}

.links-category-card:hover {
  color: var(--color-accent);
}

.links-category-card h2 {
  margin: 0;
  font-size: inherit;
  font-weight: 600;
}

.links-category-count {
  color: var(--color-text-light);
  font-size: 0.85rem;
}

/* Links paginated view */
.links-paginated-header {
  margin-bottom: 1.5rem;
}

.links-back-btn {
  font-size: 0.9rem;
}

.links-paginated-header h2 {
  margin-top: 0.5rem;
}

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

.link-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}

.link-item:last-child {
  border-bottom: none;
}

.link-note {
  color: var(--color-text-light);
  font-size: 0.92rem;
}

.external-icon {
  display: inline-block;
  margin-right: 0.4rem;
  vertical-align: middle;
  opacity: 0.5;
}

.links-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.links-page-btn {
  background: none;
  border: none;
  padding: 0.2rem 0.4rem;
  color: var(--color-text-light);
  font-size: 0.75rem;
  cursor: pointer;
  font-family: inherit;
  opacity: 0.6;
  transition: opacity 150ms ease, color 150ms ease;
}

.links-page-btn:hover:not(:disabled) {
  opacity: 1;
  color: var(--color-text);
}

.links-page-btn:disabled {
  visibility: hidden;
}

#links-page-info,
#posts-page-info {
  font-size: 0.7rem;
  color: var(--color-text-light);
  opacity: 0.5;
}

/* Book and quote specific styles */
.book-item,
.quote-item {
  border-bottom: 1px solid var(--color-border);
  padding: 2rem 0;
}

.quote-item {
  padding: 0.6rem 0;
}

.quote-text {
  margin: 0;
}

.quote-author-wrap {
  padding-top: 0.2rem;
  font-size: 0.9rem;
}

.book-item:last-child,
.quote-item:last-child {
  border-bottom: none;
}

.book-title {
  margin-bottom: 0.5rem;
}

.book-author,
.quote-author {
  color: var(--color-text-light);
  font-style: italic;
}

.book-status {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

.book-status.reading {
  background-color: #ffa726;
  color: white;
}

.book-status.finished {
  background-color: #66bb6a;
  color: white;
}

.book-rating {
  color: #ffb300;
  margin-left: 0.5rem;
}

/* Responsive design */
@media (max-width: 768px) {
  /* Mobile: keep header/footer sticky, but make header compact and non-animated */
  :root {
    --header-height: 52px;
    --header-height-scrolled: 52px;
    --header-title-size: 1.1rem;
    --header-title-size-scrolled: 1.1rem;
    --footer-height: 40px;
  }

  body {
    padding-top: calc(var(--header-height) + 12px);
    padding-bottom: calc(var(--footer-height) + 20px);
  }

  .site-header {
    backdrop-filter: none;
    box-shadow: none;
    transition: none;
  }

  html.is-scrolled .site-header {
    box-shadow: none;
  }

  .site-title {
    transition: none;
  }

  .site-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.75rem;
  }

  .nav-links {
    gap: 0.75rem;
  }

  .nav-links a {
    font-size: 0.95rem;
    padding: 0.25rem 0;
  }

  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }

  .container {
    padding: 0 1rem;
  }

  /* Tags index: let the pills run closer to the screen edge */
  .tags-index {
    /* Use full viewport width and self-center; avoid container padding squeezing content */
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding-left: 0.15rem;
    padding-right: 0.15rem;
    box-sizing: border-box;
  }
}

/* Connect card (top of home page) — full content width, left-aligned like the rest of the page */
.connect-page {
  margin: 0 0 2rem;
}

.connect-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin: 0 0 1.25rem;
  text-align: left;
}

.connect-headshot {
  flex-shrink: 0;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--color-border);
}

.connect-header-text {
  min-width: 0;
}

.connect-name {
  margin: 0;
}

.connect-email {
  display: inline-flex;
  cursor: pointer;
  align-items: center;
  gap: 0.35rem;
  margin: 0.3rem 0 0;
  color: var(--color-text-light);
  font-size: 0.85rem;
}

.connect-email-address {
  user-select: all;
  overflow-wrap: anywhere;
}

/* Address and copy icon share one hover state */
.connect-email:hover,
.connect-email:hover .connect-copy {
  color: var(--color-accent);
}

.connect-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--color-text-light);
  cursor: pointer;
}

.connect-copy .icon-check,
.connect-copy.is-copied .icon-copy {
  display: none;
}

.connect-copy.is-copied .icon-check {
  display: block;
}

.connect-copy.is-copied {
  color: var(--color-accent);
}

.connect-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  list-style: none;
  margin: 0.3rem 0 0;
  padding: 0;
}

.connect-links li {
  margin: 0;
}

.connect-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--color-text-light);
  text-decoration: none;
}

.connect-link:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.connect-icon {
  display: inline-flex;
}

/* GitHub contribution map */
.gh-contrib {
  margin-top: 1.5rem;
}

.gh-contrib-link {
  display: block;
}

.gh-contrib-grid {
  display: block;
  width: 100%;
  height: auto;
}

.gh-contrib-grid rect { fill: color-mix(in srgb, var(--color-text-light) 14%, transparent); }
.gh-contrib-grid rect.gh-level-1 { fill: color-mix(in srgb, var(--color-accent) 30%, transparent); }
.gh-contrib-grid rect.gh-level-2 { fill: color-mix(in srgb, var(--color-accent) 55%, transparent); }
.gh-contrib-grid rect.gh-level-3 { fill: color-mix(in srgb, var(--color-accent) 78%, transparent); }
.gh-contrib-grid rect.gh-level-4 { fill: var(--color-accent); }

.gh-contrib-total {
  margin: 0.5rem 0 0;
  text-align: left;
  font-size: 0.8rem;
  color: var(--color-text-light);
}

/* About (home) and posts: justified, newspaper-style text */
.home-about p,
.home-about li,
.post-content p,
.post-content li {
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}
