/* ThePrintLab typeface: TeX Gyre Heros, a free version of Helvetica's design (GUST Font License, fonts/GUST-FONT-LICENSE.txt) */
@font-face { font-family: "TeX Gyre Heros"; src: url("/fonts/TeXGyreHeros-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "TeX Gyre Heros"; src: url("/fonts/TeXGyreHeros-Italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "TeX Gyre Heros"; src: url("/fonts/TeXGyreHeros-Bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "TeX Gyre Heros"; src: url("/fonts/TeXGyreHeros-BoldItalic.woff2") format("woff2"); font-weight: 700; font-style: italic; font-display: swap; }
/* ============================================================
   Reading Against the Record — digitalarthistory.theprintlab
   
   Palette: washi-white ground and sumi ink, with three accents,
   one meaning each. Edo purple (Edo-murasaki) for the Japanese
   material; Prussian blue for the
   computational operation; vermilion, the colour of a seal, for a
   decision you make. Blue and vermilion are ThePrintLab's colours.
   
   No JavaScript anywhere on this site. Every page is HTML and
   this one stylesheet.
   ============================================================ */

:root {
    --paper:      #EEF1F4;   /* pale indigo: a calm ground, so the prints carry the warmth */
    --paper-deep: #E3E8ED;
    --sumi:       #211E18;
    --sumi-soft:  #57513F;
    --ai:         #1D4A73;   /* Prussian blue, lightened from ThePrintLab’s #0E3150 so it reads apart from sumi: the computational operation */
    --ai-deep:    #0A2338;
    --sap:        #5B3A84;   /* Edo purple (Edo-murasaki): the Japanese material */
    --ochre:      #B8301B;   /* vermilion (ThePrintLab), the colour of a seal: a decision you make */
    --rule:       #CBD3DB;
    --red:        #A3271F;   /* warning only: the construction notice */

    /* One typeface, TeX Gyre Heros, served from this site's own /fonts folder: nothing is fetched from another server.
       Japanese falls through to Hiragino Kaku Gothic (Yu Gothic / Meiryo on Windows).
       The three names stay so existing rules keep working. */
    --sans:    "TeX Gyre Heros", "Helvetica Neue", Helvetica, Arial,
               "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic Medium", "Yu Gothic", Meiryo, "Noto Sans JP", sans-serif;
    --display: var(--sans);
    --serif:   var(--sans);
    --mono:  ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --s--1: 0.875rem;
    --s-0:  1.1875rem;
    --s-1:  1.375rem;
    --s-2:  1.625rem;
    --s-3:  2.15rem;

    --measure: 66ch;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--serif);
    font-size: var(--s-0);
    line-height: 1.75;
    background: var(--paper);
    color: var(--sumi);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--sumi);
    text-decoration: underline;
    text-decoration-color: var(--rule);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}
a:hover { text-decoration-color: var(--sumi); }

a:focus-visible, summary:focus-visible {
    outline: 2px solid var(--ai);
    outline-offset: 2px;
}


/* --- under-construction notice ------------------------------ */
/* Sits above everything, in red: the one warning on the site. */

.construction {
    background: var(--red);
    border-bottom: 2px solid #7A1C16;
    padding: 0.85rem 0;
    font-family: var(--sans);
    font-size: var(--s--1);
    line-height: 1.6;
    color: #FFFFFF;
}
.construction p { margin: 0; max-width: none; }
.construction p + p { margin-top: 0.3rem; color: #F6DCD8; }
.construction strong {
    color: #FFFFFF;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.75rem;
    margin-right: 0.5rem;
}


/* --- shell -------------------------------------------------- */

.container { width: min(92vw, 720px); margin: 0 auto; padding: 0 1.25rem; }

nav {
    border-bottom: 1px solid var(--rule);
    padding: 1.1rem 0;
    margin-bottom: 3rem;
}
nav .container {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem 1.5rem;
    flex-wrap: wrap;
}
nav .logo {
    font-family: var(--display);
    font-size: var(--s-1);
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--sumi);
    text-decoration: none;
}
nav .logo { display: inline-flex; align-items: flex-end; gap: 0.5rem; }
nav .logo > span:not(.logo-rule) { line-height: 1; padding-bottom: 0.17em; }  /* the mark's bar sits on the text baseline */
nav .logo-mark { width: 1.6em; height: 1.6em; flex: 0 0 auto; }
nav .logo-brand { font-weight: 400; }
nav .logo-site { white-space: nowrap; }
/* lockup rule: as tall as the mark's drawn shapes (90.2% of its box, inset 4.9% top and bottom) */
nav .logo-rule { align-self: flex-end; width: 1px; height: calc(1.6em * 0.902); margin: 0 0.15rem calc(1.6em * 0.049); background: var(--sumi-soft); }
@media (max-width: 480px) { nav .logo .ja { display: none; } }
nav .logo .ja { color: var(--sumi-soft); font-weight: 400; }
nav ul { display: flex; gap: 1.5rem; list-style: none; flex-wrap: wrap; }
nav ul a {
    font-family: var(--sans);
    font-size: var(--s--1);
    color: var(--sumi-soft);
    text-decoration: none;
}
nav ul a:hover { color: var(--sumi); }
nav ul a[aria-current] { color: var(--sumi); border-bottom: 1px solid var(--sumi); padding-bottom: 2px; }

footer {
    border-top: 1px solid var(--rule);
    margin-top: 5rem;
    padding: 2rem 0 3rem;
    font-family: var(--sans);
    font-size: var(--s--1);
    color: var(--sumi-soft);
    line-height: 1.9;
}
footer a { color: var(--sumi-soft); }
footer a:hover { color: var(--sumi); }
footer p + p { margin-top: 0.25rem; }
footer .links a + a { margin-left: 1.25rem; }

/* --- type --------------------------------------------------- */

h1 {
    font-family: var(--display);
    font-size: var(--s-3);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: 0.75rem;
}
h2 {
    font-family: var(--display);
    font-size: var(--s-2);
    font-weight: 600;
    line-height: 1.25;
    margin: 3.5rem 0 1rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--rule);
    max-width: var(--measure);
}
h3 { font-size: var(--s-1); font-weight: 600; margin: 2rem 0 0.6rem; }
h4 { font-size: var(--s-0); font-weight: 600; margin-bottom: 0.4rem; }

