:root {
  /* brand */
  --color-primary: #40b36e;
  --color-on-primary: #fff;
  --color-link: #007bff;

  /* text */
  --color-text: #333;

  /* neutrals */
  --color-border: #ddd;
  --color-background: #f5f5f5;
  --color-surface: #fff;
  --color-muted: #52606d;
  --color-surface-translucent: rgb(255 255 255 / 80%);

  /* social */
  --color-facebook: #3b5998;
  --color-youtube: #e15759;

  /* ratings */
  --color-rating-easy: #28a745;
  --color-rating-medium: #ffc107;
  --color-rating-hard: #dc3545;

  --radius-sm: 4px;
  --radius-md: 5px;
  --radius-lg: 8px;
  --font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* brand */
    --color-link: #6cb2ff;

    /* text */
    --color-text: #e6e6e6;

    /* neutrals */
    --color-border: #444;
    --color-background: #222;
    --color-surface: #161616;
    --color-muted: #9aa5b1;
    --color-surface-translucent: rgb(22 22 22 / 85%);
  }
}
html {
  scrollbar-gutter: stable;
  overflow-x: hidden;
  height: 100%;
}

a {
  color: var(--color-primary);
}

.js-required-message {
  text-align: center;
}

body {
  font-family: var(--font-family);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  overflow-x: hidden;
  color: var(--color-text);
  background-color: var(--color-surface);
}

body:has(#map-container) {
  height: 100vh;
  overflow: hidden;
}

body>* {
  min-width: 0;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

ul {
  list-style: none;
  padding: 0;
}
/* Navigation Bar */
#navigation {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  padding: 10px 20px;
  background-color: var(--color-primary);
  color: var(--color-on-primary);
  z-index: 1000;
}

#navigation h1 {
  margin: 0;
  font-size: 1.5em;
  font-weight: 800;
  letter-spacing: 1px;
  white-space: nowrap;
}

#navigation h1 a {
  color: inherit;
  text-decoration: none;
}

/* Header search */
.header-search {
  flex: 1 1 220px;
  max-width: 380px;
  min-width: 0;
}

.map-search-container {
  position: relative;
  width: 100%;
  margin: 0;
}

#address-search {
  width: 100%;
  padding: 0.42rem 0.7rem;
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: var(--radius-md);
  background: rgb(255 255 255 / 12%);
  color: var(--color-on-primary);
  font: inherit;
  font-size: 0.9rem;
}

#address-search::placeholder {
  color: rgb(255 255 255 / 72%);
  opacity: 1;
}

#address-search:focus {
  outline: 2px solid rgb(255 255 255 / 75%);
  outline-offset: 1px;
  background: rgb(255 255 255 / 20%);
}

#address-search::-webkit-search-cancel-button {
  filter: invert(1);
  opacity: 0.7;
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 1100;
  max-height: 280px;
  overflow-y: auto;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgb(0 0 0 / 25%);
}

.search-results[hidden] {
  display: none;
}

.search-result {
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.search-result:hover,
.search-result.is-active {
  background: var(--color-background);
}

.search-result-name {
  margin-bottom: 2px;
  font-weight: 600;
  color: var(--color-text);
}

.search-result-address {
  font-size: 0.8rem;
  color: var(--color-text);
  opacity: 0.75;
}

.search-status {
  padding: 0.5rem 0.55rem;
  color: var(--color-text);
  opacity: 0.75;
}

/* Add button */
.header-add {
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-md);
  background-color: var(--color-on-primary);
  color: var(--color-primary);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.header-add:hover {
  background-color: rgb(255 255 255 / 85%);
}

/* Right-aligned group: last update + page buttons */
.header-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-left: auto;
}

.header-nav ul {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.header-nav a {
  display: inline-block;
  padding: 0.35rem 0.65rem;
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: var(--radius-md);
  color: var(--color-on-primary);
  font-size: 0.9rem;
  text-decoration: none;
  white-space: nowrap;
}

.header-nav a:hover {
  background-color: rgb(255 255 255 / 18%);
}

#navigation time {
  font-size: 0.8em;
  white-space: nowrap;
  opacity: 0.85;
}

@media (max-width: 900px) {
  #navigation time {
    display: none;
  }
}

