/* ==========================================================================
   site.css — shared design system
   Warm-paper docs aesthetic · IBM Plex Sans/Mono · HMC gold accent
   Themes via [data-theme="light"|"dark"] on <html>.
   ========================================================================== */

/* ---------- Tokens ---------- */

:root {
    color-scheme: light;

    --bg: #faf8f4;
    --surface: #ffffff;
    --surface-2: #f3efe7;
    --text: #211d18;
    --text-soft: #44403a;
    --muted: #756d60;
    --border: #e6dfd2;
    --border-strong: #d2c8b6;

    --accent: #8a6100;
    --accent-strong: #6d4c00;
    --accent-bright: #b28600;
    --accent-soft: rgba(178, 134, 0, 0.12);

    /* Terminal-style code blocks (dark in both themes) */
    --code-bg: #1d1915;
    --code-text: #e8e2d4;
    --code-border: #1d1915;
    --code-comment: #8d8474;
    --code-keyword: #e3b341;
    --code-string: #a5c989;
    --code-number: #e0996a;
    --code-operator: #9fb6c9;
    --code-function: #d8c08a;

    --note-border: #3d6b94;
    --note-bg: #eef3f8;
    --important-border: #b28600;
    --important-bg: #f8efdb;
    --warning-border: #b3402e;
    --warning-bg: #f9ecea;

    --shadow-sm: 0 1px 2px rgba(33, 29, 24, 0.05);
    --shadow-md: 0 3px 12px rgba(33, 29, 24, 0.08);

    --radius: 10px;
    --radius-sm: 6px;

    --font-sans: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
    --font-mono: "IBM Plex Mono", "SF Mono", Consolas, Menlo, monospace;
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #161310;
    --surface: #1e1a16;
    --surface-2: #272219;
    --text: #ede7dc;
    --text-soft: #cfc7b8;
    --muted: #9c9284;
    --border: #3a342b;
    --border-strong: #4d463a;

    --accent: #e3b341;
    --accent-strong: #f0c75e;
    --accent-bright: #e3b341;
    --accent-soft: rgba(227, 179, 65, 0.14);

    --code-bg: #110f0c;
    --code-border: #2c2620;

    --note-border: #6e9cc4;
    --note-bg: rgba(110, 156, 196, 0.12);
    --important-border: #e3b341;
    --important-bg: rgba(227, 179, 65, 0.1);
    --warning-border: #d66a57;
    --warning-bg: rgba(214, 106, 87, 0.12);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 3px 14px rgba(0, 0, 0, 0.4);
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
}

img,
svg,
video {
    max-width: 100%;
    height: auto;
}

h1, h2, h3, h4 {
    font-weight: 600;
    line-height: 1.25;
    color: var(--text);
}

h1 {
    font-size: 2.1rem;
    letter-spacing: -0.02em;
}

a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
    text-underline-offset: 0.18em;
    transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

a:hover {
    color: var(--accent-strong);
    text-decoration-color: currentColor;
}

::selection {
    background: var(--accent-soft);
}

:focus-visible {
    outline: 2px solid var(--accent-bright);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ---------- Inline code & terminal blocks ---------- */

code {
    font-family: var(--font-mono);
    font-size: 0.875em;
}

:not(pre) > code {
    padding: 0.1em 0.35em;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    overflow-wrap: break-word;
}

pre {
    background: var(--code-bg);
    color: var(--code-text);
    border: 1px solid var(--code-border);
    border-radius: var(--radius);
    padding: 0.9rem 1.1rem;
    overflow-x: auto;
    line-height: 1.55;
    font-size: 0.85rem;
    tab-size: 4;
    margin: 0 0 1.1rem;
}

pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
    color: inherit;
    display: block;
    white-space: pre;
}

/* JS-injected wrapper for copy buttons */
.code-block {
    position: relative;
    margin: 0 0 1.1rem;
}

.code-block > pre {
    margin: 0;
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--code-text);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    padding: 0.2rem 0.55rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.code-block:hover .copy-btn,
.copy-btn:focus-visible {
    opacity: 1;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.16);
}

.copy-btn.copied {
    color: var(--code-string);
    border-color: var(--code-string);
    opacity: 1;
}

@media (hover: none) {
    .copy-btn {
        opacity: 0.75;
    }
}

/* Prism token colors (terminal palette, both themes) */
.token.comment { color: var(--code-comment); font-style: italic; }
.token.string { color: var(--code-string); }
.token.keyword,
.token.builtin { color: var(--code-keyword); }
.token.function { color: var(--code-function); }
.token.number { color: var(--code-number); }
.token.operator,
.token.punctuation { color: var(--code-operator); background: none; }
.token.variable,
.token.parameter { color: var(--code-text); }

