/* Custom layout styles - Clean centered design */

/* Main content area */
.main-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
  padding: 3rem 2rem 1.5rem;
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 2rem;
  color: var(--light-gray);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.footer-icon-link {
  color: var(--light-gray);
  transition: color 0.15s ease, transform 0.15s ease;
  display: flex;
  align-items: center;
}

.footer-icon-link:hover {
  color: var(--accent);
  transform: scale(1.1);
  text-decoration: none;
}

.footer-divider {
  opacity: 0.4;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  main {
    padding: 2rem 1.5rem;
  }
}

/* Post styles */
.post-title {
  font-size: 2.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.post-meta {
  font-size: 0.9rem;
  color: var(--light-gray);
  margin-bottom: 2rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.post-content {
  font-size: 1.1rem;
  line-height: 1.8;
}

.post-content img {
  border-radius: 0.5rem;
  margin: 2rem 0;
  border: 2px solid var(--border);
}

.post-content h2 {
  font-size: 1.6rem;
  margin-top: 3rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.post-content h3 {
  font-size: 1.3rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  font-style: italic;
}

/* Blog list layout */
.posts-list {
  display: flex;
  flex-direction: column;
}

.blog-hero {
  margin-bottom: 2rem;
}

/* Year dividers */
.year-divider {
  display: flex;
  align-items: center;
  margin: 1.5rem 0 1rem;
  padding-top: 0.5rem;
}

.year-divider:first-child {
  margin-top: 0;
}

.year-divider span {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--light-gray);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.year-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
  margin-left: 1rem;
}

/* Post list / previews */
.post-preview {
  margin-bottom: 0;
  border-radius: 0.5rem;
  transition: background-color 0.15s ease;
}

.post-preview-link {
  display: block;
  padding: 1rem;
  margin: 0 -1rem;
  border-radius: 0.5rem;
  color: var(--foreground);
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.post-preview-link:hover {
  background-color: var(--muted);
  text-decoration: none;
}

.post-preview .post-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.post-preview h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.4;
  color: var(--foreground);
  transition: color 0.15s ease;
}

.post-preview-link:hover h2 {
  color: var(--accent);
}

.post-preview .post-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--light-gray);
  margin: 0;
}

.post-preview .meta-sep {
  opacity: 0.4;
}

.post-preview .read-time {
  opacity: 0.8;
}

.post-preview .excerpt {
  font-size: 0.9rem;
  color: var(--light-gray);
  line-height: 1.5;
  margin: 0;
}

/* Mobile adjustments for post list */
@media (max-width: 640px) {
  .post-preview-link {
    padding: 0.75rem;
    margin: 0 -0.75rem;
  }

  .post-preview h2 {
    font-size: 1.05rem;
  }

  .post-preview .excerpt {
    font-size: 0.85rem;
  }
}

/* Back navigation */
.back-home {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--light-gray);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  transition: color 0.15s ease;
}

.back-home:hover {
  color: var(--accent);
  text-decoration: none;
}

.back-home svg {
  transition: transform 0.15s ease;
}

.back-home:hover svg {
  transform: scale(1.1);
}

/* Theme toggle button in footer */
.theme-toggle-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--light-gray);
  transition: color 0.2s ease, background-color 0.2s ease;
}

.theme-toggle-btn:hover {
  color: var(--accent);
  background-color: color-mix(in srgb, var(--accent) 10%, transparent);
}

.theme-toggle-btn svg {
  position: absolute;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Light mode: show moon, hide sun */
html:not([data-theme="dark"]) .theme-toggle-btn .moon-icon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

html:not([data-theme="dark"]) .theme-toggle-btn .sun-icon {
  opacity: 0;
  transform: scale(0) rotate(90deg);
}

/* Dark mode: show sun, hide moon */
html[data-theme="dark"] .theme-toggle-btn .moon-icon {
  opacity: 0;
  transform: scale(0) rotate(-90deg);
}

html[data-theme="dark"] .theme-toggle-btn .sun-icon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* Hero section for homepage */
.hero {
  margin-bottom: 1.5rem;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  line-height: 1.15;
}

.hero .subtitle {
  font-size: 1.2rem;
  color: var(--light-gray);
  line-height: 1.5;
}

/* Search link in hero */
.search-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  color: var(--light-gray);
  background-color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  transition: all 0.2s ease;
}

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

.search-link kbd {
  padding: 0.15rem 0.4rem;
  font-size: 0.7rem;
  background-color: var(--background);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  margin-left: 0.25rem;
}

/* Content sections */
.content-section {
  margin-bottom: 2rem;
}

.content-section p {
  font-size: 1.1rem;
  line-height: 1.8;
  margin-bottom: 1.25rem;
}

/* Intro paragraph - slightly larger for emphasis */
.content-section p.intro {
  font-size: 1.2rem;
  line-height: 1.7;
  color: var(--foreground);
}

.content-section a {
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 4px;
}

.content-section a:hover {
  text-decoration-style: solid;
}

/* Inline tech tags */
.content-section code {
  font-size: 0.9em;
  padding: 0.15em 0.4em;
  background-color: var(--muted);
  border-radius: 0.25rem;
  color: var(--foreground);
  font-weight: 500;
}

