/* The History of Peterborough (templates/history*.php). Drawn in the guide's own colours, type and spacing
   (--night, --panel, --ink, --copy, --muted, --line, --amber-text, --serif), so the guide's look and every
   homepage design restyle it; only the chapters' layer colours and the dark 3D stage are its own. */

.hist { --hist-r: 18px; --hist-gap: clamp(48px, 7vw, 96px); padding-bottom: 32px; }
/* each page's own colour (history.js sets --tone from its data-tone) */
.wrap-ish { padding-left: clamp(18px, 5vw, 76px); padding-right: clamp(18px, 5vw, 76px); }

.hist-kicker { margin: 0 0 14px; color: var(--amber-text); font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.hist-kicker--warm { color: #e3a35c; }
.hist-display { margin: 0; font: 700 clamp(2.6rem, 6.4vw, 5.6rem)/.98 var(--serif); letter-spacing: -.02em; color: var(--ink); text-wrap: balance; }
.hist-lead { max-width: 58ch; margin: 24px 0 0; color: var(--copy); font-size: clamp(1.05rem, 1.4vw, 1.2rem); line-height: 1.6; text-wrap: pretty; }
.hist-h2 { margin: 0 0 14px; font: 700 clamp(1.6rem, 2.6vw, 2.25rem)/1.1 var(--serif); color: var(--ink); letter-spacing: -.01em; }

/* ---- the section's own tabs: one line that scrolls on a phone */
.hist-tabs { border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 60%, transparent); }
.hist-tabs__in { display: flex; align-items: center; gap: 12px 24px; max-width: 1360px; margin: 0 auto; padding: 10px clamp(18px, 5vw, 76px); }
.hist-tabs__title { flex: none; color: var(--ink); font: 600 1.05rem var(--serif); }
.hist-tabs__list { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.hist-tabs__list::-webkit-scrollbar { display: none; }
.hist-tab { flex: none; display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--copy); font-size: .875rem; font-weight: 600; white-space: nowrap; }
.hist-tab:hover { color: var(--ink); text-decoration: none; border-color: var(--muted); }
.hist-tab.is-on { background: var(--ink); border-color: var(--ink); color: var(--night); }
@media (max-width: 700px) { .hist-tabs__title { display: none; } }

/* ---- hub: words beside the photograph */
.hist-split { display: grid; grid-template-columns: 1fr; }
.hist-split__text { padding-top: clamp(40px, 7vw, 88px); padding-bottom: clamp(32px, 5vw, 64px); }
.hist-split__pic { position: relative; min-height: 320px; overflow: hidden; background: var(--panel2); }
.hist-split__pic img, .hist-hero__pic { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
@media (min-width: 1024px) {
  .hist-split { grid-template-columns: minmax(0, 44fr) minmax(0, 56fr); min-height: min(78vh, 720px); }
  .hist-split__text { align-self: center; }
}

/* a slow drift on the big pictures (history.js starts it; still for anyone who asks for less motion) */
@keyframes hist-kb { from { transform: scale(1.02); } to { transform: scale(1.12); } }
.hist-anim [data-kb] { animation: hist-kb 14s ease-in-out infinite alternate; }

/* a place's era colour where there is no picture yet: never an empty frame */
.hist-fill { position: absolute; inset: 0; display: flex; align-items: flex-end; padding: 18px; background: linear-gradient(160deg, color-mix(in srgb, var(--tone, #6b4a32) 85%, #fff) 0%, var(--tone, #6b4a32) 55%, color-mix(in srgb, var(--tone, #6b4a32) 70%, #000) 100%); }
.hist-fill b { color: rgba(255, 255, 255, .92); font: 700 1.5rem/1 var(--serif); }
.hist-recon { position: absolute; left: 10px; bottom: 10px; padding: 3px 8px; border-radius: 6px; background: rgba(0, 0, 0, .55); color: #fff; font-size: .6875rem; letter-spacing: .02em; }
.hist-recon--hero { z-index: 2; left: auto; right: clamp(18px, 5vw, 76px); bottom: 16px; }

/* ---- hub: the five chapters, side by side on a wide screen */
.hist-chapters { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; border-top: 1px solid var(--line); }
.hist-chapters > li { border-bottom: 1px solid var(--line); }
.hist-chapter { display: flex; flex-direction: column; height: 100%; color: inherit; }
.hist-chapter:hover { text-decoration: none; }
.hist-chapter__pic { position: relative; display: block; aspect-ratio: 16 / 10; overflow: hidden; background: var(--panel2); }
.hist-chapter__pic img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s ease; }
.hist-chapter:hover .hist-chapter__pic img { transform: scale(1.04); }
.hist-chapter__body { display: flex; flex-direction: column; gap: 6px; flex: 1; padding: 18px 20px 22px; }
.hist-chapter__body small { color: var(--amber-text); font-size: .75rem; font-weight: 700; letter-spacing: .04em; }
.hist-chapter__body strong { color: var(--ink); font: 700 1.45rem/1.12 var(--serif); }
.hist-chapter__body > span { color: var(--muted); font-size: .9rem; line-height: 1.5; }
.hist-chapter__body em { margin-top: auto; padding-top: 10px; color: var(--ink); font-style: normal; font-weight: 600; font-size: .875rem; }
.hist-chapter:hover em { color: var(--amber-text); }
@media (min-width: 640px) { .hist-chapters { grid-template-columns: repeat(2, minmax(0, 1fr)); } .hist-chapters > li:nth-child(odd) { border-right: 1px solid var(--line); } }
@media (min-width: 1100px) { .hist-chapters { grid-template-columns: repeat(5, minmax(0, 1fr)); } .hist-chapters > li { border-right: 1px solid var(--line); } .hist-chapters > li:last-child { border-right: 0; } }

/* ---- the 3D model, on its own dark stage in every look */
.hist-3d { display: grid; grid-template-columns: 1fr; background: #1b1a17; color: #f2eee6; }
.hist-3d .hist-h2 { color: #fff; }
.hist-3d__text { padding-top: 48px; padding-bottom: 24px; }
.hist-3d__text > p { max-width: 40ch; color: #d6cfc2; line-height: 1.55; }
.hist-3d__note { margin-top: 18px; color: #9a9184; font-size: .8125rem; }
.hist-3d__stage { position: relative; min-height: 340px; cursor: grab; touch-action: pan-y; }
.hist-3d__stage:active { cursor: grabbing; }
.hist-legend { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 6px; font-size: .875rem; }
.hist-legend li { display: flex; align-items: center; gap: 10px; }
.hist-legend i { width: 12px; height: 12px; border-radius: 2px; background: #888; }
@media (min-width: 900px) {
  .hist-3d { grid-template-columns: minmax(0, 36fr) minmax(0, 64fr); min-height: 420px; }
  .hist-3d__text { align-self: center; padding-top: 40px; padding-bottom: 40px; }
}

/* ---- chapter: the hero */
.hist-hero { position: relative; display: flex; align-items: flex-end; min-height: min(72vh, 640px); overflow: hidden; background: linear-gradient(120deg, #121110, color-mix(in srgb, var(--tone, #4a4640) 55%, #121110)); color: #fff; }
.hist-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(10, 9, 8, .85) 0%, rgba(10, 9, 8, .35) 45%, rgba(10, 9, 8, .1) 100%); pointer-events: none; }
.hist-hero--plain::after { background: radial-gradient(circle at 80% 20%, color-mix(in srgb, var(--tone, #6b4a32) 45%, transparent), transparent 60%); }
.hist-hero__text { position: relative; z-index: 1; width: 100%; max-width: 1360px; margin: 0 auto; padding-top: 120px; padding-bottom: clamp(36px, 6vw, 64px); }
.hist-hero .hist-kicker { color: rgba(255, 255, 255, .8); }
.hist-hero .hist-display { color: #fff; }
.hist-hero .hist-lead { color: rgba(255, 255, 255, .88); }

/* ---- chapter: the numbers, counting up as they come into view */
.hist-facts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.hist-facts li { display: flex; flex-direction: column; gap: 6px; padding: 22px clamp(18px, 3vw, 28px); border-right: 1px solid var(--line); border-top: 1px solid var(--line); }
.hist-facts b { color: var(--ink); font: 700 clamp(1.8rem, 3.4vw, 2.6rem)/1 var(--serif); }
.hist-facts li > span { color: var(--muted); font-size: .875rem; }
@media (min-width: 900px) { .hist-facts { grid-template-columns: repeat(4, minmax(0, 1fr)); } .hist-facts li { border-top: 0; } .hist-facts li:last-child { border-right: 0; } }

/* ---- chapter: the story, picture and words alternating; words alone where there is no picture yet */
.hist-sections { display: flex; flex-direction: column; gap: var(--hist-gap); padding-top: var(--hist-gap); }
.hist-section { display: grid; grid-template-columns: 1fr; gap: 24px; align-items: center; }
.hist-section__pic { margin: 0; position: relative; aspect-ratio: 4 / 3; overflow: hidden; border-radius: var(--hist-r); background: var(--panel2); }
.hist-section__pic img { width: 100%; height: 100%; object-fit: cover; }
.hist-section__pic figcaption { position: absolute; left: 10px; bottom: 10px; padding: 3px 8px; border-radius: 6px; background: rgba(0, 0, 0, .55); color: #fff; font-size: .6875rem; }
.hist-section__text small { display: block; margin-bottom: 8px; color: var(--amber-text); font-size: .75rem; font-weight: 700; }
.hist-section__text p { margin: 0; max-width: 62ch; color: var(--copy); font-size: 1.0625rem; line-height: 1.75; }
.hist-section--words .hist-section__text { max-width: 760px; }
@media (min-width: 900px) {
  .hist-section:not(.hist-section--words) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(32px, 5vw, 72px); }
  .hist-section--flip:not(.hist-section--words) .hist-section__pic { order: 2; }
}

/* ---- chapter: the timeline beside one object */
.hist-pair { display: grid; grid-template-columns: 1fr; gap: 40px; padding-top: var(--hist-gap); align-items: start; }
.hist-timeline ol { list-style: none; margin: 0; padding: 0; }
.hist-timeline li { display: grid; grid-template-columns: minmax(110px, 150px) minmax(0, 1fr); gap: 16px; padding: 13px 0; border-top: 1px solid var(--line); }
.hist-timeline li:last-child { border-bottom: 1px solid var(--line); }
.hist-timeline b { color: var(--amber-text); font-size: .875rem; }
.hist-timeline span { color: var(--copy); line-height: 1.5; }
.hist-object { overflow: hidden; border-radius: var(--hist-r); background: #15130f; color: #f2eee6; }
.hist-object figure { margin: 0; position: relative; aspect-ratio: 4 / 3; }
.hist-object figure img { width: 100%; height: 100%; object-fit: cover; }
.hist-object figcaption { position: absolute; left: 10px; bottom: 10px; padding: 3px 8px; border-radius: 6px; background: rgba(0, 0, 0, .55); font-size: .6875rem; }
.hist-object__text { padding: 22px 24px 26px; }
.hist-object__text small { color: #c9bfae; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; }
.hist-object h2 { margin: 6px 0 10px; color: #fff; font: 700 1.6rem/1.15 var(--serif); }
.hist-object p { margin: 0; color: #e4ddd1; line-height: 1.55; }
.hist-object .hist-object__where { margin-top: 10px; color: #b3a995; font-size: .875rem; }
@media (min-width: 1000px) { .hist-pair { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 56px; } }

/* ---- chapter: where to see it today */
.hist-visit { padding-top: var(--hist-gap); }
.hist-visit ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.hist-place { display: flex; flex-direction: column; height: 100%; overflow: hidden; border: 1px solid var(--line); border-radius: var(--hist-r); background: var(--panel); color: inherit; }
a.hist-place:hover { text-decoration: none; border-color: var(--muted); }
.hist-place__pic { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; background: var(--panel2); }
.hist-place__pic .hp-fill, .hist-place__pic img { width: 100%; height: 100%; object-fit: cover; }
.hist-place__pic .hp-initials { display: grid; place-items: center; height: 100%; color: var(--muted); font: 700 2.2rem var(--serif); }
.hist-place__tour { position: absolute; left: 10px; top: 10px; padding: 4px 9px; border-radius: 999px; background: rgba(0, 0, 0, .6); color: #fff; font-size: .75rem; font-weight: 700; }
.hist-place__text { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px 16px; }
.hist-place__text strong { color: var(--ink); font-size: 1.05rem; }
.hist-place__text span { color: var(--muted); font-size: .875rem; }

/* ---- chapter: sources, then the way on */
.hist-sources { display: grid; grid-template-columns: 1fr; gap: 12px 40px; margin-top: var(--hist-gap); padding-top: 24px; border-top: 1px solid var(--line); }
.hist-sources h2 { margin: 0; color: var(--ink); font-size: .9375rem; }
.hist-sources ol { margin: 0; padding-left: 1.2em; columns: 2 280px; column-gap: 40px; color: var(--muted); font-size: .875rem; line-height: 1.7; }
.hist-sources a { color: var(--copy); text-decoration: underline; text-underline-offset: 2px; }
@media (min-width: 900px) { .hist-sources { grid-template-columns: 160px minmax(0, 1fr); } }
.hist-next { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 32px; }
.hist-next a { display: flex; flex-direction: column; gap: 2px; padding: 16px 22px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); }
.hist-next a:hover { text-decoration: none; border-color: var(--muted); }
.hist-next small { color: var(--muted); font-size: .75rem; }
.hist-next strong { font: 700 1.35rem var(--serif); }
.hist-next__next { align-items: flex-end; text-align: right; background: var(--ink); }
.hist-next .hist-next__next, .hist-next .hist-next__next small { color: var(--night); }

/* ---- the plan for a day */
.hist-plan { display: grid; grid-template-columns: 1fr; gap: 24px 48px; padding-top: var(--hist-gap); }
.hist-plan ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.hist-plan li { display: flex; flex-direction: column; gap: 4px; padding-top: 14px; border-top: 2px solid var(--ink); }
.hist-plan small { color: var(--amber-text); font-size: .75rem; font-weight: 700; }
.hist-plan strong { color: var(--ink); font-size: 1.05rem; }
.hist-plan span { color: var(--muted); font-size: .9rem; line-height: 1.5; }
@media (min-width: 1000px) { .hist-plan { grid-template-columns: minmax(0, 1fr) minmax(0, 2.2fr); } }

/* content rises into view as it is scrolled to (history.js adds .hist-anim, so without it everything just shows) */
.hist-anim [data-reveal] { opacity: 0; transform: translateY(28px); transition: opacity .7s cubic-bezier(.2, .7, .2, 1), transform .7s cubic-bezier(.2, .7, .2, 1); }
.hist-anim [data-reveal].is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .hist-anim [data-reveal] { opacity: 1; transform: none; transition: none; } .hist-anim [data-kb] { animation: none; } }

/* a place's pictures, in turn (history.js) */
.hist-place__pic[data-rotate] img { position: absolute; inset: 0; opacity: 0; transition: opacity 1s ease; }
.hist-place__pic[data-rotate] img.is-on { opacity: 1; }
/* a section with fewer pages: its cards share the row */
@media (min-width: 1100px) {
  .hist-chapters--1 { grid-template-columns: minmax(0, 1fr); }
  .hist-chapters--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hist-chapters--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hist-chapters--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1000px) { .hist-pair--one { grid-template-columns: minmax(0, 1fr); max-width: 900px; } }

/* In the designer: a place to add a picture where a section has none (a click opens its picker there). */
.hist-addpic { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  width: 100%; border: 2px dashed rgba(255, 255, 255, .55); border-radius: inherit; background: rgba(0, 0, 0, .28); color: #fff; font: 600 .95rem var(--sans); cursor: pointer; }
.hist-addpic b { font-size: 1.8rem; line-height: 1; }
.hist-addpic:hover { background: rgba(0, 0, 0, .45); border-color: #fff; }
.hist-hero > .hist-addpic { inset: 16px 16px auto auto; width: auto; padding: 12px 16px; flex-direction: row; border-radius: 12px; }
.hist-section__pic .hist-addpic { color: var(--ink); border-color: var(--line); background: color-mix(in srgb, var(--ink) 4%, transparent); }
.hist-object figure:has(.hist-addpic) { min-height: 200px; }
[data-edit^="section:"] { cursor: pointer; }

/* a section's plan: each stop links to its place, and the whole plan to the Explore Planner */
.hist-plan strong a { color: inherit; }
.hist-plan strong a:hover { color: var(--amber-text); text-decoration: none; }
.hist-plan__go { margin: 24px 0 0; }
