/* =========================================================
   Dusk Theme -- RISC OS CMS
   Dark-mode-first with warm amber accents. Comfortable
   for evening reading; auto-follows system preference.
   Self-contained; no CDN, no web fonts.
   ========================================================= */

:root {
  --color-primary:   #f59e0b;
  --color-primary-h: #fbbf24;
  --color-text:      #e4e4e7;
  --color-muted:     #a1a1aa;
  --color-border:    #27272a;
  --color-bg:        #18181b;
  --color-surface:   #0f0f10;
  --color-accent:    #f59e0b;
  --color-code-bg:   #1e1e22;
  --max-width:       820px;
  --max-wide:        1120px;
  --radius:          6px;
  --font-sans:       system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif:      Georgia, "Times New Roman", Times, serif;
  --font-mono:       "Cascadia Code", "Fira Code", Consolas, monospace;
  --transition:      0.2s ease;
  --shadow:          0 1px 3px rgba(0,0,0,.4);
  --shadow-md:       0 6px 24px rgba(0,0,0,.5);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; background: var(--color-surface); }
body {
  font-family: var(--font-sans); font-size: 16.5px; line-height: 1.7;
  color: var(--color-text); background: var(--color-surface);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a   { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-h); text-decoration: underline; text-underline-offset: 3px; }

.container      { width: 100%; max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }
.container-wide { width: 100%; max-width: var(--max-wide);  margin: 0 auto; padding: 0 24px; }

.skip-link {
  position: absolute; top: -100%; left: 8px; padding: 8px 16px;
  background: var(--color-primary); color: #18181b;
  z-index: 9999; font-size: 14px; border-radius: 0 0 var(--radius) var(--radius);
  transition: top var(--transition);
}
.skip-link:focus { top: 0; }

/* Header ----------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(15, 15, 16, 0.85);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--color-border);
  padding: 14px 0;
}
.header-inner { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.site-logo    { text-decoration: none; display: flex; align-items: center; gap: 10px; }
.site-logo-image { max-height: 32px; width: auto; }
.logo-text    { font-size: 17px; font-weight: 700; color: var(--color-text); letter-spacing: 0.01em; }
.logo-text:hover { color: var(--color-primary); }

.site-nav .nav-list { list-style: none; display: flex; gap: 4px; flex-wrap: wrap; }
.nav-link {
  padding: 6px 12px; border-radius: var(--radius);
  color: var(--color-muted); font-size: 14px; font-weight: 500;
  transition: color var(--transition), background var(--transition);
}
.nav-link:hover       { color: var(--color-text); background: var(--color-bg); text-decoration: none; }
.nav-link.is-current  { color: var(--color-primary); background: rgba(245, 158, 11, 0.1); font-weight: 600; }

/* ---- v5.9.130 mobile hamburger CSS-only fallback ----
   A hidden <input type="checkbox" id="navToggleCheck"> +
   <label for="navToggleCheck" class="nav-toggle"> lets the
   menu open and close WITHOUT JavaScript. Critical for
   sites behind Cloudflare/proxies where Rocket Loader or
   similar features can break nonced scripts. The
   `#navToggleCheck:checked ~ .site-nav` rule (in the
   mobile media query below) does the actual show/hide.
   --------------------------------------------------- */
.nav-toggle-cb {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px; height: 1px;
  opacity: 0;
  margin: 0; padding: 0;
  overflow: hidden;
}

.nav-toggle {
  display: none; background: none; border: 0; padding: 6px;
  width: 40px; height: 40px; cursor: pointer;
}
.nav-toggle span {
  display: block; width: 22px; height: 2px; background: var(--color-text); margin: 5px auto;
  transition: transform var(--transition), opacity var(--transition);
}
.nav-toggle.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.is-open span:nth-child(2) { opacity: 0; }
.nav-toggle.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Hero --------------------------------------------------------- */
.site-main { min-height: 60vh; }

.hero-section {
  text-align: center; padding: 80px 0 56px;
  background: linear-gradient(180deg, rgba(245,158,11,0.06) 0%, transparent 100%);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 48px;
}
.hero-title {
  font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 800;
  letter-spacing: -0.02em; line-height: 1.15;
  background: linear-gradient(180deg, var(--color-text), var(--color-muted));
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
          color: transparent;
  margin-bottom: 20px;
}
.hero-subtitle { font-size: 1.1rem; color: var(--color-muted); max-width: 640px; margin: 0 auto 28px; }
.btn-hero {
  display: inline-block; padding: 12px 26px; border-radius: var(--radius);
  background: var(--color-primary); color: #18181b;
  text-decoration: none; font-weight: 600; font-size: 15px;
  box-shadow: 0 4px 16px rgba(245,158,11,0.3);
  transition: transform var(--transition), box-shadow var(--transition);
}
.btn-hero:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(245,158,11,0.4); text-decoration: none; }

