/* Historyworks / Creating My Cambridge
 *
 * Keeps the restrained greyscale-and-PT-Sans identity of the 2012 design, but
 * rebuilt mobile-first. The original was a fixed 960px layout, which matters
 * most for Creating My Cambridge: its history trails are meant to be walked
 * with a phone in hand.
 */

:root {
  --ink: #222;
  --ink-soft: #444;
  --muted: #777;
  --rule: #ccc;
  --rule-soft: #e6e6e6;
  --paper: #fff;
  --paper-alt: #f4f4f4;
  --accent: #333;
  --focus: #1a5fb4;

  --measure: 68ch;
  --container: 68rem;
  --gap: clamp(1rem, 3vw, 2rem);
  --radius: 2px;
}

*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: "PT Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: #000; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

h1, h2, h3, h4 { line-height: 1.2; font-weight: 700; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.8vw, 2.6rem); }
h2 { font-size: clamp(1.3rem, 1.1rem + 1vw, 1.9rem); }
h3 { font-size: clamp(1.1rem, 1rem + 0.5vw, 1.35rem); }

.container {
  width: min(100% - 2rem, var(--container));
  margin-inline: auto;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
  position: absolute; left: -9999px;
  background: var(--ink); color: #fff; padding: 0.75rem 1rem; z-index: 100;
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* -- header + nav ------------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding-block: 1rem;
}

.brand {
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--ink);
  margin-right: auto;
}

.nav-toggle {
  display: block;
  width: 2.75rem; height: 2.75rem;
  border: 1px solid var(--rule);
  background: var(--paper);
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
}
.nav-toggle-bar,
.nav-toggle-bar::before,
.nav-toggle-bar::after {
  position: absolute; left: 50%; translate: -50% 0;
  width: 1.25rem; height: 2px; background: var(--ink); content: "";
}
.nav-toggle-bar { top: 50%; }
.nav-toggle-bar::before { top: -6px; }
.nav-toggle-bar::after { top: 6px; }

.primary-nav { flex-basis: 100%; display: none; }
.primary-nav.is-open { display: block; }

