/* ---------------------------------------------------------------------------
   AMA Reader, on top of /assets/css/site.css.

   The pages are static files with no script, so everything interactive here
   is native HTML: <details> for folds and Contents, plain links for the three
   orders. Colours are site tokens, or --ama-* tokens derived from them and
   redefined for a dark preference, so nothing has a colour that only exists
   in one theme. Text colours keep at least 4.5:1 against their background in
   both themes (site.css's --ink-faint does not, so it is only used for rules
   and separators here).
   --------------------------------------------------------------------------- */

:root {
    --ama-ask-bg:    #f3f1ec;            /* a question's card: one step off --bg */
    --ama-host-rule: var(--accent);      /* the bar beside every host answer */
    --ama-note:      #6b6862;            /* bylines and small print; --ink-faint is too faint */
    --ama-measure:   44rem;              /* a reading width inside the site's 62rem frame */
}

@media (prefers-color-scheme: dark) {
    :root {
        --ama-ask-bg: #211f28;
        --ama-note:   #9a96aa;
    }
}

/* The site's footer text is --ink-faint; here it carries "Not affiliated
   with Reddit", which has to be readable. */
.ama-reader .site-footer {
    flex-wrap: wrap;
    color: var(--ama-note);
}

.ama-page { max-width: var(--ama-measure); }

/* --- keyboard ------------------------------------------------------------- */

.ama-skip {
    position: absolute;
    left: -9999px;
    top: .5rem;
    z-index: 10;
    padding: .6rem .9rem;
    border-radius: .5rem;
    background: var(--bg-raised);
    box-shadow: var(--shadow);
}

.ama-skip:focus { left: 1rem; }

.ama-reader a:focus-visible,
.ama-reader summary:focus-visible,
.md-spoiler:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: .2rem;
}

/* --- head ----------------------------------------------------------------- */

.ama-head { margin-bottom: 1.25rem; }
/* AMA titles run to two or three lines; the site's page-title size is
   meant for a few words. */
.ama-head h1 {
    font-size: clamp(1.35rem, 1.1rem + 1vw, 1.85rem);
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.ama-meta {
    margin: 0 0 .75rem;
    color: var(--ink-soft);
}

.ama-source,
.ama-scope {
    margin: 0 0 .5rem;
    color: var(--ink-soft);
    font-size: .9rem;
}

.ama-banners { margin: 0 0 1.5rem; }

.ama-banner {
    margin: 0 0 .5rem;
    padding: .7rem 1rem;
    border: 1px solid var(--rule);
    border-left: 3px solid var(--accent);
    border-radius: .5rem;
    background: var(--bg-raised);
    font-size: .92rem;
}

/* --- listen, hosts and introduction --------------------------------------- */

.ama-listen,
.ama-hosts,
.ama-intro {
    margin: 0 0 1.5rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--rule);
    border-radius: .875rem;
    background: var(--bg-raised);
}

.ama-listen h2,
.ama-hosts h2,
.ama-intro h2,
.ama-colophon h2 {
    margin: 0 0 .5rem;
    font-size: 1rem;
    letter-spacing: -.01em;
}

/* The browser's own player (no script of ours), full width so its seek bar
   is long enough to aim with on an hour-long recording. */
.ama-listen audio {
    display: block;
    width: 100%;
    margin: 0 0 .6rem;
}

.ama-listen-meta {
    margin: 0 0 .35rem;
    color: var(--ink-soft);
    font-size: .9rem;
}

.ama-listen-note {
    margin: 0;
    color: var(--ama-note);
    font-size: .85rem;
}

.ama-host-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.ama-host-list li { margin: .35rem 0; }
.ama-host-list .ama-name { font-weight: 600; }

.ama-host-why {
    display: block;
    color: var(--ama-note);
    font-size: .85rem;
}

.ama-suggested-h {
    margin: 1rem 0 .25rem;
    color: var(--ink-soft);
    font-size: .85rem;
    font-weight: 600;
}

.ama-suggested .ama-name { font-weight: 500; }

.ama-none,
.ama-intro-note {
    margin: 0 0 .5rem;
    color: var(--ink-soft);
    font-size: .9rem;
}