p  { margin-bottom: 1.15rem; max-width: var(--measure); }
ul, ol { margin: 0 0 1.5rem 1.4rem; max-width: var(--measure); }
li { margin-bottom: 0.45rem; }

em { font-style: italic; }

.lede { font-size: var(--s-1); line-height: 1.6; margin-bottom: 1.5rem; }
.meta {
    font-family: var(--sans);
    font-size: var(--s--1);
    color: var(--sumi-soft);
    line-height: 1.7;
    max-width: var(--measure);
}
.eyebrow {
    font-family: var(--sans);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--sumi-soft);
    margin-bottom: 0.5rem;
}
.ja { font-family: var(--sans); }

code {
    font-family: var(--mono);
    font-size: 0.86em;
    background: var(--paper-deep);
    padding: 0.1em 0.35em;
    word-break: break-word;
}

/* --- masthead ----------------------------------------------- */

.masthead { margin-bottom: 3.5rem; }
.masthead h1 { max-width: 20ch; }
.masthead .lede { max-width: 48ch; color: var(--sumi-soft); }

/* --- the one box -------------------------------------------- */
/* Every aside on the site is this. The label says what it is;
   the styling never varies. Two exceptions below. */

.box > *:last-child { margin-bottom: 0; }
.box-label {
    display: block;
    font-family: var(--sans);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--sumi-soft);
    margin-bottom: 0.6rem;
}
.box p, .box ul, .box ol { max-width: none; }
.box ul, .box ol { margin-bottom: 0.9rem; }

