/* --- Variables & Reset --- */
:root {
  --primary: #2563eb;
  --secondary: #1f2937;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --bg-sidebar: whitesmoke;
  --border-color: #e5e7eb;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --max-width: 970px;
  --content-width: 720px;
}

* { box-sizing: border-box; }

body {
  font-family: sans-serif;
  font-size: 21px;
  color: var(--text-main);
  line-height: 1.7;
  margin: 0 auto;
  background: #fff;
  display: grid;
  grid-template-areas: 
    "header header"
    "main sidebar"
    "footer footer";
  grid-template-columns: 1fr 300px;
  max-width: var(--max-width);
}

/* --- Layout Areas --- */
body > header { 
  grid-area: header; 
  border-bottom: 6px solid var(--text-main); 
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 35px 40px;
}

body > header a {
  color: var(--text-main);
}

header img { 
  width: 100%; 
  height: auto; 
  display: block; 
}

main { 
  grid-area: main; 
  padding: 40px; 
  min-height: 80vh;
  border-left: 2px solid black;
  border-right: 2px solid black;
}

aside { 
  border-right: 2px solid black; 
  grid-area: sidebar; 
  padding: 30px 20px; 
  background-color: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
}

footer { 
  grid-area: footer; 
  padding: 40px 20px; 
  text-align: center; 
  background: var(--text-main); 
  color: #fff;
  font-size: 0.9rem;
}

/* --- Header Structural Layout (Desktop: One Clean Row) --- */
.site-title {
  font-size: 60px;
  font-family: Georgia, serif;
  font-weight: 900;
  letter-spacing: -3px;
}

.nav-container {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 24px;
}

.site-nav {
  display: flex;
  gap: 20px;
}

.site-nav a {
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 500;
}

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

/* --- Dropdown Core Functionality (Desktop & Mobile Base) --- */
.dropdown-wrapper {
  position: relative;
}

.filter-trigger {
  display: block;
  padding: 8px 14px;
  background: var(--bg-sidebar);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  transition: background 0.2s;
}

.filter-trigger:hover {
  background: #eee;
}

/* Hide filter menu items safely by default */
.filter-menu {
  display: none; 
  position: absolute;
  top: 100%;
  right: 0; 
  min-width: 160px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 100;
  margin: 4px 0 0 0;
  padding: 6px 0;
  list-style: none;
}

/* Show the dropdown list on hover or when element has focus */
.dropdown-wrapper:hover .filter-menu,
.dropdown-wrapper:focus-within .filter-menu {
  display: block;
}

.filter-menu li {
  width: 100%;
}

.filter-menu a {
  display: block;
  padding: 10px 16px;
  text-align: left;
  color: var(--text-main);
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
}

.filter-menu a:hover {
  background: var(--bg-sidebar);
  text-decoration: none;
}

.filter-menu a.active {
  background: var(--text-main) !important;
  color: #fff !important;
}

/* Disabled Content-Type Switcher Filter Items */
.filter-menu .filter-disabled {
  display: block;
  padding: 10px 16px;
  text-align: left;
  color: var(--text-muted);
  background: var(--bg-sidebar);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: not-allowed;
  user-select: none;
  opacity: 0.6;
}

/* Hide mobile-specific pieces on desktop viewports */
.collection-nav .archive-jump,
.back-to-top {
  display: none;
}

/* --- Active Static Page States --- */
body.page-about .site-nav .nav-about,
body.page-portfolio .site-nav .nav-portfolio,
body.page-contact .site-nav .nav-contact,
body.page-feeds .site-nav .nav-feeds {
  color: var(--text-main);
  font-weight: 700;
}

/* --- Typography & Global Elements --- */
h1, h2, h3 { color: #111; line-height: 1.2 }
a { color: var(--primary); text-decoration: none; transition: color 0.2s; }
a:hover { text-decoration: underline; }

/* --- Code Block Spacing & Layout --- */
pre,
pre[class*="language-"] {
  margin: 2.5em 0 !important; 
  padding: 20px;
  border-radius: 4px;
  overflow-x: auto;
}

/* Inline code styling only */
:not(pre) > code {
  font-family: var(--font-mono); 
  font-size: 0.9em; 
  background: #f3f4f6; 
  padding: 2px 4px; 
  border-radius: 3px; 
}

pre code {
  padding: 0;
  background: none;
  border-radius: 0;
}

/* --- Post Title Typography & Spacing --- */
.post-wrapper h2 {
  font-size: 2.0rem;
  margin-top: 18px; 
  margin-bottom: 25px; 
  line-height: 1.3;
}

.post-wrapper h3 {
  font-size: 1.8rem;
  margin-top: 18px; 
  margin-bottom: 25px; 
  line-height: 1.3;
}

.post-wrapper h3 a,
.post-wrapper h2 a {
  color: var(--text-main);
  text-decoration: none;
}

.post-wrapper h3 a:hover,
.post-wrapper h2 a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.blog-entry header h2,
.note-header h2 {
  font-size: 2rem;     
  margin-top: 18px;
  margin-bottom: 10px; 
  line-height: 1.3;
}

.blog-entry header h2 a,
.note-header h2 a {
  color: var(--text-main);
  text-decoration: none;
}

.blog-entry header h2 a:hover,
.note-header h2 a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.blog-entry header p {
  margin-top: 0;
  margin-bottom: 35px; 
  color: var(--text-muted);
}

/* Add a comma and space after every tag span */
.post-tags .tag:not(:last-child)::after {
  content: ", ";
}

/* Style the tags container and individual tags */
.post-tags {
  font-size: 0.85rem; 
  color: #666; 
  text-align: right;
}

/* Style the time and author text block */
.post-meta {
  font-size: 0.85rem; 
  color: #666; 
}

/* --- The Unified Entry Container --- */
.entry-container {
  max-width: var(--content-width);
  margin-bottom: 20px;
}

.entry-container, 
.entry-container p, 
.entry-container li, 
.note-wrapper, 
.post-wrapper,
.slice-wrapper,
h1, h2, h3, h4 {
  font-family: sans-serif;
}

h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -1px;
}

