/* ==========================================================
   Roscomroe Monastery - 1a Folio, production stylesheet
   ========================================================== */

/* Self-hosted EB Garamond regular (no third-party font requests). */
@font-face {
  font-family: "EB Garamond";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/eb-garamond-latin-400-normal.woff2") format("woff2");
}

/* Self-hosted EB Garamond italic. */
@font-face {
  font-family: "EB Garamond";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/eb-garamond-latin-400-italic.woff2") format("woff2");
}

/* Colour and spacing tokens used across the page. */
:root {
  --paper: #f3efe6;
  --ink: #1f1c17;
  --ink-soft: #1f1c1733;
  --accent: #8b3a2b;
  --accent-light: #d99a86;
  --gutter: clamp(20px, 5vw, 64px);
  --max: 1280px;
}

/* Include padding and borders in element widths. */
*, *::before, *::after { box-sizing: border-box; }

/* Page base: parchment background, dark ink, serif type. */
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "EB Garamond", Garamond, Georgia, serif;
  font-size: clamp(18px, 1.5vw, 22px);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Images never overflow their container. */
img { max-width: 100%; height: auto; display: block; }

/* Remove default paragraph spacing; spacing is set per component. */
p { margin: 0; text-wrap: pretty; }

/* Remove default heading spacing and weight. */
h1, h2 { margin: 0; font-weight: 400; }

/* Links keep an underline and dim on hover. */
a { color: inherit; text-underline-offset: 3px; }
a:hover { opacity: .7; }

/* Visible keyboard focus. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Small uppercase label style used for section tags. */
.caps {
  font-size: clamp(13px, 1.1vw, 15px);
  letter-spacing: .22em;
  text-transform: uppercase;
}

/* Accent colour for labels. */
.caps--accent { color: var(--accent); }

/* Light label colour for the dark treasure band. */
.caps--light { color: var(--accent-light); }

/* Smaller label for the timeline. */
.caps--small { font-size: 13px; }

/* ---------- Top bar ---------- */

/* Site name on the left, tagline on the right; wraps on phones. */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 24px;
  padding: 24px var(--gutter);
  border-bottom: 1px solid var(--ink-soft);
  font-size: clamp(13px, 1.1vw, 15px);
  letter-spacing: .2em;
  text-transform: uppercase;
}

/* Italic tagline in normal case. */
.topbar__tag {
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
  font-size: clamp(16px, 1.4vw, 18px);
}

/* Centre all main sections within a maximum width. */
main > section { max-width: var(--max); margin-inline: auto; }

/* ---------- Plates (figures) ---------- */

/* Figure with no browser margin. */
.plate { margin: 0; }

/* Photos fill the figure width. */
.plate img { width: 100%; }

/* Caption: text on the left, plate number on the right. */
.plate figcaption {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  font-size: clamp(14px, 1.15vw, 16px);
  font-style: italic;
  line-height: 1.35;
}

/* Plate number does not wrap. */
.plate__no { white-space: nowrap; font-style: normal; letter-spacing: .08em; }

/* Zoom button wraps an image; removes default button styling. */
.zoom {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

/* ---------- Hero ---------- */

/* Two columns: title and lead text, then the main photo. */
.hero {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: clamp(32px, 5vw, 56px);
  padding: clamp(40px, 6vw, 72px) var(--gutter) clamp(32px, 5vw, 56px);
  align-items: end;
}

/* Stack the label, title and lead text. */
.hero__text { display: flex; flex-direction: column; gap: clamp(24px, 3.4vw, 40px); }

/* Very large two-line title that scales with the screen. */
.hero__title {
  font-size: clamp(44px, 8.4vw, 112px);
  line-height: .88;
  letter-spacing: -.03em;
  overflow-wrap: anywhere;
}

/* Hero photo: portrait crop, focused on the gable. */
.hero__figure img { aspect-ratio: 3 / 4; object-fit: cover; object-position: 50% 30%; }

/* Lead paragraph beside the hero photo. */
.lede { max-width: 30em; font-size: clamp(19px, 1.7vw, 22px); line-height: 1.5; }

/* Red drop cap in the lead paragraph. */
.dropcap {
  float: left;
  font-size: 4.2em;
  line-height: .8;
  padding: 6px 12px 0 0;
  color: var(--accent);
}

/* ---------- Timeline ---------- */

/* Four columns on desktop, divided by thin rules. */
.timeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  margin-inline: var(--gutter);
  max-width: calc(var(--max) - 2 * var(--gutter));
}