/* Exception 1: the question, whose answer folds away */
.box details { margin-top: 0.75rem; }
.box summary {
    cursor: pointer;
    list-style: none;
    font-family: var(--sans);
    font-size: var(--s--1);
    color: var(--sumi-soft);
}
.box summary::-webkit-details-marker { display: none; }
.box summary::marker { content: ""; }
.box summary::before { content: "▸ "; }
.box details[open] summary::before { content: "▾ "; }
.box details[open] summary { margin-bottom: 0.75rem; }


/* Two columns for questions and objectives */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.split h4 {
    font-family: var(--sans);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--sumi-soft);
}
.split ul { font-size: var(--s--1); line-height: 1.6; margin-left: 1.1rem; }

/* --- hairline lists ----------------------------------------- */
/* Replaces the card. A rule between items, nothing around them. */

.rows { list-style: none; margin: 2rem 0; max-width: var(--measure); }
.rows > li {
    padding: 1.25rem 0;
    border-top: 1px solid var(--rule);
    margin: 0;
}
.rows > li:last-child { border-bottom: 1px solid var(--rule); }
.rows h3 { margin: 0 0 0.35rem; }
.rows p { margin-bottom: 0.6rem; }
.rows .num {
    font-family: var(--sans);
    font-size: var(--s--1);
    color: var(--sumi-soft);
    margin-right: 0.6rem;
}
.rows .note { font-family: var(--sans); font-size: var(--s--1); color: var(--sumi-soft); }

/* Numbered sequence: the three things you do, in order */
.numbered { list-style: none; margin: 2rem 0; max-width: var(--measure); counter-reset: n; }
.numbered > li {
    counter-increment: n;
    padding: 0.9rem 0 0.9rem 2.5rem;
    border-top: 1px solid var(--rule);
    position: relative;
    margin: 0;
}
.numbered > li:last-child { border-bottom: 1px solid var(--rule); }
.numbered > li::before {
    content: counter(n);
    position: absolute;
    left: 0;
    top: 0.9rem;
    font-family: var(--sans);
    font-size: var(--s--1);
    color: var(--sumi-soft);
}
.numbered strong { display: block; }
.numbered p { margin: 0.2rem 0 0; font-size: var(--s--1); color: var(--sumi-soft); }

/* --- tables -------------------------------------------------- */

table {
    width: 100%;
    max-width: var(--measure);
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: var(--s--1);
}
th, td { text-align: left; padding: 0.6rem 0.75rem 0.6rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-family: var(--sans); font-weight: 600; }
td:not(:last-child), th:not(:last-child) { padding-right: 1.5rem; }

/* --- code and output ----------------------------------------- */
/* The frame echoes the printed image field: a single thin rule
   with the ground showing through. */

.code, .output { margin: 1.5rem 0; max-width: var(--measure); }
.code-label {
    display: block;
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--sumi-soft);
    margin-bottom: 0.4rem;
}
.code pre, .output pre {
    font-family: var(--mono);
    font-size: 0.82rem;
    line-height: 1.7;
    padding: 1rem 1.1rem;
    overflow-x: auto;
    tab-size: 4;
}
.code pre { border: 1px solid var(--sumi); background: var(--paper-deep); }
.output { margin-top: -0.5rem; }
.output pre { border: 1px dashed var(--rule); background: none; color: var(--sumi-soft); }
.code pre code, .output pre code { font: inherit; background: none; padding: 0; }

/* --- the run bar and badges ---------------------------------- */

.run {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 0;
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
    margin: 0 0 2.5rem;
    max-width: var(--measure);
    font-family: var(--sans);
    font-size: var(--s--1);
    color: var(--sumi-soft);
}
.run img { display: block; height: 20px; width: auto; }

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

.toc { list-style: none; margin: 0 0 3rem; max-width: var(--measure); font-family: var(--sans); font-size: var(--s--1); }
.toc li { padding: 0.35rem 0; border-bottom: 1px solid var(--rule); margin: 0; }
.toc a { color: var(--sumi); text-decoration: none; }
.toc a:hover { color: var(--sumi); }
.toc .num { color: var(--sumi-soft); margin-right: 0.7rem; }