.primary-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.primary-nav a {
  display: block;
  padding: 0.6rem 0.25rem;
  text-decoration: none;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--rule-soft);
}
.primary-nav a:hover { color: #000; }
.primary-nav .is-current > a { font-weight: 700; color: var(--ink); }

@media (min-width: 48rem) {
  .nav-toggle { display: none; }
  .primary-nav { display: block; flex-basis: auto; }
  .primary-nav ul { flex-direction: row; gap: 1.25rem; }
  .primary-nav a { border-bottom: 2px solid transparent; padding: 0.25rem 0; }
  .primary-nav .is-current > a { border-bottom-color: var(--ink); }
}

/* -- banner ------------------------------------------------------------- */

.banner { position: relative; background: var(--paper-alt); }

.banner.has-image { min-height: clamp(9rem, 26vw, 21rem); display: grid; }
.banner.has-image > * { grid-area: 1 / 1; }

.banner-image { width: 100%; height: 100%; object-fit: cover; }

.banner.has-image .banner-inner {
  align-self: end;
  padding-block: 1.5rem;
  background: linear-gradient(to top, rgb(0 0 0 / 0.65), rgb(0 0 0 / 0));
}
.banner.has-image h1 { color: #fff; text-shadow: 0 1px 3px rgb(0 0 0 / 0.5); }

.banner-inner { padding-block: 1.5rem; }
.banner-inner h1 { margin: 0; }

/* -- breadcrumbs -------------------------------------------------------- */

.breadcrumbs {
  border-bottom: 1px solid var(--rule-soft);
  font-size: 0.9rem;
}
.breadcrumbs ol {
  list-style: none; margin: 0; padding: 0.75rem 0;
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  color: var(--muted);
}
.breadcrumbs li + li::before { content: "»"; margin-right: 0.4rem; color: var(--rule); }
.breadcrumbs a { color: var(--muted); }

/* -- content ------------------------------------------------------------ */

main { padding-block: clamp(1.5rem, 4vw, 3rem); }

.teaser { font-size: 1.1em; color: var(--ink-soft); max-width: var(--measure); }
.dateline { color: var(--muted); font-size: 0.9rem; margin-top: 0; }

.prose > * { max-width: var(--measure); }
.prose p, .prose ul, .prose ol { margin-block: 0 1em; }
.prose img { margin-block: 1.5rem; border-radius: var(--radius); }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin-block: 2rem; }
.prose blockquote {
  margin-inline: 0; padding-left: 1rem;
  border-left: 3px solid var(--rule); color: var(--ink-soft);
}
/* Wide content must scroll inside itself rather than the page. */
.prose table { display: block; overflow-x: auto; max-width: 100%; border-collapse: collapse; }
.prose td, .prose th { border: 1px solid var(--rule-soft); padding: 0.4rem 0.6rem; }

.page-section { margin-block: 2.5rem; scroll-margin-top: 1rem; }

/* Two-column intro, as the old homepage had. Stacks on narrow screens, which
   the fixed 960px original could not do. */
/* Overrides the .prose reading-measure cap. Wagtail wraps every StreamField
   block in its own div, so it is that wrapper the `.prose > *` rule caps --
   not the .columns element inside it. */
.prose > .block-columns { max-width: none; }

.columns {
  display: grid;
  gap: 0 var(--gap);
  grid-template-columns: 1fr;
  max-width: none;
}
.columns .column { max-width: var(--measure); }
.columns .column > :first-child { margin-top: 0; }
@media (min-width: 44rem) {
  .columns { grid-template-columns: 1fr 1fr; }
}

/* Embeds keep their aspect ratio instead of the fixed pixel sizes the old
   pasted markup hardcoded. */
.embed { max-width: var(--measure); margin-block: 1.5rem; }
.embed :is(iframe, object, embed) { width: 100%; border: 0; }
.embed iframe[src*="vimeo"],
.embed iframe[src*="youtube"] { aspect-ratio: 16 / 9; height: auto; }
/* Wagtail's own embed_frontend.html wraps a responsive embed's iframe in
   this, with an inline padding-bottom sized to the provider's aspect ratio --
   meant to pair with a position: absolute iframe filling that padded box.
   The aspect-ratio rule above already sizes the iframe correctly on its own,
   so left alone the padding-bottom just reserves a second, empty block of
   that same height underneath it. */
.responsive-object { padding-bottom: 0 !important; }

/* -- listings ----------------------------------------------------------- */

.card-list {
  list-style: none; margin: 2.5rem 0 0; padding: 0;
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
}

.card a {
  display: block; height: 100%;
  text-decoration: none; color: inherit;
  border: 1px solid var(--rule-soft); border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 120ms ease;
}
.card a:hover { border-color: var(--muted); }
.card img { aspect-ratio: 8 / 5; object-fit: cover; width: 100%; }
/* Originals the bucket never had a bigger copy of: show at their real size,
   letterboxed, rather than upscaled into a soft, stretched thumbnail. */
.card img.is-native { object-fit: contain; background: var(--paper-alt); }
.card h3 { margin: 0.75rem 0.9rem 0.35rem; }
.card p { margin: 0 0.9rem 1rem; color: var(--ink-soft); font-size: 0.95rem; }
.card time { display: block; margin: 0.75rem 0.9rem 0; color: var(--muted); font-size: 0.85rem; }
.card h3 + p { margin-top: 0; }

.archive-note { color: var(--muted); }

/* -- people ------------------------------------------------------------- */

.people-list {
  list-style: none; padding: 0; margin: 1rem 0 0;
  display: flex; flex-wrap: wrap; gap: 1.25rem;
}
.people-list a { display: block; text-align: center; text-decoration: none; color: inherit; }
.avatar { border-radius: 50%; width: 80px; height: 80px; object-fit: cover; }
.person-photo { float: none; margin-block: 0 1.5rem; border-radius: var(--radius); }
.role { color: var(--muted); font-weight: 700; }

@media (min-width: 40rem) {
  .person-photo { float: left; margin: 0 1.5rem 1rem 0; max-width: 18rem; }
}

/* -- footer ------------------------------------------------------------- */

.site-footer {
  margin-top: clamp(3rem, 8vw, 6rem);
  border-top: 1px solid var(--rule);
  background: var(--paper-alt);
}
.footer-inner {
  padding-block: 2.5rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
}
@media (min-width: 44rem) {
  .footer-inner { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
}

.footer-contact p { margin: 0 0 0.5em; }
.footer-contact p:last-child { margin-bottom: 0; }
.footer-contact a { color: var(--ink-soft); }

.footer-links h2 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.6rem;
}
.footer-links ul { list-style: none; margin: 0; padding: 0; }
.footer-links li + li { margin-top: 0.35rem; }
.footer-links a { color: var(--ink-soft); }

.copyright { margin: 0; }

@media print {
  .site-header, .breadcrumbs, .site-footer, .nav-toggle { display: none; }
  body { color: #000; }
}

/* -- people grid -------------------------------------------------------- */

.people-grid {
  list-style: none;
  margin: 2.5rem 0 0;
  padding: 0;
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr));
}

