/* --- theme.css --- */
/*
 * Solarized, both variants.  https://ethanschoonover.com/solarized/
 *
 * The palette is defined once here as custom properties; nothing else in the
 * project should contain a hex colour.  Light is the base definition, dark
 * overrides it in two places:
 *
 *   1. @media (prefers-color-scheme: dark) -- for the no-JavaScript case and
 *      the instant before the inline script in app.html runs.
 *   2. [data-theme='dark']                 -- an explicit choice, which wins.
 *
 * The :not([data-theme='light']) guard on the media query is what lets the
 * toggle switch *to* light on a machine set to dark.
 */

:root {
    --bg: #fdf6e3;        /* base3  */
    --bg-alt: #eee8d5;    /* base2  */
    --rule: #93a1a1;      /* base1  */
    --fg: #657b83;        /* base00 */
    --fg-strong: #586e75; /* base01 */
    --accent: #268bd2;    /* blue   */
    --error: #dc322f;     /* red    */
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) {
        --bg: #002b36;        /* base03 */
        --bg-alt: #073642;    /* base02 */
        --rule: #586e75;      /* base01 */
        --fg: #839496;        /* base0  */
        --fg-strong: #93a1a1; /* base1  */
        --accent: #268bd2;
        --error: #dc322f;
        color-scheme: dark;
    }
}

:root[data-theme='dark'] {
    --bg: #002b36;
    --bg-alt: #073642;
    --rule: #586e75;
    --fg: #839496;
    --fg-strong: #93a1a1;
    --accent: #268bd2;
    --error: #dc322f;
    color-scheme: dark;
}

/* --- global.css --- */
/* Layout, typography and components.  Colours come from theme.css. */

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

html {
    /* Nudge type up slightly on wide screens rather than at every size. */
    font-size: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: ui-serif, Georgia, 'Times New Roman', serif;
    line-height: 1.65;
    -webkit-text-size-adjust: 100%;
}

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

/* --- header ------------------------------------------------------------ */
/* Fixed corners: back arrow top left (article pages only), theme toggle top
   right (everywhere).  Both are outside the flow so they cannot push content
   around on narrow screens. */

.corner {
    position: fixed;
    top: 0.75rem;
    z-index: 10;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;   /* >= 44px: a comfortable touch target */
    height: 2.75rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    background: var(--bg);
    color: var(--fg-strong);
    cursor: pointer;
    text-decoration: none;
}

.corner:hover,
.corner:focus-visible {
    border-color: var(--rule);
    color: var(--accent);
}

.corner-left {
    left: 0.75rem;
}

.corner-right {
    right: 0.75rem;
}

/* Sign out, sitting immediately left of the theme toggle. */
.corner-right-2 {
    right: 3.75rem;
}

/* --- the wordmark ------------------------------------------------------- */
/* fonts.css owns the face; these rules own its size in each of the three
   places it appears.  The size cannot live with the face: `.centred h1` and
   `.index caption` are both more specific than a bare `.wordmark` and would
   win.  See DOCS/06-frontend.md. */

.centred h1.wordmark {
    font-size: 2.1rem;
    font-weight: 400;
}

.index caption.wordmark {
    font-size: 2rem;
    letter-spacing: 0.04em;
}

/* The site name on article pages.  Hidden first, shown at the breakpoint --
   mobile never pays for it, and the rule reads the same way as .index below. */
.site-mark {
    display: none;
}

@media (min-width: 768px) {
    /* A full-width strip, not a floating word: article text scrolls UNDER this
       and would otherwise show through on either side of the letters.  z-index
       9 puts it below the .corner controls (10), which keep their own --bg and
       stay clickable; pointer-events:none means it can never swallow a click
       meant for one of them.  4.25rem fits inside the 4.5rem top padding that
       `main` already has, so nothing shifts when it appears. */
    .site-mark {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 9;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 4.25rem;
        background: var(--bg);
        color: var(--fg-strong);
        font-size: 1.7rem;
        pointer-events: none;
    }
}

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

main {
    padding: 4.5rem 1rem 4rem;
}

/* --- index table -------------------------------------------------------- */

.index {
    width: 100%;
    margin-inline: auto;
    border-collapse: collapse;
    font-size: 0.95rem;
}

@media (min-width: 768px) {
    /* Half the viewport on desktop, as specified in PRD section 6.2. */
    .index {
        width: 50%;
    }
}

.index caption {
    margin-bottom: 1.25rem;
    color: var(--fg-strong);
    font-size: 1.35rem;
    letter-spacing: 0.02em;
}

.index th {
    padding: 0 0.75rem 0.4rem;
    border-bottom: 1px solid var(--rule);
    color: var(--fg-strong);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-align: left;
    text-transform: uppercase;
}

.index td {
    padding: 0;
    border-bottom: 1px solid color-mix(in srgb, var(--rule) 35%, transparent);
}

/* The whole row is clickable without any JavaScript: every cell holds a
   block-level anchor that fills it, so there is no dead space in the row. */
.index td a {
    display: block;
    padding: 0.7rem 0.75rem;
    color: inherit;
    text-decoration: none;
}

.index tbody tr:hover {
    background: var(--bg-alt);
}

.index tbody tr:hover .title {
    color: var(--accent);
}

.index .title {
    color: var(--fg-strong);
}

.index .date,
.index .course {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.82rem;
    white-space: nowrap;
}

.index .course {
    white-space: normal;
}

.empty {
    margin-top: 3rem;
    text-align: center;
    color: var(--fg);
}

/* --- article ------------------------------------------------------------ */

.prose {
    max-width: 65ch;
    margin-inline: auto;
}

.prose h1 {
    margin: 0;
    color: var(--fg-strong);
    font-size: clamp(1.6rem, 5vw, 2.2rem);
    line-height: 1.2;
}

.prose .subhead {
    margin: 0.4rem 0 2.5rem;
    color: var(--fg);
    font-size: 1rem;
    font-style: italic;
    font-weight: 400;
}

.prose h2 {
    margin: 2.5rem 0 0.75rem;
    color: var(--fg-strong);
    font-size: 1.25rem;
}

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

.prose figure {
    margin: 2rem 0;
}

.prose img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 0.25rem;
}

.prose figcaption {
    margin-top: 0.6rem;
    color: var(--fg);
    font-size: 0.85rem;
    font-style: italic;
    text-align: center;
}

.prose blockquote {
    margin: 1.5rem 0;
    padding-left: 1rem;
    border-left: 3px solid var(--rule);
    color: var(--fg-strong);
}

.prose code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9em;
    background: var(--bg-alt);
    padding: 0.1em 0.35em;
    border-radius: 0.2em;
}

/* --- centred single-purpose pages (login, denied, errors) --------------- */

.centred {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1.5rem;
    text-align: center;
}

.centred h1 {
    margin: 0;
    color: var(--fg-strong);
    font-size: 1.5rem;
    font-weight: 600;
}

.centred p {
    margin: 0;
    max-width: 42ch;
}

.button {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.5rem;
    padding: 0.8rem 1.4rem;
    border: 1px solid var(--rule);
    border-radius: 0.4rem;
    background: var(--bg-alt);
    color: var(--fg-strong);
    font-family: inherit;
    font-size: 1rem;
    text-decoration: none;
}

.button:hover,
.button:focus-visible {
    border-color: var(--accent);
    color: var(--accent);
}

.code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 3rem;
    font-weight: 700;
    color: var(--error);
    line-height: 1;
}

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