.pager {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 3.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--rule);
    max-width: var(--measure);
    font-family: var(--sans);
    font-size: var(--s--1);
}
.pager a { text-decoration: none; }
.pager a:hover { text-decoration: underline; }
.pager .nav-label {
    display: block;
    font-size: 0.7rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--sumi-soft);
}

/* --- provenance stamp ----------------------------------------- */

.provenance {
    font-family: var(--mono);
    font-size: 0.75rem;
    line-height: 1.6;
    color: var(--sumi-soft);
    max-width: var(--measure);
}

/* --- small screens -------------------------------------------- */

@media (max-width: 640px) {
    :root { --s-3: 1.8rem; --s-2: 1.45rem; }
    .container { padding: 0 1rem; }
    p, ul, ol, h2, table, .box, .code, .output, .run, .toc, .pager,
    .rows, .numbered, .meta, .provenance { max-width: 100%; }
    .split { grid-template-columns: 1fr; gap: 1.25rem; }
    nav { margin-bottom: 2rem; }
    nav ul { gap: 1rem; }
    h2 { margin-top: 2.5rem; }
}

/* --- glossed terms -------------------------------------------- */
/* A term marked in prose is a link to its glossary entry. Dotted
   underline, no colour change, so the sentence still reads as a
   sentence. No JavaScript: the reader clicks, reads, comes back. */

.term {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted var(--sumi-soft);
}
.term:hover { border-bottom-style: solid; }

/* The short list at the head of a recipe: the words that recipe needs */
.terms { margin: 0; }
.terms dt {
    font-weight: 600;
    font-size: var(--s--1);
    margin-top: 0.6rem;
}
.terms dt:first-child { margin-top: 0; }
.terms dd {
    margin: 0;
    font-size: var(--s--1);
    line-height: 1.6;
    color: var(--sumi-soft);
}

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

.glossary { margin: 0 0 3rem; max-width: var(--measure); }
.glossary dt {
    font-family: var(--serif);
    font-size: var(--s-1);
    font-weight: 600;
    margin-top: 2rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--rule);
    scroll-margin-top: 1.5rem;
}
.glossary dt:first-of-type { margin-top: 0; }
.glossary dt .ja { font-weight: 400; color: var(--sumi-soft); font-size: var(--s-0); margin-left: 0.5rem; }
.glossary dd { margin: 0.5rem 0 0; }
.glossary dd p { margin-bottom: 0.7rem; }
.glossary dd p:last-child { margin-bottom: 0; }
.glossary dd .seealso {
    font-family: var(--sans);
    font-size: var(--s--1);
    color: var(--sumi-soft);
}

/* Highlight the entry the reader arrived at */
.glossary dt:target,
.glossary dt:target + dd {
    background: var(--paper-deep);
    box-shadow: -0.75rem 0 0 var(--paper-deep), 0.75rem 0 0 var(--paper-deep);
}

/* Jump bar */
.alphabet {
    font-family: var(--mono);
    font-size: var(--s--1);
    letter-spacing: 0.15em;
    padding: 0.75rem 0;
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
    margin: 0 0 2.5rem;
    max-width: var(--measure);
}
.alphabet a { text-decoration: none; }
.alphabet span { color: var(--rule); }

/* ==============================================================
   e_tehon — module layer
   
   A module page is one wide column with a margin column beside it.
   The margin column carries the two side-panels: one for readers
   who know computers and not Japan, one for readers who know Japan
   and not computers. Below 1080px they fall inline, in place.
   ============================================================== */

.wide { width: min(94vw, 1080px); margin: 0 auto; padding: 0 1.25rem; }
.wide p, .wide ul, .wide ol, .wide h2, .wide table,
.wide .box, .wide .code, .wide .output, .wide .run,
.wide .toc, .wide .pager, .wide .meta, .wide .provenance,
.wide .steps { max-width: 66ch; }
.wide h1 { max-width: 24ch; }

