/* ==========================================================================
   Andrew Sarafa: personal site theme
   Palette: Sanzo Wada combination 255 (raw sienna, pyrite yellow, calamine
   blue, black) on cream. Flat color only.
   Type: Archivo (display + UI), Courier Prime (meta), Newsreader (long reads).
   ========================================================================== */

/* ---- Tokens: Light ---- */
:root {
    /* Brand palette: Wada 255 (hex from Matt DesLauriers's digitization) */
    --sienna: #bb7125;
    --pyrite: #cab356;
    --calamine: #78cdd0;
    --black: #111314;
    --cream: #f4efe4;               /* neutral paper, not from the combination */
    --sienna-deep: #8c551c;         /* sienna deepened for text: 5.3:1 on cream */

    /* Roles */
    --bg: var(--cream);
    --surface: #ebe5d6;
    --ink: var(--black);
    --text: #26282a;
    --muted: #4a4b50;               /* 7.6:1 on cream */
    --line: #ddd5c3;
    --accent: var(--sienna-deep);   /* 5.3:1 on cream, 4.9:1 on surface */
    --edge: var(--pyrite);          /* blockquote edge */
    --focus: var(--sienna-deep);
    --meta: var(--sienna-deep);     /* dates and years: 5.3:1 on cream */
    --invite: #dcece9;              /* subscribe box: calamine tint; ink 15.3:1, accent 5.0:1 */
    --key-face: #e6dcc6;            /* beige keycap; ink label 13.7:1 */

    /* Stripes */
    --s1: var(--black);
    --s2: var(--pyrite);
    --s3: var(--calamine);
    --s4: var(--sienna);

    --font-display: var(--gh-font-heading, "Archivo", "Helvetica Neue", Arial, sans-serif);
    --font-ui: "Archivo", "Helvetica Neue", Arial, sans-serif;
    --font-meta: "Courier Prime", "Courier New", ui-monospace, monospace;
    --font-read: var(--gh-font-body, "Newsreader", "Iowan Old Style", Georgia, serif);

    --measure: 680px;
    --wide: 1000px;
    --gutter: 20px;

    color-scheme: light;
}

/* ---- Tokens: Dark ---- */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: var(--black);
        --surface: #1d1f21;
        --ink: var(--cream);
        --text: #e2ddd1;
        --muted: #bdb9b0;
        --line: #2b2d30;
        --accent: var(--calamine);   /* 10.2:1 on black */
        --focus: var(--calamine);
        --meta: var(--pyrite);       /* 9.0:1 on black */
        --invite: #13292b;           /* calamine tint; cream 13.3:1, calamine 8.3:1 */
        --key-face: #2c2e31;         /* cream label 11.9:1 */
        --s1: var(--cream);          /* black stripe flips to cream on dark */
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: var(--black);
    --surface: #1d1f21;
    --ink: var(--cream);
    --text: #e2ddd1;
    --muted: #bdb9b0;
    --line: #2b2d30;
    --accent: var(--calamine);
    --focus: var(--calamine);
    --meta: var(--pyrite);
    --invite: #13292b;
    --key-face: #2c2e31;
    --s1: var(--cream);
    color-scheme: dark;
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 1.125rem;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--ink);
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}
a:hover { color: var(--accent); }

::selection { background: var(--pyrite); color: var(--black); }   /* 9.0:1 */
img { max-width: 100%; height: auto; display: block; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 2px; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -9999px; top: 0; }
.skip-link:focus { left: var(--gutter); top: var(--gutter); background: var(--surface); padding: 8px 14px; z-index: 10; }

.wrap { max-width: calc(var(--measure) + var(--gutter) * 2); margin: 0 auto; padding: 0 var(--gutter); }
.wrap-wide { max-width: calc(var(--wide) + var(--gutter) * 2); margin: 0 auto; padding: 0 var(--gutter); }

