/* nikhilsinghal.com / library */
/* Shared styles for the library hub, topic landings, and individual documents. */
/* Inherits palette and typography from the home page; adds library-specific patterns. */

:root {
    --ink: #1c1917;
    --paper: #faf9f7;
    --accent: #92400e;
    --accent-light: #b45309;
    --accent-soft: #fef3c7;
    --muted: #78716c;
    --rule: #e7e5e4;
    --card: #ffffff;
    --card-border: #f5f5f4;
    --code-bg: #f5f5f4;
    --code-ink: #44403c;
    --callout-bg: #fffbeb;
    --callout-border: #fcd34d;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 17px; scroll-behavior: smooth; }

body {
    font-family: 'DM Sans', -apple-system, sans-serif;
    background: var(--paper);
    color: var(--ink);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

/* ---- Layout ---- */

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 2rem;
}

.container--prose {
    max-width: 720px;
}

/* ---- Breadcrumb ---- */

.breadcrumb {
    padding: 1.5rem 0;
    font-size: 0.8rem;
    color: var(--muted);
}

.breadcrumb a {
    color: var(--muted);
    text-decoration: none;
}

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

.breadcrumb .sep {
    margin: 0 0.5rem;
}

/* ---- Hero header (hub and topic landings) ---- */

.hero {
    padding: 1rem 0 3rem;
    border-bottom: 1px solid var(--rule);
}

.hero .label {
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.hero h1 {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 600;
    font-size: 2.4rem;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--ink);
}

.hero .lead {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.1rem;
    line-height: 1.7;
    color: var(--ink);
    margin-top: 1.5rem;
}

/* ---- Group sections (hub landing) ---- */

.group {
    padding: 2.5rem 0;
    border-bottom: 1px solid var(--rule);
}

.group:last-of-type {
    border-bottom: none;
}

.group h2 {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 600;
    font-size: 1.3rem;
    margin-bottom: 0.3rem;
    color: var(--ink);
}

.group .group-intro {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 1.5rem;
}

/* ---- Topic cards ---- */

.topic-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.topic-card {
    display: block;
    padding: 1.1rem 1.2rem;
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, transform 0.1s;
}

.topic-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.topic-card h3 {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--accent);
    margin-bottom: 0.3rem;
}

.topic-card .desc {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.55;
    margin-bottom: 0.5rem;
}

.topic-card .meta {
    font-size: 0.75rem;
    color: var(--muted);
    letter-spacing: 0.03em;
}

/* Placeholder cards for topics not yet written */
.topic-card--empty {
    background: transparent;
    border-style: dashed;
    border-color: var(--rule);
    cursor: default;
}

.topic-card--empty:hover {
    border-color: var(--rule);
    transform: none;
}

.topic-card--empty h3 {
    color: var(--muted);
}

.badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--card-border);
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
}

/* ---- Role tag (Dossier, Landscape, Plan, etc.) ---- */

.role-tag {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--card-border);
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
}

/* ---- Doc list (topic landings) ---- */

.doc-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.doc-card {
    display: block;
    padding: 1.2rem 1.3rem;
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s;
}

.doc-card:hover {
    border-color: var(--accent);
}

.doc-card-head {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
}

.doc-card h3 {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--accent);
}

.doc-card .desc {
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.65;
}

.doc-card .meta {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.5rem;
}

/* ---- Dossier layout (with TOC sidebar on wide screens) ---- */

.dossier-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 2rem;
}

@media (min-width: 1024px) {
    .dossier-layout {
        grid-template-columns: minmax(0, 1fr) 220px;
    }
}

.dossier-content {
    min-width: 0;
}

/* ---- TOC ---- */

.toc {
    font-size: 0.85rem;
}

.toc h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

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

.toc li {
    line-height: 1.4;
}

.toc li.toc-sub {
    margin-left: 1rem;
    font-size: 0.8rem;
}

.toc a {
    color: var(--ink);
    text-decoration: none;
    display: block;
    padding: 0.4rem 0;
    min-height: 24px;
}

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

