/* ==========================================================================
   1. VARIABLES & DARK MODE PALETTE (Your Old Style Colors)
   ========================================================================== */
:root {
    /* Light Mode */
    --bg: #ffffff;
    --text: #1a1a1a;
    --heading: #222;
    --accent-gold: #B5882F;
    --link: #0066cc;
    --link-visited: #8b6fcb;
    
    /* Box Colors */
    --now-bg: whitesmoke;
    --now-border: #d4e5d9;
    --note-bg: ghostwhite;
    --note-border: #e3d5e8;
    --link-bg: #f9fbfc;
    --link-border: #d5e1e8;
}

@media (prefers-color-scheme: dark) {
    :root {
        /* Your Preferred Dark Mode Palette */
        --bg: #333;           /* --dark-background */
        --text: linen;        /* --dark-text */
        --heading: #eee;      /* --dark-heading */
        --link: #8cc2dd;      /* --dark-link */
        --link-visited: #d4af37;

        /* Reintegrating Old Section Backgrounds */
        --now-bg: #2f4f4f;    /* darkslategrey */
        --note-bg: #008080;   /* teal */
        --link-bg: #191970;   /* midnightblue */
        
        --now-border: #daa520;
        --note-border: #444;
        --link-border: #444;
    }
}

/* ==========================================================================
   2. RESET & BASE STYLES
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Hoefler Text', ui-serif, 'Georgia', 'Times New Roman', serif;
    font-size: clamp(1.2rem, 2vw, 1.5rem);
    line-height: 1.65;
    color: var(--text);
    background-color: var(--bg);
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ==========================================================================
   3. TYPOGRAPHY
   ========================================================================== */
h1, h2, h3 {
    font-family: 'Gill Sans', 'Gill Sans MT', 'Calibri', 'Trebuchet MS', sans-serif;
    font-weight: normal;
    line-height: 1.3;
}

h1 { 
    font-size: clamp(2rem, 5vw, 3rem); 
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

h1 span {
    font-size: 0.5em; 
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: #666;
    margin-top: 0.2em;
}

h2 { 
    font-size: clamp(1.25rem, 2.5vw, 1.5rem);
    margin-top: 1.5em;
    margin-bottom: 0.75em;
    position: relative;
    display: inline-block;
    padding-bottom: 8px;
}

/* Gold Underline from your previous design */
h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60%;
    height: 4px;
    background: var(--accent-gold);
    border-radius: 2px;
}

a {
    color: var(--link);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover { text-decoration: underline; }

li {
    font-size: clamp(1rem, 2vw, 1.2rem); 
}

/* ==========================================================================
   4. HEADER & NAV (Preserved)
   ========================================================================== */
header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 30px;
    padding-bottom: 10px;
}

header .title-link {
    color: saddlebrown;
    text-decoration: none;
}

header .logo {
    width: clamp(4rem, 10vw, 8rem);
    height: auto;
}

nav {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 30px;

}

nav a {
    border: 2px solid var(--text);
    border-bottom: none;
    margin-right: 5px;
    padding: 8px 15px;
    background: var(--bg);
    font-weight: bold;
    color: var(--text);
}

/* 1. The Active State Look */
nav a.active {
    background-color: var(--text);
    color: var(--bg);
    border-bottom: 2px solid var(--text); /* Match other tabs */
}

@media (prefers-color-scheme: dark) {
    nav a.active {
        background-color: var(--accent-gold);
        color: #1a1a1a;
        border-color: var(--accent-gold);
    }
}