/* ---- Header ---- */
.site-header { padding: 24px 0 0; }
.header-inner { display: flex; align-items: center; gap: 12px 24px; flex-wrap: wrap; }
.site-name { margin-right: auto; text-decoration: none; color: var(--ink); }
.site-name:hover { color: var(--ink); }
.wordmark {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 1.45rem;
    letter-spacing: -0.02em;
    line-height: 1;
    white-space: nowrap;
}
.site-nav { display: flex; gap: 4px 18px; flex-wrap: wrap; font-family: var(--font-meta); font-size: .95rem; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); }
/* Nav marker: a small block beside the current page or section, like a menu cursor */
.site-nav a { position: relative; }
.site-nav a[aria-current] { color: var(--ink); }
.site-nav a[aria-current]::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 50%;
    width: 7px;
    height: 7px;
    transform: translateY(-50%);
    background: var(--accent);
}

/* Light switch as a power button: latching key (pushed in = lights on), indicator light, state in words */
html:not(.js) .power { display: none; }   /* without JavaScript the switch cannot work; the device setting applies */
.power {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--ink);
    font-family: var(--font-meta);
    font-size: 1rem;
    cursor: pointer;
}
.power-key {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin-bottom: 4px;
    border: 2px solid var(--ink);
    background: var(--key-face);
    box-shadow: 0 4px 0 var(--ink);
}
.power-key svg { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linecap: square; }
.power[aria-checked="true"] .power-key { transform: translateY(4px); box-shadow: none; }
.power:hover .power-key { background: var(--pyrite); }
.power:hover .power-key svg { stroke: var(--black); }
.power-led { width: 10px; height: 10px; border: 2px solid var(--ink); }
.power[aria-checked="true"] .power-led { background: var(--accent); }
.power[aria-checked="true"] .power-off,
.power[aria-checked="false"] .power-on { display: none; }
.power:hover .power-text { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* ---- Hero ---- */
.hero { padding: 80px 0 32px; }
.hero-title {                      /* the hello: a friendly greeting above the mission line */
    font-family: var(--font-display);
    font-weight: 800;
    font-stretch: 112%;
    font-size: 1.5rem;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 0 0 14px;
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) 190px; grid-template-areas: "text art"; column-gap: 40px; align-items: center; }
.hero-text { grid-area: text; }
.hero-grid .computer { grid-area: art; }
.hero-line {                       /* the mission line is the main message */
    font-family: var(--font-display);
    font-weight: 800;
    font-stretch: 105%;
    font-size: clamp(1.6rem, 4.2vw, 2.05rem);
    line-height: 1.18;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin: 0 0 22px;
    text-wrap: balance;
}
.hero-intro { font-size: 1.15rem; line-height: 1.5; color: var(--muted); margin: 0 0 20px; }   /* used on the error page */
.arrow { display: inline-block; margin-left: 6px; }

/* NOW panel: a small window under the intro; label above value, four across (two by two on phones) */
.now { margin-top: 40px; border: 2px solid var(--ink); }
.now .now-title { height: 32px; border-width: 0 0 2px; margin: 0; }   /* 32px: no top border, so the stripes stay centered on the close box */
.now-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; }
.now-list > div { padding: 14px 16px 16px; border-left: 1px solid var(--line); }
.now-list > div:first-child { border-left: 0; }
.now-list dt { font-family: var(--font-meta); color: var(--meta); font-size: .9rem; line-height: 1.3; margin: 0 0 4px; }
.now-list dd { margin: 0; font-weight: 700; color: var(--ink); font-size: 1.05rem; line-height: 1.3; text-wrap: balance; }
.text-link { display: inline-block; padding: 4px 0; font-weight: 600; }   /* taller tap target */

