:root {
  --color-bg: #faf8f5;
  --color-surface: #ffffff;
  --color-text: #1e2a24;
  --color-muted: #5a6b62;
  --color-primary: #2d5a47;
  --color-primary-dark: #1e3d30;
  --color-accent: #8b6914;
  --color-accent-dark: #6f5310;
  --color-pill-quiz: #5a4a8a;
  --color-pill-event: #4a6a8a;
  --color-border: #d4cfc4;
  --color-highlight: #e8f0ec;
  --color-next: #fff8e6;
  --color-next-border: #c9a227;
  --font-serif: 'Source Serif 4', Georgia, serif;
  --font-sans: 'Source Sans 3', system-ui, sans-serif;
  --max-width: 42rem;
  --header-height: 3.5rem;
  --radius: 0.5rem;
  --shadow: 0 1px 3px rgba(30, 42, 36, 0.08);
}

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

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.25;
  color: var(--color-primary-dark);
}

h1 { font-size: 1.75rem; margin-top: 0; }
h2 { font-size: 1.35rem; margin-top: 2rem; }

a {
  color: var(--color-primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover { color: var(--color-accent); }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--header-height);
  padding: 0 1rem;
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: #fff;
  text-decoration: none;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
}

.brand-logo {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  object-fit: contain;
  border-radius: 0.25rem;
  background: rgba(255, 255, 255, 0.95);
  padding: 0.15rem;
}

.brand-link:hover { color: #e8f0ec; }

.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0.5rem;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius);
}

.nav-toggle:hover { background: rgba(255,255,255,0.1); }

.nav-toggle-bar {
  display: block;
  width: 100%;
  height: 2px;
  background: #fff;
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.site-nav {
  position: fixed;
  inset: var(--header-height) 0 auto 0;
  background: var(--color-primary-dark);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.site-nav.is-open {
  max-height: calc(100vh - var(--header-height));
  overflow-y: auto;
}

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0 1rem;
}

.site-nav a {
  display: block;
  padding: 0.75rem 1.25rem;
  color: #e8f0ec;
  text-decoration: none;
  font-weight: 600;
  border-left: 3px solid transparent;
}

.site-nav a:hover,
.site-nav a.active {
  background: rgba(255,255,255,0.08);
  border-left-color: var(--color-accent);
  color: #fff;
}

@media (min-width: 768px) {
  .nav-toggle { display: none; }

  .site-header {
    flex-wrap: wrap;
    padding: 0 1.5rem;
  }

  .site-nav {
    position: static;
    max-height: none;
    overflow: visible;
    background: transparent;
    margin-left: auto;
  }

  .site-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    padding: 0;
  }

  .site-nav a {
    padding: 0.5rem 0.65rem;
    font-size: 0.9rem;
    border-left: none;
    border-bottom: 2px solid transparent;
  }

  .site-nav a:hover,
  .site-nav a.active {
    border-bottom-color: var(--color-accent);
    background: transparent;
  }
}

/* Main */
.main-content {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

@media (min-width: 768px) {
  .main-content {
    padding: 2rem 1.5rem 4rem;
    max-width: 48rem;
  }
}

/* Wide layout for content that needs more room than the site's normal
   reading-width column — currently just the admin/manage page, whose
   talks-schedule table otherwise forces sideways scrolling on desktop. */
.main-content.main-content--wide {
  max-width: 75rem;
}

.hero {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.hero h1 { font-size: 2rem; }

.lead {
  font-size: 1.15rem;
  color: var(--color-muted);
  margin: 0;
}

.prose p { margin: 0 0 1rem; }

.page-figure {
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-figure img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow);
  object-fit: cover;
}

.page-figure figcaption {
  /* Always its own full-width line below the image(s), even when two
     images are sitting side by side above it. */
  flex: 1 1 100%;
  font-style: italic;
}

/* Standard crop presets so photography reads as curated rather than
   "whatever size the file happened to be" (square thumbnails, a fixed
   landscape ratio for the hero) — object-fit: cover above crops to fit
   rather than stretching. */
.page-figure--square img {
  aspect-ratio: 1 / 1;
}

.page-figure--hero img {
  aspect-ratio: 3 / 2;
}

ul, ol { padding-left: 1.25rem; }
li { margin-bottom: 0.5rem; }

.acknowledgement {
  font-size: 0.95rem;
  color: var(--color-muted);
  margin-bottom: 0;
}

.empty-state {
  color: var(--color-muted);
  font-style: italic;
  padding: 1rem;
  background: var(--color-highlight);
  border-radius: var(--radius);
}

/* Shared card surface — the common "white surface, border, radius,
   shadow" look reused by upload cards, the next-talk highlight,
   newsletter links, publication items, and contact entries, so they
   read as one consistent design language instead of near-identical
   bespoke rules with drifting padding. Components add class="card"
   alongside their own class and override only what's genuinely
   different (background, border colour, padding, etc). */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

/* Homepage aims/activities lists — small cards with a gold accent
   edge, rather than bare default bullets, to match the level of
   polish used everywhere else on the site. */
.list-cards {
  list-style: none;
  padding: 0;
}

.list-cards li {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}

/* Newsletters */
.newsletter-list {
  list-style: none;
  padding: 0;
}

.newsletter-link {
  display: block;
  margin-bottom: 0.5rem;
  text-decoration: none;
  font-weight: 600;
}

.newsletter-link:hover {
  border-color: var(--color-primary);
  background: var(--color-highlight);
}

/* Publications */
.publication-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.publication-item {
  margin-bottom: 0.75rem;
}

/* Contact */
.contact-list {
  list-style: none;
  padding: 0;
}

.contact-list li {
  margin-bottom: 0.75rem;
}

.contact-list strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--color-primary-dark);
}

