/* Shared page style for explorable articles. Article colors go in article.css. */

:root {
    --page: #f8f8f6;
    --text: #444;
    --heading: #333;
    --link: #0b78d0;

    /* Neutral tokens that each figure can read with fig.color("ink") and so on. */
    --c-ink: #3a3a3a;
    --c-muted: #9a9a9a;
    --c-faint: #dcdcd8;
    --c-paper: #f8f8f6;
    --c-action: #b8862b;
}

.dark {
    --text: #ddd;
    --heading: #f2f2f2;
    --link: #6db4f0;
    --c-ink: #e6e6e6;
    --c-muted: #8a8a8a;
    --c-faint: #2c2c2c;
    --c-paper: #000;
    --c-action: #dfb870;
}

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

body {
    margin: 0;
    background: var(--page);
    color: var(--text);
    font: 19px/1.62 "Avenir Next", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

.article { padding: 3rem 0 5rem; }

.article > *,
.dark > * {
    max-width: 42rem;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    box-sizing: content-box;
}

h1, h2, h3 { color: var(--heading); font-weight: 650; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 2.3rem; margin-top: 0; margin-bottom: 0.6rem; }
h2 { font-size: 1.55rem; margin-top: 3rem; margin-bottom: 0.3rem; }
h3 { font-size: 1.2rem; margin-top: 2rem; margin-bottom: 0.2rem; }
p { margin-top: 0.75em; margin-bottom: 0.75em; }
.date { color: var(--c-muted); font-size: 0.9rem; margin-bottom: 0; }
a { color: var(--link); text-underline-offset: 0.12em; text-decoration-thickness: 0.06em; }
strong { font-weight: 650; color: var(--heading); }

/* A word that names a colored element of a figure. */
.k { color: var(--k); font-weight: 600; }
.k.dashed { text-decoration: underline dashed; text-underline-offset: 0.2em; }

/* A link that sets a figure to a state. */
a[data-set], a[data-pause-all] { color: var(--c-action); cursor: pointer; }


.article > .dark {
    max-width: none;
    padding: 4rem 0;
    margin: 7rem 0;
    background: #000;
    color: var(--text);
    position: relative;
}
.dark::before, .dark::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 5rem;
    padding: 0;
    max-width: none;
    pointer-events: none;
}
.dark::before { top: -5rem; background: linear-gradient(to bottom, var(--page), #000); }
.dark::after { bottom: -5rem; background: linear-gradient(to top, var(--page), #000); }


.figure {
    position: relative;
    max-width: 430px;
    aspect-ratio: 1 / var(--ratio, 0.66);
    margin-top: 2.2rem;
    margin-bottom: 1.6rem;
    padding: 0 !important;
    user-select: none;
    -webkit-user-select: none;
}
.figure.wide { max-width: min(46rem, 100% - 1.5rem); }
.figure.mid { max-width: 560px; }
.figure canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.figure canvas.draggable { cursor: grab; touch-action: none; }
.figure canvas.dragging { cursor: grabbing; }

.controls { max-width: 380px; margin-top: -0.4rem; margin-bottom: 2rem; }
.controls:empty { display: none; }

.slider {
    position: relative;
    height: 48px;
    margin: 0 18px;
    touch-action: none;
    cursor: pointer;
    --k: var(--c-muted);
}
.slider .track, .slider .fill { position: absolute; left: 0; top: 22px; height: 4px; border-radius: 2px; background: var(--k); }
.slider .track { right: 0; opacity: 0.22; }
.slider .knob {
    position: absolute;
    top: 6px;
    width: 36px;
    height: 36px;
    margin-left: -18px;
    border-radius: 50%;
    background: var(--k);
    cursor: grab;
    outline-offset: 3px;
}
.slider.active .knob { cursor: grabbing; }

.segments { display: flex; margin: 0 0 0.6rem; border-radius: 8px; overflow: hidden; background: color-mix(in srgb, var(--c-ink) 10%, transparent); }
.segments button {
    flex: 1;
    border: 0;
    padding: 0.45em 0.3em;
    background: none;
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}
.segments button.on { background: color-mix(in srgb, var(--c-ink) 22%, transparent); font-weight: 600; }

.play {
    position: absolute;
    left: 4px;
    bottom: 4px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 7px;
    background: color-mix(in srgb, var(--c-ink) 10%, transparent);
    cursor: pointer;
}
.play::before {
    content: "";
    position: absolute;
    left: 13px;
    top: 10px;
    border-style: solid;
    border-width: 7px 0 7px 11px;
    border-color: transparent transparent transparent var(--c-ink);
}
.play.playing::before { left: 11px; width: 4px; height: 14px; border-width: 0 4px; border-color: var(--c-ink); }
body.all-paused .play { opacity: 0.4; }

.equation { text-align: center; font-size: 1.35rem; font-style: italic; margin-top: 1.4rem; margin-bottom: 1.4rem; font-family: Georgia, "Times New Roman", serif; }
.equation .k { font-weight: 400; }

.photo { margin-top: 2rem; margin-bottom: 2rem; text-align: center; }
.photo img { max-width: 100%; height: auto; border-radius: 6px; }


#xa-error {
    position: fixed;
    z-index: 99;
    top: 0;
    left: 0;
    right: 0;
    margin: 0;
    padding: 10px 14px;
    background: #c62828;
    color: #fff;
    font: 13px/1.4 ui-monospace, Menlo, monospace;
    white-space: pre-wrap;
}

body.shot .article { display: none; }
#shot-root { padding: 24px; background: var(--page); min-height: 100vh; box-sizing: border-box; }
#shot-root.dark { background: #000; }
#shot-root.dark::before, #shot-root.dark::after { display: none; }
#shot-root > * { max-width: none; padding: 0; }
#shot-root > .figure { max-width: 430px; margin-left: auto; margin-right: auto; }
#shot-root > .figure.mid { max-width: 560px; }
#shot-root > .figure.wide { max-width: 44rem; }
#shot-root > .controls { max-width: 380px; margin-left: auto; margin-right: auto; }

@media (max-width: 560px) {
    body { font-size: 17px; }
    h1 { font-size: 1.9rem; }
    .article > *, .dark > * { padding-left: 1.1rem; padding-right: 1.1rem; }
}