pre::selection, pre *::selection {
    background: rgba(227, 179, 65, 0.25);
}

/* ---------- Callouts ---------- */

.note,
.important,
.warning {
    border-left: 3px solid;
    border-radius: var(--radius-sm);
    padding: 0.85rem 1.1rem;
    margin: 1.25rem 0;
}

.note > :first-child,
.important > :first-child,
.warning > :first-child {
    margin-top: 0;
}

.note > :last-child,
.important > :last-child,
.warning > :last-child {
    margin-bottom: 0;
}

.note {
    background: var(--note-bg);
    border-left-color: var(--note-border);
}

.important {
    background: var(--important-bg);
    border-left-color: var(--important-border);
}

.warning {
    background: var(--warning-bg);
    border-left-color: var(--warning-border);
}

.callout-title {
    display: block;
    font-weight: 600;
    margin: 0 0 0.35rem;
}

.note .callout-title { color: var(--note-border); }
.important .callout-title { color: var(--important-border); }
.warning .callout-title { color: var(--warning-border); }

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

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.25rem 0;
    font-size: 0.92rem;
}

th, td {
    text-align: left;
    padding: 0.55rem 0.8rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

th {
    font-weight: 600;
    border-bottom: 2px solid var(--border-strong);
}

.table-wrap {
    overflow-x: auto;
    margin: 1.25rem 0;
}

.table-wrap > table {
    margin: 0;
}

/* ---------- Theme toggle ---------- */

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.theme-toggle:hover {
    color: var(--accent);
    border-color: var(--border-strong);
    background: var(--surface);
}

.theme-toggle svg {
    width: 1.05rem;
    height: 1.05rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* show the icon for the mode you would switch to */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Buttons & utility links ---------- */

.home-link {
    margin: 2.5rem 0 0;
}

.home-link a {
    display: inline-block;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-soft);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.9rem;
    transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.home-link a:hover {
    color: var(--accent-strong);
    border-color: var(--accent-bright);
    transform: translateY(-1px);
}

/* ---------- Section eyebrow labels ---------- */

.eyebrow {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 0.9rem;
}

.eyebrow::before {
    content: "";
    width: 1.4rem;
    height: 2px;
    background: var(--accent-bright);
    border-radius: 1px;
}

/* ---------- Link cards ---------- */

.cards {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 0.8rem;
}

.card {
    display: block;
    height: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.95rem 1.15rem;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
    color: inherit;
    border-color: var(--accent-bright);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-title {
    display: block;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.2rem;
}

.card-title::after {
    content: "→";
    display: inline-block;
    margin-left: 0.4rem;
    color: var(--accent-bright);
    transition: transform 0.15s ease;
}

.card:hover .card-title::after {
    transform: translateX(3px);
}

.card-desc {
    display: block;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--muted);
}

/* Featured cards (Projects & Apps) — gold-washed to stand apart */
.card-featured {
    background: linear-gradient(135deg, var(--accent-soft) 0%, var(--surface) 60%);
    border-color: color-mix(in srgb, var(--accent-bright) 45%, var(--border));
}

.card-featured .card-title {
    color: var(--accent-strong);
}

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

/* ---------- Homepage ---------- */

.home-wrap {
    max-width: 880px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 3rem;
}

.site-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    padding-bottom: 1.75rem;
    margin-bottom: 2.25rem;
    border-bottom: 1px solid var(--border);
}

.site-header .tagline {
    margin: 0.4rem 0 0;
    color: var(--muted);
    font-size: 1.02rem;
}

.site-header h1 {
    margin: 0;
    font-size: 2.4rem;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.seal {
    height: 84px;
    width: auto;
    flex: none;
}

[data-theme="dark"] .seal {
    filter: brightness(0.92);
}

.home-section {
    margin-bottom: 2.5rem;
}

.deprecated {
    font-size: 0.85rem;
    color: var(--muted);
}

.deprecated a {
    color: inherit;
}

.site-footer {
    margin-top: 3rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.82rem;
    color: var(--muted);
}

.site-footer a {
    color: inherit;
}

@media (max-width: 640px) {
    .home-wrap {
        padding: 1.75rem 1.1rem 2.5rem;
    }

    .site-header {
        flex-direction: column-reverse;
        align-items: flex-start;
        gap: 1rem;
    }

    .site-header h1 {
        font-size: 1.9rem;
    }

    .header-meta {
        width: 100%;
        justify-content: space-between;
    }

    .seal {
        height: 64px;
    }

    .cards {
        grid-template-columns: 1fr;
    }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