/* --- the two side-panels --------------------------------------- */
/* Folded shut by default: a tab in the margin the reader opens when
   they want it. <details> does this with no JavaScript, and stays
   keyboard-operable and legible to a screen reader. */

.side {
    float: right;
    clear: right;
    width: 17rem;
    margin: 0.5rem 0 1.75rem 2.5rem;
    font-size: var(--s--1);
    line-height: 1.6;
    color: var(--sumi-soft);
}
.side > summary {
    cursor: pointer;
    list-style: none;
    display: block;
    position: relative;
    padding: 0.3rem 1.6rem 0.3rem 0;
}
.side > summary::-webkit-details-marker { display: none; }
.side > summary::marker { content: ""; }
.side > summary::after {
    content: "+";
    position: absolute;
    right: 0;
    top: 0;
    font-family: var(--sans);
    font-size: var(--s--1);
    line-height: 1.2;
}
.side[open] > summary::after { content: "\2212"; }
.side[open] > summary { margin-bottom: 0.7rem; }
.side > summary:hover .side-label { text-decoration: underline; text-underline-offset: 3px; }
.side p { margin-bottom: 0.7rem; max-width: none; }
.side p:last-child { margin-bottom: 0; }
.side ul { margin: 0 0 0.7rem 1.1rem; max-width: none; }
.side li { margin-bottom: 0.3rem; }
.side-label {
    display: block;
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    margin-bottom: 0;
    line-height: 1.4;
}
/* Edo purple for what the material requires, Prussian blue for what the
   operation decides, each doing one job. */
.side-japan  { color: var(--sap); }
.side-machine { color: var(--ai); }
.side-japan .side-label,  .side-japan > summary::after  { color: var(--sap); }
.side-machine .side-label, .side-machine > summary::after { color: var(--ai); }
/* Open, the panel gets a ground of its own colour at low strength, so the
   margin reads as a second voice rather than a footnote. */
.side-japan[open]  { background: rgba(91, 58, 132, 0.06); }
.side-machine[open] { background: rgba(29, 74, 115, 0.05); }
.side[open] > summary { padding-top: 0.5rem; }
.side p, .side li { color: var(--sumi-soft); }

@media (max-width: 1080px) {
    .side {
        float: none;
        width: auto;
        max-width: 66ch;
        margin: 1.5rem 0;
    }
}

/* --- module header --------------------------------------------- */

.crumb {
    font-family: var(--sans);
    font-size: var(--s--1);
    color: var(--sumi-soft);
    margin-bottom: 0.75rem;
}
.crumb a { color: var(--sumi-soft); }

.chip {
    display: inline-block;
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.55rem;
    background: var(--paper-deep);
    border: 1px solid var(--rule);
    color: var(--sumi-soft);
    margin-bottom: 1rem;
}

.subtitle {
    font-size: var(--s-1);
    line-height: 1.5;
    color: var(--sumi-soft);
    margin-bottom: 1.25rem;
    max-width: 46ch;
}

/* The facts strip: duration, prerequisite, sources, licence */
.facts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.75rem;
    list-style: none;
    margin: 0 0 2.5rem;
    padding: 0.75rem 0;
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
    max-width: 66ch;
    font-family: var(--sans);
    font-size: var(--s--1);
    color: var(--sumi-soft);
}
.facts li { margin: 0; }

/* --- the starting point ----------------------------------------- */
/* Every module opens with a research question in the first person,
   because that is how it arrives in real work. */

.starting .box-label { color: var(--ai); }
.starting p {
    margin-bottom: 0;
    max-width: none;
    font-size: var(--s-1);
    line-height: 1.55;
}

/* --- steps ------------------------------------------------------- */

.step-label {
    font-family: var(--sans);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--sumi-soft);
    margin: 3rem 0 0.75rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--rule);
    max-width: 66ch;
}

/* --- the choice point -------------------------------------------- */
/* Not a recipe: at each fork the module names the options and says
   what each one costs. */