.ama-intro .md { font-size: .95rem; }

/* The long-introduction fold: the h2 stays above it (a heading inside a
   <summary> drops out of screen readers' heading lists); the summary reads
   "Hide the introduction" / "Show the introduction". */
.ama-intro-fold > summary {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin: -.4rem 0 .25rem;
    color: var(--accent);
    font-size: .85rem;
    cursor: pointer;
    list-style: none;
}

.ama-intro-fold > summary::-webkit-details-marker { display: none; }

.ama-intro-fold > summary::before { content: "Hide\00a0"; }
.ama-intro-fold:not([open]) > summary::before { content: "Show\00a0"; }

/* --- order switcher and contents ------------------------------------------ */

.ama-tools { margin: 0 0 1.5rem; }

.ama-orders {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
    margin: 0 0 .75rem;
}

.ama-orders-label {
    margin-right: .2rem;
    color: var(--ink-soft);
    font-size: .9rem;
}

.ama-orders a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 .9rem;
    border: 1px solid var(--rule);
    border-radius: 999px;
    background: var(--bg-raised);
    color: var(--ink);
    font-size: .9rem;
    text-decoration: none;
    touch-action: manipulation;
}

.ama-orders a:hover { border-color: var(--accent); }

.ama-orders a[aria-current="page"] {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.ama-contents {
    border: 1px solid var(--rule);
    border-radius: .875rem;
    background: var(--bg-raised);
}

/* Flex takes the summary out of display: list-item, which removes the
   browser's disclosure triangle, so the state is spelled out instead. */
.ama-contents > summary {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 1rem;
    cursor: pointer;
    font-weight: 600;
    list-style: none;
}

.ama-contents > summary::-webkit-details-marker { display: none; }

.ama-contents > summary::after {
    content: "Show";
    margin-left: auto;
    color: var(--accent);
    font-size: .85rem;
    font-weight: 400;
}

.ama-contents[open] > summary::after { content: "Hide"; }

.ama-contents ol {
    margin: 0;
    padding: .25rem 1.25rem 1rem 2.75rem;
    font-size: .92rem;
}

.ama-contents li { margin: .35rem 0; }

.ama-contents li::marker {
    color: var(--ama-note);
    font-variant-numeric: tabular-nums;
}

.ama-when,
.ama-voices {
    color: var(--ama-note);
    font-size: .82rem;
    white-space: nowrap;
}

.ama-voices { white-space: normal; }
.ama-voices::before { content: "\00b7\00a0"; }

/* A way back to the contents on a phone, where the list is far behind. */
.ama-top { display: none; }

/* --- exchanges ------------------------------------------------------------ */

.ama-x {
    padding: 1.75rem 0 .5rem;
    border-top: 1px solid var(--rule);
    scroll-margin-top: 1rem;
}

.ama-x-head { margin-bottom: .75rem; }

.ama-x-head h2 {
    margin: 0;
    font-size: 1.15rem;
    line-height: 1.35;
    letter-spacing: -.01em;
    overflow-wrap: anywhere;
}

.ama-num {
    color: var(--ama-note);
    font-variant-numeric: tabular-nums;
}

.ama-x-when {
    margin: .2rem 0 0;
    color: var(--ama-note);
    font-size: .85rem;
}

.ama-turn {
    margin: .75rem 0;
    scroll-margin-top: 1rem;
}

/* Questions and other people's comments: a muted card. */
.ama-asker,
.ama-context {
    padding: .7rem .95rem;
    border-radius: .6rem;
    background: var(--ama-ask-bg);
    color: var(--ink-soft);
    font-size: .95rem;
}

/* Host answers: full size, with the accent bar. The host is also always
   named in the byline, so the colour is never the only signal. */
.ama-host {
    padding: .15rem 0 .15rem 1rem;
    border-left: 3px solid var(--ama-host-rule);
    color: var(--ink);
}

/* Follow-ups take one indent, however deep they sat on Reddit. */
.ama-follow { margin-left: 1.5rem; }

.ama-turn:target {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
}

.ama-by {
    margin: 0 0 .3rem;
    color: var(--ama-note);
    font-size: .85rem;
}

.ama-host .ama-by .ama-name { color: var(--ink); font-weight: 650; }
.ama-asker .ama-by .ama-name,
.ama-context .ama-by .ama-name { color: var(--ink-soft); font-weight: 600; }
.ama-speaker { color: var(--ink); font-weight: 600; }
.ama-acct { overflow-wrap: anywhere; }

.ama-note {
    display: inline-block;
    margin-left: .25rem;
    padding: 0 .45rem;
    border: 1px solid var(--rule);
    border-radius: 999px;
    font-size: .75rem;
    line-height: 1.6;
}

.ama-reply,
.ama-aside {
    margin: -.15rem 0 .35rem;
    color: var(--ama-note);
    font-size: .82rem;
}

.ama-aside { font-style: italic; }

.ama-placeholder {
    margin: 0;
    color: var(--ama-note);
    font-style: italic;
}

.ama-x-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .2rem .5rem;
    margin: .75rem 0 0;
    color: var(--ama-note);
    font-size: .85rem;
}

