/* File: static/css/style.css */

/*
  ═══════════════════════════════════════════════════════════════
  ITCSS Architecture:
  - Settings:    CSS variables and theme definitions
  - Generic:     Low-specificity, far-reaching styles
  - Elements:    Unclassed HTML elements
  - Objects:     Design patterns and layout primitives
  - Components:  Specific UI components
  - Vendor:      Third-party styles (Prism)
  - Responsive:  Media queries and breakpoints
  ═══════════════════════════════════════════════════════════════
*/

/*
  ═══════════════════════════════════════════════════════════════
  SETTINGS - CSS Custom Properties
  ═══════════════════════════════════════════════════════════════
*/

/*
  ─ Light (default) ───────────────
*/
:root {
    --border-radius: 0.3rem;
    --line-height: 1.6rem;
    --bg-accent: #e0e0e0;
    --bg-primary: #fff;
    --bg-secondary: #f6f6f6;
    --border-light: #dcdcdc;
    --link-hover: #000;
    --link-primary: #212529;
    --link-visited: #4a235a;
    --text-primary: #212121;
    --text-secondary: #333;
    --prism-bg: #fff;
    --prism-comment: #2b2b2b;
    --prism-function: #5c2bc1;
    --prism-keyword: #d73a49;
    --prism-property: #06c;
    --prism-punctuation: #444;
    --prism-selector: #22863a;
    --prism-text: #2b2b2b;
    --prism-variable: #b08800;
}

/*
  ─ Dark (auto) ───────────────────
*/
@media (prefers-color-scheme: dark) {
    :root {
        --bg-accent: #2c2c2c;
        --bg-primary: #121212;
        --bg-secondary: #1f1f1f;
        --border-light: #333;
        --link-hover: #fff;
        --link-primary: #cfcfcf;
        --link-visited: #6f42c1;
        --text-primary: #e0e0e0;
        --text-secondary: #b0b0b0;
        --prism-bg: #1b1b1b;
        --prism-comment: #707a80;
        --prism-function: #f5c477;
        --prism-keyword: #7ab4ff;
        --prism-property: #88e2eb;
        --prism-punctuation: #b0b7ba;
        --prism-selector: #79d26e;
        --prism-text: #e2e4e5;
        --prism-variable: #d8b38e;
    }
}

/*
  ─ Light (manual) ────────────────
*/
[data-theme='light'] {
    --bg-accent: #e0e0e0;
    --bg-primary: #fff;
    --bg-secondary: #f6f6f6;
    --border-light: #dcdcdc;
    --link-hover: #000;
    --link-primary: #212529;
    --link-visited: #4a235a;
    --text-primary: #212121;
    --text-secondary: #333;
    --prism-bg: #fff;
    --prism-comment: #2b2b2b;
    --prism-function: #5c2bc1;
    --prism-keyword: #d73a49;
    --prism-property: #06c;
    --prism-punctuation: #444;
    --prism-selector: #22863a;
    --prism-text: #2b2b2b;
    --prism-variable: #b08800;
}

/*
  ─ Dark (manual) ─────────────────
*/
[data-theme='dark'] {
    --bg-accent: #2c2c2c;
    --bg-primary: #121212;
    --bg-secondary: #1f1f1f;
    --border-light: #333;
    --link-hover: #fff;
    --link-primary: #cfcfcf;
    --link-visited: #6f42c1;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --prism-bg: #1b1b1b;
    --prism-comment: #707a80;
    --prism-function: #f5c477;
    --prism-keyword: #7ab4ff;
    --prism-property: #88e2eb;
    --prism-punctuation: #b0b7ba;
    --prism-selector: #79d26e;
    --prism-text: #e2e4e5;
    --prism-variable: #d8b38e;
}

/*
  ─ Forest ────────────────────────
*/
[data-theme='forest'] {
    --bg-accent: #2c3a32;
    --bg-primary: #121a16;
    --bg-secondary: #1c2620;
    --border-light: #324238;
    --link-hover: #ecf7f0;
    --link-primary: #9fd6b6;
    --link-visited: #7fb59a;
    --text-primary: #e2f0e7;
    --text-secondary: #b9d0c3;
    --prism-bg: #163226;
    --prism-comment: #7fa892;
    --prism-function: #e2cc88;
    --prism-keyword: #82bdf0;
    --prism-property: #6fead8;
    --prism-punctuation: #9ac5ab;
    --prism-selector: #8fe287;
    --prism-text: #dff1e1;
    --prism-variable: #deb37f;
}

