:root {
  --ink: #201c18;
  --paper: #faf7f1;
  --surface: #ffffff;
  --accent: #b5482a;
  --accent-dark: #93391f;
  --accent-tint: #fbeee7;
  --muted: #746b60;
  --border: #e6ddce;
  --shadow: 0 1px 2px rgba(32, 28, 24, 0.04), 0 8px 24px -12px rgba(32, 28, 24, 0.12);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  font-size: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f1ece2;
    --paper: #17140f;
    --surface: #211c16;
    --accent: #e07a53;
    --accent-dark: #f0956f;
    --accent-tint: #382318;
    --muted: #a89b8a;
    --border: #382f26;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --ink: #f1ece2;
  --paper: #17140f;
  --surface: #211c16;
  --accent: #e07a53;
  --accent-dark: #f0956f;
  --accent-tint: #382318;
  --muted: #a89b8a;
  --border: #382f26;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

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

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

/* ---------- Header ---------- */

.site-header {
  padding: 1.75rem 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.header-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}
.brand em { color: var(--accent); font-style: normal; }

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.9rem;
}
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}
.site-nav a:hover { color: var(--ink); }
.site-nav .lang-switch {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  color: var(--ink);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}
.site-nav .lang-switch:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tagline {
  max-width: 760px;
  margin: 0.6rem auto 0;
  color: var(--muted);
}

/* ---------- Layout ---------- */

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

h2 {
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  margin: 2.5rem 0 1rem;
}

/* ---------- Hero ---------- */

.hero { margin-bottom: 1.75rem; }
.hero h1 {
  font-size: 1.9rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 0.6rem;
}
.hero-subtext {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0;
  max-width: 56ch;
}

/* ---------- Search ---------- */

.search form {
  display: flex;
  gap: 0.5rem;
}
.search input[type="search"] {
  flex: 1;
  padding: 0.8rem 1.1rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  font-size: 1rem;
}
.search input[type="search"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.search form button {
  padding: 0.8rem 1.4rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}
.search form button:hover { background: var(--accent-dark); }

/* ---------- Cards ---------- */

.card-list {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.card {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}
.card h3 { margin: 0 0 0.3rem; font-size: 1.02rem; font-weight: 700; }
.card .meta { color: var(--muted); font-size: 0.85rem; margin: 0; }

.card-media {
  flex: 0 0 84px;
  width: 84px;
  position: relative;
  background: var(--accent-tint);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-media .card-icon { font-size: 1.7rem; line-height: 1; }
.card-media:not(.no-image) .card-icon {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  font-size: 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-body {
  flex: 1;
  min-width: 0;
  padding: 0.85rem 1rem;
}

.empty-state { color: var(--muted); }
.empty-state-card {
  display: block;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  background: transparent;
}
.empty-state-card a { font-weight: 600; }

/* ---------- CTA band ---------- */

.cta {
  border-top: 1px solid var(--border);
  padding-top: 1.75rem;
  margin-top: 2.5rem;
}

/* ---------- Footer ---------- */

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 2rem 1.25rem;
  border-top: 1px solid var(--border);
}
.site-footer a { color: var(--muted); }

/* ---------- Detail pages ---------- */

.breadcrumb { margin: 0 0 1.25rem; }
.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}
.breadcrumb a:hover { color: var(--accent); }

.detail {
  --pad-x: 2rem;
  --pad-top: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--pad-top) var(--pad-x) 2rem;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.detail h1 {
  font-size: 1.65rem;
  letter-spacing: -0.01em;
  margin: 0 0 0.6rem;
}
.detail-icon { font-size: 1.15em; margin-right: 0.15em; }

.detail-hero {
  position: relative;
  margin: calc(var(--pad-top) * -1) calc(var(--pad-x) * -1) 1.25rem;
  aspect-ratio: 16 / 9;
  background: var(--accent-tint);
}
.detail-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.detail-hero-icon {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
/* If the image URL 404s or is blocked client-side, fall back to a large
 * centered icon rather than leaving the hero band empty. */
.detail-hero.no-image {
  display: flex;
  align-items: center;
  justify-content: center;
}
.detail-hero.no-image .detail-hero-icon {
  position: static;
  width: auto;
  height: auto;
  background: none;
  box-shadow: none;
  font-size: 3.5rem;
}
.image-credit {
  font-size: 0.72rem;
  text-align: right;
  margin: -0.9rem 0 1rem;
}
.detail .meta {
  color: var(--muted);
  margin: 0.25rem 0;
}
.detail .description {
  margin: 1.1rem 0 0.4rem;
  line-height: 1.65;
}
.detail .meta.original-note {
  font-size: 0.78rem;
  font-style: italic;
}
.cta, .detail .cta { margin-top: 1.75rem; border: none; padding-top: 0; }
.btn-outbound {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 0.8rem 1.5rem;
  text-decoration: none;
  font-weight: 700;
  transition: background 0.15s ease, transform 0.12s ease;
}
.btn-outbound:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

/* ---------- Section head + view toggle ---------- */

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 2.5rem 0 1rem;
}
.section-head h2 { margin: 0; }

.view-toggle { display: flex; gap: 0.4rem; }
.view-toggle-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.view-toggle-btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* ---------- Grid (masonry) view for event cards ---------- */

.card-list.grid-view {
  display: block;
  column-count: 2;
  column-gap: 0.75rem;
}
.card-list.grid-view li {
  break-inside: avoid;
  margin-bottom: 0.75rem;
  display: block;
}
.card-list.grid-view .card { flex-direction: column; }
.card-list.grid-view .card-media {
  flex: none;
  width: 100%;
  aspect-ratio: 4 / 3;
}
.card-list.grid-view .card-media .card-icon { font-size: 2.2rem; }
.ar-square { aspect-ratio: 1 / 1 !important; }
.ar-portrait { aspect-ratio: 3 / 4 !important; }
.ar-landscape { aspect-ratio: 16 / 9 !important; }
.ar-tall { aspect-ratio: 2 / 3 !important; }

@media (min-width: 640px) {
  .card-list.grid-view { column-count: 3; }
}

/* ---------- Slide-over event panel ---------- */

#panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 12, 0.45);
  z-index: 40;
  opacity: 0;
  transition: opacity 0.2s ease;
}
#panel-overlay:not([hidden]) { opacity: 1; }

.event-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  z-index: 50;
  overflow-y: auto;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.18);
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.event-panel.open { transform: translateX(0); }

.panel-close {
  position: sticky;
  top: 0.75rem;
  float: right;
  margin: 0.75rem 0.75rem 0 0;
  border: none;
  background: var(--paper);
  width: 36px;
  height: 36px;
  border-radius: 999px;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

#panel-content.detail {
  --pad-x: 1.5rem;
  --pad-top: 3.25rem;
  background: none;
  border: none;
  box-shadow: none;
  overflow: visible;
  clear: both;
}
#panel-content.detail h2 {
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  margin: 0 0 0.6rem;
}

body.panel-open { overflow: hidden; }

/* ---------- Responsive ---------- */

@media (max-width: 520px) {
  .header-inner { flex-wrap: wrap; }
  .search form { flex-direction: column; }
  .search form button { width: 100%; }
  .detail { --pad-x: 1.25rem; --pad-top: 1.25rem; padding-bottom: 1.5rem; }
  .event-panel { max-width: 100%; }
  .section-head { flex-wrap: wrap; }
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