.contact-list a {
  word-break: break-all;
}

.links-list li { margin-bottom: 0.75rem; }

/* Docx content */
.docx-content h1,
.docx-content h2,
.docx-content h3 {
  font-size: 1.15rem;
}

.docx-content p { margin: 0 0 1rem; }

.docx-content ul,
.docx-content ol {
  margin: 0 0 1rem;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 1.25rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  color: #fff;
}

.btn-secondary {
  background: var(--color-border);
  color: var(--color-text);
}

.btn-accent {
  background: var(--color-accent);
  color: #fff;
}

.btn-accent:hover {
  background: var(--color-accent-dark);
  color: #fff;
}

.btn-danger {
  background: #a33;
  color: #fff;
}

.btn-small {
  padding: 0.4rem 0.75rem;
  font-size: 0.875rem;
}

/* Admin */
.admin-login {
  max-width: 30rem;
}

.admin-panel {
  max-width: 100%;
}

.admin-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.upload-card {
  margin-bottom: 1.25rem;
}

.upload-card-grid {
  display: grid;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.upload-card-grid .upload-card {
  margin-bottom: 0;
}

@media (min-width: 900px) {
  .upload-card-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.upload-card h2 {
  margin-top: 0;
  font-size: 1.15rem;
}

.upload-card code {
  font-size: 0.85em;
  background: var(--color-highlight);
  padding: 0.1rem 0.35rem;
  border-radius: 0.2rem;
}

.status {
  font-size: 0.9rem;
  color: var(--color-muted);
  margin: 0.5rem 0 1rem;
}

.upload-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.upload-form input[type="file"] {
  flex: 1 1 100%;
  font-size: 0.9rem;
}

.admin-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.admin-form input[type="password"] {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.form-error {
  color: #a33;
  background: #fee;
  padding: 0.75rem;
  border-radius: var(--radius);
}

.form-success {
  color: var(--color-primary-dark);
  background: var(--color-highlight);
  padding: 0.75rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.upload-form--stacked {
  flex-direction: column;
  align-items: stretch;
}

.upload-form--stacked label {
  font-weight: 600;
  margin-top: 0.5rem;
}

.upload-form--stacked select,
.upload-form--stacked input[type="file"] {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  min-height: 2.75rem;
}

.talks-grid-form {
  margin-top: 0.5rem;
}

.talks-grid-scroll {
  overflow-x: auto;
  margin-bottom: 1rem;
  -webkit-overflow-scrolling: touch;
}

.talks-grid {
  width: 100%;
  min-width: 48rem;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.9rem;
}

/* Fixed, desktop-sized columns — narrow for date/time, roomier for
   speaker/title, and description gets whatever space is left. Content
   that's too long for the column wraps inside the textarea instead of
   being clipped or forcing the field to scroll sideways. */
.talks-grid th:nth-child(1),
.talks-grid td:nth-child(1) { width: 7rem; }

.talks-grid th:nth-child(2),
.talks-grid td:nth-child(2) { width: 6.5rem; }

.talks-grid th:nth-child(3),
.talks-grid td:nth-child(3) { width: 11rem; }

.talks-grid th:nth-child(4),
.talks-grid td:nth-child(4) { width: 13rem; }

.talks-grid th:nth-child(5),
.talks-grid td:nth-child(5) { width: auto; }

.talks-grid th,
.talks-grid td {
  border: 1px solid var(--color-border);
  padding: 0.35rem;
  text-align: left;
  vertical-align: top;
}

.talks-grid th {
  background: var(--color-highlight);
  font-weight: 600;
  white-space: nowrap;
}

.talks-grid textarea {
  display: block;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem;
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1.4;
  border: 1px solid var(--color-border);
  border-radius: 0.25rem;
  resize: vertical;
  overflow-wrap: break-word;
}

/* Date and time are always short, fixed-format values (e.g. "19/02/2026",
   "3pm") — they never need to wrap or be resized taller, so keep them at
   a fixed, sensible single-line height with no resize handle. */
.talks-grid textarea[id$="_date"],
.talks-grid textarea[id$="_time"] {
  height: 3rem;
  resize: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

/* The header sits on the brand-green background, which exactly matches
   (or nearly matches, on the open mobile panel) the default focus-ring
   colour above — so keyboard focus would otherwise be invisible on the
   logo link, menu button, and every nav link. Use a white ring instead,
   just in this context (.site-nav is nested inside .site-header, so this
   also covers the off-canvas mobile menu). */
.site-header a:focus-visible,
.site-header button:focus-visible {
  outline-color: #fff;
}

.inline-form { display: inline; }

/* Footer */
.site-footer {
  margin-top: auto;
  padding: 1.25rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-muted);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.site-footer p { margin: 0; }
.site-footer p + p { margin-top: 0.35rem; }

.cookie-settings-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.85rem;
  color: var(--color-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  cursor: pointer;
}

.cookie-settings-link:hover { color: var(--color-accent); }

/* Cookie banner */
.cookie-banner {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  z-index: 200;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  background: var(--color-highlight);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(30, 42, 36, 0.18);
}

.cookie-banner[hidden] { display: none; }

.cookie-banner-text {
  flex: 1 1 16rem;
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text);
}

.cookie-banner-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-left: auto;
}