/* ---- Sections ---- */
.section { padding: 56px 0 0; scroll-margin-top: 24px; }
.section-first { padding-top: 64px; }
/* Section titles are early-desktop window title bars: pinstripes, a close box, a centered label */
.section-title {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Fixed geometry: 34px bar = 2px border + 6px padding + 18px stripe area (the four palette stripes, 3px each) */
    height: 34px;
    padding: 6px 8px;
    border: 2px solid var(--ink);
    background: linear-gradient(var(--s1) 0 3px, transparent 3px 5px, var(--s2) 5px 8px, transparent 8px 10px, var(--s3) 10px 13px, transparent 13px 15px, var(--s4) 15px 18px) content-box;
    font-family: var(--font-display);
    font-weight: 800;
    font-stretch: 125%;
    font-size: 1.05rem;
    line-height: 18px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink);
    margin: 0 0 8px;
}
.section-title::before {           /* close box: 18px tall, exactly the stripe area */
    content: "";
    position: absolute;
    top: 50%;
    left: 12px;
    width: 18px;
    height: 18px;
    transform: translateY(-50%);
    border: 2px solid var(--ink);
    background: var(--bg);
    box-shadow: -4px 0 0 var(--bg), 4px 0 0 var(--bg);   /* clears stripes to each side only */
}
.section-title > span { height: 18px; background: var(--bg); padding: 0 12px; }

/* ---- Rows (Work, Education, Online) ---- */
.rows { list-style: none; margin: 0; padding: 0; }
.row { padding: 16px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.row-title { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--ink); }
a.row-title { text-decoration: underline; text-decoration-color: var(--accent); }
.row-meta { font-family: var(--font-meta); color: var(--meta); font-size: .95rem; white-space: nowrap; }
.row-body { margin: 6px 0 0; max-width: 60ch; }