@media (min-width: 1024px) {
    .toc-sticky {
        position: sticky;
        top: 2rem;
        max-height: calc(100vh - 4rem);
        overflow-y: auto;
        padding-top: 1rem;
    }
}

/* ---- Prose (dossier body) ---- */

.prose {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.05rem;
    line-height: 1.75;
    color: var(--ink);
}

.prose h2 {
    font-weight: 600;
    font-size: 1.6rem;
    margin: 3rem 0 1rem;
    letter-spacing: -0.01em;
    scroll-margin-top: 2rem;
}

.prose h3 {
    font-weight: 600;
    font-size: 1.2rem;
    margin: 2rem 0 0.7rem;
    scroll-margin-top: 2rem;
}

.prose h4 {
    font-weight: 600;
    font-size: 1.05rem;
    margin: 1.5rem 0 0.5rem;
}

.prose p {
    margin-bottom: 1rem;
}

.prose ul, .prose ol {
    margin: 0 0 1rem 1.5rem;
}

.prose li {
    margin-bottom: 0.3rem;
}

.prose a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

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

.prose blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    margin: 1.5rem 0;
    color: var(--muted);
    font-style: italic;
}

.prose strong {
    color: var(--ink);
    font-weight: 600;
}

/* ---- Code ---- */

.prose code {
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.9em;
    background: var(--code-bg);
    color: var(--code-ink);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
}

.prose pre {
    background: var(--code-bg);
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 1rem 1.2rem;
    margin: 1.5rem 0;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.55;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
}

.prose pre code {
    background: transparent;
    padding: 0;
    color: var(--ink);
    font-size: inherit;
}

/* ---- Tables ---- */

.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
}

.prose th {
    text-align: left;
    font-weight: 600;
    padding: 0.6rem 0.8rem;
    border-bottom: 2px solid var(--rule);
    background: var(--card);
}

.prose td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--rule);
    vertical-align: top;
}

.prose tr:last-child td {
    border-bottom: none;
}

/* ---- Diagrams (inline SVG, optional caption) ---- */

.figure {
    margin: 2rem 0;
    text-align: center;
}

.figure svg {
    max-width: 100%;
    height: auto;
}

.figure .caption {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.6rem;
    text-align: center;
}

/* ---- Callout (asides for important notes) ---- */

.callout {
    background: var(--callout-bg);
    border-left: 3px solid var(--callout-border);
    padding: 1rem 1.2rem;
    margin: 1.5rem 0;
    border-radius: 0 4px 4px 0;
    font-size: 0.95rem;
    font-family: 'DM Sans', sans-serif;
    line-height: 1.65;
}

.callout .callout-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.3rem;
}

/* ---- Per-doc footer ---- */

.doc-footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--rule);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
}

.doc-footer .siblings {
    margin-bottom: 1.5rem;
}

.doc-footer .siblings-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.doc-footer .siblings ul {
    list-style: none;
    padding-left: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.doc-footer .siblings a {
    color: var(--ink);
    text-decoration: none;
}

.doc-footer .siblings a:hover {
    color: var(--accent);
}

.doc-footer .nav-links {
    display: flex;
    gap: 1.5rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.doc-footer .nav-links a {
    color: var(--muted);
    text-decoration: none;
}

.doc-footer .nav-links a:hover {
    color: var(--accent);
}

/* ---- Page footer (small) ---- */

.page-footer {
    padding: 3rem 0 4rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 4rem;
}

.page-footer a {
    color: var(--muted);
    text-decoration: none;
}

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

/* ---- Responsive ---- */

@media (max-width: 600px) {
    html { font-size: 16px; }
    .container { padding: 0 1.25rem; }
    .hero { padding: 0.5rem 0 2rem; }
    .hero h1 { font-size: 1.9rem; }
    .topic-list { grid-template-columns: 1fr; }
    .dossier-layout { padding: 0 1.25rem; }
}

/* ---- Print ---- */

@media print {
    body { background: white; }
    .toc, .breadcrumb, .doc-footer .nav-links { display: none; }
    .container, .dossier-layout { max-width: none; }
}