/*
  ─ Ocean ─────────────────────────
*/
[data-theme='ocean'] {
    --bg-accent: #203744;
    --bg-primary: #0f1820;
    --bg-secondary: #172733;
    --border-light: #2c4554;
    --link-hover: #eef7ff;
    --link-primary: #8fcfe6;
    --link-visited: #6ea6c9;
    --text-primary: #deeff8;
    --text-secondary: #aacbda;
    --prism-bg: #0b2232;
    --prism-comment: #6f9bb6;
    --prism-function: #edd98a;
    --prism-keyword: #7fbaff;
    --prism-property: #5ee6ff;
    --prism-punctuation: #8fb6cf;
    --prism-selector: #7eeec5;
    --prism-text: #dcebf4;
    --prism-variable: #cbb78a;
}

/*
  ─ Amber ─────────────────────────
*/
[data-theme='amber'] {
    --bg-accent: #3a2c16;
    --bg-primary: #171308;
    --bg-secondary: #261d0d;
    --border-light: #4a3a1c;
    --link-hover: #fff4d4;
    --link-primary: #f0c06d;
    --link-visited: #d3a03d;
    --text-primary: #f5ead0;
    --text-secondary: #d2c3a0;
    --prism-bg: #221b0a;
    --prism-comment: #9f9366;
    --prism-function: #f0cd7e;
    --prism-keyword: #ffba52;
    --prism-property: #ffd98a;
    --prism-punctuation: #bfb089;
    --prism-selector: #e2cd63;
    --prism-text: #f4ead2;
    --prism-variable: #e0bc88;
}

/*
  ─ Amethyst ──────────────────────
*/
[data-theme='amethyst'] {
    --bg-accent: #2f253a;
    --bg-primary: #140f18;
    --bg-secondary: #221a2a;
    --border-light: #44345a;
    --link-hover: #f6edff;
    --link-primary: #caaaf0;
    --link-visited: #ab86e3;
    --text-primary: #ece4f7;
    --text-secondary: #c7b9db;
    --prism-bg: #1d1032;
    --prism-comment: #937fb3;
    --prism-function: #f0cd82;
    --prism-keyword: #aebaff;
    --prism-property: #d29bff;
    --prism-punctuation: #c6aedf;
    --prism-selector: #9ff5d6;
    --prism-text: #eee1ff;
    --prism-variable: #daf;
}

/*
  ═══════════════════════════════════════════════════════════════
  GENERIC - Low-specificity base styles
  ═══════════════════════════════════════════════════════════════
*/

html {
    line-height: var(--line-height);
    text-size-adjust: 100%;
}

/*
  ═══════════════════════════════════════════════════════════════
  ELEMENTS - Unclassed HTML elements
  ═══════════════════════════════════════════════════════════════
*/

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        'Segoe UI',
        Roboto,
        Oxygen,
        Ubuntu,
        Cantarell,
        'Open Sans',
        'Helvetica Neue',
        sans-serif;
    margin: 0 auto;
    max-width: 48rem;
    text-wrap: pretty;
}

::selection {
    background-color: var(--bg-accent);
    color: var(--text-primary);
}

/*
  ─ Headings ──────────────────────
*/

h1,
h2,
h3,
h4,
h5,
h6 {
    border-bottom: 0.1rem solid var(--bg-secondary);
    font-weight: bold;
    line-height: 2rem;
    margin-bottom: 0;
    margin-top: 3rem;
    padding-bottom: 0.1rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.4;
    margin-top: 2rem;
}

/*
  ─ Paragraphs ────────────────────
*/

p,
article li,
blockquote {
    margin-bottom: 1.6rem;
    color: var(--text-secondary);
}

p {
    margin-top: 0.7rem;
}

strong {
    font-weight: bold;
}

/*
  ─ Lists ─────────────────────────
*/

ul {
    margin-left: 0.5rem;
}

ol {
    margin-left: 0.5rem;
}

/*
  ─ Images ────────────────────────
*/

img {
    display: block;
    height: auto;
    max-width: 100%;
}

figure {
    display: block;
    margin: 1.5em auto;
}

figcaption {
    color: var(--text-secondary);
    font-size: 0.9em;
    font-style: italic;
    margin-top: 0.5em;
    text-align: center;
}

/*
  ─ Code ──────────────────────────
*/

code,
pre {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 0.1rem solid var(--border-light);
    font-family: 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.9em;
}

code {
    overflow-wrap: break-word;
    padding: 0.2em 0.4em;
}

pre {
    line-height: var(--line-height);
    margin: 1.5em 0;
    overflow-x: auto;
    padding: 1em;
}

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