/* 2. Solving the Right Gutter / Alignment Issue */
@media (max-width: 400px) {
    body {
        padding: 15px 10px; /* Reduces side air to prevent overflow */
        overflow-x: hidden; /* Prevents tiny horizontal wobbles */
    }

    header {
        flex-direction: row; /* Keep logo and text side-by-side */
        align-items: center;
        gap: 10px;
    }

    header h1 {
        font-size: 1.5rem; /* Shrink to keep it from pushing the width */
    }

    header h1 span {
        font-size: 0.6em;
        letter-spacing: 0.1em; /* Tightened from 0.2em to stay on screen */
    }

    nav {
        display: flex;
        flex-wrap: wrap;
        gap: 4px; /* Tighter gap for small screens */
    }

    nav a {
        flex: 1 1 auto; /* Allow tabs to fill rows intelligently */
        min-width: 70px; /* Prevent them from getting TOO skinny */
        padding: 4px 6px;
        font-size: 0.8rem;
        text-align: center;
        border-bottom: 2px solid var(--text); /* Essential for the "wrapped" look */
    }
}

/* ==========================================================================
   5. HOMEPAGE GRID & WELCOME
   ========================================================================== */
.homepage-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; 
    gap: 40px; 
    align-items: start; 
    margin-bottom: 3rem;
}

.welcome-text {
    text-align: center;
    font-size: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
} /* FIXED: This brace was missing! */

.welcome-text b {
    color: var(--accent-gold);
    text-transform: uppercase;
    font-family: 'Gill Sans', sans-serif;
    font-size: 0.9em;
}

/* ==========================================================================
   6. RECENT WRITING (LIST VIEW)
   ========================================================================== */
.writing-list {
    list-style: none;
}

.writing-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}

.writing-list li a {
    font-weight: 500;
    margin-right: 10px;
}

.type-tag {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-gold);
    background: rgba(128, 128, 128, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    margin-right: 10px;
}

.meta-date {
    font-size: 0.85rem;
    color: #888;
    margin-left: auto;
}

/* ==========================================================================
   7. NOW, NOTES, & LINKS (BOX VIEWS)
   ========================================================================== */

/* ==========================================================================
   NOW SECTION SPECIFICS
   ========================================================================== */

/* ==========================================================================
   HOMEPAGE SNIPPET: .now-section
   ========================================================================== */

/* The Container */
.now-section {
    border: 2px solid var(--now-border);
    background-color: var(--now-bg);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

/* Headers inside the snippet */
.now-section h3 {
    font-family: 'Gill Sans', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.95rem; /* Slightly smaller for the snippet */
    color: var(--accent-gold);
    margin: 1.5rem 0 0.5rem 0;
    border-bottom: 1px solid rgba(128, 128, 128, 0.1);
    padding-bottom: 2px;
}

/* Paragraphs */
.now-section .entry-content p {
    font-size: 0.95em; /* Tighter for homepage readability */
    line-height: 1.5;
    margin-bottom: 1rem;
}

/* List Styles */
.now-section ul {
    list-style: none;
    padding: 0;
    margin-bottom: 1rem;
}

.now-section li {
    position: relative;
    padding-left: 1.2rem;
    margin-bottom: 0.4rem;
    line-height: 1.4;
}

/* Custom Arrow for Homepage Snippet */
.now-section li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--accent-gold);
    font-weight: bold;
}

/* The "Last Updated" timestamp at the bottom */
.now-section small {
    display: block;
    margin-top: 1.5rem;
    font-family: 'Gill Sans', sans-serif;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.6;
    text-align: right;
}

/* Dark Mode logic for the snippet */
@media (prefers-color-scheme: dark) {
    .now-section {
        border-style: dashed;
    }
    .now-section h3 {
        color: var(--link); /* A cooler color for dark mode section headers */
    }
}

/* Ensure we target H3s inside the Now page content specifically */
.page-now .entry-content h3 {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 1.1rem;
    margin-top: 2.5rem;   /* Space above new sections */
    margin-bottom: 1rem;
    color: var(--accent-gold);
    display: block;
    border-bottom: 1px solid var(--now-border); /* Subtle underline for sectioning */
    padding-bottom: 5px;
}

/* First H3 shouldn't have a massive top margin */
.page-now .entry-content h3:first-of-type {
    margin-top: 1.5rem;
}

/* Style the paragraphs for readability */
.page-now .entry-content p {
    margin-bottom: 1.2rem;
}