/* Each timeline cell. */
.timeline__item {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 32px 24px;
  border-right: 1px solid var(--ink-soft);
}

/* First cell has no left padding; last cell has no right border. */
.timeline__item:first-child { padding-left: 0; }
.timeline__item:last-child { padding-right: 0; border-right: 0; }

/* Large date or numeral. */
.timeline__mark { font-size: clamp(44px, 5.6vw, 72px); line-height: 1; }

/* Roman numerals are italic and red. */
.timeline__mark--accent { font-style: italic; color: var(--accent); }

/* Timeline description text. */
.timeline__item p { font-size: clamp(16px, 1.4vw, 18px); line-height: 1.4; }

/* ---------- The Pattern ---------- */

/* Date on the left, text on the right, quern stone plate below. */
.pattern {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(32px, 5vw, 64px);
  padding: clamp(56px, 8vw, 96px) var(--gutter);
  align-items: start;
}

/* Huge italic date. */
.pattern__big {
  font-size: clamp(64px, 13vw, 168px);
  line-height: .9;
  font-style: italic;
  letter-spacing: -.03em;
  color: var(--accent);
  margin-top: 8px;
}

/* Right-hand text column. */
.pattern__text { display: flex; flex-direction: column; gap: 24px; font-size: clamp(19px, 1.7vw, 22px); line-height: 1.55; }

/* Date sits in the left column and spans both rows. */
.pattern__date { grid-row: 1 / 3; align-self: start; }

/* Text sits top right. */
.pattern__text { grid-column: 2; }

/* Quern stone plate sits under the text in the right column. */
.pattern__figure { grid-column: 2; }

/* Quern stone crop. */
.pattern__figure img { aspect-ratio: 5 / 4; object-fit: cover; }

/* ---------- The Church ---------- */

/* Gate photo on the left, text on the right. */
.church {
  display: grid;
  grid-template-columns: minmax(220px, 380px) 1fr;
  gap: clamp(32px, 5vw, 64px);
  padding: 0 var(--gutter) clamp(56px, 8vw, 96px);
  align-items: start;
}

/* Gate photo: portrait crop. */
.church__figure img { aspect-ratio: 3 / 4; object-fit: cover; }

/* Stack the label and paragraphs. */
.church__text { display: flex; flex-direction: column; gap: 28px; padding-top: 24px; }

/* Larger lead paragraph. */
.church__lead { font-size: clamp(21px, 2.1vw, 26px); line-height: 1.45; }

/* Body paragraph in two columns on wide screens. */
.church__body { font-size: clamp(18px, 1.6vw, 20px); line-height: 1.55; columns: 2; column-gap: 40px; }

/* ---------- Gallery ---------- */

/* Gallery section with a rule above. */
.gallery {
  padding: clamp(56px, 8vw, 96px) var(--gutter);
  border-top: 1px solid var(--ink);
}

/* Gallery heading block. */
.gallery__head { margin-bottom: clamp(28px, 4vw, 48px); }

/* Gallery title. */
.gallery__head h2 { font-size: clamp(36px, 5vw, 64px); line-height: 1.05; font-style: italic; margin-top: 8px; }

/* 12-column grid so plates can have different widths. */
.gallery__grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: clamp(28px, 4vw, 48px) clamp(16px, 2.4vw, 32px);
  align-items: start;
}

/* Interior view: wide. */
.g-interior { grid-column: span 7; }

/* Oldest masonry: narrower. */
.g-masonry { grid-column: span 5; }

/* Bell Stone: narrower. */
.g-bell { grid-column: span 5; }