/*
  ─ Blockquotes ───────────────────
*/

blockquote {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-style: italic;
    margin: 1.25em 0;
    padding: 1em;
}

blockquote p {
    margin: 0;
}

blockquote h2 {
    margin-top: 0;
}

.permalink {
    opacity: 0.1;
    text-decoration: none;
    user-select: none;
}

blockquote .permalink {
    display: none;
}

.permalink:hover {
    opacity: 1;
}

/*
  ─ Tables ────────────────────────
*/

table {
    border-collapse: collapse;
    display: block;
    margin: 1.5em 0;
    overflow-x: auto;
    width: 100%;
}

th,
td {
    border: 0.1rem solid var(--border-light);
    padding: 0.75em;
    text-align: left;
}

th {
    background: var(--bg-secondary);
    font-weight: normal;
}

td {
    overflow-wrap: break-word;
}

/*
  ─ Links ─────────────────────────
*/

a {
    color: var(--link-primary);
    text-decoration: underline dotted;
    text-underline-offset: 0.1em;
}

/* Component link overrides (element-only selectors, specificity 0,0,2) */
footer a {
    text-decoration: underline;
}

/* Pseudo-class selectors (specificity 0,1,1) */
a:hover,
a:focus {
    background: var(--bg-secondary);
    color: var(--link-hover);
}

a:focus-visible {
    outline: 0.2rem solid var(--link-primary);
    outline-offset: 0.2rem;
}

/* Class-based selectors (specificity 0,1,1) */
.breadcrumbs a {
    color: var(--link-primary);
}

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

.tag-cloud a {
    text-decoration: none;
}

.index-layout a {
    text-decoration: none;
}

/* Element with pseudo-class (specificity 0,0,2,1) */
a:visited {
    color: var(--link-primary);
}

article p a:visited {
    color: var(--link-visited);
}

/* Higher specificity overrides */
header li a:hover {
    border: 0.1rem solid var(--text-secondary);
}

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

.breadcrumbs a:visited {
    color: var(--link-primary);
}

/*
  ═══════════════════════════════════════════════════════════════
  OBJECTS - Design patterns and layout primitives
  ═══════════════════════════════════════════════════════════════
*/

.grid-container {
    display: grid;
    gap: 0;
}

.grid-two-column {
    grid-template-columns: auto auto;
}

.grid-three-column {
    grid-template-columns: auto auto auto;
}

.grid-header {
    font-weight: bold;
}

.grid-cell,
.grid-header {
    align-items: center;
    border-bottom: 0.1rem solid var(--border-light);
    display: flex;
    padding: 0.25rem;
}

.grid-cell {
    box-sizing: border-box;
    min-height: 2.5rem;
}

.grid-row,
.grid-header-row {
    display: contents;
}

.grid-container .grid-row:nth-of-type(odd) .grid-cell {
    background: var(--bg-secondary);
}

/*
  ═══════════════════════════════════════════════════════════════
  COMPONENTS - Specific UI components
  ═══════════════════════════════════════════════════════════════
*/

/*
  ─ Accessibility ─────────────────
*/

/* Screen-reader helper */
.sr-only {
    border-width: 0;
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

/* Skip link */
.skip-link {
    background: var(--bg-primary);
    border: 2px solid var(--link-primary);
    color: var(--link-primary);
    font-weight: bold;
    left: 50%;
    padding: var(--padding-normal);
    position: absolute;
    text-decoration: none;
    top: -200px;
    transform: translateX(-50%);
    z-index: 1000;
}

.skip-link:focus {
    top: 1rem;
}

/*
  ─ Breadcrumbs ───────────────────
*/

.breadcrumbs {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    line-height: 2rem;
    margin-left: 1rem;
    margin-right: 1rem;
}

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

.breadcrumbs li {
    display: inline;
}

.breadcrumbs li:not(:last-child)::after {
    content: ' ▸ ';
}

/*
  ─ Navigation ────────────────────
*/

#navigation {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    line-height: 2rem;
    list-style: none;
    margin: 2rem auto 1rem;
    padding: 0;
}

#navigation li a {
    border-radius: var(--border-radius);
    border: 0.1rem solid var(--link-primary);
    display: block;
    font-weight: bold;
    padding: 0 0.4rem;
    text-decoration: none;
}

#navigation li a:hover {
    background-color: var(--bg-secondary);
}

#navigation li a:active {
    box-shadow: none;
}

#navigation li a.active {
    color: var(--link-hover);
}

/*
  ─ Frontmatter ───────────────────
*/