@media (max-width: 520px) {
  .header-search {
    flex: 1 1 160px;
    max-width: none;
  }
}
/* Map Page */
#map-container {
  position: relative;
  max-width: none;
  margin: 0;
  padding: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

#map-fullscreen {
  width: 100%;
  height: 100%;
  text-align: left;
}

/* Template Styles */
.maplibregl-ctrl-group {
  background-color: var(--color-surface);
}

.maplibregl-ctrl-group button {
  background-color: var(--color-surface);
}

.maplibregl-ctrl-group button:hover {
  background-color: var(--color-background);
}

.maplibregl-ctrl-group button + button {
  border-top-color: var(--color-border);
}

.maplibregl-ctrl-attrib {
  background-color: var(--color-surface-translucent);
  color: var(--color-muted);
}

.maplibregl-ctrl-attrib a {
  color: var(--color-muted);
}

.maplibregl-ctrl-attrib.maplibregl-compact {
  background-color: var(--color-surface);
}

.maplibregl-popup-content {
  max-width: 300px;
  padding: 0.75rem 0.9rem;
  background-color: var(--color-surface);
  color: var(--color-text);
}

.maplibregl-popup-tip {
  border-top-color: var(--color-surface);
  border-bottom-color: var(--color-surface);
}

.maplibregl-popup-close-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 0;
  border-radius: 0 var(--radius-sm) 0 0;
  background: transparent;
  color: var(--color-text);
  font-size: 1.6rem;
  line-height: 1;
  opacity: 0.5;
  cursor: pointer;
}

.maplibregl-popup-close-button:hover {
  background-color: var(--color-background);
  color: var(--color-text);
  opacity: 1;
}

.maplibregl-popup-content h3 {
  padding-right: 2.25rem;
}

.maplibregl-popup-content h3,
.maplibregl-popup-content p {
  margin: 0 0 10px 0;
}

@media (prefers-color-scheme: dark) {
  .maplibregl-ctrl-group button .maplibregl-ctrl-icon,
  .maplibregl-ctrl-attrib-button {
    filter: invert(1) hue-rotate(180deg);
  }
}

.maplibregl-popup-content button:not(.maplibregl-popup-close-button) {
  display: block;
  margin: 0 auto;
  background: var(--color-primary);
  color: var(--color-on-primary);
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
}
/* Stats Page */
.stats-header {
  text-align: center;
  margin-bottom: 40px;
}

.stats-header p {
  margin: 0;
}

.stats-header span {
  display: inline-block;
  margin: 0 10px;
}

.stats-header strong {
  font-size: 1.5em;
}

#charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 24px;
}

figure {
  text-align: center;
}

figcaption {
  margin-top: 10px;
  font-size: smaller;
}

figcaption h3 {
  margin: 0 0 10px;
  font-size: 1em;
}

/* Charts */
.chart-canvas {
  position: relative;
  height: 200px;
}

/* Monthly Chart */
#monthly-chart {
  margin-bottom: 40px;
}

#monthly-chart .chart-canvas {
  height: 300px;
  max-width: 800px;
  margin: 0 auto;
}

/* Rankings Section */
#rankings {
  display: grid;
  grid-template-columns: minmax(0, 40%) minmax(0, 60%);
  gap: 24px;
  margin-bottom: 40px;
  box-sizing: border-box;
}

@media (max-width: 900px) {
  #rankings {
    grid-template-columns: minmax(0, 1fr);
  }
}

#monthly-chart h3,
#city-ranking h3,
#church-ranking h3 {
  text-align: center;
  margin-bottom: 20px;
}

.ranking {
  list-style: none;
  counter-reset: rank;
  margin: 0;
}

.ranking li {
  counter-increment: rank;
  display: grid;
  grid-template-columns: 2em 1fr auto;
  gap: 2px 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.ranking li:last-child {
  border-bottom: none;
}

.ranking li::before {
  content: counter(rank);
  color: var(--color-primary);
  font-weight: 700;
  text-align: right;
}

.ranking a {
  grid-column: 2;
  text-decoration: none;
}

.ranking span {
  grid-column: 2;
  font-size: 0.9em;
}

.ranking b {
  grid-column: 3;
}
hr {
  border: none;
  border-top: 2px solid var(--color-border);
}

main>p {
  max-width: 700px;
  margin: 0 auto 40px;
  font-size: 1.25rem;
  line-height: 1.7;
  text-align: center;
}

main > h2 {
  text-align: center;
}

#links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  font-size: 1rem;
  line-height: 1.2;
}