.entry-container img, 
.entry-container video {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

/* --- Blog / Links Feed & Library Grouping --- */
.day-group, .year-group { 
  margin-bottom: 60px; 
}

.day-header, .year-header, .page-header {
  top: 0;
  background: #fff;
  z-index: 10;
  padding: 10px 0;
}

.day-header h2, .year-header h2, .page-header h2 {
  font-family: Rockwell, "Courier New", Courier, monospace;
  font-size: 32px;
  font-weight: bold;
  margin-bottom: 30px;
  letter-spacing: -2px;
}

.day-header h2 a, .year-header h2 a, .page-header h2 a {
  color: var(--text-main);
}

/* --- Blog Posts, Notes, and Standalone Entry Card Layout --- */
.post-wrapper, .note-wrapper, .blog-entry, .note-entry .note-wrapper, .slice-wrapper {
  border: 2px solid black;
  padding: 25px; 
  margin-bottom: 15px; 
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.01);
}

.post-wrapper:last-child, .note-wrapper:last-child, .slice-wrapper:last-child {
  margin-bottom: 0;
}

.day-notes, .day-posts {
  margin-bottom: 30px;
}

.day-notes:last-child, .day-posts:last-child {
  margin-bottom: 0;
}

.img-container {
  display: flex;
  justify-content: center;
  max-width: 100%; 
  overflow: hidden; 
}

.img-container img {
  display: block; 
  max-width: 100%; 
  height: auto;    
}

.img-container-floatright {
  float: right;
  padding-left: 25px;
  padding-bottom: 10px;
  padding-top: 10px;
  padding-right: 15px;
}

/* --- Link Collection Styling --- */
.day-links { 
  padding-top: 8px;
  background: none; 
  border: none;     
  box-shadow: none; 
}

.day-links h3 {
  font-size: 1.5rem;
  margin-bottom: 15px;
  line-height: 1.3;
}

.day-links h3 a {
  color: var(--text-main);
  text-decoration: none;
}

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

.links-wrapper {
  border-left: 6px solid var(--secondary);
  padding-left: 25px; 
  margin-top: 20px;   
}

.link-wrapper {
  margin-bottom: 15px;
}

.link-wrapper:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.note-permalink, .link-permalink {
  margin-left: 0.5ch;
  text-decoration: none;
}

/* --- Library List (Posts Template Only) --- */
.posts-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-row {
  display: flex;
  align-items: baseline;
  gap: 20px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.post-row:last-child { border-bottom: none; }

.post-row .post-date {
  flex-shrink: 0;
  min-width: 100px;
  color: var(--text-muted);
  background: none;
  padding: 0;
}

/* Static pages */
.slice-group {
  margin-bottom: 40px;
}

.page-slice {
  margin-bottom: 15px;
}

/* --- Sidebar and Archive Tree --- */
aside h4 { 
  font-size: 16px; 
  letter-spacing: 0.1em; 
  color: black; 
  margin: 0 0 8px 0; 
  text-align: center;
}

.greeting {
  font-family: sans-serif;
  font-size: 16px;
  text-align: center;
}

.site-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: black;
}

.site-links li {
  width: 100%;
  text-align: center;
}

.site-links a {
  display: inline-block;
  color: #000;         
  padding: 6px 0;
  text-decoration: none; 
  font-weight: 501;
}

.site-links a:hover {
  text-decoration: none; 
  color: var(--primary); 
}

.history-tree {
  padding: 0;
  width: 100%;
}

.history-tree details { 
  margin-bottom: 8px; 
}

.history-tree summary::-webkit-details-marker,
.history-tree summary::marker {
  display: none !important;
}

.history-tree summary { 
  cursor: pointer; 
  font-weight: 700; 
  padding: 6px 0; 
  outline: none;
  color: var(--text-main);
  transition: color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  list-style: none;
  position: relative;
}

