/* ========================================
General Body and Typography Styles
========================================
*/
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  margin: 0;
  padding: 0;
  background-color: #f0f0f0; /* Light theme background */
  color: #111;
  transition: background-color 0.3s, color 0.3s;
}

html.dark body {
  background-color: #121212; /* Dark theme background */
  color: #eee;
}

/* General Link Styles */
a {
  color: inherit; /* Inherit color from parent */
  text-decoration: none;
}

/* ========================================
Header Styles
========================================
*/
.header {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  padding: 1.5rem 2rem;
  gap: 1.5rem;
}

.logo {
  font-size: 2.2rem;
  font-weight: bold;
  cursor: pointer;
  color: #333;
  transition: color 0.3s;
}

html.dark .logo {
  color: #ccc;
}

/* ========================================
Navigation Pill Styles (Inverted Theme)
========================================
*/
.nav-pill {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.25rem;
  padding: 0.6rem;
  border-radius: 9999px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  transition: background-color 0.3s;
  background-color: #000;
}

.nav-pill a {
  padding: 0.5rem 0.9rem;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 9999px;
  white-space: nowrap;
  transition: color 0.2s, background-color 0.2s;
  color: #a0a0a0;
}

.nav-pill a:hover {
  color: #fff;
}

.nav-pill a.active {
  background-color: #333;
  color: #fff;
}

html.dark .nav-pill {
  background-color: #f0f0f0;
  box-shadow: 0 5px 20px rgba(255, 255, 255, 0.1);
}

html.dark .nav-pill a {
  color: #555;
}

html.dark .nav-pill a:hover {
  color: #000;
}

html.dark .nav-pill a.active {
  background-color: #ddd;
  color: #000;
}

/* ========================================
Theme Toggle Button
========================================
*/
.theme-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border-radius: 50%;
  transition: color 0.3s, background-color 0.2s;
  color: #555;
}

.theme-toggle:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

html.dark .theme-toggle {
  color: #aaa;
}

html.dark .theme-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

.moon-icon { display: none; }
.sun-icon { display: block; }
html.dark .moon-icon { display: block; }
html.dark .sun-icon { display: none; }

/* ========================================
Main Content Styles
========================================
*/
.main {
  flex-grow: 1;
  width: 100%;
  padding: 2rem;
  box-sizing: border-box;
}

.homepage .main {
  max-width: 1200px;
  margin: 0 auto;
}

.main.single-column {
    max-width: 1200px;
    margin: 0 auto;
}

.intro-full-width {
    margin-bottom: 3rem;
    text-align: left;
}

.intro-full-width h1 {
    font-size: 2.5rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.intro-full-width .adventure-statement {
    font-size: 1.25rem;
    line-height: 1.6;
    color: #555;
    max-width: 900px;
}

html.dark .intro-full-width .adventure-statement {
    color: #bbb;
}

.content-wrapper {
    display: flex;
    gap: 4rem;
    align-items: flex-start;
}

.main-content {
    flex: 3;
}

.sidebar {
    flex: 1;
    position: sticky;
    top: 2rem;
}

.writing-intro {
    margin-bottom: 2rem;
    color: #555;
}

html.dark .writing-intro {
    color: #bbb;
}

.main-content h2 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 1rem;
    color: #555;
}

html.dark .main-content h2 {
    color: #bbb;
}

.article-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 3rem;
}

.article-card {
    background-color: #fff;
    border: 1px solid #e0e0e0;
    padding: 1.5rem;
    border-radius: 8px;
    transition: background-color 0.3s, border-color 0.3s;
}

html.dark .article-card {
    background-color: #1e1e1e;
    border-color: #333;
}

.article-card .date {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 0.75rem;
}

html.dark .article-card .date {
    color: #777;
}

.article-card h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
}

.article-card h3 a {
    text-decoration: underline;
    text-decoration-color: #ddd;
    transition: text-decoration-color 0.2s;
}

.article-card h3 a:hover {
    text-decoration-color: #333;
}