#links a,
.intro-cta a,
main > p:last-child a {
  display: inline-block;
  padding: 6px 12px;
  font-size: 1rem;
  color: var(--color-on-primary);
  background-color: var(--color-primary);
  border-radius: var(--radius-md);
  text-decoration: none;
}

.intro-cta a {
  font-weight: 700;
}

#links a[href*="facebook.com"] {
  background-color: var(--color-facebook);
}

#links a[href*="youtube.com"] {
  background-color: var(--color-youtube);
}

main > p:last-child {
  margin-bottom: 0;
  padding: 20px 0 0;
  text-align: center;
}
/* Church Details Page */
.church-details {
  max-width: 800px;
}

.church-details>header {
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--color-border);
}

.church-details>header h1 {
  margin: 0 0 10px 0;
  color: var(--color-text);
}

.church-details address {
  font-size: 1.1em;
  color: var(--color-text);
  margin-bottom: 10px;
  font-style: normal;
}

.church-details>header>div {
  margin-top: 10px;
}

.church-details>header>div a {
  text-decoration: none;
}

.church-details>header>a {
  display: inline-block;
  margin: 16px 0;
  padding: 10px 20px;
  background-color: var(--color-primary);
  color: var(--color-on-primary);
  text-decoration: none;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-primary);
  font-family: inherit;
  font-size: inherit;
  font-weight: 700;
  line-height: normal;
  white-space: nowrap;
}

.church-details>section {
  margin-bottom: 30px;
}

.church-details article {
  margin-bottom: 20px;
  padding: 15px;
  background-color: var(--color-background);
  border-radius: var(--radius-lg);
  border-left: 4px solid var(--color-link);
}

.church-details article.rating-easy {
  border-left-color: var(--color-rating-easy);
}

.church-details article.rating-medium {
  border-left-color: var(--color-rating-medium);
}

.church-details article.rating-hard {
  border-left-color: var(--color-rating-hard);
}

.church-details article header {
  margin-bottom: 8px;
  opacity: 0.75;
}

.church-details article footer {
  text-align: left;
  font-size: 0.9em;
  color: var(--color-text);
  opacity: 0.7;
  margin: 0;
}

.church-details article>p {
  line-height: 1.5;
  color: var(--color-text);
  margin-top: 0;
  margin-bottom: 10px;
}

.source-compare summary {
  font-size: 0.8em;
  color: var(--color-text);
  opacity: 0.4;
  cursor: pointer;
}

.source-compare table {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  font-size: 0.9em;
}

.source-compare th,
.source-compare td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.source-compare tbody tr:last-child th,
.source-compare tbody tr:last-child td {
  border-bottom: none;
}

.source-compare thead th {
  font-weight: 600;
}

.source-compare tbody th {
  font-weight: normal;
  white-space: nowrap;
}

.source-compare a {
  text-decoration: none;
}
.news-item {
  max-width: 760px;
  margin: 0 auto 40px;
}

.news-item h2 {
  margin-bottom: 4px;
}

.news-item h2 a {
  text-decoration: none;
}

.news-item h2 a:hover {
  text-decoration: underline;
}

.news-date {
  color: #888;
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.news-summary,
.news-content {
  line-height: 1.7;
}

.news-summary ul,
.news-content ul {
  margin: 0 0 10px;
  padding-left: 1.5rem;
  list-style: disc;
}

.news-summary ol,
.news-content ol {
  margin: 0 0 10px;
  padding-left: 1.5rem;
  list-style: decimal;
}

.news-summary li,
.news-content li {
  margin-bottom: 4px;
}

.news-post {
  max-width: 760px;
  margin: 0 auto;
}

.news-content img {
  max-width: 100%;
}

.news-content pre {
  padding: 12px;
  overflow-x: auto;
  background-color: var(--color-background);
  border-radius: var(--radius-md);
}

.news-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.news-content blockquote {
  margin: 0;
  padding-left: 16px;
  color: #666;
  border-left: 3px solid var(--color-border);
}