/* ---- Post list ---- */
.post-list { list-style: none; margin: 0; padding: 0; }
.post-row { border-bottom: 1px solid var(--line); }
.post-row:last-child { border-bottom: 0; }
.post-link { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 14px 0; text-decoration: none; color: var(--ink); }
.post-title { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; line-height: 1.35; text-decoration: underline; text-decoration-color: transparent; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.post-link:hover { color: var(--ink); }
.post-link:hover .post-title { text-decoration-color: var(--accent); }
.post-date { font-family: var(--font-meta); color: var(--meta); font-size: .95rem; white-space: nowrap; }
.more-link { display: inline-block; margin-top: 12px; }
.empty { color: var(--muted); font-family: var(--font-meta); }

/* Linked rows light up like a selected menu item (inverse video); the whole row is the link */
.row { position: relative; }
.row:has(a.row-title) a.row-title::after { content: ""; position: absolute; inset: 0; }
.row:has(a.row-title):hover, .row:has(a.row-title:focus-visible),
.post-link:hover, .post-link:focus-visible {
    background: var(--ink);
    box-shadow: -12px 0 0 var(--ink), 12px 0 0 var(--ink);
}
.row:has(a.row-title):hover *, .row:has(a.row-title:focus-visible) *,
.post-link:hover *, .post-link:focus-visible * { color: var(--bg); text-decoration-color: var(--bg); }
.post-link:focus-visible { outline-offset: 0; }

/* Reading stripe on posts: fixed to the top, revealed left to right by site.js */
.progress { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; height: 4px; clip-path: inset(0 100% 0 0); pointer-events: none; }
.progress i { flex: 1; }
.progress i:nth-child(1) { background: var(--s1); }
.progress i:nth-child(2) { background: var(--s2); }
.progress i:nth-child(3) { background: var(--s3); }
.progress i:nth-child(4) { background: var(--s4); }
html:not(.js) .progress { display: none; }

/* ---- Subscribe ---- */
.subscribe {
    margin: 28px 0 0;
    padding: 20px;
    background: var(--invite);
}
.subscribe-title { display: block; font-family: var(--font-display); font-weight: 700; color: var(--ink); margin: 0 0 12px; font-size: 1.05rem; }
.subscribe-form { display: flex; flex-wrap: wrap; gap: 10px; }
.subscribe-form input {
    flex: 1 1 220px;
    min-width: 0;
    font-family: var(--font-meta);
    font-size: 1rem;
    padding: 10px 14px;
    border: 2px solid var(--ink);
    border-radius: 0;
    background: var(--bg);
    color: var(--ink);
}
.subscribe-form input::placeholder { color: var(--muted); opacity: 1; }   /* 7.6:1 light, 9.5:1 dark */
/* Subscribe is a keyboard key: flat face, solid edge below, presses down into its edge */
.subscribe-form button {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    padding: 10px 18px;
    margin-bottom: 4px;
    border: 2px solid var(--ink);
    border-radius: 0;
    background: var(--key-face);
    color: var(--ink);
    box-shadow: 0 4px 0 var(--ink);
    cursor: pointer;
}
.subscribe-form button:hover { background: var(--pyrite); color: var(--black); }   /* 9.0:1 */
.subscribe-form button:active { transform: translateY(4px); box-shadow: none; }
.subscribe-status { flex-basis: 100%; }
.subscribe-msg { display: none; margin: 4px 0 0; font-family: var(--font-meta); font-size: .95rem; }
.subscribe-form.success .subscribe-ok { display: block; }
.subscribe-form.error .subscribe-err { display: block; color: var(--accent); }
.subscribe-form.loading button { opacity: .6; }

/* ---- Articles ---- */
.article-header { padding-top: 64px; padding-bottom: 24px; }
.article-meta { font-family: var(--font-meta); color: var(--meta); font-size: .95rem; margin: 0 0 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.article-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-stretch: 105%;
    font-size: clamp(2.1rem, 6vw, 3.25rem);
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin: 0;
}
.article-excerpt { font-family: var(--font-read); font-size: 1.35rem; color: var(--muted); margin: 16px 0 0; }
.article-image { margin: 8px auto 32px; }
.article-image img { width: 100%; }
.article-image figcaption { font-family: var(--font-meta); color: var(--muted); font-size: .9rem; text-align: center; margin-top: 8px; }
.article-footer { padding-bottom: 16px; }
.article-comments { margin-top: 40px; }
/* Ghost's comments frame is a light document; matching its color-scheme keeps it transparent in dark mode (otherwise browsers paint it white) */
.article-comments iframe { color-scheme: light; }

/* ---- Drawn home computer (homepage top) ---- */
.computer { justify-self: end; width: 100%; max-width: 210px; }
.computer-art { display: block; width: 100%; height: auto; }
.computer-art .case { fill: var(--key-face); stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; }
.computer-art .k { fill: var(--bg); stroke: var(--ink); stroke-width: 1.5; }
.computer-art .kx { fill: var(--sienna); }   /* one accent key */
.computer-art .screen { fill: var(--black); stroke: var(--ink); stroke-width: 2.5; }
.computer-art .glow { stroke: var(--calamine); }
.computer-art .cur { fill: var(--calamine); }
.computer-art .hello { fill: var(--calamine); font-family: var(--font-meta); font-size: 14px; font-weight: 700; }
.computer[role="button"] { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }   /* taps respond right away on phones */
.computer[role="button"] .computer-art { transition: none; }
.computer[role="button"]:active .computer-art { transform: translateY(2px); }
.computer-art .led { fill: var(--sienna); stroke: var(--ink); stroke-width: 1.5; }
.computer-art .s1 { fill: var(--s1); } .computer-art .s2 { fill: var(--s2); } .computer-art .s3 { fill: var(--s3); } .computer-art .s4 { fill: var(--s4); }

/* ---- About page: headings are window title bars that fold their section ---- */
.about-content h2.fold-title { margin: 2.2em 0 0; font-size: 1.05rem; }
.fold-toggle {
    display: flex; justify-content: center; align-items: center;
    height: 18px; padding: 0; margin: 0;
    border: 0; background: transparent; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit;
    cursor: pointer;
}
.fold-toggle::after { content: ""; position: absolute; inset: 0; }   /* the whole title bar is the button */
.fold-toggle > span { height: 18px; line-height: 18px; background: var(--bg); padding: 0 12px; }
.fold-toggle:hover > span { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.fold-title:has([aria-expanded="false"])::before { background: var(--ink); }   /* folded: the box fills in, like a window shade pulled up */
.fold-body > :first-child { margin-top: 1em; }
.fold-body > * + * { margin-top: 1.25em; }
.fold-body > * { margin-bottom: 0; }

/* ---- Ghost content ---- */
.gh-content { font-family: var(--font-read); font-size: 1.25rem; line-height: 1.7; color: var(--text); }
.gh-content > * + * { margin-top: 1.25em; }
.gh-content > * { margin-bottom: 0; }
.gh-content h2, .gh-content h3, .gh-content h4 { font-family: var(--font-display); color: var(--ink); line-height: 1.2; margin-top: 1.8em; }
.gh-content h2 { font-size: 1.6rem; font-weight: 800; }
.gh-content h3 { font-size: 1.3rem; font-weight: 700; }
.gh-content blockquote { margin-left: 0; padding-left: 20px; border-left: 4px solid var(--edge); font-style: italic; }
.gh-content hr { border: 0; height: 4px; width: 26px; margin: 2.4em auto; background: linear-gradient(var(--s1) 0 25%, var(--s2) 25% 50%, var(--s3) 50% 75%, var(--s4) 75%); }
.gh-content pre { font-family: var(--font-meta); background: var(--surface); padding: 16px; overflow-x: auto; font-size: .9rem; }
.gh-content code { font-family: var(--font-meta); font-size: .9em; }
.gh-content figure { margin-left: 0; margin-right: 0; }
.gh-content figcaption { font-family: var(--font-meta); color: var(--muted); font-size: .9rem; text-align: center; margin-top: 8px; }
.gh-content ul, .gh-content ol { padding-left: 1.3em; }

/* Required by Ghost editor cards */
.kg-width-wide { position: relative; width: min(var(--wide), 100vw - var(--gutter) * 2); left: 50%; transform: translateX(-50%); }
.kg-width-full { position: relative; width: 100vw; left: 50%; transform: translateX(-50%); }

/* ---- Pagination ---- */
.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; font-family: var(--font-meta); color: var(--muted); }

/* ---- Footer ---- */
.site-footer { margin-top: 80px; padding: 0 0 40px; }

/* Stripe band: the four palette colors, full width */
.stripes { display: flex; gap: 3px; margin-bottom: 24px; }
.stripes i { flex: 1; height: 6px; }
.stripes i:nth-child(1) { background: var(--s1); }
.stripes i:nth-child(2) { background: var(--s2); }
.stripes i:nth-child(3) { background: var(--s3); }
.stripes i:nth-child(4) { background: var(--s4); }

/* ---- Small screens ---- */
/* ---- Motion: only for people who have not asked their device to reduce it ---- */
@media (prefers-reduced-motion: no-preference) {
    body { transition: background-color .25s ease, color .25s ease; }
    .post-title { transition: text-decoration-color .15s; }
}

/* Wider screens: the header stays at the top so the nav marker is always visible */
@media (min-width: 721px) {
    .site-header { position: sticky; top: 0; z-index: 10; background: var(--bg); padding-bottom: 14px; border-bottom: 1px solid transparent; }
    .section { scroll-margin-top: 96px; }
}

/* ---- Medium and small screens: nav drops to its own row under the name and power button ---- */
@media (max-width: 720px) {
    .header-inner { column-gap: 12px; }
    .site-nav { order: 3; flex-basis: 100%; }
    .hero-grid { grid-template-columns: 1fr; grid-template-areas: "art" "text"; }
    .hero-grid .computer { justify-self: start; max-width: 240px; margin-bottom: 20px; }   /* big enough on phones to read the greeting */
    .now-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .now-list > div:nth-child(odd) { border-left: 0; }
    .now-list > div:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 359px) {
    .power-text { display: none; }   /* very narrow phones: key and indicator only, so it stays beside the name */
}

@media (max-width: 560px) {
    .hero { padding-top: 56px; }
    .hero-title { font-size: 1.2rem; margin-bottom: 10px; }
    .wordmark { font-size: 1.3rem; }
    .post-link { flex-direction: column; gap: 2px; }
    .row-head { flex-wrap: wrap; gap: 2px 16px; }
    .gh-content { font-size: 1.1875rem; }
}