/* Arch stone: wide. */
.g-arch { grid-column: span 7; }

/* Architrave pair: centred, medium width. */
.g-architraves { grid-column: 3 / span 8; }

/* Wide plates share one ratio; narrow plates match their height so rows align. */
.g-interior img, .g-arch img { aspect-ratio: 4 / 3; object-fit: cover; }
.g-masonry img, .g-bell img { aspect-ratio: 15 / 16; object-fit: cover; }

/* Keep the key stone visible when the wall photos are cropped. */
.g-masonry img { object-position: 35% 50%; }
.g-bell img { object-position: 30% 50%; }

/* Interior photo keeps the gable centred when cropped. */
.g-interior img { object-position: 50% 45%; }

/* Pair of photos side by side under one caption. */
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(12px, 2vw, 24px); }

/* Architrave photos share a portrait ratio. */
.pair img { aspect-ratio: 3 / 4; object-fit: cover; }

/* Landscape pair for the church yard stones. */
.pair--landscape img { aspect-ratio: 4 / 3; }

/* Slight lift on hover for clickable photos. */
.zoom img { transition: filter .2s; }
.zoom:hover img { filter: brightness(1.06); }

/* ---------- The Abbot's Treasure ---------- */

/* Dark full-width band with a centred pull-quote. */
.treasure {
  max-width: none !important;
  background: var(--ink);
  color: var(--paper);
  padding: clamp(64px, 9vw, 112px) var(--gutter);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(24px, 3.4vw, 40px);
  text-align: center;
}

/* Large italic pull-quote. */
.treasure blockquote {
  margin: 0;
  max-width: 900px;
  font-size: clamp(30px, 5vw, 56px);
  line-height: 1.15;
  font-style: italic;
  text-wrap: balance;
}

/* Supporting text under the quote. */
.treasure__text { max-width: 720px; font-size: clamp(18px, 1.6vw, 20px); line-height: 1.6; opacity: .85; }

/* ---------- Church yard stones ---------- */

/* Pair of yard stones, centred. */
.yard { padding: clamp(56px, 8vw, 96px) var(--gutter) 0; }

/* Keep the pair at a moderate width. */
.yard__figure { max-width: 860px; margin-inline: auto; }

/* ---------- Survey ---------- */

/* Date and photo on the left, text on the right. */
.survey {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: clamp(32px, 5vw, 64px);
  padding: clamp(56px, 8vw, 96px) var(--gutter);
  border-bottom: 1px solid var(--ink-soft);
}

/* Stack label, date and photo. */
.survey__side { display: flex; flex-direction: column; gap: 16px; }

/* Large date. */
.survey__date { font-size: clamp(44px, 5.6vw, 72px); line-height: 1; letter-spacing: -.02em; }

/* Survey photo: moderate size because the source is low resolution. */
.survey__side .plate { margin-top: 16px; max-width: 360px; }

/* Survey photo crop. */
.survey__side img { aspect-ratio: 4 / 5; object-fit: cover; }

/* Survey text. */
.survey__text { font-size: clamp(19px, 1.7vw, 22px); line-height: 1.55; }

/* ---------- Map ---------- */

/* Text on the left, map on the right. */
.map {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: clamp(32px, 5vw, 64px);
  padding: clamp(56px, 8vw, 96px) var(--gutter);
  align-items: stretch;
}

/* Stack the map text. */
.map__text { display: flex; flex-direction: column; gap: 16px; }

/* Map heading. */
.map__text h2 { font-size: clamp(32px, 4vw, 48px); line-height: 1.1; font-style: italic; }

/* Map frame with a thin border; muted colour to suit the parchment. */
.map__frame { border: 1px solid var(--ink); min-height: 340px; }

/* Map fills the frame; slight sepia blends with the page. */
.map__frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 340px;
  border: 0;
  filter: sepia(.35) saturate(.8);
}

/* ---------- Footer ---------- */

/* Thanks line and bottom bar. */
.footer { border-top: 1px solid var(--ink-soft); }

