/*
 * Cool Zine - Lighter, more whitespace, blue-gray undertones
 */

:root {
    --paper: #fafafa;
    --paper-dark: #f0f0f0;
    --ink: #2a2a2e;
    --ink-light: #6a6a70;
    --accent: #5a7a9a;
    --accent-light: rgba(90, 122, 154, 0.1);
    --link: #3a5a7a;
    --link-hover: #1a3a5a;
    --code-bg: #f0f0f2;
    --border: #d0d0d5;
}

* {
    box-sizing: border-box;
}

html {
    font-size: 17px;
}

body {
    font-family: 'IBM Plex Mono', 'Courier New', Courier, monospace;
    background-color: var(--paper);
    color: var(--ink);
    line-height: 1.7;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* Reading progress bar */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, var(--accent) 0%, var(--link) 100%);
    z-index: 1000;
    transition: width 0.1s ease-out;
}

/* Top navigation */
.top-nav {
    padding: 0.75rem 2rem;
    border-bottom: 1px solid var(--border);
    background: var(--paper);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.nav-left, .nav-right {
    flex-shrink: 0;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-sep {
    color: var(--border);
    font-size: 0.85rem;
}

.nav-title {
    flex: 1;
    text-align: center;
    font-size: 0.85rem;
    color: var(--ink-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 1rem;
}

.top-nav a {
    color: var(--ink-light);
    text-decoration: none;
    font-size: 0.85rem;
    border-bottom: none;
}

.top-nav a:hover {
    color: var(--ink);
}

.last-modified {
    font-size: 0.75rem;
    color: var(--ink-light);
}

.reading-time {
    font-size: 0.75rem;
    color: var(--ink-light);
    margin-right: 0.75rem;
}

/* Page layout */
.page-wrapper {
    display: block;
}

/* Table of contents in right margin */
.toc {
    position: fixed;
    right: 2rem;
    top: 6rem;
    width: 11rem;
}

.toc .toc-title {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-light);
    margin-bottom: 0.75rem;
}

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

.toc li {
    margin: 0.35rem 0;
}

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

.toc a {
    font-size: 0.75rem;
    color: var(--ink-light);
    text-decoration: none;
    border-bottom: none;
    display: block;
    line-height: 1.4;
}

.toc a:hover {
    color: var(--ink);
}

/* Main content area */
main {
    max-width: 38rem;
    margin: 0 auto;
    padding: 3rem 2rem;
}

article {
    padding: 1rem 0;
    counter-reset: sidenote-counter;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 500;
    margin-top: 2rem;
    margin-bottom: 1rem;
    line-height: 1.3;
}

h1 {
    font-size: 1.6rem;
    margin-top: 0;
    margin-bottom: 2rem;
    color: var(--ink);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}

h2 {
    font-size: 1.1rem;
    margin-top: 3rem;
    color: var(--ink-light);
    border-bottom: none;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

h3 {
    font-size: 1rem;
}

p {
    margin: 1.4rem 0;
    text-align: left;
}

/* Collapsible sections */
.collapsible-section {
    margin: 2rem 0;
    border: none;
}

.collapsible-section summary {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--ink-light);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.collapsible-section summary::-webkit-details-marker {
    display: none;
}

.collapsible-section summary::before {
    content: '▸';
    font-size: 0.8em;
    transition: transform 0.2s;
}

.collapsible-section[open] summary::before {
    transform: rotate(90deg);
}

.collapsible-section summary:hover {
    color: var(--ink);
}

.section-content {
    padding-left: 0;
}

/* Links */
a {
    color: var(--link);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

a:hover {
    color: var(--link-hover);
    border-bottom-color: var(--accent);
    background: var(--accent-light);
}

/* External link indicator */
article a[href^="http"]::after,
article a[href^="https"]::after {
    content: " ↗";
    font-size: 0.7em;
    vertical-align: super;
    color: var(--ink-light);
}

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

li {
    margin: 0.5rem 0;
}

/* Post list (blog index) */
.post-list,
.section-intro ul {
    list-style: none;
    padding-left: 0;
}

.post-list li,
.section-intro li {
    margin: 0.5rem 0;
}

.post-date {
    font-size: 0.85rem;
    color: var(--ink-light);
    font-variant-numeric: tabular-nums;
    margin-right: 0.5rem;
}

.post-count {
    color: var(--ink-light);
    margin-bottom: 2rem;
}

/* Blockquotes */
blockquote {
    margin: 2rem 0;
    padding: 1rem 1.5rem;
    border-left: 3px solid var(--accent);
    background: var(--accent-light);
    color: var(--ink-light);
}

blockquote p {
    margin: 0.5rem 0;
}

/* Tufte-style sidenotes */
.sidenote-checkbox {
    display: none;
}

.sidenote-toggle {
    cursor: pointer;
    color: var(--accent);
}

.sidenote-toggle sup {
    font-size: 0.7em;
    vertical-align: super;
}

.sidenote {
    float: right;
    clear: right;
    margin-right: -14rem;
    width: 12rem;
    margin-top: 0.3rem;
    margin-bottom: 1rem;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--ink-light);
    position: relative;
}

.sidenote::before {
    content: counter(sidenote-counter) ". ";
    counter-increment: sidenote-counter;
    font-weight: 500;
    color: var(--accent);
}

/* Mobile: sidenotes become inline toggles */
@media (max-width: 1100px) {
    .sidenote {
        display: none;
        float: none;
        width: auto;
        margin: 0.5rem 0 0.5rem 1rem;
        padding: 0.5rem;
        background: var(--accent-light);
        border-left: 2px solid var(--accent);
    }

    .sidenote-checkbox:checked + .sidenote {
        display: block;
    }
}

/* Code */
code {
    font-family: 'IBM Plex Mono', 'Courier New', Courier, monospace;
    background: var(--code-bg);
    padding: 0.2rem 0.4rem;
    font-size: 0.85em;
    border-radius: 2px;
}

pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    padding: 1rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    border-radius: 2px;
}

pre code {
    background: none;
    padding: 0;
}

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

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

th {
    background: var(--paper-dark);
}

/* Images */
img {
    max-width: 100%;
    height: auto;
    margin: 1rem 0;
    border: 1px solid var(--border);
}

/* Index page */
.site-header {
    text-align: center;
    padding: 4rem 2rem 2rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.site-header h1 {
    font-size: 1.8rem;
    border: none;
    margin: 0;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    font-weight: 400;
}

.site-subtitle {
    color: var(--ink-light);
    font-size: 0.95rem;
    margin: 0.5rem 0 0;
    font-style: italic;
    text-align: center;
}

.note-count {
    color: var(--ink-light);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.note-count a {
    border-bottom: none;
    text-decoration: underline;
}

/* Letter navigation */
.letter-nav {
    text-align: center;
    padding: 1rem;
    background: var(--paper);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
}

.letter-nav a {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    margin: 0.1rem;
    text-decoration: none;
    color: var(--ink-light);
    border-bottom: none;
}

.letter-nav a:hover {
    color: var(--ink);
    background: var(--paper-dark);
}

/* Index list */
main.index {
    max-width: 50rem;
}

.letter-group {
    margin: 2rem 0;
}

.letter-group h2 {
    font-size: 1.2rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.3rem;
    margin-bottom: 0.5rem;
    text-transform: none;
    letter-spacing: normal;
    color: var(--ink);
}

.letter-group ul {
    list-style: none;
    padding: 0;
    column-count: 2;
    column-gap: 2rem;
}

.letter-group li {
    margin: 0.3rem 0;
    break-inside: avoid;
}

.letter-group a {
    text-decoration: none;
    color: var(--ink);
    border-bottom: none;
}

.letter-group a:hover {
    color: var(--link-hover);
    border-bottom: 1px solid var(--link-hover);
}

/* Recent page */
.month-group {
    margin: 2rem 0;
}

.month-group h2 {
    font-size: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.3rem;
    margin-bottom: 0.5rem;
    color: var(--ink-light);
}

.month-group ul {
    list-style: none;
    padding: 0;
}

.month-group li {
    margin: 0.4rem 0;
    display: flex;
    gap: 1rem;
    align-items: baseline;
}

.month-group .date {
    font-size: 0.8rem;
    color: var(--ink-light);
    min-width: 6rem;
    flex-shrink: 0;
}

.month-group a {
    text-decoration: none;
    color: var(--ink);
    border-bottom: none;
}

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

/* Related notes section */
.related-notes {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.related-notes h2 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-light);
    border: none;
    margin-bottom: 1rem;
}

.related-notes ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
}

.related-notes li {
    margin: 0;
}

.related-notes a {
    color: var(--ink-light);
    text-decoration: none;
    border-bottom: 1px dotted var(--border);
    font-size: 0.9rem;
}

.related-notes a:hover {
    color: var(--ink);
    border-bottom-color: var(--ink);
}

/* Backlinks section */
.backlinks {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.backlinks h2 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-light);
    border: none;
    margin-bottom: 1rem;
}

.backlink-item {
    margin: 1.25rem 0;
}

.backlink-item a {
    font-weight: 500;
    text-decoration: none;
    color: var(--link);
    border-bottom: none;
}

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

.backlink-context {
    margin: 0.5rem 0 0 0;
    font-size: 0.85rem;
    color: var(--ink-light);
    font-style: italic;
    line-height: 1.5;
}

.backlink-context strong {
    color: var(--ink);
    font-style: normal;
    background: rgba(58, 74, 90, 0.1);
    padding: 0 0.2rem;
}

/* Footer */
footer {
    margin-top: 3rem;
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.8rem;
    color: var(--ink-light);
}

.footer-stats {
    margin-bottom: 0.75rem;
    color: var(--ink-light);
}

.footer-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.footer-nav a {
    color: var(--ink-light);
    text-decoration: none;
    border-bottom: none;
}

.footer-nav a:hover {
    color: var(--ink);
}

.footer-nav .nav-sep {
    color: var(--border);
}

/* Link preview tooltip */
.link-preview {
    position: absolute;
    z-index: 1000;
    width: 300px;
    max-width: 90vw;
    padding: 0.75rem 1rem;
    background: var(--paper);
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    font-size: 0.85rem;
    line-height: 1.5;
}

.link-preview strong {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--ink);
}