/* Target the lists under Watching, Listening, etc. */
.page-now .entry-content ul {
    list-style: none;
    padding: 0;
    margin-bottom: 2rem;
}

.page-now .entry-content li {
    position: relative;
    padding: 0.5rem 0 0.5rem 1.5rem;
    border-bottom: 1px dotted rgba(128, 128, 128, 0.2);
}


/* Clean up the last item in each list */
.page-now .entry-content li:last-child {
    border-bottom: none;
}

/* ==========================================================================
   DARK MODE ADJUSTMENTS FOR NOW
   ========================================================================== */
@media (prefers-color-scheme: dark) {
    .now-section {
        /* Your old 'darkslategrey' background via variable */
        background-color: var(--now-bg); 
        border-style: dashed; /* A nod to your old CSS style */
    }
    
    .now-section .entry-content h3 {
        color: linen; /* Softens the subhead in dark mode */
    }
}

/* Common Container Styles */
.now-section, .recent-notes, .recent-links {
    margin: 30px 0;
    padding: 25px 20px;
    border-radius: 8px;
    border: 1px solid;
}

.now-section { border-color: var(--now-border); background-color: var(--now-bg); }
.recent-notes { border-color: var(--note-border); background-color: var(--note-bg); }
.recent-links { border-color: var(--link-border); background-color: var(--link-bg); }

.note-item {
    background: var(--bg);
    border: 1px solid rgba(128, 128, 128, 0.2);
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
}

.link-item {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px dotted rgba(128, 128, 128, 0.3);
}

.link-item h3 { margin-bottom: 5px; color: var(--heading); }
.link-item small { display: block; margin-bottom: 5px; color: #888; }

.permalink-wrapper a {
    font-size: 0.8rem;
    background: rgba(128, 128, 128, 0.1);
    padding: 2px 8px;
    border-radius: 3px;
    color: var(--text);
}

/* ==========================================================================
   8. DARK MODE SPECIAL FIXES (SVGs)
   ========================================================================== */
@media (prefers-color-scheme: dark) {
    .logo {
        /* 1. brightness(1.4): Makes the whole thing visible.
           2. contrast(1.1): Keeps the layers from looking flat.
           3. saturate(1.3): Over-emphasizes the gold/browns.
           4. sepia(0.3): Forces a warm/gold tint back into the inverted colors.
        */
        filter: brightness(1.3) contrast(1.1) saturate(1.4) sepia(0.2);
        
        /* Optional: Add a subtle 'backlight' effect */
        filter: drop-shadow(0 0 2px rgba(218, 165, 32, 0.3));
    }
}

/* ==========================================================================
   9. MOBILE RESPONSIVENESS
   ========================================================================== */
@media (max-width: 768px) {
    .homepage-grid { grid-template-columns: 1fr; gap: 20px; }
    header { flex-direction: column; align-items: flex-start; }
    h2::after { width: 100%; }
    .meta-date { margin-left: 0; width: 100%; margin-top: 5px; }
}

/* ==========================================================================
   10. ARCHIVE PAGES (Notes & Links Stream)
   ========================================================================== */
.archive-nav {
    margin-bottom: 3rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
    font-family: 'Gill Sans', sans-serif;
    font-size: 0.9rem;
}

.archive-nav strong {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-gold);
}

.archive-nav a {
    margin: 0 0.5rem;
    color: var(--text);
    opacity: 0.7;
}

.archive-nav a.active {
    font-weight: bold;
    color: var(--link);
    opacity: 1;
    text-decoration: underline;
}

/* Individual Post Stream */
.stream-item {
    margin-bottom: 4rem;
    border-left: 3px solid var(--accent-gold);
    padding-left: 1.5rem;
}

.stream-item time a {
    display: block;
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 0.5rem;
    font-family: 'Gill Sans', sans-serif;
}

.stream-item h3 {
    margin: 0.5rem 0;
    font-size: 1.6rem;
}

.stream-item p {
    margin-bottom: 1rem;
}

.stream-item .permalink-wrapper {
    margin-top: 1rem;
}

