/*
 * kcm-global.css
 * King Charles the Martyr — Falmouth Parish Church
 * Global stylesheet — drop in after existing Joomla template CSS
 * ─────────────────────────────────────────────────────────────────
 * Works with unmodified Joomla 1.6 HTML output.
 * Transforms the flat document into a sidebar-nav + content layout
 * using pure CSS, no HTML changes required.
 */

/* ═══════════════════════════════════════════════
   1. TOKENS & RESET
═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400&family=Inter:wght@300;400;500;600&display=swap');

:root {
  --kcm-primary:       #d2b064;       /* gold */
  --kcm-primary-dim:   rgba(210,176,100,0.14);
  --kcm-primary-glow:  rgba(210,176,100,0.35);
  --kcm-dark:          #171e23;       /* deep navy */
  --kcm-dark-2:        #232c32;
  --kcm-bg:            #ffffff;
  --kcm-page-bg:       #f6f4f0;
  --kcm-text:          #1e2830;
  --kcm-text-subtle:   #5a6370;
  --kcm-border:        #e2ddd6;
  --kcm-nav-w:         260px;
  --kcm-radius:        4px;
  --kcm-ease:          0.28s cubic-bezier(0.4, 0, 0.2, 1);
  --font-heading:      'Cormorant Garamond', Georgia, serif;
  --font-body:         'Inter', system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--kcm-page-bg);
  color: var(--kcm-text);
  line-height: 1.7;
  font-size: 15px;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

a {
  color: var(--kcm-primary);
  text-decoration: none;
  transition: color var(--kcm-ease);
}
a:hover { color: var(--kcm-dark); }

img { max-width: 100%; height: auto; }

hr { display: none; }   /* hide blueprint spacer/divider HRs */
hr.space { display: none; }


/* ═══════════════════════════════════════════════
   2. PAGE SKELETON
   The Joomla template emits three .container divs:
     [0] header   [1] nav   [2] content + footer
   We position the nav as a fixed sidebar and shift
   everything else to the right.
═══════════════════════════════════════════════ */