.choice .box-label { color: var(--ochre); }
.choice dt { font-weight: 600; margin-top: 0.8rem; }
.choice dt:first-of-type { margin-top: 0; }
.choice dd { margin: 0.15rem 0 0; color: var(--sumi-soft); font-size: var(--s--1); line-height: 1.6; }

/* --- module list on the front page -------------------------------- */

.modules { list-style: none; margin: 2rem 0; max-width: var(--measure); }
.modules > li { padding: 1.5rem 0; border-top: 1px solid var(--rule); margin: 0; }
.modules > li:last-child { border-bottom: 1px solid var(--rule); }
.modules h3 { margin: 0.3rem 0 0.4rem; }
.modules .num { font-family: var(--mono); font-size: var(--s--1); color: var(--sumi-soft); }
.modules .thread {
    font-family: var(--sans);
    font-size: var(--s--1);
    color: var(--sumi-soft);
    display: block;
    margin-top: 0.5rem;
}
.modules .thread strong { color: var(--sap); font-weight: 600; }

/* --- masthead wordmark -------------------------------------------- */

.wordmark { font-family: var(--display); font-size: var(--s-3); font-weight: 600; letter-spacing: -0.02em; }
.wordmark .ja { display: block; font-size: 0.6em; font-weight: 400; color: var(--sumi-soft); margin: 0.3em 0 0.6em; letter-spacing: 0.02em; }  /* Japanese on its own line, lighter and smaller */

/* --- glossary in two parts ------------------------------------- */
/* The reference layer mirrors the side-panels: one part for readers
   who know computers, one for readers who know Japan. */

.gloss-part {
    margin: 3.5rem 0 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--rule);
    max-width: var(--measure);
}
.gloss-part:first-of-type { margin-top: 2rem; }
.gloss-part h2 { margin: 0 0 0.3rem; border-bottom: none; padding-bottom: 0; }
.gloss-part p {
    margin: 0;
    font-family: var(--sans);
    font-size: var(--s--1);
    color: var(--sumi-soft);
}
.gloss-japan { border-bottom-color: var(--sap); }
.gloss-japan h2 { color: var(--sap); }
.gloss-machine { border-bottom-color: var(--ai); }
.gloss-machine h2 { color: var(--ai); }

/* --- per-step run links ---------------------------------------- */
/* Each code block links to the matching cell in the notebook, using
   Colab's #scrollTo=<cell id>. If an id ever stops matching, Colab
   opens the notebook at the top, which is a graceful failure. */

.code-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
}
.code-run {
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ai);
    text-decoration: none;
    border-bottom: 1px solid currentColor;
    white-space: nowrap;
}
.code-run:hover { color: var(--sumi); }

/* --- figures ---------------------------------------------------- */
/* The credit block is a teaching device, not a caption. Every field
   an image record should carry is present and legible, including the
   licence, which is not the site's licence. */

figure { margin: 2.5rem 0; }
figure img {
    display: block;
    width: 100%;
    height: auto;
    background: var(--paper-deep);
}
figcaption {
    margin-top: 0.85rem;
    font-family: var(--sans);
    font-size: var(--s--1);
    line-height: 1.65;
    color: var(--sumi-soft);
    max-width: 66ch;
}
figcaption .fig-title { color: var(--sumi); }
figcaption .fig-title em { font-style: italic; }

/* Source, capture date, licence — the row the register also holds */
.fig-record {
    display: block;
    margin-top: 0.55rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--rule);
    font-family: var(--mono);
    font-size: 0.75rem;
    line-height: 1.7;
}
.fig-record span { display: block; }
.fig-record b { font-weight: 400; color: var(--sumi); }

/* A figure that runs the full width of a module page, margin column included */
.figure-wide { max-width: none; }
.figure-wide figcaption { max-width: 66ch; }

/* The opening on the front page: edge to edge of the reading column */
.figure-lead { margin: 0 0 3rem; }


/* --- colour legend ---------------------------------------------- */
/* Three colours, one meaning each. Said once, on the front page. */