/* Section divider */
.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
  opacity: 0.5;
}

/* Social links - icon row */
.social-links {
  display: flex;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.social-links a {
  color: var(--light-gray);
  text-decoration: none;
  transition: color 0.2s ease, transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.social-links a:hover {
  color: var(--accent);
  transform: translateY(-2px);
}

/* Blockquotes */
blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  font-style: italic;
  opacity: 0.85;
}

/* Lists */
ul, ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

li {
  margin-bottom: 0.5rem;
}

li::marker {
  color: var(--accent);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

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

th {
  background-color: var(--muted);
  font-weight: 600;
}

/* Horizontal rule - shorter, centered */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem auto;
  width: 60%;
  opacity: 0.5;
}

/* Pagination */
.pagination {
  margin-top: 3rem;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}

.pagination a {
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  background-color: var(--muted);
  color: var(--foreground);
}

.pagination a:hover {
  background-color: var(--accent);
  color: var(--background);
  text-decoration: none;
}

/* Reading Progress Bar */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #fff));
  width: 0%;
  z-index: 1000;
  transition: width 0.1s ease-out;
}

/* Post article layout */
.post-article {
  position: relative;
}

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

.post-body {
  position: relative;
}

/* Table of Contents Sidebar */
.toc-sidebar {
  display: none;
  position: fixed;
  top: 120px;
  right: calc((100vw - var(--content-max-width)) / 2 - 220px);
  width: 200px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  z-index: 50;
}

.toc-sidebar.visible {
  display: block;
}

@media (max-width: 1400px) {
  .toc-sidebar {
    display: none !important;
  }
}

.toc {
  padding: 1rem;
  background-color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.toc-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--light-gray);
  margin-bottom: 0.75rem;
}

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

.toc-item {
  margin-bottom: 0.35rem;
}

.toc-item.toc-h3 {
  padding-left: 0.75rem;
}

.toc-link {
  display: block;
  font-size: 0.8rem;
  color: var(--light-gray);
  text-decoration: none;
  padding: 0.25rem 0;
  border-left: 2px solid transparent;
  padding-left: 0.5rem;
  transition: all 0.15s ease;
  line-height: 1.4;
}

.toc-link:hover {
  color: var(--foreground);
  text-decoration: none;
}

.toc-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

/* Code Block Wrapper */
.code-block-wrapper {
  position: relative;
  margin: 1.5rem 0;
  border-radius: 0.5rem;
  background-color: var(--muted);
  border: 1px solid var(--border);
}

.code-block-wrapper .highlight {
  overflow-x: auto;
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background-color: color-mix(in srgb, var(--muted) 80%, var(--border));
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  position: relative;
  z-index: 1;
  width: 100%;
  box-sizing: border-box;
}

.code-lang {
  color: var(--light-gray);
  font-weight: 500;
  text-transform: lowercase;
}

.code-copy-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  background-color: transparent;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  color: var(--light-gray);
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.code-copy-btn:hover {
  background-color: var(--background);
  color: var(--foreground);
  border-color: var(--light-gray);
}

.code-copy-btn.copied {
  color: #22c55e;
  border-color: #22c55e;
}

.code-block-wrapper pre,
.prose .code-block-wrapper pre {
  margin: 0 !important;
  border-radius: 0 !important;
  border: none !important;
  padding: 1rem 1.25rem !important;
  background-color: var(--muted) !important;
}

.code-block-wrapper .highlight,
.prose .code-block-wrapper .highlight {
  margin: 0 !important;
  border-radius: 0 !important;
  border: none !important;
}

/* Syntax highlighting - Custom theme matching site colors */
.highlight {
  margin: 1.5rem 0;
  border-radius: 0.5rem;
  overflow: hidden;
}