/* Generic container reset (Blueprint sets width/padding) */
.container {
  width: auto !important;
  max-width: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* ── Container 0: top bar (holds joomla-header) ── */
.container:has(.joomla-header),
.container:first-child {
  position: fixed;
  top: 0;
  left: var(--kcm-nav-w);
  right: 0;
  height: 60px;
  background: var(--kcm-bg);
  border-bottom: 1px solid var(--kcm-border);
  display: flex;
  align-items: center;
  padding: 0 48px !important;
  z-index: 50;
  box-shadow: 0 1px 0 var(--kcm-border);
}

/* ── Container 1: sidebar nav ── */
.container:has(.joomla-nav) {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--kcm-nav-w);
  height: 100vh;
  background: var(--kcm-dark);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  display: block !important;
  /* custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: rgba(210,176,100,0.3) transparent;
}
.container:has(.joomla-nav)::-webkit-scrollbar { width: 4px; }
.container:has(.joomla-nav)::-webkit-scrollbar-track { background: transparent; }
.container:has(.joomla-nav)::-webkit-scrollbar-thumb { background: rgba(210,176,100,0.3); border-radius: 2px; }

/* Sidebar pseudo-brand header */
.container:has(.joomla-nav)::before {
  content: '';
  display: block;
  height: 80px;
  background: var(--kcm-dark);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  /* Cross icon drawn via box-shadow trick in ::after */
}
.container:has(.joomla-nav)::after {
  content: 'King Charles\A the Martyr\A ─ Falmouth';
  white-space: pre;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 80px;
  display: flex;
  align-items: center;
  padding: 0 24px 0 52px;
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 500;
  color: var(--kcm-primary);
  line-height: 1.4;
  letter-spacing: 0.04em;
  pointer-events: none;
}

/* ── Container 2: main + footer ── */
.container:last-child {
  margin-left: var(--kcm-nav-w) !important;
  margin-top: 60px !important;
  padding: 0 !important;
  min-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
}


/* ═══════════════════════════════════════════════
   3. HEADER
═══════════════════════════════════════════════ */

.joomla-header {
  width: 100% !important;
  float: none !important;
  margin: 0 !important;
}

.joomla-header h1 {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 500;
  color: var(--kcm-text);
  letter-spacing: 0.01em;
  margin: 0;
  line-height: 1;
}


/* ═══════════════════════════════════════════════
   4. SIDEBAR NAVIGATION
═══════════════════════════════════════════════ */

ul.joomla-nav {
  list-style: none;
  margin: 0;
  padding: 16px 0 32px;
  width: 100%;
  /* insert a top offset to clear the brand header */
  margin-top: 80px;
}

ul.joomla-nav li {
  display: block;
  margin: 0;
  padding: 0;
}

/* Section separators become group labels */
ul.joomla-nav li span.separator {
  display: block;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  padding: 18px 24px 6px;
  pointer-events: none;
}
ul.joomla-nav li:first-child span.separator {
  padding-top: 8px;
}

/* Nav links */
ul.joomla-nav li a {
  display: block;
  padding: 7px 24px;
  font-size: 13px;
  color: rgba(255,255,255,0.68);
  border-left: 2px solid transparent;
  transition: color var(--kcm-ease), background var(--kcm-ease), border-color var(--kcm-ease);
  line-height: 1.4;
  /* strip leading dashes from sub-items */
}

ul.joomla-nav li a:hover {
  color: #fff;
  background: rgba(255,255,255,0.06);
  border-left-color: var(--kcm-primary);
}

/* Home link */
ul.joomla-nav li.item465 > a {
  color: rgba(255,255,255,0.9);
  font-weight: 500;
}

/* KCM Events — standalone call-to-action */
ul.joomla-nav li.item494 > a {
  margin-top: 6px;
  color: rgba(255,255,255,0.88);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Active / current page */
ul.joomla-nav li#current > a,
ul.joomla-nav li.selected > a,
ul.joomla-nav li.active > a {
  color: var(--kcm-primary) !important;
  border-left-color: var(--kcm-primary) !important;
  background: rgba(210,176,100,0.08);
  font-weight: 500;
}


/* ═══════════════════════════════════════════════
   5. CONTENT WRAPPERS (Blueprint grid override)
═══════════════════════════════════════════════ */

.span-16,
.span-16.append-1 {
  width: auto !important;
  float: none !important;
  margin: 0 !important;
  padding: 0 !important;
  flex: 1;
}

/* The main content block sits inside span-16 */
.item-page,
.blog-featured {
  padding: 48px;
  max-width: 820px;
}

/* Blueprint append helpers — neutralise */
.append-1 { margin-right: 0 !important; }


/* ═══════════════════════════════════════════════
   6. ARTICLE TYPOGRAPHY
═══════════════════════════════════════════════ */

/* Page / article title */
.articletitle {
  font-family: var(--font-heading);
  font-size: clamp(28px, 3.5vw, 44px);
  font-weight: 400;
  color: var(--kcm-text);
  line-height: 1.2;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

/* Gold divider line under title */
.articletitle::after {
  content: '';
  display: block;
  width: 48px;
  height: 2px;
  background: var(--kcm-primary);
  margin-top: 16px;
  margin-bottom: 24px;
}

/* Sub-headings within articles */
.articlesubtitle {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 500;
  color: var(--kcm-text);
  margin: 28px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--kcm-border);
  letter-spacing: 0.01em;
}

/* Blockquote-style pull quote */
.articlequote {
  font-family: var(--font-heading);
  font-style: italic;
  font-size: 16px;
  font-weight: 400;
  color: var(--kcm-text-subtle);
  line-height: 1.65;
  border-left: 3px solid var(--kcm-primary);
  padding: 10px 16px;
  margin: 14px 0 8px;
  background: var(--kcm-primary-dim);
  border-radius: 0 var(--kcm-radius) var(--kcm-radius) 0;
}

/* Body text paragraphs */
.mainright,
.frontcol2,
.item-page > p,
.item-page > div {
  font-size: 14.5px;
  color: var(--kcm-text-subtle);
  line-height: 1.85;
}

.mainright p,
.frontcol2 p {
  margin-bottom: 14px;
}

/* ── History page two-column layout ── */
.subleftAbout {
  float: left;
  width: 220px;
  margin: 0 28px 20px 0;
}

.subleftAbout img {
  border-radius: var(--kcm-radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  width: 100%;
  margin-bottom: 12px;
}

/* Attribution line after blockquote */
.subleftAbout > *:last-child {
  font-size: 12px;
  color: var(--kcm-text-subtle);
  font-style: italic;
}

/* ── Homepage columns ── */
.frontcol {
  float: right;
  width: 46%;
  margin: 0 0 20px 28px;
}

.frontcol img {
  border-radius: var(--kcm-radius);
  box-shadow: 0 4px 24px rgba(0,0,0,0.1);
  width: 100%;
}

/* Clear floats */
.item-page::after,
.blog-featured::after {
  content: '';
  display: table;
  clear: both;
}


/* ═══════════════════════════════════════════════
   7. BLOG / FEATURED ARTICLES (Homepage)
═══════════════════════════════════════════════ */

.blog-featured .items-leading {}

.leading-0 h2 {
  font-family: var(--font-heading);
  font-size: 38px;
  font-weight: 400;
  color: var(--kcm-text);
  margin-bottom: 0;
}
.leading-0 h2::after {
  content: '';
  display: block;
  width: 48px;
  height: 2px;
  background: var(--kcm-primary);
  margin: 14px 0 22px;
}

/* Notices within homepage content */
.leading-0 > div[dir="ltr"] {
  background: var(--kcm-bg);
  border: 1px solid var(--kcm-border);
  border-left: 3px solid var(--kcm-primary);
  border-radius: var(--kcm-radius);
  padding: 14px 18px;
  margin: 10px 0;
  font-size: 13.5px;
  color: var(--kcm-text-subtle);
  line-height: 1.7;
  transition: box-shadow var(--kcm-ease), transform var(--kcm-ease);
}
.leading-0 > div[dir="ltr"]:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.07);
  transform: translateX(2px);
}
.leading-0 > div[dir="ltr"] strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--kcm-text);
  margin-bottom: 4px;
}