/* Buttons ----------------------------------------------------- */
.btn {
  display: inline-block; padding: 8px 18px; border-radius: var(--radius);
  font-size: 14px; font-family: inherit; font-weight: 600;
  text-decoration: none; border: 1px solid transparent; cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.btn-primary { background: var(--color-primary); color: #18181b; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-h); border-color: var(--color-primary-h); text-decoration: none; }
.btn-outline { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.btn-outline:hover { background: var(--color-primary); color: #18181b; text-decoration: none; }

/* Section heads, cards, lists --------------------------------- */
.section-heading {
  font-size: 1.4rem; font-weight: 700; letter-spacing: -0.01em;
  margin: 48px 0 24px; padding-bottom: 12px;
  border-bottom: 2px solid var(--color-primary);
  display: inline-block; padding-right: 24px;
}

.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }
.post-card {
  background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius);
  overflow: hidden; transition: transform var(--transition), border-color var(--transition);
}
.post-card:hover { transform: translateY(-2px); border-color: var(--color-primary); }
.post-card-body  { padding: 22px; }
.post-card-title { font-size: 1.2rem; font-weight: 700; margin: 6px 0 10px; line-height: 1.3; }
.post-card-title a { color: var(--color-text); text-decoration: none; }
.post-card-title a:hover { color: var(--color-primary); }
.view-all-wrap { text-align: center; margin: 16px 0 48px; }

/* Blog -------------------------------------------------------- */
.blog-header { padding: 48px 0 24px; border-bottom: 1px solid var(--color-border); margin-bottom: 40px; }
.blog-title  { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.02em; }

.post-list { display: flex; flex-direction: column; }
.post-list-item {
  padding: 32px 0; border-bottom: 1px solid var(--color-border);
}
.post-list-item:last-child { border-bottom: none; }
.post-list-title { font-size: 1.5rem; font-weight: 700; margin: 10px 0 14px; line-height: 1.25; letter-spacing: -0.01em; }
.post-list-title a { color: var(--color-text); text-decoration: none; }
.post-list-title a:hover { color: var(--color-primary); }

.post-meta { font-size: 13px; color: var(--color-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.post-meta time, .post-meta span { display: inline; }
.post-author { color: var(--color-muted); }
.post-excerpt { color: var(--color-muted); font-size: 15px; margin-bottom: 14px; max-width: 62ch; }
.post-excerpt p { margin: 0; }

.read-more-link { font-size: 14px; font-weight: 600; color: var(--color-primary); text-decoration: none; }
.read-more-link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Single post ------------------------------------------------- */
.single-post { max-width: var(--max-width); margin: 0 auto; padding: 56px 0; }
.post-header { margin-bottom: 36px; }
.post-title  {
  font-size: clamp(2rem, 4.5vw, 2.8rem); font-weight: 800;
  letter-spacing: -0.02em; line-height: 1.2; margin: 14px 0;
}

.post-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.tag-link  {
  font-size: 12px; background: rgba(245,158,11,0.1); color: var(--color-primary);
  padding: 4px 12px; border-radius: 16px; text-decoration: none;
  font-weight: 600; letter-spacing: 0.02em;
}
.tag-link:hover { background: var(--color-primary); color: #18181b; }

.post-footer { margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--color-border); }
.back-link   { font-weight: 600; font-size: 14px; color: var(--color-primary); text-decoration: none; }
.back-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.page-container { padding-top: 56px; padding-bottom: 56px; }
.page-header    { margin-bottom: 36px; }
.page-title     { font-size: clamp(2rem, 4.5vw, 2.6rem); font-weight: 800; letter-spacing: -0.02em; }
.page-subtitle  { color: var(--color-muted); font-size: 1.1rem; margin-top: 8px; }

.breadcrumbs { font-size: 13px; color: var(--color-muted); margin-bottom: 24px; }
.breadcrumbs a { color: var(--color-primary); }

/* Prose ------------------------------------------------------- */
.prose h1,.prose h2,.prose h3,.prose h4,.prose h5,.prose h6 {
  margin: 2em 0 0.6em; font-weight: 700; letter-spacing: -0.01em; color: var(--color-text);
}
.prose h1 { font-size: 2rem; }
.prose h2 { font-size: 1.5rem; }
.prose h3 { font-size: 1.25rem; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre { margin: 0 0 1.25em; }
.prose ul, .prose ol { padding-left: 1.5em; }
.prose li { margin: 0.35em 0; }
.prose blockquote {
  padding: 6px 0 6px 20px; border-left: 3px solid var(--color-primary);
  color: var(--color-muted); font-style: italic;
}
.prose code {
  font-family: var(--font-mono); font-size: 0.9em;
  background: var(--color-code-bg); color: var(--color-primary);
  padding: 1px 6px; border-radius: 3px;
}
.prose pre {
  background: var(--color-code-bg); border: 1px solid var(--color-border);
  padding: 14px 16px; overflow-x: auto;
  font-family: var(--font-mono); font-size: 0.9em; border-radius: var(--radius);
}
.prose pre code { background: transparent; padding: 0; color: var(--color-text); }
.prose img { margin: 1.5em 0; border-radius: var(--radius); }
.prose a { color: var(--color-primary); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.prose a:hover { color: var(--color-primary-h); }

.prose table {
  border-collapse: collapse; width: 100%; margin: 1.5em 0; font-size: 14px;
}
.prose th, .prose td {
  padding: 8px 12px; border: 1px solid var(--color-border); text-align: left;
}
.prose th { font-weight: 700; background: var(--color-bg); }

/* Photo albums ------------------------------------------------ */
.photo-gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
}
.photo-item { margin: 0; }
.photo-item img {
  width: 100%; height: 240px; object-fit: cover;
  border-radius: var(--radius); display: block;
  transition: transform var(--transition);
}
.photo-item img:hover { transform: scale(1.02); }
.photo-caption { font-size: 13px; color: var(--color-muted); padding: 8px 2px 0; }

.empty-state { color: var(--color-muted); font-style: italic; padding: 32px 0; }

/* Pagination -------------------------------------------------- */
.pagination { display: flex; gap: 8px; justify-content: center; margin: 48px 0; font-size: 14px; }
.pagination a, .pagination span {
  padding: 6px 12px; border: 1px solid var(--color-border); border-radius: var(--radius);
  color: var(--color-text); text-decoration: none;
}
.pagination a:hover { border-color: var(--color-primary); color: var(--color-primary); }
.pagination .current { background: var(--color-primary); color: #18181b; border-color: var(--color-primary); font-weight: 700; }
.pagination .disabled { color: var(--color-muted); opacity: 0.5; }

/* Footer ------------------------------------------------------ */
.site-footer {
  border-top: 1px solid var(--color-border); padding: 48px 0 32px;
  margin-top: 72px; background: var(--color-surface);
}
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 20px; }
.footer-brand { font-size: 15px; font-weight: 700; color: var(--color-text); margin: 0; }
.footer-tagline { font-size: 13px; color: var(--color-muted); margin: 0; flex: 1 1 auto; }
.footer-nav { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-nav a { font-size: 13px; color: var(--color-muted); text-decoration: none; }
.footer-nav a:hover { color: var(--color-primary); }

/* Responsive -------------------------------------------------- */
@media (max-width: 720px) {
  .nav-toggle { display: block; }
  .site-nav {
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--color-surface); padding: 16px 24px;
    border-bottom: 1px solid var(--color-border); display: none;
  }
  .site-nav.is-open { display: block; }
  #navToggleCheck:checked ~ .site-nav { display: block; }
  /* v5.9.131: position:relative on the header-inner is
     REQUIRED so the absolutely-positioned mobile nav uses
     the header-inner as its containing block. Without it,
     `top: 100%` resolves against the viewport and the menu
     opens off-screen at the bottom of the page. */
  .header-inner { position: relative; }
  .site-nav .nav-list { flex-direction: column; gap: 0; }
  .nav-link { display: block; padding: 10px 0; border-radius: 0; }
  .photo-gallery { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .photo-item img { height: 180px; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}

/* Dusk intentionally stays dark even when theme_mode is "light" - if the user
   picks this theme they're picking a dark look on purpose. We still expose
   data-theme="light" so the admin toggle doesn't feel broken, but only for
   slight adjustments (lift the surface a shade; we keep amber everywhere). */
html[data-theme="light"], body[data-theme="light"] {
  --color-text:    #f5f5f4;
  --color-surface: #1c1b18;
  --color-bg:      #24231f;
}

/* ---- Homepage intro card + CTA buttons ---------------------- */
/* Optional editable intro rendered on the default homepage layout.
   Content comes from Admin -> Settings -> Homepage intro page.
   Buttons come from the Admin -> Menus -> Homepage menu. */
.home-intro-card {
  margin: 32px auto 16px;
  padding: 0;
}
.homepage-ctas {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-top: 20px; padding-top: 20px;
  border-top: 1px solid var(--color-border);
}
.homepage-ctas .btn { margin: 0; }

/* =============================================================
   ALBUM LIGHTBOX
   =============================================================
   Full-viewport overlay shown when a gallery photo is clicked.
   Caption is parked in a slim bar at the bottom that doesn't
   cover the image. Counter ("3 / 12") sits alongside.
   Colors pulled from the theme's existing custom properties, so
   the overlay visually belongs to whichever theme is active.
   ============================================================= */

html.lightbox-lock, html.lightbox-lock body { overflow: hidden; }

.lightbox {
  position: fixed; inset: 0;
  display: none;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.92);
  -webkit-backdrop-filter: blur(4px);
          backdrop-filter: blur(4px);
  padding: 48px 56px 96px;
  box-sizing: border-box;
}
.lightbox.is-open { display: flex; align-items: center; justify-content: center; }

.lightbox-stage {
  max-width: 100%; max-height: 100%;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.lightbox-image {
  max-width: 100%;
  max-height: calc(100vh - 144px);
  width: auto; height: auto;
  display: block;
  margin: 0 auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  pointer-events: auto;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 28px; line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.lightbox-close:hover, .lightbox-close:focus-visible {
  background: var(--color-primary, #fff);
  border-color: var(--color-primary, #fff);
  color: #000;
  outline: none;
}

.lightbox-nav {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  width: 56px; height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 34px; line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-nav:hover, .lightbox-nav:focus-visible {
  background: var(--color-primary, #fff);
  border-color: var(--color-primary, #fff);
  color: #000;
  outline: none;
}

.lightbox-info {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 14px 72px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0));
  color: #fff;
  font-size: 14px;
  display: flex; align-items: baseline; gap: 20px;
  pointer-events: none;
  min-height: 48px;
}
.lightbox-counter {
  color: var(--color-primary, #fff);
  font-weight: 600;
  letter-spacing: 0.02em;
  flex: 0 0 auto;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
.lightbox-caption {
  flex: 1 1 auto;
  color: rgba(255, 255, 255, 0.95);
  line-height: 1.5;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  max-height: 3em;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

@media (max-width: 600px) {
  .lightbox { padding: 16px 16px 88px; }
  .lightbox-nav { width: 44px; height: 44px; font-size: 26px; }
  .lightbox-prev { left: 8px; }
  .lightbox-next { right: 8px; }
  .lightbox-close { top: 8px; right: 8px; width: 40px; height: 40px; font-size: 24px; }
  .lightbox-info { padding: 10px 14px; font-size: 13px; }
  .lightbox-image { max-height: calc(100vh - 120px); }
}

.lightbox:not(.is-open) { display: none !important; }


/* v5.9.3: protective marking banner (public-side render) and the
   UNCLASSIFIED permanent background rule. Per-marking user colours
   come from a nonced `<style>` block emitted via
   markings.style_block_for(), since CSP blocks inline styles. */
.marking-banner {
  color: #fff;
  text-align: center;
  padding: 10px 16px;
  font-weight: 600;
  letter-spacing: 0.1em;
  font-size: 13px;
  text-transform: uppercase;
  margin: 0 0 20px 0;
  border-radius: 4px;
}
.marking-banner-bottom { margin: 28px 0 16px 0; }
.marking-bg-unclassified { background: #6b7280; }


/* v5.9.49: top-right login/admin button. Sits inside
   .header-inner after the nav. The flex layout in the
   existing header already places the right-most child
   at the right edge; the button just needs typography
   + colours that fit each theme's palette. */
.site-login-btn {
  display: inline-block;
  margin-left: 12px;
  padding: 6px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: 6px;
  border: 1px solid currentColor;
  opacity: 0.85;
  transition: opacity 0.15s, background-color 0.15s;
  white-space: nowrap;
}
.site-login-btn:hover,
.site-login-btn:focus {
  opacity: 1;
  text-decoration: none;
  outline: none;
}
@media (max-width: 720px) {
  /* On narrow viewports the nav collapses behind the
     hamburger; the login button stays visible but moves
     to a more pragmatic spot. */
  .site-login-btn {
    margin-left: 6px;
    padding: 4px 10px;
    font-size: 0.85rem;
  }
}

/* =================================================================
 * v5.9.78 — Phase 1 UX improvements (reduced-motion, print, forced-colors)
 * ================================================================= */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  .btn, .nav-link, .post-card, .pagination-link {
    border: 1px solid ButtonText;
  }
  a:focus, .btn:focus, .nav-link:focus {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }
}

@media print {
  /* Hide site chrome; the article is the artefact. */
  .site-header,
  .site-footer,
  .nav-toggle,
  .skip-link,
  .pagination,
  #lightbox {
    display: none !important;
  }

  /* Force light-on-white regardless of theme/dark-mode. */
  body, .site-body, .site-main {
    background: #fff !important;
    color: #000 !important;
  }

  a, a:visited {
    color: #000 !important;
    text-decoration: underline;
  }

  /* Show external URLs after each link for offline reading. */
  a[href^="http"]:after {
    content: " (" attr(href) ")";
    font-size: 90%;
    font-style: italic;
  }

  /* Headings stay with their content; long blocks wrap. */
  h1, h2, h3 { page-break-after: avoid; }
  pre, code { white-space: pre-wrap !important; word-wrap: break-word !important; }
  img { max-width: 100% !important; page-break-inside: avoid; }
}
