/* The inventions guide (/uses/inventions): workshop paper and ink, one colour for each kind of problem on every lane,
   dot and chip. Marks meet 3:1 on their lane; text meets 4.5:1. */
.pg-inv-guide {
    --i-ink: #1f2933;
    --i-soft: #4e5966;
    --i-paper: #f8f7f3;
    --i-line: #e3e0d6;
    --c-writing: #7a4fa3;
    --c-communication: #2a62ad;
    --c-computing: #0f7480;
    --c-medicine: #b23a48;
    --c-agriculture: #4c7a28;
    --c-transport: #b85a14;
    --c-materials: #6b5a45;
    --c-energy: #8f6c00;
    --c-instruments: #3b5576;
    --c-everyday: #a13d7e;
    --toc-group: var(--c-communication);
}
.pg-inv-guide .eyebrow { color: var(--c-communication); }
.pg-inv-guide :is(.pg-inv-hero, .pg-inv-reader, .pg-inv-pictures, .pg-inv-section, .pg-guide-build, .pg-guide-fields) { scroll-margin-top: 24px; }
/* The reader and the pictures change in place; the browser must not scroll the page to follow what moved inside them. */
.pg-inv-reader, .pg-inv-wall-frame { overflow-anchor: none; }
.pg-c-writing { --c: var(--c-writing); }
.pg-c-communication { --c: var(--c-communication); }
.pg-c-computing { --c: var(--c-computing); }
.pg-c-medicine { --c: var(--c-medicine); }
.pg-c-agriculture { --c: var(--c-agriculture); }
.pg-c-transport { --c: var(--c-transport); }
.pg-c-materials { --c: var(--c-materials); }
.pg-c-energy { --c: var(--c-energy); }
.pg-c-instruments { --c: var(--c-instruments); }
.pg-c-everyday { --c: var(--c-everyday); }