html.dark .article-card h3 a {
    text-decoration-color: #555;
}

html.dark .article-card h3 a:hover {
    text-decoration-color: #eee;
}

/* ========================================
Recent Notes Section
========================================
*/
.recent-notes ul {
    list-style: none;
    padding: 0;
    margin-bottom: 1rem;
}

.recent-notes li {
    padding: 0.4rem 0;
    border: none;
    display: flex;
    align-items: baseline;
}

.recent-notes li::before {
    content: "•";
    margin-right: 0.75rem;
    color: #888;
}

.recent-notes li a {
    font-size: 1rem;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 2px;
    transition: border-color 0.2s;
}

.recent-notes li a:hover {
    border-bottom-color: #333;
}

html.dark .recent-notes li a {
     border-bottom-color: #444;
}

html.dark .recent-notes li a:hover {
    border-bottom-color: #eee;
}

.recent-notes li .date {
    font-size: 0.75rem;
    color: #666;
    background-color: #eaeaea;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-weight: 500;
    margin-left: 0.75rem;
    white-space: nowrap;
}

html.dark .recent-notes li .date {
    color: #aaa;
    background-color: #2c2c2c;
}

/* ========================================
Library Section (Sidebar)
========================================
*/
.library-section h2 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #777;
    margin-bottom: 1.5rem;
}

html.dark .library-section h2 {
    color: #888;
}

.book-item {
    margin-bottom: 1.25rem;
}

.book-item h3 {
    font-size: 1rem;
    font-weight: 500;
    margin: 0 0 0.25rem 0;
}

.book-item h3 a {
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 2px;
    transition: border-color 0.2s;
}

.book-item h3 a:hover {
    border-bottom-color: #333;
}

html.dark .book-item h3 a {
    border-bottom-color: #444;
}

html.dark .book-item h3 a:hover {
    border-bottom-color: #eee;
}

.book-item .book-author {
    color: #555;
    font-weight: 400;
}

html.dark .book-item .book-author {
    color: #bbb;
}

.book-item p {
    font-size: 0.9rem;
    color: #555;
    margin: 0 0 0.5rem 0;
    line-height: 1.5;
}

html.dark .book-item p {
    color: #bbb;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-weight: 500;
}

.status-pill .light {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: blink 1.5s infinite;
}

.status-pill.yet-to-start { background-color: #ffebee; color: #c62828; }
.status-pill.yet-to-start .light { background-color: #e53935; }
.status-pill.reading { background-color: #fffde7; color: #f9a825; }
.status-pill.reading .light { background-color: #fdd835; }
.status-pill.completed { background-color: #e8f5e9; color: #2e7d32; }
.status-pill.completed .light { background-color: #43a047; }

.read-more-link {
    display: inline-block;
    margin-top: 1rem;
    font-size: 0.9rem;
    text-decoration: underline;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ========================================
Bottom Content Wrapper
========================================
*/
.bottom-content-wrapper {
    display: flex;
    gap: 4rem;
    align-items: flex-start;
    margin-top: 4rem;
    padding-top: 4rem;
}

.connect-section {
    flex: 1;
}

.consuming-section {
    flex: 3;
}

.connect-section h2, .consuming-section h2 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #777;
    margin-bottom: 1.5rem;
}

html.dark .connect-section h2, html.dark .consuming-section h2 {
    color: #888;
}

.connect-section p {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.6;
}

.connect-section p a {
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 2px;
    transition: border-color 0.2s;
}

.connect-section p a:hover {
    border-bottom-color: #333;
}

html.dark .connect-section p a {
    border-bottom-color: #444;
}

html.dark .connect-section p a:hover {
    border-bottom-color: #eee;
}

html.dark .connect-section p {
    color: #bbb;
}

.consuming-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tab-link {
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 9999px;
    color: #555;
    transition: color 0.2s, background-color 0.2s;
}

html.dark .tab-link {
    color: #bbb;
}

.tab-link.active {
    background-color: #333;
    color: #fff;
}

html.dark .tab-link.active {
    background-color: #ddd;
    color: #000;
}

#consuming-content ul {
    list-style: none;
    padding: 0;
}

#consuming-content li {
    padding: 0;
    margin-bottom: 1.25rem;
}

#consuming-content h3 {
    font-size: 1rem;
    font-weight: 500;
    margin: 0 0 0.25rem 0;
}

#consuming-content h3 a {
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 2px;
    transition: border-color 0.2s;
}

#consuming-content h3 a:hover {
    border-bottom-color: #333;
}

html.dark #consuming-content h3 a {
    border-bottom-color: #444;
}