.people-grid a {
  display: block;
  text-decoration: none;
  color: inherit;
}

.people-grid img {
  width: 100%;
  aspect-ratio: 5 / 6;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--paper-alt);
}

.people-grid .name {
  display: block;
  margin-top: 0.6rem;
  font-weight: 700;
}

.people-grid .role {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.people-grid a:hover .name { text-decoration: underline; }

/* -- tile menu ------------------------------------------------------------
   Curated picture-tile grids: the homepage's four-tile menu and the six-tile
   grid under /products/. Both used the same markup at three or four across.
*/

.tile-menu {
  list-style: none; margin: 0 0 2.5rem; padding: 0;
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 30rem) {
  .tile-menu--3 { grid-template-columns: repeat(3, 1fr); }
  .tile-menu--4 { grid-template-columns: repeat(4, 1fr); }
}

.tile a {
  position: relative; display: block; overflow: hidden;
  border-radius: var(--radius);
  aspect-ratio: 1 / 1;
  color: #fff; text-decoration: none;
}
.tile-image { width: 100%; height: 100%; object-fit: cover; }
.tile-label {
  position: absolute; inset: auto 0 0 0;
  padding: 0.6rem 0.75rem;
  font-weight: 700; text-align: center;
  background: linear-gradient(to top, rgb(0 0 0 / 0.7), rgb(0 0 0 / 0));
  text-shadow: 0 1px 3px rgb(0 0 0 / 0.5);
}
.tile a:hover .tile-label { text-decoration: underline; }

/* -- banner slideshow ----------------------------------------------------- */

.banner-slides { min-height: clamp(9rem, 26vw, 21rem); display: grid; }
.banner-slide {
  grid-area: 1 / 1; display: grid;
  opacity: 0; transition: opacity 800ms ease;
  color: inherit; text-decoration: none;
}
.banner-slide.is-active { opacity: 1; }
.banner-slide > * { grid-area: 1 / 1; }
.banner-slide .banner-inner {
  align-self: end;
  padding-block: 1.5rem;
  background: linear-gradient(to top, rgb(0 0 0 / 0.65), rgb(0 0 0 / 0));
}
.banner-slide h1 { color: #fff; text-shadow: 0 1px 3px rgb(0 0 0 / 0.5); margin: 0; }

/* -- jump-to nav ------------------------------------------------------------
   The right-hand menu the old theme generated for a page's Sections. Boxed
   and left-aligned on narrow screens; floated to echo the original layout
   once there is room for it beside the prose.
*/

.jump-to {
  margin: 2rem 0;
  padding: 1rem 1.25rem;
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius);
  background: var(--paper-alt);
  max-width: var(--measure);
}
.jump-to h2 { font-size: 1rem; margin-bottom: 0.5rem; }
.jump-to ul { list-style: none; margin: 0; padding: 0; }
.jump-to li + li { margin-top: 0.3rem; }
@media (min-width: 60rem) {
  .jump-to { float: right; margin: 0 0 1.5rem 2rem; max-width: 14rem; }
}

/* -- front-page news feed --------------------------------------------------
   The homepage's editorial "Recent projects" pick, reusing the card grid.
*/

.front-news { margin-top: 2.5rem; }
.front-news h2 { margin-bottom: 1rem; }