/* ---- Every invention on one line ---- */
.pg-inv-hero { margin: 4px 0 28px; padding: 32px 32px 24px; background: var(--i-paper); border: 1px solid var(--i-line); border-radius: 18px; color: var(--i-ink); }
.pg-inv-hero h2 { margin: 0 0 10px; }
.pg-inv-intro { max-width: 780px; margin: 0; line-height: 1.65; color: var(--i-soft); font-size: .96rem; }
.pg-inv-intro b { color: var(--i-ink); }
.pg-inv-figure { margin: 18px 0 8px; }
/* The line and its lane names share one grid cell, so the names keep a readable size at any width. */
.pg-inv-plot { position: relative; display: grid; container-type: inline-size; }
.pg-inv-plot > :is(svg, ol) { grid-area: 1 / 1; }
.pg-inv-line { display: block; width: 100%; height: auto; overflow: visible; }
.pg-lane rect { fill: color-mix(in srgb, var(--c) 6%, #fff); }
.pg-lane:nth-child(even) rect { fill: color-mix(in srgb, var(--c) 10%, #fff); }
.pg-inv-lanes { position: relative; z-index: 1; justify-self: start; width: 16.8%; margin: 0; padding: 0; list-style: none; pointer-events: none; }
.pg-inv-lanes li { position: absolute; left: 0; padding: 0 6px; transform: translateY(-50%); font: 600 .74rem/1.3 system-ui, sans-serif; color: color-mix(in srgb, var(--c) 80%, #000); white-space: nowrap; }
.pg-inv-lane-short { display: none; }
.pg-tick line { stroke: #d6d2c6; stroke-dasharray: 2 3; }
.pg-tick text { font: 600 9.5px system-ui, sans-serif; fill: var(--i-soft); text-anchor: middle; }
/* Where the full names would not fit their column, the lanes keep their first words; the years grow as the line
   shrinks, so they stay readable on a tablet. */
@container (max-width: 1049px) {
    .pg-inv-lane-full { display: none; }
    .pg-inv-lane-short { display: inline; }
    .pg-tick text { font-size: 11px; }
}
@container (max-width: 760px) {
    .pg-tick text { font-size: 13px; }
}
.pg-links path { fill: none; stroke: #b9b4a6; stroke-width: .8; opacity: .55; }
.pg-links path.pg-on { stroke: var(--i-ink); stroke-width: 1.8; opacity: 1; }
.pg-marks circle { fill: var(--c); stroke: #fff; stroke-width: 1.2; cursor: pointer; opacity: .55; }
.pg-marks circle.pg-chain { opacity: 1; }
.pg-marks circle.pg-on { stroke: var(--i-ink); stroke-width: 2.5; opacity: 1; }
/* The dot nearest the pointer (the script finds it, so a near miss still counts). */
.pg-marks circle:is(:hover, .pg-near) { opacity: 1; stroke: var(--i-ink); stroke-width: 2; }
/* Pointing near a dot names it, and the name clears on the way out (as the Titanic memorial's marks do). */
.pg-inv-tip { position: absolute; z-index: 2; top: 0; left: 0; margin: 0; padding: 7px 11px; border-radius: 8px; background: var(--i-ink); color: #fff; font-size: .78rem; line-height: 1.35; white-space: nowrap; pointer-events: none; box-shadow: 0 4px 14px rgb(15 28 46 / .25); }
.pg-inv-tip[hidden] { display: none; }
.pg-inv-tip strong { display: block; font-size: .85rem; }
.pg-inv-tip span { color: #c9d3dc; }
.pg-inv-scale { margin-top: 6px; font-size: .85rem; color: var(--i-soft); }
.pg-inv-swipe { display: none; }
.pg-inv-choose { margin-top: 14px; }
.pg-inv-choose > label { display: block; margin-bottom: 6px; font-weight: 700; }
.pg-inv-choose-row { display: flex; flex-wrap: wrap; gap: 10px; }
.pg-inv-choose select { flex: 0 1 380px; min-width: 0; padding: 10px 12px; font-size: 1rem; border: 1px solid #b7b2a4; border-radius: 10px; background: #fff; color: var(--i-ink); }
.pg-inv-error { margin: 10px 0 0; color: #8f1d14; font-weight: 600; }
/* The chosen invention, under the line: a choice made here opens below without moving the page, so this says what opened. */
.pg-inv-cue { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 18px; max-width: 780px; margin: 12px 0 0; padding: 9px 14px; background: #fff; border: 1px solid var(--i-line); border-left: 4px solid var(--c); border-radius: 10px; line-height: 1.5; }
.pg-inv-cue i { display: inline-block; width: 10px; height: 10px; margin: 0 9px 0 2px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--i-ink); vertical-align: 0; }
.pg-inv-cue [data-cue-meta] { color: var(--i-soft); }
.pg-inv-cue a { font-weight: 700; white-space: nowrap; }
.pg-inv-cue-flash { animation: pg-inv-cue-flash 1.4s ease-out; }
@keyframes pg-inv-cue-flash { from { background: color-mix(in srgb, var(--c) 18%, #fff); } to { background: #fff; } }
@media (prefers-reduced-motion: reduce) { .pg-inv-cue-flash { animation: none; } }

/* ---- Follow an invention ---- */
.pg-inv-reader { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 24px 34px; margin: 0 0 44px; }
.pg-inv-about { align-self: start; }
/* The reader wears the chosen invention's colour, as its dot on the line does. */
.pg-inv-guide .pg-inv-kind { display: flex; align-items: center; gap: 8px; color: color-mix(in srgb, var(--c) 80%, #000); }
.pg-inv-kind::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.pg-inv-about h2 { margin: 0 0 6px; font-size: 1.7rem; }
.pg-inv-meta { margin: 0 0 14px; color: var(--i-soft); }
.pg-inv-about h3, .pg-inv-steps h3 { margin: 16px 0 6px; font-size: 1rem; }
.pg-inv-about > p, .pg-inv-about > div > p { line-height: 1.6; }
.pg-inv-about [data-r="images"] { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-bottom: 4px; }
.pg-inv-picture { margin: 0; padding: 10px; background: var(--i-paper); border: 1px solid var(--i-line); border-radius: 12px; }
/* The picture's own width and height are on the img, so its space is kept while it loads and the text below stays put. */
.pg-inv-picture img { display: block; width: 100%; height: auto; max-height: 300px; object-fit: contain; background: #fff; border-radius: 6px; }
.pg-inv-picture figcaption { margin-top: 8px; font-size: .84rem; line-height: 1.5; color: var(--i-ink); }
.pg-inv-picture figcaption > span { display: block; color: var(--i-soft); font-size: .78rem; }
.pg-inv-context { margin: 12px 0; padding: 10px 14px; border-left: 4px solid var(--c-energy); background: #fbf6e6; line-height: 1.55; }
.pg-inv-context[hidden] { display: none; }
.pg-inv-links p { margin: 6px 0; }
.pg-inv-links b { margin-right: 6px; }
.pg-inv-steps h3 span { margin-left: 6px; font-weight: 600; color: var(--i-soft); }
.pg-inv-people { margin: 0 0 10px; color: var(--i-soft); }
.pg-inv-steps ol { margin: 0 0 0 8px; padding: 0; list-style: none; border-left: 2px solid var(--i-line); }
.pg-inv-steps li { position: relative; margin: 0 0 12px; padding: 0 0 0 16px; }
.pg-inv-steps li::before { content: ""; position: absolute; left: -7px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--c, var(--i-soft)); }
/* The first step is the invention's dot on the line. */
.pg-inv-steps li:first-child::before { background: var(--c, var(--i-soft)); }
.pg-inv-steps li p { margin: 2px 0; line-height: 1.55; }
.pg-step-head b { margin-right: 6px; }
.pg-stage { display: inline-block; margin-right: 6px; padding: 1px 8px; border-radius: 999px; background: #eef1f5; color: var(--i-ink); font-size: .76rem; font-weight: 700; }
.pg-flag { display: inline-block; margin-right: 6px; padding: 1px 8px; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.pg-f-independent { background: #e7f0fb; color: #1d4f91; }
.pg-f-disputed { background: #fbeaea; color: #8f1d14; }
.pg-f-design, .pg-f-reconstruction { background: #f1ecf8; color: #5b3a85; }
.pg-f-legend { background: #f3f0e7; color: #5d5136; }
.pg-step-meta { font-size: .84rem; color: var(--i-soft); }
.pg-step-meta a { margin-left: 4px; }

/* ---- Inventions in pictures: the pictured inventions on the same stretched line, as cards on a grid of 1000 columns
   (InventionsGuide.PictureColumns). Each card's dot sits on its top edge at its year; rows fill from the top. ---- */
.pg-inv-pictures { margin: 0 0 44px; }
.pg-inv-pictures h2 { margin: 0 0 8px; }
.pg-inv-pictures .pg-inv-lead { margin: 0; }
.pg-inv-pic-keys { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 12px; }
.pg-inv-pic-keys[hidden] { display: none; }
.pg-inv-pic-key { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 5px 12px; border: 1px solid color-mix(in srgb, var(--c, var(--i-ink)) 35%, #fff); border-radius: 999px; background: #fff; color: var(--i-ink); font: inherit; font-size: .84rem; cursor: pointer; }
.pg-inv-pic-key i { width: 11px; height: 11px; border-radius: 50%; background: var(--c); }
.pg-inv-pic-key b { font-weight: 600; color: color-mix(in srgb, var(--c, var(--i-ink)) 85%, #000); }
.pg-inv-pic-key:hover { border-color: var(--c, var(--i-ink)); }
.pg-inv-pic-key[aria-pressed='true'] { background: var(--c, var(--i-ink)); border-color: var(--c, var(--i-ink)); color: #fff; }
.pg-inv-pic-key[aria-pressed='true'] i { background: #fff; }
.pg-inv-pic-key[aria-pressed='true'] b { color: #fff; }
.pg-inv-wall-frame { margin: 14px 0 8px; padding: 10px 14px 16px; background: var(--i-paper); border: 1px solid var(--i-line); border-radius: 14px; overflow-x: auto; overscroll-behavior-x: contain; }
.pg-inv-wall { position: relative; min-width: 1040px; padding-top: 32px; }
.pg-inv-wall-tick { position: absolute; top: 0; bottom: 0; border-left: 1px dashed #d6d2c6; }
.pg-inv-wall-tick b { position: absolute; top: 4px; left: 5px; font: 600 .74rem system-ui, sans-serif; color: var(--i-soft); white-space: nowrap; }
.pg-inv-wall-tick:nth-last-child(2) b { left: auto; right: 5px; }
.pg-inv-wall-grid { display: grid; grid-template-columns: repeat(1000, minmax(0, 1fr)); row-gap: 10px; }
.pg-inv-pic { position: relative; grid-column: var(--col) / span var(--span); grid-row: var(--row); display: flex; flex-direction: column; padding: 0 0 5px; background: #fff; border: 1px solid var(--i-line); border-top: 3px solid var(--c); border-radius: 5px; color: var(--i-ink); text-decoration: none; }
.pg-inv-pic[hidden] { display: none; }
.pg-inv-pic-img { order: -1; position: relative; display: block; }
.pg-inv-pic img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; background: #ece9e0; }
/* On the picture: when the picture was made, which is often long after the invention's first step. */
.pg-inv-pic-made { position: absolute; left: 4px; bottom: 4px; max-width: calc(100% - 8px); padding: 1px 5px; border-radius: 4px; background: rgb(255 255 255 / .93); font-size: .62rem; font-weight: 600; line-height: 1.35; color: var(--i-ink); }
.pg-inv-pic b { margin: 5px 5px 0; font-size: .72rem; line-height: 1.22; hyphens: auto; overflow-wrap: break-word; }
/* Under the name: the invention's earliest known step, the year its dot marks. */
.pg-inv-pic-date { margin: 1px 5px 0; font-size: .66rem; line-height: 1.3; color: var(--i-soft); }
/* The dot: the invention's year, on the card's top edge (corner to corner). */
.pg-inv-pic::before { content: ""; position: absolute; z-index: 1; top: -7.5px; left: var(--at); width: 12px; height: 12px; margin-left: -6px; box-sizing: border-box; border: 2px solid #fff; border-radius: 50%; background: var(--c); }
.pg-inv-pic:hover { border-color: var(--c); text-decoration: none; }
.pg-inv-pic:hover b { text-decoration: underline; }
.pg-inv-pic[aria-current='true'] { border-color: var(--i-ink); border-top-color: var(--c); box-shadow: 0 0 0 1.5px var(--i-ink); }
.pg-inv-pic:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* Era headings carry the order for screen readers here, and become the list's headings on a phone. */
.pg-inv-pic-era { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.pg-inv-pic-era[hidden] { display: none; }
.pg-inv-wall-note { margin: 0; }

/* ---- Who invented it? and study ---- */
.pg-inv-section { margin: 0 0 44px; }
.pg-inv-lead { max-width: 780px; line-height: 1.65; color: var(--i-soft); }
.pg-inv-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.pg-inv-groups > div { padding: 16px 18px; border: 1px solid var(--i-line); border-radius: 14px; background: #fff; }
.pg-inv-groups h3 { margin: 0 0 4px; font-size: 1rem; }
.pg-inv-groups p { margin: 0 0 10px; font-size: .9rem; color: var(--i-soft); }
.pg-inv-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.pg-inv-chips a { display: inline-block; padding: 4px 10px; border: 1px solid color-mix(in srgb, var(--c) 45%, #fff); border-left: 4px solid var(--c); border-radius: 8px; color: var(--i-ink); font-size: .86rem; text-decoration: none; }
.pg-inv-chips a:hover { border-color: var(--c); }
.pg-inv-ideas { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.pg-inv-ideas article { padding: 16px 18px; border: 1px solid var(--i-line); border-radius: 14px; background: #fff; }
.pg-inv-ideas h3 { margin: 4px 0 6px; font-size: 1.02rem; }
.pg-inv-ideas p { margin: 0; line-height: 1.6; font-size: .92rem; }
.pg-inv-ideas .pg-level-tag { font-size: .76rem; font-weight: 700; color: var(--c-communication); }

@media (max-width: 899px) {
    .pg-inv-reader { grid-template-columns: 1fr; }
    .pg-inv-groups, .pg-inv-ideas { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
    .pg-inv-hero { padding: 22px 14px 18px; }
    /* Stacked one above the other, the reader's pictures are a little shorter, so the story starts sooner. */
    .pg-inv-picture img { max-height: 240px; }
    /* On a phone the line keeps a readable size and scrolls sideways inside its frame. */
    .pg-inv-frame { overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
    .pg-inv-plot { min-width: 880px; }
    /* The lane names stay at the left edge while the line scrolls, on a wash of the paper so the dots show through. */
    .pg-inv-lanes { position: sticky; left: 0; }
    .pg-inv-lanes li { padding: 0 6px 0 5px; border-radius: 0 6px 6px 0; background: color-mix(in srgb, var(--i-paper) 78%, transparent); font-size: .7rem; }
    .pg-inv-swipe { display: inline; }
    /* On a phone the pictures become a list, oldest first, under their eras' headings. */
    .pg-inv-wall-frame { margin-top: 8px; padding: 0; background: none; border: 0; overflow: visible; }
    .pg-inv-wall { min-width: 0; padding-top: 0; }
    .pg-inv-wall-tick, .pg-inv-wall-note, .pg-inv-pic::before { display: none; }
    .pg-inv-wall-grid { grid-template-columns: minmax(0, 1fr); row-gap: 6px; }
    .pg-inv-pic-era { position: static; width: auto; height: auto; margin: 12px 0 0; overflow: visible; clip-path: none; white-space: normal; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--c-communication); }
    .pg-inv-cue { font-size: .92rem; }
    .pg-inv-pic-keys { gap: 6px; }
    .pg-inv-pic-key { gap: 6px; padding: 4px 11px; }
    .pg-inv-key-more, .pg-inv-wide { display: none; }
    /* Each picture is a row: the picture, then the name over the date, centred beside it. A long name makes the row
       taller and the picture fills it. */
    .pg-inv-pic { grid-column: auto; grid-row: auto; display: grid; grid-template-columns: 104px minmax(0, 1fr); grid-template-rows: 1fr auto auto 1fr; column-gap: 12px; padding: 0; border-top-width: 1px; border-left: 4px solid var(--c); }
    .pg-inv-pic-img { grid-row: 1 / -1; grid-column: 1; min-height: 78px; }
    .pg-inv-pic img { height: 100%; }
    .pg-inv-pic b { grid-row: 2; grid-column: 2; margin: 8px 10px 0 0; font-size: .95rem; line-height: 1.3; }
    .pg-inv-pic-date { grid-row: 3; grid-column: 2; margin: 1px 10px 8px 0; font-size: .85rem; }
}
@media (min-width: 520px) and (max-width: 700px) {
    .pg-inv-wall-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 10px; }
    .pg-inv-pic-era { grid-column: 1 / -1; }
}