/* Thanks to the book author. */
.footer__thanks {
  max-width: var(--max);
  margin-inline: auto;
  padding: 32px var(--gutter) 0;
  font-size: clamp(15px, 1.25vw, 17px);
  line-height: 1.5;
  opacity: .85;
}

/* Bottom bar with site name and location. */
.footer__bar {
  max-width: var(--max);
  margin-inline: auto;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 24px;
  padding: 28px var(--gutter);
}

/* ---------- Image viewer ---------- */

/* Full-screen dialog with a dark backdrop. */
.viewer {
  max-width: min(96vw, 1200px);
  max-height: 94vh;
  padding: 16px;
  border: 0;
  background: var(--paper);
  color: var(--ink);
}

/* Dim the page behind the viewer. */
.viewer::backdrop { background: rgba(20, 18, 15, .85); }

/* Viewer photo scales to fit the window. */
.viewer img { max-width: 100%; max-height: 78vh; margin-inline: auto; }

/* Viewer caption. */
.viewer p { margin-top: 12px; font-style: italic; font-size: 16px; }

/* Close button in the top-right corner. */
.viewer__close {
  position: absolute;
  top: 4px;
  right: 8px;
  border: 0;
  background: none;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
}

/* ---------- Tablet ---------- */

/* Below 900px: stack the main two-column sections. */
@media (max-width: 900px) {
  /* Hero stacks: text first, photo below. */
  .hero { grid-template-columns: 1fr; align-items: start; }
  .hero__figure { max-width: 520px; }

  /* Timeline becomes 2 x 2. */
  .timeline { grid-template-columns: 1fr 1fr; }
  .timeline__item { padding: 24px 20px; border-bottom: 1px solid var(--ink-soft); }
  .timeline__item:nth-child(odd) { padding-left: 0; }
  .timeline__item:nth-child(even) { padding-right: 0; border-right: 0; }
  .timeline__item:nth-child(n+3) { border-bottom: 0; }

  /* Hero title can be larger when the column is full width. */
  .hero__title { font-size: clamp(56px, 16vw, 140px); }

  /* Pattern stacks. */
  .pattern { grid-template-columns: 1fr; }
  .pattern__date, .pattern__text, .pattern__figure { grid-column: 1; grid-row: auto; }
  .pattern__figure { max-width: 560px; }

  /* Church stacks. */
  .church { grid-template-columns: 1fr; }
  .church__figure { max-width: 380px; }
  .church__body { columns: 1; }

  /* Gallery uses 2 columns of equal width; architraves span both. */
  .gallery__grid { grid-template-columns: 1fr 1fr; }
  .g-interior { grid-column: 1 / -1; }
  .g-masonry, .g-bell { grid-column: span 1; }
  .g-arch { grid-column: 1 / -1; }
  .g-architraves { grid-column: 1 / -1; }

  /* Survey and map stack. */
  .survey, .map { grid-template-columns: 1fr; }
}

/* ---------- Phone ---------- */

/* Below 600px: single column everywhere. */
@media (max-width: 600px) {
  /* Gallery becomes one column. */
  .gallery__grid { grid-template-columns: 1fr; }
  .g-masonry, .g-bell { grid-column: 1 / -1; }
  .g-masonry img, .g-bell img { aspect-ratio: 4 / 3; }

  /* Timeline becomes one column. */
  .timeline { grid-template-columns: 1fr; }
  .timeline__item, .timeline__item:nth-child(odd), .timeline__item:nth-child(even) {
    padding: 20px 0;
    border-right: 0;
    border-bottom: 1px solid var(--ink-soft);
  }
  .timeline__item:last-child { border-bottom: 0; }

  /* Drop cap shrinks slightly. */
  .dropcap { font-size: 3.6em; }

  /* Caption wraps under the text if the plate number is long. */
  .plate figcaption { flex-wrap: wrap; }
}

/* Respect users who prefer less motion. */
@media (prefers-reduced-motion: reduce) {
  .zoom img { transition: none; }
}
