/* ---------------------------------------------------------------------------
   One stylesheet for the whole site. Projects add their own on top of it if
   they need to; most will not.

   Colours are all tokens, defined light and redefined for a dark preference,
   so nothing has a colour that only exists in one theme.
   --------------------------------------------------------------------------- */

:root {
    --bg:          #fbfaf8;
    --bg-raised:   #ffffff;
    --ink:         #1b1a17;
    --ink-soft:    #5c5a54;
    --ink-faint:   #8b8880;
    --rule:        #e4e1da;
    --accent:      #a8471f;
    --accent-soft: #f4e6e0;
    --shadow:      0 1px 2px rgba(27, 26, 23, .06), 0 4px 12px rgba(27, 26, 23, .04);

    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:          #16151a;
        --bg-raised:   #1e1d24;
        --ink:         #eceaf2;
        --ink-soft:    #a9a5b5;
        --ink-faint:   #77738a;
        --rule:        #2e2c37;
        --accent:      #ff9d6e;
        --accent-soft: #35251d;
        --shadow:      0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .25);
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-text-size-adjust: 100%;
}

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

code, pre {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: .92em;
}

/* --- frame ---------------------------------------------------------------- */

.site-header,
.site-main,
.site-footer {
    max-width: 62rem;
    margin: 0 auto;
    padding: 0 1.25rem;
}

.site-header {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
}

.site-name {
    font-weight: 650;
    letter-spacing: -.01em;
    color: var(--ink);
    text-decoration: none;
}

.crumb-sep { color: var(--ink-faint); }
.crumb     { color: var(--ink-soft); }

.site-footer {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-top: 4rem;
    padding-top: 1.25rem;
    padding-bottom: 3rem;
    border-top: 1px solid var(--rule);
    color: var(--ink-faint);
    font-size: .875rem;
}

.env-tag {
    padding: .05rem .4rem;
    border: 1px solid var(--rule);
    border-radius: 999px;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .06em;
}

/* --- page furniture ------------------------------------------------------- */

.page-head { margin-bottom: 2rem; }

.page-head h1 {
    margin: 0 0 .35rem;
    font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem);
    letter-spacing: -.02em;
}

.blurb {
    margin: 0;
    max-width: 46ch;
    color: var(--ink-soft);
}

.empty {
    padding: 2rem;
    border: 1px dashed var(--rule);
    border-radius: .75rem;
    color: var(--ink-soft);
    text-align: center;
}

.trace {
    overflow-x: auto;
    padding: 1rem;
    border: 1px solid var(--rule);
    border-radius: .5rem;
    background: var(--bg-raised);
    color: var(--ink-soft);
    font-size: .8rem;
    line-height: 1.5;
}

.button {
    display: inline-block;
    padding: .5rem .9rem;
    border-radius: .5rem;
    background: var(--accent);
    color: var(--bg-raised);
    font-weight: 550;
    text-decoration: none;

    /* Tapping a button twice quickly is two presses, not a request to zoom.
       Phones treat a double tap as zoom unless told otherwise, so scoring two
       cards in a row, or stepping back a few, would leave the page magnified.
       `manipulation` drops that one gesture and keeps the rest: pinch zoom and
       panning still work, which `user-scalable=no` would have taken away
       wholesale and from everyone.

       The desktop half of the same problem is selection: a double click on a
       button picks out its label, and a third click takes the line, so a few
       quick presses leave the page streaked blue. Nothing here is text anyone
       wants to copy, so the buttons simply opt out. The highlight colour goes
       with it -- the grey box Android flashes over a tapped control lags a
       press or two behind when they come this fast, and ends up marking the
       wrong one. */
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* --- project cards -------------------------------------------------------- */

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

.card-link {
    display: block;
    height: 100%;
    /* A tile is a link, and two quick taps on one are two attempts to follow
       it, not a request to zoom. The words stay selectable: a deck's name is
       worth copying, a button's label is not. */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    padding: 1.25rem;
    border: 1px solid var(--rule);
    border-radius: .875rem;
    background: var(--bg-raised);
    box-shadow: var(--shadow);
    color: inherit;
    text-decoration: none;
    transition: border-color .15s, transform .15s;
}

a.card-link:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.card-link.is-inert { opacity: .55; }

.card-icon {
    display: block;
    margin-bottom: .5rem;
    font-size: 1.75rem;
    line-height: 1;
}

.card-title {
    margin: 0 0 .3rem;
    font-size: 1.05rem;
    letter-spacing: -.01em;
}

.card-blurb {
    margin: 0 0 .9rem;
    color: var(--ink-soft);
    font-size: .9rem;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin: 0;
}

.tag {
    padding: .1rem .45rem;
    border-radius: 999px;
    background: var(--rule);
    color: var(--ink-soft);
    font-size: .7rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.tag-live { background: var(--accent-soft); color: var(--accent); }

/* --- scaffold notice ------------------------------------------------------ */

.scaffold {
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--rule);
    border-left: 3px solid var(--accent);
    border-radius: .5rem;
    background: var(--bg-raised);
}

.scaffold h2 { margin-top: 0; font-size: 1rem; }
.scaffold ul { margin: 0; padding-left: 1.25rem; color: var(--ink-soft); }
.scaffold li { margin: .25rem 0; }

/* --- prose and source listings (firebox) ---------------------------------- */

.prose {
    max-width: 64ch;
    color: var(--ink);
}

.prose p { margin: 0 0 1rem; }

.section-head {
    margin: 2.5rem 0 1rem;
    padding-bottom: .4rem;
    border-bottom: 1px solid var(--rule);
    font-size: 1.1rem;
    letter-spacing: -.01em;
}

.filegroups,
.filelist {
    margin: 0;
    padding: 0;
    list-style: none;
}

.filegroups > li { margin-bottom: 1.5rem; }

.filegroups h3 {
    margin: 0 0 .5rem;
    color: var(--ink-soft);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .85rem;
    font-weight: 600;
}

.filelist {
    display: grid;
    gap: .2rem .75rem;
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
}

.filelist li {
    display: flex;
    justify-content: space-between;
    gap: .5rem;
    padding: .2rem .5rem;
    border-radius: .3rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .82rem;
}

.filelist li:hover { background: var(--bg-raised); }
.filesize { color: var(--ink-faint); white-space: nowrap; }

.filetable {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}

.filetable th,
.filetable td {
    padding: .4rem .6rem;
    border-bottom: 1px solid var(--rule);
    text-align: left;
}

.filetable th {
    color: var(--ink-faint);
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.filetable td:first-child {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.filetable .num { text-align: right; font-variant-numeric: tabular-nums; }
.filetable tr:hover td { background: var(--bg-raised); }

.filename {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 1.1rem !important;
    word-break: break-all;
}

/* highlight_string() emits its own inline colours, which are tuned for a light
   page. Give it one so the code is readable whatever the viewer's theme. */
.source {
    overflow-x: auto;
    padding: 1rem;
    border: 1px solid var(--rule);
    border-radius: .5rem;
    background: #fdfdfc;
    color: #1b1a17;
}

.source pre,
.source code {
    margin: 0;
    font-size: .8rem;
    line-height: 1.5;
}