.legend { list-style: none; margin: 1.25rem 0 0; }
.legend li {
    display: flex;
    align-items: baseline;
    gap: 0.7rem;
    margin-bottom: 0.5rem;
    font-size: var(--s--1);
    line-height: 1.6;
}
.legend .swatch {
    flex: 0 0 auto;
    width: 1.6rem;
    height: 0.2rem;
    border-radius: 1px;
    transform: translateY(-0.2em);
}
.legend .sw-japan   { background: var(--sap); }
.legend .sw-machine { background: var(--ai); }
.legend .sw-choice  { background: var(--ochre); }
.legend b { font-weight: 600; color: var(--sumi); }

/* --- wide layout ---------------------------------------------- */
/* Reading text keeps its measure (66ch); the wider frame is used by
   the opening image, the introduction beside "Where to begin",
   and the modules in two columns. */
.container { width: min(94vw, 1080px); }
.figure-lead { max-width: none; }
.figure-lead img { width: 100%; height: auto; }
.figure-lead figcaption { max-width: 66ch; }
.intro { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 0 3rem; align-items: end; margin-bottom: 3rem; }
.intro .masthead { margin-bottom: 0; }
.intro .box { margin: 0; }
.modules { max-width: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 3rem; border-bottom: 1px solid var(--rule); }
.modules > li:last-child { border-bottom: none; }
@media (max-width: 760px) {
    .intro { display: block; }
    .intro .box { margin-top: 2rem; }
    .modules { display: block; border-bottom: none; }
    .modules > li:last-child { border-bottom: 1px solid var(--rule); }
}

/* ==============================================================
   Book layer
   The page is set like a woodblock-printed book (wahon): text sits
   inside ruled frames (kyōkaku 匡郭), the masthead and the end of
   the page carry the thick-and-thin double rule of the frame's top
   edge, and sections are counted 其一, 其二 (part one, part two), the way
   an Edo-period series counts its parts.
   ============================================================== */
