:root {
  --blue: #0f6ea8;
  --blue-dark: #0a4f7a;
  --terracotta: #c1440e;
  --terracotta-dark: #9c360b;
  --purple: #7a3b6d;
  --green: #2f7d32;
  --cream: #f8f6f1;
  --ink: #1a2b3c;
  --muted: #5c6b78;
  --border: #e4e0d8;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(20, 30, 40, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--cream);
  line-height: 1.6;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

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

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.5em; color: var(--blue-dark); }
p { margin: 0 0 1em; }

/* Header */
.site-header {
  background: #fff;
  border-bottom: 3px solid var(--terracotta);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  flex-wrap: wrap;
  gap: 10px;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-logo { width: 52px; height: 52px; object-fit: cover; border-radius: 50%; border: 2px solid var(--terracotta); }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 1.05rem; color: var(--blue-dark); }
.brand-text small { color: var(--muted); font-size: 0.75rem; }

.main-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.main-nav a {
  color: var(--ink);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 8px 12px;
  border-radius: 6px;
}
.main-nav a:hover { background: var(--cream); text-decoration: none; color: var(--blue); }
.main-nav a.active { background: var(--blue); color: #fff; }
.main-nav a.active:hover { background: var(--blue-dark); color: #fff; }
.nav-toggle { display: none; background: none; border: none; font-size: 1.5rem; cursor: pointer; }

.footer-col a.active { color: #fff; text-decoration: underline; }

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .main-nav { display: none; width: 100%; flex-direction: column; }
  .main-nav.open { display: flex; }
}

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
  color: #fff;
  padding: 64px 0;
  text-align: center;
}
.hero h1 { color: #fff; font-size: 2.2rem; margin-bottom: 0.3em; }
.hero p.lead { font-size: 1.15rem; max-width: 720px; margin: 0 auto 1.2em; color: #eaf3fa; }
.hero .btn { margin: 4px; }

/* Hero carousel (home page) */
.hero-carousel {
  position: relative;
  overflow: hidden;
  min-height: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--blue-dark);
}
.hero-slides { position: absolute; inset: 0; }
.hero-slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1.2s ease;
}
.hero-slide.is-active { opacity: 1; }
.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10,20,30,0.55) 0%, rgba(10,20,30,0.72) 100%);
}
.hero-content { position: relative; z-index: 2; padding: 64px 20px; }
.hero-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero-nav:hover { background: rgba(255,255,255,0.32); }
.hero-nav.prev { left: 18px; }
.hero-nav.next { right: 18px; }
.hero-dots {
  position: absolute;
  bottom: 18px;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  justify-content: center;
  gap: 8px;
}
.hero-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.45);
  cursor: pointer;
  padding: 0;
}
.hero-dot.is-active { background: #fff; }

@media (max-width: 640px) {
  .hero-carousel { min-height: 400px; }
  /* Arrows crowd the headline text at narrow widths — swipe still works. */
  .hero-nav { display: none; }
  .hero-content { padding: 48px 20px; }
  .hero-content h1 { font-size: 1.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-slide { transition: none; }
}

/* Page-navigation loading indicator */
#pjaxBar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: var(--terracotta);
  z-index: 9999;
  opacity: 0;
  transition: width 0.4s ease, opacity 0.2s ease;
}
#pjaxBar.loading { width: 70%; opacity: 1; }
#pjaxBar.done { width: 100%; opacity: 1; }

.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;
}

#page-content:focus { outline: none; }

