/* ============================================================
 *  iannjh blog — default.css
 *  A terminal-inspired, zero-JavaScript geek theme
 *  "No JS. No tracking. Just text."
 * ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg:        #0d1117;
    --bg-alt:    #161b22;
    --fg:        #c9d1d9;
    --fg-dim:    #8b949e;
    --accent:    #00ff41;
    --accent2:   #58a6ff;
    --accent3:   #f0883e;
    --border:    #30363d;
    --code-bg:   #0d1117;
    --selection: #264f78;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code',
                 'Source Code Pro', 'Consolas', 'Monaco', monospace;
    --font-sans: 'Inter', 'Noto Sans SC', sans-serif;
    --max-w:     48rem;
}

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

body {
    font-family: var(--font-mono);
    background:  var(--bg);
    color:       var(--fg);
    line-height: 1.75;
    min-height:  100vh;
    display:     flex;
    flex-direction: column;
}

/* selection */
::selection {
    background: var(--selection);
    color:      #fff;
}

/* ---------- Layout ---------- */
#preamble,
#content,
#postamble {
    max-width: var(--max-w);
    margin:    0 auto;
    padding:   0 1.5rem;
    width:     100%;
}

/* ---------- Preamble / Header ---------- */
#preamble {
    padding-top: 2rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

#preamble h1 {
    font-size:   1.1rem;
    font-weight: 400;
    color:       var(--accent);
    letter-spacing: 0;
}

#preamble h1 a {
    color:           var(--accent);
    text-decoration: none;
}

#preamble h1::before {
    content: "$ ";
    color:   var(--fg-dim);
}

/* Navigation */
#preamble nav {
    margin:  0.75rem 0 1rem;
    display: flex;
    gap:     1.5rem;
    flex-wrap: wrap;
}

#preamble nav a {
    color:           var(--accent2);
    text-decoration: none;
    font-size:       0.9rem;
    position:        relative;
}

#preamble nav a::before {
    content: "[";
    color:   var(--fg-dim);
}

#preamble nav a::after {
    content: "]";
    color:   var(--fg-dim);
}

#preamble nav a:hover {
    color: var(--accent);
}

/* ---------- Content ---------- */
#content {
    flex: 1;
    padding-bottom: 3rem;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    color:       var(--accent);
    font-weight: 600;
    margin:      2rem 0 0.75rem;
    line-height: 1.3;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }

h2::before { content: "## "; color: var(--fg-dim); }
h3::before { content: "### "; color: var(--fg-dim); }
h4::before { content: "#### "; color: var(--fg-dim); }

/* Title area (Org exports title as h1.title) */
h1.title {
    font-size:    1.6rem;
    border-bottom: 1px dashed var(--border);
    padding-bottom: 0.5rem;
}

h1.title::before {
    content: "# ";
    color:   var(--fg-dim);
}

