/* Lettuce reader theme — system-native typography, light/dark via prefers-color-scheme. */

:root {
    color-scheme: light dark;
    --content-width: 38rem;     /* ~68ch — comfortable measure for long-form prose */
    --header-height: 3.25rem;

    --bg: #ffffff;
    --fg: #1d1d1f;
    --fg-secondary: #4f4f55;    /* AA-comfortable on white */
    --rule: #e3e3e6;
    --accent: #2f6feb;
    --code-bg: #f5f5f7;
    --code-fg: #1d1d1f;
    --mark: #fff3b0;
    --table-stripe: #fafafa;

    --callout-note: #2f6feb;
    --callout-tip: #1aa251;
    --callout-warning: #d98b0b;
    --callout-danger: #e5484d;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1c1c1e;
        --fg: #e8e8ed;
        --fg-secondary: #b3b3ba;
        --rule: #3a3a3d;
        --accent: #5e9bff;
        --code-bg: #2a2a2e;
        --code-fg: #e8e8ed;
        --mark: #5c5320;
        --table-stripe: #232326;
    }
}

html { -webkit-text-size-adjust: 100%; }

body {
    font: 17px/1.65 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
    margin: 0;
    color: var(--fg);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.lettuce-content {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 2.5rem clamp(1rem, 4vw, 2.5rem) 6rem;
}

/* Metadata bar */
.lettuce-meta { margin-bottom: 2rem; }
.lettuce-title {
    font-size: clamp(1.7rem, 1.3rem + 1.6vw, 2.1rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
    margin: 0 0 0.5rem;
}
.lettuce-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.lettuce-tag {
    font-size: 0.8rem;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    padding: 0.1rem 0.5rem;
    border-radius: 0.5rem;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.25;
    letter-spacing: -0.01em;
    margin: 1.5rem 0 0.6rem;
    scroll-margin-top: calc(var(--header-height) + 0.75rem);  /* clear the sticky header */
}
h1 { font-size: 1.7rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }
h5, h6 { font-size: 1rem; color: var(--fg-secondary); }

p { margin: 0.9rem 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Wikilinks */
a.wikilink { color: var(--accent); border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
a.wikilink.unresolved { color: var(--callout-danger); border-bottom-style: dashed; }
.embed-placeholder {
    border: 1px dashed var(--rule);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    color: var(--fg-secondary);
    margin: 1rem 0;
}
img.wikilink-embed, img { max-width: 100%; height: auto; border-radius: 0.4rem; }

/* Lists */
ul, ol { padding-left: 1.5rem; }
li { margin: 0.25rem 0; }
li.task-list-item { list-style: none; margin-left: -1.2rem; }
li.task-list-item input { margin-right: 0.5rem; }

/* Code */
code {
    font-family: "SF Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.88em;
    background: var(--code-bg);
    color: var(--code-fg);
    padding: 0.12em 0.35em;
    border-radius: 0.3rem;
}
pre {
    background: var(--code-bg);
    border-radius: 0.6rem;
    padding: 1rem 1.1rem;
    overflow-x: auto;
    line-height: 1.5;
}
pre code { background: none; padding: 0; font-size: 0.85rem; }

/* Blockquotes */
blockquote {
    margin: 1rem 0;
    padding: 0.2rem 0 0.2rem 1rem;
    border-left: 3px solid var(--rule);
    color: var(--fg-secondary);
}

/* Callouts */
.callout {
    margin: 1.2rem 0;
    border: 1px solid var(--rule);
    border-left: 3px solid var(--callout-note);
    border-radius: 0.5rem;
    background: color-mix(in srgb, var(--callout-note) 7%, var(--bg));
    overflow: hidden;
}
.callout-title {
    font-weight: 600;
    padding: 0.6rem 1rem;
    color: var(--callout-note);
}
.callout-body { padding: 0 1rem 0.6rem; }
.callout-body > :first-child { margin-top: 0; }
.callout-body > :last-child { margin-bottom: 0; }
.callout-tip, .callout-success { border-left-color: var(--callout-tip); background: color-mix(in srgb, var(--callout-tip) 7%, var(--bg)); }
.callout-tip .callout-title, .callout-success .callout-title { color: var(--callout-tip); }
.callout-warning, .callout-caution { border-left-color: var(--callout-warning); background: color-mix(in srgb, var(--callout-warning) 7%, var(--bg)); }
.callout-warning .callout-title, .callout-caution .callout-title { color: var(--callout-warning); }
.callout-danger, .callout-error, .callout-bug { border-left-color: var(--callout-danger); background: color-mix(in srgb, var(--callout-danger) 7%, var(--bg)); }
.callout-danger .callout-title, .callout-error .callout-title, .callout-bug .callout-title { color: var(--callout-danger); }

/* Tables */
table { border-collapse: collapse; width: 100%; margin: 1.2rem 0; font-size: 0.95rem; }
th, td { border: 1px solid var(--rule); padding: 0.45rem 0.7rem; text-align: left; }
thead th { background: var(--code-bg); font-weight: 600; }
tbody tr:nth-child(even) { background: var(--table-stripe); }

hr { border: none; border-top: 1px solid var(--rule); margin: 2rem 0; }

/* Index page: subtle vertical stack of rows with hairline dividers. */
ul.site-index {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0 0;
    border-top: 1px solid var(--rule);
}
ul.site-index li {
    margin: 0;
    border-bottom: 1px solid var(--rule);
}
ul.site-index a {
    display: block;
    padding: 0.85rem 0.25rem;
    font-size: 1.02rem;
    color: var(--fg);
    text-decoration: none;
    transition: background-color 80ms ease;
}
ul.site-index a:hover {
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 6%, transparent);
}

del { color: var(--fg-secondary); }
mark { background: var(--mark); }

/* Mermaid container */
pre.mermaid { background: transparent; text-align: center; }

/* (editor autocomplete + CodeMirror styles live in the editor page, not here) */

/* Footnotes */
sup.footnote-ref { font-size: 0.7em; line-height: 0; }
sup.footnote-ref a { text-decoration: none; padding: 0 0.1em; }
.footnotes { margin-top: 3rem; font-size: 0.9rem; color: var(--fg-secondary); }
.footnotes hr { margin-bottom: 1rem; }
.footnotes li { margin: 0.4rem 0; }
.footnote-backref { text-decoration: none; }

/* Responsive: phones / narrow windows. Tables get horizontal scroll instead of
   overflowing the page, code-block padding tightens, and body font drops a notch. */
@media (max-width: 640px) {
    body { font-size: 16px; line-height: 1.6; }
    .lettuce-content { padding: 1.5rem 1rem 4rem; }
    .lettuce-meta { margin-bottom: 1.25rem; }
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.1rem; }
    table { display: block; overflow-x: auto; max-width: 100%; }
    pre { padding: 0.85rem 0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
    ul.site-index a { transition: none; }
}