.btn {
  display: inline-block;
  padding: 10px 22px;
  border-radius: 999px;
  font-weight: 700;
  background: var(--terracotta);
  color: #fff;
  border: none;
  cursor: pointer;
}
.btn:hover { background: var(--terracotta-dark); text-decoration: none; }
.btn.secondary { background: transparent; border: 2px solid #fff; }
.btn.secondary:hover { background: rgba(255,255,255,0.15); }

/* Sections */
.section { padding: 56px 0; }
.section.alt { background: #fff; }
.section-title { text-align: center; margin-bottom: 8px; }
.section-subtitle { text-align: center; color: var(--muted); max-width: 640px; margin: 0 auto 36px; }

.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card h3 { color: var(--terracotta-dark); margin-bottom: 6px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 20px; text-align: center; margin-top: 30px; }
.stat-grid .stat-number { font-size: 2rem; font-weight: 800; color: var(--terracotta); }
.stat-grid .stat-label { color: var(--muted); font-size: 0.9rem; }

.pillar-list, .issue-list, .values-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.pillar-list li, .card.value {
  background: #fff;
  border-left: 4px solid var(--terracotta);
  border-radius: 6px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
}
.issue-list { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.issue-list li {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
}

.values-list { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.value-badge {
  text-align: center;
  background: #fff;
  border-radius: var(--radius);
  padding: 20px 10px;
  box-shadow: var(--shadow);
  font-weight: 700;
  color: var(--blue-dark);
  border-top: 3px solid var(--purple);
}

/* Gallery */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.gallery-grid figure { margin: 0; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: #fff; }
.gallery-grid img { width: 100%; height: 190px; object-fit: cover; }
.gallery-grid figcaption { padding: 8px 12px; font-size: 0.85rem; color: var(--muted); }

/* Parishes */
.archdeaconry-block { margin-bottom: 32px; }
.archdeaconry-block h3 { color: var(--terracotta-dark); border-bottom: 2px solid var(--border); padding-bottom: 6px; }
.parish-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; box-shadow: var(--shadow); }
.parish-card h4 { margin-bottom: 6px; color: var(--blue-dark); }
.parish-card p { margin: 0; color: var(--muted); font-size: 0.92rem; }

/* News */
.news-item { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.news-item h3 a { color: var(--blue-dark); }
.news-meta { color: var(--muted); font-size: 0.82rem; margin-bottom: 8px; }

/* Contact */
.contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }

/* Footer */
.site-footer { background: var(--blue-dark); color: #dceaf3; margin-top: 40px; }
.footer-inner { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 30px; padding: 44px 20px; }
.footer-col h4 { color: #fff; margin-bottom: 10px; }
.footer-col a { color: #cfe6f4; }
.footer-logo { width: 56px; height: 56px; object-fit: cover; border-radius: 50%; margin-bottom: 10px; }
.muted { color: #a9c3d3; }
.footer-bottom { background: #0a3f60; color: #a9c3d3; text-align: center; padding: 14px 0; font-size: 0.85rem; }

/* Admin */
.admin-body { background: var(--cream); min-height: 100vh; }
.admin-header { background: var(--blue-dark); color: #fff; padding: 14px 0; }
.admin-header .container { display: flex; align-items: center; justify-content: space-between; }
.admin-header a { color: #fff; }
.admin-header .role-badge { background: var(--terracotta); padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; margin-left: 8px; }
.admin-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; padding: 24px 0; }
.admin-sidebar { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; position: sticky; top: 90px; }
.admin-sidebar a { display: block; padding: 9px 12px; border-radius: 6px; color: var(--ink); font-weight: 600; font-size: 0.9rem; margin-bottom: 2px; }
.admin-sidebar a:hover, .admin-sidebar a.active { background: var(--cream); color: var(--blue); text-decoration: none; }
.admin-sidebar .group-label { font-size: 0.72rem; text-transform: uppercase; color: var(--muted); margin: 14px 0 4px; padding: 0 12px; letter-spacing: 0.04em; }
.admin-main { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; }

@media (max-width: 760px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; }
}

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 0.9rem; }
.form-group .hint { color: var(--muted); font-size: 0.8rem; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 120px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--blue); outline-offset: 1px; }

table.admin-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
table.admin-table th, table.admin-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 0.9rem; vertical-align: top; }
table.admin-table th { background: var(--cream); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; align-items: center; }
.btn-row form { display: inline-block; margin: 0; }
.btn.small { padding: 6px 14px; font-size: 0.85rem; }
.btn.outline { background: #fff; color: var(--terracotta); border: 2px solid var(--terracotta); }
.btn.outline:hover { background: var(--terracotta); color: #fff; }
.btn.danger { background: #a53030; }
.btn.danger:hover { background: #7f2323; }
.btn.gray { background: var(--muted); }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 0.92rem; }
.alert.success { background: #e5f6e6; color: #205c22; border: 1px solid #b7e0b9; }
.alert.error { background: #fbe6e2; color: #8a2c17; border: 1px solid #f0b8ab; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--blue-dark); padding: 20px; }
.login-card { background: #fff; border-radius: var(--radius); padding: 36px; max-width: 380px; width: 100%; box-shadow: 0 10px 30px rgba(0,0,0,0.25); text-align: center; }
.login-card img { width: 70px; margin: 0 auto 12px; border-radius: 50%; }
.login-card h1 { font-size: 1.3rem; }
.login-card .btn { width: 100%; margin-top: 6px; }

.thumb-manage { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.thumb-manage figure { margin: 0; background: var(--cream); border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.thumb-manage img { height: 130px; width: 100%; object-fit: cover; }
.thumb-manage .thumb-body { padding: 8px 10px; }
.thumb-manage form { margin-top: 6px; }