/* Light mode syntax */
.highlight .c, .highlight .c1, .highlight .cm { color: #6a737d; font-style: italic; } /* Comments */
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp { color: #d73a49; font-weight: 500; } /* Keywords */
.highlight .s, .highlight .s1, .highlight .s2, .highlight .se { color: #032f62; } /* Strings */
.highlight .n, .highlight .nv, .highlight .vi { color: #24292e; } /* Names/Variables */
.highlight .nf, .highlight .nc, .highlight .nd { color: #6f42c1; } /* Functions/Classes */
.highlight .o, .highlight .p { color: #24292e; } /* Operators/Punctuation */
.highlight .m, .highlight .mi, .highlight .mf { color: #005cc5; } /* Numbers */
.highlight .nb { color: #005cc5; } /* Builtins */
.highlight .na { color: #005cc5; } /* Attributes */
.highlight .nt { color: #22863a; } /* Tags (HTML) */
.highlight .err { color: #cb2431; background-color: #ffeef0; } /* Errors */

/* Dark mode syntax - GitHub Dark inspired */
html[data-theme="dark"] pre {
  background-color: #161b22 !important;
  border-color: #30363d;
}

html[data-theme="dark"] pre code {
  color: #e6edf3;
}

html[data-theme="dark"] code {
  color: #e6a07c;
  background-color: rgba(255, 255, 255, 0.08);
}

/* Better inline code contrast */
.post-content code:not(pre code) {
  font-size: 0.88em;
  padding: 0.2em 0.45em;
  background-color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  color: var(--foreground);
  font-weight: 500;
  white-space: nowrap;
}

html[data-theme="dark"] .post-content code:not(pre code) {
  background-color: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  color: #e6a07c;
}

html[data-theme="dark"] .highlight .c,
html[data-theme="dark"] .highlight .c1,
html[data-theme="dark"] .highlight .cm { color: #8b949e; }
html[data-theme="dark"] .highlight .k,
html[data-theme="dark"] .highlight .kd,
html[data-theme="dark"] .highlight .kn,
html[data-theme="dark"] .highlight .kp { color: #ff7b72; }
html[data-theme="dark"] .highlight .s,
html[data-theme="dark"] .highlight .s1,
html[data-theme="dark"] .highlight .s2,
html[data-theme="dark"] .highlight .se { color: #a5d6ff; }
html[data-theme="dark"] .highlight .n,
html[data-theme="dark"] .highlight .nv,
html[data-theme="dark"] .highlight .vi { color: #e6edf3; }
html[data-theme="dark"] .highlight .nf,
html[data-theme="dark"] .highlight .nc,
html[data-theme="dark"] .highlight .nd { color: #d2a8ff; }
html[data-theme="dark"] .highlight .o,
html[data-theme="dark"] .highlight .p { color: #e6edf3; }
html[data-theme="dark"] .highlight .m,
html[data-theme="dark"] .highlight .mi,
html[data-theme="dark"] .highlight .mf { color: #79c0ff; }
html[data-theme="dark"] .highlight .nb { color: #79c0ff; }
html[data-theme="dark"] .highlight .na { color: #79c0ff; }
html[data-theme="dark"] .highlight .nt { color: #7ee787; }
html[data-theme="dark"] .highlight .err { color: #ffa198; background-color: rgba(248, 81, 73, 0.15); }

/* Tag/Badge styles */
/* Tags - minimal style */
.post-tags::before {
  content: "·";
  margin-right: 0.5rem;
}

.tag {
  display: inline;
  color: var(--light-gray);
  font-size: 0.85rem;
  font-weight: 400;
  text-decoration: none;
  transition: color 0.15s ease;
}

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

.tag + .tag::before {
  content: " · ";
  opacity: 0.5;
}

/* Post navigation (Prev/Next) */
.post-navigation {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.post-nav-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem;
  border-radius: 0.5rem;
  background-color: var(--muted);
  border: 1px solid var(--border);
  color: var(--foreground);
  transition: all 0.2s ease;
}

.post-nav-link:hover {
  border-color: var(--accent);
  background-color: color-mix(in srgb, var(--accent) 5%, var(--muted));
  text-decoration: none;
}

.post-nav-prev {
  text-align: left;
}

.post-nav-next {
  text-align: right;
}

.post-nav-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--light-gray);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.post-nav-next .post-nav-label {
  justify-content: flex-end;
}

.post-nav-title {
  font-weight: 500;
  font-size: 0.95rem;
  line-height: 1.3;
}

.post-nav-spacer {
  flex: 1;
}

@media (max-width: 640px) {
  .post-navigation {
    flex-direction: column;
    gap: 1rem;
  }

  .post-nav-next {
    text-align: left;
  }

  .post-nav-next .post-nav-label {
    justify-content: flex-start;
    flex-direction: row-reverse;
  }
}

/* Back to top button */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: var(--muted);
  border: 1px solid var(--border);
  color: var(--light-gray);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
  z-index: 100;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background-color: var(--accent);
  border-color: var(--accent);
  color: var(--background);
  transform: translateY(-2px);
}

@media (max-width: 640px) {
  .back-to-top {
    bottom: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
  }
}

/* Search page styles */
.search-container {
  margin-bottom: 2.5rem;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 1rem;
  color: var(--light-gray);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 1rem 3rem 1rem 3rem;
  font-size: 1.1rem;
  font-family: inherit;
  background-color: var(--muted);
  border: 2px solid var(--border);
  border-radius: 0.75rem;
  color: var(--foreground);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.search-input::placeholder {
  color: var(--light-gray);
}

.search-kbd {
  position: absolute;
  right: 1rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-family: inherit;
  background-color: var(--background);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  color: var(--light-gray);
  pointer-events: none;
}

.search-input:focus + .search-kbd {
  display: none;
}

.search-hint {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--light-gray);
}

.search-hint kbd {
  padding: 0.15rem 0.4rem;
  font-size: 0.75rem;
  background-color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
}

.search-count {
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--light-gray);
}

.search-results {
  min-height: 200px;
}

.search-no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--light-gray);
}

.search-no-results svg {
  margin-bottom: 1rem;
  opacity: 0.5;
}

.search-no-results p {
  margin: 0;
  font-size: 1.1rem;
}

/* Highlight matches in search */
.search-results mark {
  background-color: color-mix(in srgb, var(--accent) 25%, transparent);
  color: inherit;
  padding: 0.1em 0.2em;
  border-radius: 0.2em;
}