.frontmatter dt {
    color: var(--text-primary);
    font-weight: bold;
}

.frontmatter dd {
    margin: 0 0 0.5em 1.5em;
}

/*
  ─ Frontmatter (grid) ────────────
*/

.frontmatter-grid dl {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    display: grid;
    gap: 0.25rem 1rem;
    grid-template-columns: max-content 1fr;
    padding: 1rem;
}

.frontmatter-grid dt {
    font-weight: bold;
    color: var(--text-primary);
}

.frontmatter-grid dd {
    margin: 0;
    color: var(--text-secondary);
}

.frontmatter-grid dd:last-child {
    padding-bottom: 0;
}

/*
  ─ Table of contents ─────────────
*/

.table-of-contents {
    background-color: var(--bg-secondary);
    border-bottom: 0;
    border-radius: var(--border-radius);
}

summary::marker {
    color: var(--link-primary);
}

.table-of-contents-header {
    color: var(--text-primary);
    cursor: pointer;
    font-weight: bold;
    padding: 1rem;
}

.table-of-contents details > ul {
    overflow: hidden;
}

.table-of-contents details[open] > ul {
    margin: 0;
}

.table-of-contents details[open] ul {
    margin-left: 1rem;
}

.toc-close-item {
    list-style: none;
    text-align: center;
}

.toc-close {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    border: 0.1rem solid var(--link-primary);
    color: var(--text-primary);
    cursor: pointer;
    font-weight: bold;
    margin: 1rem 0;
    padding: 0.6rem 0.8rem;
}

.toc-close:hover,
.toc-close:focus {
    background-color: var(--border-light);
    border: 0.1rem solid var(--link-primary);
}

/* Fix for pages *without* a close button */
.table-of-contents details[open]:not(:has(.toc-close-item)) {
    padding-bottom: 1rem;
}

/*
  ─ Tag cloud ─────────────────────
*/

.tag-cloud {
    line-height: 3.5rem;
}

/*
  ─ Search ────────────────────────
*/

.search-noscript {
    background: var(--bg-secondary);
    border: 0.1rem solid var(--border-light);
    margin: 1rem 0;
    padding: 1rem;
}

#search-interface {
    display: none;
}

.search-label {
    display: block;
    font-weight: bold;
    margin-bottom: 0.5rem;
    padding: 0.2rem;
}

#search-input {
    background: var(--bg-primary);
    border: 0.1rem solid var(--border-light);
    box-sizing: border-box;
    color: var(--text-primary);
    font-size: 1rem;
    padding: 0.75rem;
    width: 100%;
}

#search-status {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

#search-results {
    margin-top: 2rem;
}

.search-results-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.search-result-title {
    font-size: 1.2rem;
    font-weight: bold;
    text-decoration: underline;
}

/*
  ─ Header ────────────────────────
*/

header {
    text-align: center;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: var(--line-height);
    margin: 0 0 1rem;
}

header h1 {
    border: none;
    font-size: 1.6rem;
    line-height: var(--line-height);
    margin: 0 0 0.5rem;
}

header .logo {
    filter: drop-shadow(0 10rem 0 var(--text-primary));
    transform: translateY(-10rem);
}

header .logo-link {
    display: block;
    margin: 0 auto;
    max-width: 40%;
}

/*
  ─ Footer ────────────────────────
*/

#footer {
    color: var(--text-secondary);
    margin: 1rem 0 7rem;
    text-align: center;
}

footer p {
    margin: 0;
}

/*
  ─ Main content ──────────────────
*/

main {
    margin-bottom: 2rem;
}

main img {
    margin: 1.5rem auto 0.5rem;
}

main p:last-child {
    margin-bottom: 0;
}

/*
  ─ Article ───────────────────────
*/

article {
    font-family: Helvetica, Arial, sans-serif;
    font-size: 1.1em;
    font-weight: 200;
    line-height: 2.3rem;
    padding-bottom: 2rem;
}

/*
  ─ Permalink ─────────────────────
*/

/* Position permalink-before in left margin */
.permalink-before {
    margin-left: -1em;
    position: absolute;
}

/* Permalink-after stays inline (no special positioning needed) */
.permalink-after {
    margin-left: 0;
}

/* Permalink is the heading text itself */
.permalink-heading-text {
    opacity: 1;
}

/*
  ─ Back to top ───────────────────
*/

.back-to-top {
    display: block;
    float: right;
    margin-top: 1.5rem;
}

/*
  ─ External link icon ────────────
*/