.ama-x-foot a {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
}

/* A very long question folds behind its first lines. */
.ama-long > summary {
    cursor: pointer;
    list-style: none;
}

.ama-long > summary::-webkit-details-marker { display: none; }

.ama-more,
.ama-less {
    display: inline-block;
    margin-top: .2rem;
    color: var(--accent);
    font-size: .85rem;
    font-weight: 600;
}

.ama-less,
.ama-long[open] .ama-excerpt,
.ama-long[open] .ama-more { display: none; }

.ama-long[open] .ama-less { display: inline-block; margin: 0 0 .4rem; }

/* --- closing notes -------------------------------------------------------- */

.ama-colophon {
    margin-top: 2.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--rule);
    color: var(--ink-soft);
    font-size: .88rem;
}

.ama-colophon p { margin: 0 0 .6rem; }

/* --- landing and about ---------------------------------------------------- */

.ama-pitch { margin-bottom: 1rem; }

.ama-list {
    display: grid;
    gap: .75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ama-list-item {
    padding: 1rem 1.25rem;
    border: 1px solid var(--rule);
    border-radius: .875rem;
    background: var(--bg-raised);
    box-shadow: var(--shadow);
}

.ama-list-title {
    font-weight: 600;
    letter-spacing: -.01em;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.ama-list-title:hover { text-decoration: underline; }

.ama-list-meta {
    margin: .3rem 0 0;
    color: var(--ama-note);
    font-size: .85rem;
}

.ama-updated {
    margin: .75rem 0 0;
    color: var(--ama-note);
    font-size: .85rem;
}

.ama-index-about {
    margin-top: 2rem;
    color: var(--ink-soft);
    font-size: .92rem;
}

.ama-about .section-head:first-of-type { margin-top: 1.5rem; }

/* --- Markdown bodies (amareader/markdown.py) ------------------------------ */

.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .75rem; }

.md .md-h {
    margin: 1rem 0 .5rem;
    font-weight: 650;
}

.md blockquote {
    margin: .5rem 0 .75rem;
    padding: 0 0 0 .9rem;
    border-left: 3px solid var(--rule);
    color: var(--ink-soft);
}

.md ul,
.md ol {
    margin: 0 0 .75rem;
    padding-left: 1.5rem;
}

.md li { margin: .2rem 0; }
.md li > p { margin: 0 0 .3rem; }

.md code {
    padding: .05rem .3rem;
    border-radius: .25rem;
    background: var(--rule);
}

.md pre {
    overflow-x: auto;
    margin: 0 0 .75rem;
    padding: .75rem 1rem;
    border: 1px solid var(--rule);
    border-radius: .5rem;
    background: var(--bg-raised);
    line-height: 1.45;
}

.md pre code {
    padding: 0;
    background: none;
    white-space: pre;
}

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

/* A wide table scrolls inside itself, never the page. */
.md table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
    margin: 0 0 .75rem;
    border-collapse: collapse;
    font-size: .9rem;
}

.md th,
.md td {
    padding: .3rem .6rem;
    border: 1px solid var(--rule);
    text-align: left;
    vertical-align: top;
}