.history-tree summary::before {
  content: "►";
  font-size: 0.7em;
  margin-right: 6px;
  transition: transform 0.2s ease;
  display: inline-block;
  flex-shrink: 0;
}

.history-tree details[open] > summary::before {
  transform: rotate(90deg);
}

.history-tree summary:hover {
  color: var(--primary);
}

.history-tree ul { 
  list-style: none; 
  padding: 0; 
  margin: 4px 0; 
  border-left: none; 
  display: flex;
  flex-direction: column;
  align-items: center;
}

.history-tree a { 
  display: inline-block;
  font-size: 0.95rem; 
  color: var(--text-main); 
  padding: 4px 0;
  width: auto;
  text-align: center;
}

/* --- Footer Nav & Pagination --- */
.entry-footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  font-weight: bold;
}

.pagination { 
  display: flex; 
  justify-content: space-between; 
  padding: 40px 0; 
  border-top: 1px solid var(--border-color); 
}

/* --- Unified Responsive Layout Modifications (Mobile overrides) --- */
@media (max-width: 850px) {
  body {
    display: block;
    border: none;
    width: 100%;
  }

  body > header {
    flex-direction: column;
    gap: 8px;           /* Pulled title and navigation tight */
    padding: 15px 20px; /* Cut top/bottom padding by more than half */
    text-align: center;
  }

  /* Shrink the global body font scale for small screens */
  body {
    font-size: 17px; /* Dropped from 21px for clean readability */
  }

  .site-title {
    font-size: 36px;
    letter-spacing: -1.5px;
  }

  /* Shrink the day, year, and page stream headers */
  .day-header h2, .year-header h2, .page-header h2 {
    font-size: 24px;       /* Dropped from 32px */
    margin-bottom: 20px;   /* Pulls content up closer under the date */
    letter-spacing: -1px;  /* Relaxes the negative tracking slightly */
  }

  .nav-container {
    flex-direction: column;
    width: 100%;
    gap: 10px;          /* Compressed space between links row and button blocks */
    align-items: center;
  }

  .site-nav {
    justify-content: center;
    gap: 18px;
    width: 100%;
    margin-bottom: 5px; /* Pulls button grid tightly under the page links */
  }

  /* Downsize h3 post titles on the main feed to sit beautifully under the day-header */
  .post-wrapper h3 {
    font-size: 1.25rem;    /* Approx 26px—prominent, but structurally secondary to the day header */
    margin-top: 10px;      /* Tighten top gap */
    margin-bottom: 15px;   /* Pull the post content closer */
  }

  /* Downsize h2 post titles on individual standalone pages */
  .post-wrapper h2 {
    font-size: 1.5rem;     /* Approx 31px—gives it that crucial "main attraction" size without hogging the screen */
    margin-top: 12px;
    margin-bottom: 18px;
  }
  
  /* Catch standalone blog/note headers if your templates use these classes too */
  .blog-entry header h2,
  .note-header h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
  }

  /* Structural 2-column grid button blocks on mobile */
  .collection-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    max-width: 400px;
  }

  .dropdown-wrapper {
    width: 100%;
  }

  /* Tightened layout padding and text footprint for mobile buttons */
  .filter-trigger {
    width: 100%;
    padding: 0 12px;       /* Removed top/bottom padding since height handles it */
    font-size: 14px;
    
    /* Perfect normalization mechanics */
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    height: 36px;          /* Forces a locked, matching pixel height */
  }

  .filter-menu {
    width: 100%;
    left: 0; 
  }

  /* Compact spacing applied to mobile Archive Jump button to look identical to Filter Button */
  .collection-nav .archive-jump {
    display: flex;         /* Swapped from block to flex */
    align-items: center;
    justify-content: center;
    padding: 0 12px;       /* Removed top/bottom padding since height handles it */
    background: var(--bg-sidebar);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    
    /* Match the layout mechanics exactly with the filter trigger */
    line-height: 1;
    height: 36px;          /* Forces the exact same matching pixel height */
  }

  .collection-nav .archive-jump:hover {
    background: #eee;
  }

  /* Core Layout overrides for Main, Sidebar, and Back-to-Top triggers */
  main { 
    padding: 20px 15px; 
    width: 100%;
  }

  aside {
    padding: 40px 15px;
    width: 100%;
  }

  aside h4 {
    text-align: center;
    margin-bottom: 25px;
  }

  .back-to-top {
    display: table; 
    text-align: center;
    margin: 40px auto 10px auto; 
    padding: 10px 24px;
    background-color: var(--text-main); 
    color: #fff !important; 
    border-radius: 30px; 
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    width: fit-content;
  }

  .back-to-top:hover {
    background-color: var(--primary);
  }

  .history-tree summary {
    padding: 12px 0; 
  }
  
  .history-tree summary a {
    padding: 0; 
  }

  .history-tree ul a {
    padding: 10px 0;
  }
}