.stream-item .permalink-wrapper a {
    font-family: 'Gill Sans', sans-serif;
    font-size: 0.8rem;
    background: rgba(128, 128, 128, 0.1);
    padding: 4px 10px;
    border-radius: 3px;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ==========================================================================
   11. FOOTER (Simplified Single Column)
   ========================================================================== */
footer[role="contentinfo"] {
    margin-top: 3rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--text);
    background: var(--now-bg);
    display: flex;
    flex-direction: column;
    align-items: center;    /* Centers everything horizontally */
    text-align: center;      /* Centers the text lines */
    font-size: 1rem;
    line-height: 1.5;
    gap: 1.5rem;            /* Spacing between license, rss, and webrings */
}

.footer-license img {
    height: 31px;
    width: 88px;
    margin: 0 auto 1rem;
    display: block;
}

@media (prefers-color-scheme: dark) {
    .footer-license img {
        filter: brightness(0.8) contrast(1.2);
    }
}

.footer-rss p {
    margin: 0;
}

.footer-rss a {
    font-weight: bold;
    color: var(--link);
    white-space: nowrap;    /* Keeps RSS links from breaking awkwardly */
}

/* Updated Webrings: Smaller and Inline */
.footer-webrings {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.footer-webrings p {
    margin: 0 auto;
    padding: 4px 12px;
    border: 1px solid var(--accent-gold);
    background: var(--bg);
    border-radius: 20px;     /* Pill shape for a more modern "badge" look */
    width: fit-content;      /* Only as wide as the text inside */
    font-size: 0.8rem;
}

.footer-webrings a {
    padding: 0 8px;
    font-weight: bold;
    font-size: 1rem;
    color: var(--link);
}

/* ==========================================================================
   12. MOBILE FOOTER ADJUSTMENTS
   ========================================================================== */
@media (max-width: 600px) {
    /* Since the footer is now naturally a column, we just tweak spacing */
    footer[role="contentinfo"] {
        padding: 2rem 1rem;
    }

    .stream-item {
        border-left-width: 5px;
        padding-left: 1rem;
    }
}

/* ==========================================================================
   13. NOW PAGE (SINGLE ENTRY VIEW)
   ========================================================================== */

/* The main container for the Now page */
.page-now {
    max-width: 700px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: var(--now-bg);
    border: 2px solid var(--now-border);
    border-radius: 12px;
    box-shadow: 4px 4px 0px var(--now-border); /* "Neobrutalist" shadow */
}

/* Specific styling for the main title on the Now page */
.page-title {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--heading);
    display: block; /* Overrides the inline-block from general H2 */
}

/* Style for the "What I'm doing now" subtitle */
.page-now .entry-content h3 {
    font-style: italic;
    font-size: 1.4rem;
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--accent-gold);
    border: none; /* Remove any underlines here */
}

/* The List of activities */
.page-now ul {
    list-style: none;
    padding: 0;
}

.page-now .entry-content li {
    position: relative;
    padding-left: 2rem; /* Make room for the arrow */
    list-style: none;   /* Hide the default browser dot */
}

article.page-now .entry-content li::before {
    content: "→";
    position: absolute;
    left: 0;
    top: 0.6rem; /* Adjust based on your line-height to center vertically */
    color: var(--accent-gold);
    font-weight: bold;
    display: inline-block;
}

/* Remove border from the last list item */
.page-now li:last-child {
    border-bottom: none;
}

/* Styling for the new Last Updated section in renderPage */
.page-meta {
    margin-top: 2.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(128, 128, 128, 0.1);
    text-align: right; /* Keeps it tucked in the bottom right */
}

.page-meta small {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.7rem;
    color: var(--text);
    opacity: 0.5;
}

/* Specific adjustment for the Now page footer */
.page-now .page-meta {
    border-top-style: dashed;
}

/* ==========================================================================
   DARK MODE ADJUSTMENTS FOR NOW PAGE
   ========================================================================== */