.md th { font-weight: 600; }
/* Column alignment from the table's :-: / -: row (markdown.py emits a class, never style=). */
.md th.md-center,
.md td.md-center { text-align: center; }
.md th.md-right,
.md td.md-right { text-align: right; }
.md sup { font-size: .75em; line-height: 0; }
.md del { color: var(--ama-note); }

/* Spoilers: hidden until hovered or focused (markdown.py gives them
   tabindex="0", so a keyboard reaches them too). */
.md-spoiler {
    padding: 0 .15rem;
    border-radius: .2rem;
    background: var(--ink-soft);
    color: transparent;
}

.md-spoiler * { color: transparent; }

.md-spoiler:hover,
.md-spoiler:focus,
.md-spoiler:focus-within {
    background: var(--ama-ask-bg);
    color: inherit;
}

.md-spoiler:hover *,
.md-spoiler:focus *,
.md-spoiler:focus-within * { color: inherit; }

.md-spoiler:hover a,
.md-spoiler:focus a,
.md-spoiler:focus-within a { color: var(--accent); }

/* --- phones --------------------------------------------------------------- */

@media (max-width: 48rem) {
    .ama-listen,
    .ama-hosts,
    .ama-intro { padding: .85rem 1rem; }

    .ama-asker,
    .ama-context { padding: .6rem .8rem; }

    .ama-host { padding-left: .8rem; }
    .ama-follow { margin-left: .75rem; }
    .ama-contents ol { padding-left: 2.25rem; }
    .ama-x-head h2 { font-size: 1.08rem; }
    .ama-orders a { padding: 0 .75rem; font-size: .85rem; }
    .ama-orders-label { font-size: .85rem; }

    .ama-top {
        display: inline-flex;
        align-items: center;
        position: fixed;
        right: .75rem;
        bottom: .75rem;
        z-index: 5;
        min-height: 44px;
        padding: 0 .9rem;
        border: 1px solid var(--rule);
        border-radius: 999px;
        background: var(--bg-raised);
        box-shadow: var(--shadow);
        font-size: .85rem;
        text-decoration: none;
    }

    /* Leave room so the floating link never sits over the last lines; and
       when the footer wraps, a separator would dangle at a line end, so the
       gap does the separating instead. */
    .ama-reader .site-footer { padding-bottom: 5rem; gap: .5rem 1.25rem; }
    .ama-reader .site-footer .crumb-sep { display: none; }
}

/* --- print ---------------------------------------------------------------- */

@media print {
    :root {
        --bg:          #fff;
        --bg-raised:   #fff;
        --ink:         #000;
        --ink-soft:    #222;
        --ama-note:    #333;
        --rule:        #bbb;
        --accent:      #000;
        --accent-soft: #fff;
        --ama-ask-bg:  #fff;
        --shadow:      none;
    }

    body { font-size: 11pt; }

    /* A player and "Listen from" links mean nothing on paper. */
    .ama-skip,
    .ama-orders,
    .ama-contents-nav,
    .ama-top,
    .ama-listen,
    .ama-x-foot a.ama-listen-from,
    .ama-intro-fold > summary { display: none; }

    .ama-asker,
    .ama-context { border: 1px solid var(--rule); }

    /* Turns stay whole; an exchange may break between them. */
    .ama-turn,
    .ama-x-head { break-inside: avoid; }
    .ama-x-head { break-after: avoid; }

    /* On paper only the Reddit link means anything, so it prints its URL
       and the in-page link goes. (Inline, not inline-flex: a flex item
       would trim the space before the URL.) */
    .ama-x-foot a { display: inline; }
    .ama-x-foot a[href^="#"],
    .ama-x-foot [aria-hidden="true"] { display: none; }

    .ama-x-foot a[href^="http"]::after {
        content: " <" attr(href) ">";
        overflow-wrap: anywhere;
    }

    .md-spoiler,
    .md-spoiler * { background: none; color: inherit; }

    /* Print folded questions in full where the browser allows styling the
       hidden part of a <details>; elsewhere the excerpt prints. */
    @supports selector(::details-content) {
        .ama-long::details-content,
        .ama-intro-fold::details-content {
            content-visibility: visible;
            display: block;
        }

        .ama-long > summary { display: none; }
    }
}