/* Date / author meta */
p.date, p.author, .org-info {
    color:     var(--fg-dim);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

p.date::before   { content: "// date: "; }
p.author::before { content: "// author: "; }

/* Paragraphs */
p {
    margin-bottom: 1rem;
}

/* ---------- Links ---------- */
a {
    color:           var(--accent2);
    text-decoration: underline;
    text-underline-offset: 3px;
}

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

/* External link indicator */
a[href^="http"]::after {
    content: " ↗";
    font-size: 0.75em;
    color:   var(--fg-dim);
}

/* ---------- Code ---------- */
code, pre {
    font-family: var(--font-mono);
    background:  var(--code-bg);
    border:      1px solid var(--border);
    border-radius: 4px;
}

code {
    padding:  0.15em 0.4em;
    font-size: 0.9em;
    color:    var(--accent3);
}

pre {
    padding:      1rem 1.25rem;
    margin:       1rem 0 1.5rem;
    overflow-x:   auto;
    line-height:  1.5;
    font-size:    0.875rem;
    position:     relative;
}

pre::before {
    content:     "```";
    display:     block;
    color:       var(--fg-dim);
    margin-bottom: 0.25rem;
    font-size:   0.8rem;
}

pre code {
    border:     none;
    padding:    0;
    background: transparent;
    color:      var(--fg);
}

/* org-src-container */
.org-src-container {
    position:   relative;
    margin:     1rem 0 1.5rem;
}

.org-src-container .src {
    margin: 0;
}

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

li {
    margin-bottom: 0.35rem;
}

ul li::marker {
    color: var(--accent);
    content: "→ ";
}

ol li::marker {
    color: var(--accent2);
}

/* Definition lists */
dl {
    margin: 1rem 0;
}

dt {
    color:       var(--accent);
    font-weight: 600;
    margin-top:  0.75rem;
}

dd {
    margin-left: 1.5rem;
    color:       var(--fg-dim);
}

/* ---------- Blockquotes ---------- */
blockquote {
    border-left:  3px solid var(--accent);
    padding:      0.5rem 1rem;
    margin:       1rem 0 1.5rem;
    background:   var(--bg-alt);
    color:        var(--fg-dim);
    font-style:   italic;
}

blockquote::before {
    content: "> ";
    color:   var(--accent);
}

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

th {
    background:  var(--bg-alt);
    color:       var(--accent);
    text-align:  left;
    padding:     0.5rem 0.75rem;
    border:      1px solid var(--border);
    font-weight: 600;
}

td {
    padding: 0.5rem 0.75rem;
    border:  1px solid var(--border);
}

tr:nth-child(even) td {
    background: var(--bg-alt);
}

/* ---------- Horizontal Rule ---------- */
hr {
    border:        none;
    border-top:    1px dashed var(--border);
    margin:        2rem 0;
    position:      relative;
}

hr::before {
    content:  "/* --- */";
    display:  block;
    color:    var(--fg-dim);
    font-size: 0.8rem;
    position: absolute;
    top:      -0.6rem;
    left:     50%;
    transform: translateX(-50%);
    background: var(--bg);
    padding:   0 0.5rem;
}

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

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

figcaption {
    color:     var(--fg-dim);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* ---------- Tags (Org tag columns) ---------- */
.tag {
    display:     inline-block;
    background:  var(--bg-alt);
    color:       var(--accent3);
    border:      1px solid var(--border);
    padding:     0.1rem 0.5rem;
    border-radius: 3px;
    font-size:   0.8rem;
    margin-right: 0.3rem;
}

/* ---------- TODO / DONE keywords ---------- */
.todo  { color: var(--accent3); font-weight: 600; }
.done  { color: var(--accent);  font-weight: 600; }

/* ---------- Footnotes ---------- */
.footdef sup {
    color: var(--accent2);
}

.footpara {
    color:     var(--fg-dim);
    font-size: 0.9rem;
}

/* ---------- Org Table of Contents ---------- */
#table-of-contents {
    background:  var(--bg-alt);
    border:      1px solid var(--border);
    padding:     1rem 1.5rem;
    margin:      1rem 0 2rem;
    border-radius: 4px;
}

#table-of-contents h2 {
    font-size: 1rem;
    margin-top: 0;
}

#table-of-contents h2::before {
    content: "$ cat ";
    color:   var(--fg-dim);
}

#table-of-contents ul {
    list-style: none;
    margin-left: 1rem;
}

#table-of-contents ul li::marker {
    content: "";
}

#table-of-contents a {
    text-decoration: none;
}

/* ---------- Postamble / Footer ---------- */
#postamble {
    border-top:  1px solid var(--border);
    margin-top:  2rem;
    padding:     1.5rem;
    color:       var(--fg-dim);
    font-size:   0.8rem;
    text-align:  center;
}

#postamble p {
    margin-bottom: 0.4rem;
}

#postamble a {
    color: var(--accent2);
}

/* ---------- ASCII Banner (for index) ---------- */
.ascii-banner {
    color:       var(--accent);
    font-size:   0.7rem;
    line-height: 1.2;
    white-space: pre;
    overflow-x:  auto;
    margin:      1rem 0 1.5rem;
    user-select: none;
}

/* ---------- Post list (for blog index) ---------- */
.post-list {
    list-style: none;
    margin:     1rem 0;
    padding:    0;
}

.post-list li {
    padding:       0.6rem 0;
    border-bottom: 1px dashed var(--border);
    display:       flex;
    justify-content: space-between;
    align-items:   baseline;
    gap:           1rem;
}

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

.post-list .post-date {
    color:     var(--fg-dim);
    font-size: 0.85rem;
    white-space: nowrap;
}

/* ---------- Cursor blink (CSS only, no JS!) ---------- */
.cursor-blink::after {
    content:        "█";
    color:          var(--accent);
    animation:      blink 1s step-end infinite;
}

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

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
    html { font-size: 14px; }

    #preamble,
    #content,
    #postamble {
        padding-left:  1rem;
        padding-right: 1rem;
    }

    .ascii-banner {
        font-size: 0.45rem;
    }

    .post-list li {
        flex-direction: column;
        gap: 0.2rem;
    }
}

/* ---------- Scrollbar (Webkit) ---------- */
::-webkit-scrollbar {
    width:  8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background:    var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--fg-dim);
}

/* ---------- Print ---------- */
@media print {
    body {
        background: #fff;
        color:      #000;
    }

    a { color: #000; text-decoration: underline; }
    pre, code { border-color: #ccc; }
    #preamble nav { display: none; }
}