:root { --frame: #7D8894; }

/* thick-and-thin rule: a 3px line, a gap, a 1px line */
.masthead, footer .container {
    background:
        linear-gradient(var(--sumi), var(--sumi)) 0 0 / 100% 3px no-repeat,
        linear-gradient(var(--sumi), var(--sumi)) 0 6px / 100% 1px no-repeat;
    padding-top: 1.75rem;
}
footer { border-top: 0; }

/* sections counted 其一, 其二, 其三 in a small frame */
main { counter-reset: sec; }
main h2 { counter-increment: sec; display: flex; align-items: baseline; gap: 0.75rem; }
main h2::before {
    content: "其" counter(sec, japanese-informal);
    flex: 0 0 auto;
    display: inline-flex; align-items: center; justify-content: center;
    height: 1.75em; padding: 0 0.35em; letter-spacing: 0.05em;
    border: 1px solid var(--sumi);
    font-size: 0.62em; font-weight: 400; line-height: 1;
    transform: translateY(-0.15em);
}
.gloss-part h2::before { content: none; }
.toc ol { list-style: none; margin-left: 0; counter-reset: toc; }
.toc ol li { counter-increment: toc; display: flex; gap: 0.75rem; }
.toc ol li::before { content: "其" counter(toc, japanese-informal); min-width: 2.6em; color: var(--sumi-soft); }

/* every aside is a framed block of text */
.box, .choice {
    border: 1px solid var(--frame);
    padding: 1.1rem 1.35rem 1.2rem;
    margin: 2rem 0;
    max-width: 66ch;
}
.box-close { background: var(--paper-deep); }

/* the research question: the double frame of a title slip (daisen 題簽) */
.starting {
    border: 2px solid var(--sumi);
    box-shadow: inset 0 0 0 3px var(--paper-deep), inset 0 0 0 4px var(--sumi);
    background: var(--paper-deep);
    padding: 1.4rem 1.6rem;
    margin: 1.5rem 0 2.5rem;
    max-width: 66ch;
}

/* margin panels: framed in their colour, no side bar */
.side { border: 1px solid currentColor; padding: 0 0.9rem; }
.side[open] { padding-bottom: 0.7rem; }

/* the label above a framed block */
.chip {
    font-family: var(--sans); font-size: var(--s--1); letter-spacing: 0;
    background: none; border: 1px solid var(--sumi); color: var(--sumi);
    padding: 0.15rem 0.6rem;
}

/* tables to fill in */
.fill td { height: 3.2rem; }
.fill td:first-child { width: 34%; }
.fill td + td { border-left: 1px solid var(--rule); padding-left: 0.75rem; }
.fill .hint { display: block; color: var(--sumi-soft); font-size: 0.9em; line-height: 1.5; margin-top: 0.15rem; }
.fill th + th { padding-left: 0.75rem; }
.tools dt { font-weight: 600; margin-top: 1rem; }
.tools dd { margin: 0.1rem 0 0; max-width: 66ch; font-size: var(--s--1); line-height: 1.65; color: var(--sumi-soft); }

/* one reading column: every block on a module page ends at the same line */
.wide { --col: 44rem; }
.wide p, .wide ul, .wide ol, .wide h2, .wide table, .wide .box, .wide .choice,
.wide .starting, .wide .code, .wide .output, .wide .run, .wide .toc, .wide .pager,
.wide .meta, .wide .provenance, .wide .steps, .wide .step-label, .wide .facts,
.wide .rows, .wide .numbered, .wide .tools dd, .wide figcaption { max-width: var(--col); }
.box p, .box ul, .box ol, .choice p, .starting p, .rows p, .numbered p { max-width: none; }
.choice .meta { margin-top: 1rem; }
.ref { border-top: 1px solid var(--rule); max-width: var(--col, 44rem); }
.ref + .ref { border-top: 1px solid var(--rule); }
.ref:has(+ :not(.ref)) { border-bottom: 1px solid var(--rule); margin-bottom: 2rem; }
.ref > summary { cursor: pointer; list-style: none; position: relative; padding: 0.7rem 2rem 0.7rem 0; font-weight: 600; }
.ref > summary::-webkit-details-marker { display: none; }
.ref > summary::after { content: "+"; position: absolute; right: 0; top: 0.7rem; font-weight: 400; }
.ref[open] > summary::after { content: "\2212"; }
.ref[open] { padding-bottom: 1rem; }
.ref h4 { margin: 1.25rem 0 0.25rem; font-size: var(--s-0); }
.wide .masthead { margin-bottom: 0; }
.wide .masthead .facts { margin-bottom: 0; }
.wide .masthead + .run { border-top: 0; }
.wide .masthead + .toc, .wide .masthead + .run + * { margin-top: 2.5rem; }

@media print {
    nav, .pager, .run { display: none; }
    body { background: #fff; font-size: 11pt; }
    .wide { width: auto; }
    .wide table { max-width: none; }
    h2 { break-after: avoid; }
    table, .box { break-inside: avoid; }
    .fill td { height: 2.4rem; }
    a { text-decoration: none; }
}
.masthead .outline { margin-top: 1rem; }


/* --- references ------------------------------------------------- */
/* Author-date references in the text link to the Sources list at the
   end of the page. "source to add" marks a claim still being checked. */
.cite { color: var(--sumi-soft); text-decoration: none; white-space: nowrap; }
.cite:hover { color: var(--sumi); text-decoration: underline; }
.cite-open { color: var(--ochre); font-size: 0.9em; white-space: nowrap; }
.sources { list-style: none; margin-left: 0; font-size: var(--s--1); line-height: 1.65; }
.sources li { padding-left: 1.5rem; text-indent: -1.5rem; margin-bottom: 0.5rem; scroll-margin-top: 1.5rem; }
.sources li:target { background: var(--paper-deep); }

/* --- site map ----------------------------------------------------- */
.sitemap { display: block; width: 100%; height: auto; }
.sitemap a { text-decoration: none; }
.sitemap-figure { margin-top: 0; }
@media (max-width: 640px) { .sitemap-figure { overflow-x: auto; } .sitemap { min-width: 640px; } }