@media (prefers-color-scheme: dark) {
    .page-now {
        border-style: dashed; /* Matches your dashboard preference */
        box-shadow: 4px 4px 0px var(--accent-gold);
    }
    
    .page-now li {
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }
}

/* ==========================================================================
   14. GENERIC LIST CONTAINERS (Posts, Archive Indexes)
   ========================================================================== */

.list-container {
    max-width: 800px; /* Slightly wider than 'Now' to accommodate dates */
    margin: 2rem auto;
    padding: 2.5rem;
    background-color: var(--bg);
    border: 1px solid rgba(128, 128, 128, 0.2);
    border-radius: 8px;
    background-color: var(--bg);
    border: 2px solid var(--text);
    box-shadow: 6px 6px 0px var(--accent-gold); /* Different color shadow for Posts */
}

/* Matching the "Now" Page logic for section-specific containers */
.section-posts {
    background-color: var(--bg);
    border: 2px solid var(--text);
    box-shadow: 6px 6px 0px var(--accent-gold); /* Different color shadow for Posts */
}

.list-title {
    font-size: 2.2rem;
    margin-bottom: 2rem;
    color: var(--heading);
}

/* The List Items */
.index-list {
    list-style: none;
    padding: 0;
}

.list-item {
    display: flex;
    align-items: baseline;
    padding: 0.8rem 0;
    border-bottom: 1px solid rgba(128, 128, 128, 0.1);
    font-size: inherit; /* Respects your body clamp */
}

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

/* Date Styling */
.publication-date {
    color: #888;
    min-width: 100px; /* Ensures vertical alignment of titles */
    margin-right: 1.5rem;
    flex-shrink: 0;
}

.list-link {
    font-weight: 500;
    line-height: 1.4;
}

/* ==========================================================================
   DARK MODE ADJUSTMENTS
   ========================================================================== */
@media (prefers-color-scheme: dark) {
    .section-posts {
        border-color: var(--note-border);
        box-shadow: 6px 6px 0px var(--link-visited); /* Swapping shadow color */
    }
}

/* Mobile Tweak for List Pages */
@media (max-width: 600px) {
    .list-container {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .list-item {
        flex-direction: column; /* Stack date above title on small screens */
    }
    
    .publication-date {
        margin-bottom: 0.2rem;
    }
}

/* ==========================================================================
   16. LISTENING PAGE - CLEAN READABILITY
   ========================================================================== */

/* The Main Container - Matching the 'Now' and 'Posts' layout */
.page-listening {
    max-width: 800px;
    margin: 2rem auto;
    padding: 2.5rem;
    background-color: var(--bg);
    border: 2px solid var(--link-visited); /* Using your purple as the thematic anchor */
    border-radius: 8px;
    box-shadow: 8px 8px 0px var(--link-visited);
}

/* Date Headers - Simple and consistent */
.page-listening .entry-content h2 {
    font-family: 'Gill Sans', sans-serif;
    font-size: 1.4rem;
    margin-top: 3rem;
    margin-bottom: 1rem;
    color: var(--text);
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
    padding-bottom: 5px;
}

/* Categories (Podcasts / Music) */
.page-listening h3 {
    font-family: 'Gill Sans', sans-serif;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--link-visited);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

/* List Items */
.page-listening ul {
    list-style: none;
    padding: 0;
    margin-bottom: 2rem;
}

.page-listening li {
    padding: 0.4rem 0;
    border-bottom: 1px dotted rgba(128, 128, 128, 0.1);
    line-height: 1.5;
}

.page-listening li:last-child {
    border-bottom: none;
}

/* Liner Notes (Details) - Subtle and tucked away */
.page-listening details {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    padding: 10px;
    background: var(--now-bg); /* Reusing your light grey/teal background */
    border-radius: 4px;
    color: var(--text);
}

.page-listening summary {
    cursor: pointer;
    font-weight: bold;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--link-visited);
}

/* The Horizontal Rule */
.page-listening hr {
    border: 0;
    border-top: 1px solid rgba(128, 128, 128, 0.2);
    margin: 3rem 0;
}