/* Newsletter link */
.leading-0 > p > a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--kcm-primary);
  border-bottom: 1px solid var(--kcm-primary-glow);
  padding-bottom: 1px;
  transition: border-color var(--kcm-ease);
}
.leading-0 > p > a:hover { border-color: var(--kcm-primary); }

.item-separator { display: none; }


/* ═══════════════════════════════════════════════
   8. FOOTER
═══════════════════════════════════════════════ */

.joomla-footer {
  background: var(--kcm-dark-2);
  color: rgba(255,255,255,0.38);
  font-size: 12px;
  padding: 20px 48px !important;
  letter-spacing: 0.03em;
  border-top: 1px solid rgba(255,255,255,0.06);
  width: 100% !important;
  float: none !important;
  margin: 0 !important;
}

.joomla-footer a {
  color: rgba(255,255,255,0.45);
}
.joomla-footer a:hover {
  color: var(--kcm-primary);
}


/* ═══════════════════════════════════════════════
   9. UTILITY CLASSES
═══════════════════════════════════════════════ */

/* Images inside articles */
img[border="0"] {
  border: none;
}

/* Remove Blueprint's default paragraph margins competing with ours */
p { margin: 0 0 14px; }
p:last-child { margin-bottom: 0; }


/* ═══════════════════════════════════════════════
   10. SCROLL ANIMATIONS (progressive enhancement)
═══════════════════════════════════════════════ */

@media (prefers-reduced-motion: no-preference) {

  .item-page,
  .blog-featured,
  .leading-0 > div[dir="ltr"] {
    animation: kcmFadeUp 0.5s ease both;
  }

  .leading-0 > div[dir="ltr"]:nth-child(2) { animation-delay: 0.08s; }
  .leading-0 > div[dir="ltr"]:nth-child(3) { animation-delay: 0.16s; }
  .leading-0 > div[dir="ltr"]:nth-child(4) { animation-delay: 0.24s; }

  @keyframes kcmFadeUp {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}


/* ═══════════════════════════════════════════════
   11. RESPONSIVE
═══════════════════════════════════════════════ */

/* Tablet */
@media (max-width: 1024px) {
  :root { --kcm-nav-w: 230px; }
  .item-page, .blog-featured { padding: 36px; }
  .joomla-footer { padding: 16px 36px !important; }
  .container:first-child { padding: 0 36px !important; }
}

/* Mobile — collapse sidebar to off-canvas */
@media (max-width: 768px) {

  :root { --kcm-nav-w: 260px; }

  /* Nav becomes off-canvas, hidden by default */
  .container:has(.joomla-nav) {
    transform: translateX(-100%);
    transition: transform var(--kcm-ease);
    z-index: 200;
  }
  .container:has(.joomla-nav).kcm-nav-open {
    transform: translateX(0);
    box-shadow: 4px 0 40px rgba(0,0,0,0.25);
  }

  /* Top bar: full width */
  .container:has(.joomla-header),
  .container:first-child {
    left: 0;
    padding: 0 20px !important;
  }

  /* Main + footer: full width */
  .container:last-child {
    margin-left: 0 !important;
  }

  /* Hamburger toggle injected by kcm-global.js */
  .kcm-menu-toggle {
    display: flex !important;
  }

  .item-page, .blog-featured { padding: 24px 20px; }
  .joomla-footer { padding: 16px 20px !important; }

  .subleftAbout {
    float: none;
    width: 100%;
    margin: 0 0 20px;
  }

  .frontcol {
    float: none;
    width: 100%;
    margin: 0 0 20px;
  }
}

/* Inject hamburger button via CSS + a small JS shim below */
.kcm-menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  flex-direction: column;
  gap: 5px;
  margin-right: 14px;
  flex-shrink: 0;
}
.kcm-menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--kcm-text);
  border-radius: 1px;
  transition: var(--kcm-ease);
}
.kcm-menu-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.kcm-menu-toggle.open span:nth-child(2) { opacity: 0; }
.kcm-menu-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Overlay when nav is open on mobile */
.kcm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 150;
  backdrop-filter: blur(2px);
}
.kcm-overlay.active { display: block; }


/* ═══════════════════════════════════════════════
   12. SELECTION & FOCUS
═══════════════════════════════════════════════ */

::selection {
  background: var(--kcm-primary-dim);
  color: var(--kcm-text);
}

:focus-visible {
  outline: 2px solid var(--kcm-primary);
  outline-offset: 3px;
  border-radius: 2px;
}


/* ═══════════════════════════════════════════════
   13. PRINT
═══════════════════════════════════════════════ */

@media print {
  .container:has(.joomla-nav) { display: none !important; }
  .container:has(.joomla-header) { position: static; box-shadow: none; border: none; }
  .container:last-child { margin: 0 !important; }
  .item-page, .blog-featured { padding: 0; }
}