/* License: MIT. Made by halfmage: https://github.com/halfmage/pixelarticons */
a.external-link::after {
    -webkit-mask-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iODAwcHgiIGhlaWdodD0iODAwcHgiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICAgIDxwYXRoIGQ9Ik0yMSAxMVYzaC04djJoNHYyaC0ydjJoLTJ2MmgtMnYySDl2Mmgydi0yaDJ2LTJoMlY5aDJWN2gydjRoMnpNMTEgNUgzdjE2aDE2di04aC0ydjZINVY3aDZWNXoiIGZpbGw9IiMwMDAwMDAiLz4KPC9zdmc+');
    -webkit-mask-size: 100% 100%;
    background-color: currentcolor;
    content: '';
    display: inline-block;
    height: 1em;
    margin-left: 0.25em;
    mask-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iODAwcHgiIGhlaWdodD0iODAwcHgiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICAgIDxwYXRoIGQ9Ik0yMSAxMVYzaC04djJoNHYyaC0ydjJoLTJ2MmgtMnYySDl2Mmgydi0yaDJ2LTJoMlY5aDJWN2gydjRoMnpNMTEgNUgzdjE2aDE2di04aC0ydjZINVY3aDZWNXoiIGZpbGw9IiMwMDAwMDAiLz4KPC9zdmc+');
    mask-size: 100% 100%;
    vertical-align: middle;
    width: 1em;
}

/*
  ─ Layout caption ────────────────
*/

.layout-caption {
    font-size: 1.1em;
    font-weight: bold;
    margin: 1em 0 0.25em;
    text-align: left;
}

/*
  ═══════════════════════════════════════════════════════════════
  VENDOR - Third-party styles
  ═══════════════════════════════════════════════════════════════
*/

/*
  ─ Prism syntax highlighting ─────
*/

code[class*='language-'],
pre[class*='language-'] {
    -moz-hyphens: none;
    -moz-tab-size: 4;
    -ms-hyphens: none;
    -o-tab-size: 4;
    -webkit-hyphens: none;
    color: var(--prism-text);
    font-weight: 300;
    hyphens: none;
    line-height: 1.5;
    tab-size: 4;
    text-align: left;
    white-space: pre;
    word-break: normal;
    word-spacing: normal;
    overflow-wrap: normal;
}

/* Code blocks with language specified */
pre[class*='language-'] {
    background: var(--prism-bg);
}

/* Prism tokens */
.token.cdata,
.token.comment,
.token.doctype,
.token.prolog {
    color: var(--prism-comment);
}

.token.class-name,
.token.function {
    color: var(--prism-function);
}

.token.atrule,
.token.attr-value,
.token.keyword {
    color: var(--prism-keyword);
}

.token.boolean,
.token.constant,
.token.deleted,
.token.number,
.token.property,
.token.symbol,
.token.tag {
    color: var(--prism-property);
}

.token.punctuation {
    color: var(--prism-punctuation);
}

.token.attr-name,
.token.builtin,
.token.char,
.token.inserted,
.token.selector,
.token.string,
.token.url {
    color: var(--prism-selector);
}

.token.important,
.token.regex,
.token.variable {
    color: var(--prism-variable);
}

.token.bold,
.token.important {
    font-weight: inherit;
}

.token.entity {
    cursor: help;
}

.token.italic {
    font-style: italic;
}

.token.namespace {
    opacity: 0.7;
}

/*
  ═══════════════════════════════════════════════════════════════
  RESPONSIVE - Media queries and breakpoints
  ═══════════════════════════════════════════════════════════════
*/

@media (width <=600px) {
    body {
        font-size: 1rem;
        padding: 0 1rem;
    }

    #navigation {
        gap: 0.5rem;
    }

    #navigation li a {
        font-size: 1rem;
        padding: 0.3rem 0.8rem;
    }

    header {
        padding-top: 1.5rem;
    }

    main {
        padding: 0.5rem 0;
    }

    header .logo-link {
        max-width: 50%;
    }

    .frontmatter-grid dl {
        grid-template-columns: 1fr;
    }

    .layout-caption {
        margin: 1.5rem 0 1rem;
    }

    /* Reset permalink to inline on mobile - no left margin available */
    .permalink-before {
        margin-left: auto;
        padding-right: 0.1rem;
        position: static;
    }

    .grid-cell {
        min-height: 3rem;
        padding: 0.75rem 0.25rem;
    }
}

@media (width >=601px) {
    body {
        font-size: 1rem;
        padding: 0 2.5rem;
    }

    header {
        padding-top: 2rem;
    }
}