html.dark #consuming-content h3 a:hover {
    border-bottom-color: #eee;
}

.consuming-item-description {
    font-size: 0.9rem;
    color: #555;
    margin: 0;
    line-height: 1.5;
}

html.dark .consuming-item-description {
    color: #bbb;
}

/* ========================================
Subpage Layout
========================================
*/
.subpage-wrapper {
    display: flex;
    gap: 3rem;
    max-width: 1200px;
    margin: 0 auto;
}

.subpage-sidebar {
    flex: 1;
    min-width: 200px;
}

.subpage-sidebar h2 {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.subpage-nav {
    list-style: none;
    padding: 0;
}

.subpage-nav a {
    display: block;
    padding: 0.6rem 0;
    text-decoration: none;
    font-size: 0.9rem;
    border-bottom: 1px solid #e0e0e0;
}

html.dark .subpage-nav a {
    border-bottom-color: #333;
}

.subpage-nav a.active {
    font-weight: 600;
}

.subpage-content {
    flex: 3;
}

/* ========================================
Footer Styles
========================================
*/
.footer {
  text-align: center;
  padding: 4rem 2rem 2rem;
  font-size: 0.9rem;
  color: #777;
  transition: color 0.3s;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.footer-links a {
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.footer-links a:hover {
  border-bottom-color: #555;
  text-decoration: none;
}

html.dark .footer-links a:hover {
    border-bottom-color: #aaa;
}

.footer-copyright p {
  margin: 0;
  font-size: 0.85rem;
  color: #888;
  transition: color 0.3s;
}

html.dark .footer { color: #888; }
html.dark .footer-copyright p { color: #777; }

/* ========================================
Responsive Adjustments
========================================
*/
.mobile-nav-toggle {
    display: none;
}

.sidebar-overlay {
    display: none;
}

@media (max-width: 992px) {
    .content-wrapper, .bottom-content-wrapper {
        flex-direction: column;
        gap: 2rem;
    }

    .sidebar {
        position: static;
        width: 100%;
    }

    .consuming-section {
        order: -1;
    }

    .subpage-wrapper {
        flex-direction: column;
    }

    .mobile-nav-toggle {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        background-color: #fff;
        border: 1px solid #ddd;
        padding: 0.5rem;
        border-radius: 8px;
        cursor: pointer;
        position: fixed;
        top: 1.5rem;
        left: 1.5rem;
        z-index: 1001;
    }

    html.dark .mobile-nav-toggle {
        background-color: #222;
        border-color: #444;
    }
    
    .mobile-nav-toggle + .main {
        padding-top: 5rem;
    }

    .subpage-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: 280px;
        background-color: #f8f8f8;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        padding: 4rem 2rem 2rem;
        box-sizing: border-box;
        overflow-y: auto;
        box-shadow: 2px 0 15px rgba(0,0,0,0.1);
    }

    html.dark .subpage-sidebar {
        background-color: #1a1a1a;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    }

    body.drawer-open .subpage-sidebar {
        transform: translateX(0);
    }

    body.drawer-open .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }
}

@media (max-width: 768px) {
    .article-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .article-grid {
        grid-template-columns: 1fr;
    }
    .intro-full-width h1 {
        font-size: 2rem;
    }
    .intro-full-width .adventure-statement {
        font-size: 1.1rem;
    }
}