.link-preview p {
    margin: 0;
    color: var(--ink-light);
    text-align: left;
}

/* 404 page */
.page-404 {
    text-align: center;
    padding: 4rem 2rem;
    max-width: 500px;
    margin: 0 auto;
}

.page-404 h1 {
    font-size: 4rem;
    margin: 0 0 1rem;
    color: var(--ink-light);
    border: none;
}

.page-404 p {
    color: var(--ink-light);
    line-height: 1.8;
}

.nav-404 {
    margin-top: 2rem;
}

/* Responsive - hide TOC when viewport is too narrow */
@media (max-width: 1100px) {
    .toc {
        display: none;
    }
}

@media (max-width: 600px) {
    html {
        font-size: 16px;
    }

    main {
        padding: 1.5rem 1rem;
    }

    .letter-group ul {
        column-count: 1;
    }

    .site-header h1 {
        font-size: 1.5rem;
        letter-spacing: 0.15em;
    }
}

/* Records */
.records-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.record-link {
    display: block;
    border: none;
    transition: transform 0.15s, box-shadow 0.15s;
}

.record-link:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    background: none;
}

.record-thumbnail {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 2px;
}

.record-container {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.record-image-container {
    flex: 0 0 300px;
}

.record-image {
    width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.record-info {
    flex: 1;
    min-width: 200px;
}

.record-info p {
    margin: 0.5rem 0;
}

@media (max-width: 600px) {
    .record-container {
        flex-direction: column;
    }

    .record-image-container {
        flex: none;
        width: 100%;
        max-width: 300px;
    }
}

/* Print styles */
@media print {
    body {
        background: white;
    }

    .top-nav, .letter-nav, footer {
        display: none;
    }

    main {
        max-width: none;
    }
}
