/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f3f4f5;
  --surface: #ffffff;
  --border: #e6e7e8;
  --text: #0b0c0c;
  --text-muted: #505a5f;
  --text-light: #626a6e;
  --primary: #AD0908;
  --primary-dark: #7a0706;
  --primary-light: #c73534;
  --primary-bg: #fef5f5;
  --gold: #febc0a;
  --gold-dark: #d9a008;
  --gold-bg: #fff8e0;
  --accent: #00703c;
  --accent-bg: #e6f4ed;
  --info: #1d70b8;
  --info-bg: #e8f1f8;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --max-width: 1200px;
}

body {
  font-family: 'Noto Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ── Header ── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  background: linear-gradient(135deg, #AD0908 0%, #7a0706 100%);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  padding: 1rem 0;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  text-decoration: none;
  color: #fff;
}

.logo:hover { text-decoration: none; color: #fff; }

.logo-crest {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.logo h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
}

.logo .subtitle {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.75);
  font-style: italic;
  letter-spacing: 0.02em;
}

nav {
  background: #8b0a09;
  border-bottom: 3px solid var(--gold);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  gap: 0;
}

.nav-link {
  padding: 0.75rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  transition: all 0.15s;
  border-bottom: 3px solid transparent;
  margin-bottom: -3px;
}

.nav-link:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  text-decoration: none;
}

.nav-link.active {
  color: #fff;
  border-bottom-color: var(--gold);
  background: rgba(255,255,255,0.08);
}

/* ── Main ── */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
  flex: 1;
}

/* ── Footer ── */
footer {
  background: linear-gradient(180deg, #2d3436 0%, #0b0c0c 100%);
  border-top: 3px solid var(--primary);
  padding: 2rem 1.5rem;
  text-align: center;
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.6);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

footer a { color: rgba(255,255,255,0.8); }
footer a:hover { color: #fff; }

.footer-copy {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.4);
}

/* ── Loading ── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
  gap: 1rem;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Search Bar ── */
.search-bar {
  position: relative;
  margin-bottom: 1.5rem;
}

.search-bar input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 0.9375rem;
  font-family: inherit;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(173, 9, 8, 0.12);
}

.search-bar::before {
  content: '\1F50D';
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  pointer-events: none;
}

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.filter-bar select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-family: inherit;
  background: var(--surface);
  cursor: pointer;
}

.filter-bar select:focus {
  outline: none;
  border-color: var(--primary-light);
}

.result-count {
  display: flex;
  align-items: center;
  margin-left: auto;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ── Cards Grid ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 1.25rem;
  transition: box-shadow 0.15s, transform 0.15s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-top-color: var(--gold);
  text-decoration: none;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.card-flag {
  width: 48px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.card-flag-large {
  width: 64px;
  height: 48px;
}

.card-flag.flag-nonrect {
  object-fit: contain;
  border: none;
  border-radius: 0;
  filter: drop-shadow(0 0 0.5px var(--border)) drop-shadow(0 0 0.5px var(--border));
}

/* Thin border on ALL flag images across the site */
img[alt="flag"],
.upcoming-flag,
.detail-flag,
.calendar-flag,
.highlight-item img,
.leader-country-row img {
  border: 1px solid var(--border);
  border-radius: 3px;
}

.card-name {
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.3;
}

.card-official {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.card-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
}

.card-label {
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 5rem;
}

.card-value {
  font-weight: 500;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-accent { background: var(--accent-bg); color: var(--accent); }
.badge-muted { background: #f3f4f5; color: var(--text-muted); }

.region-icon {
  width: 1.4em;
  height: 1.4em;
  flex-shrink: 0;
}

/* ── Section titles ── */
.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  letter-spacing: -0.02em;
}

.section-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

/* ── Today's highlight ── */
.highlight-banner {
  background: linear-gradient(135deg, #AD0908 0%, #7a0706 100%);
  color: white;
  padding: 1.5rem 2rem;
  border-radius: var(--radius-lg);
  margin-bottom: 2rem;
}

.highlight-banner h2 {
  font-size: 1rem;
  font-weight: 600;
  opacity: 0.85;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.highlight-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.highlight-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255,255,255,0.15);
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s;
}

.highlight-item:hover {
  background: rgba(255,255,255,0.25);
  text-decoration: none;
}

.highlight-item img {
  width: 28px;
  height: 19px;
  object-fit: cover;
  border-radius: 3px;
}

.highlight-empty {
  opacity: 0.7;
  font-size: 0.875rem;
}

/* ── Stats row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-align: center;
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

/* ── Detail: Hero ── */
.detail-hero {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin-bottom: 2rem;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.detail-flag {
  width: 160px;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
}

.detail-flag.flag-nonrect {
  object-fit: contain;
  border: none;
  box-shadow: none;
  border-radius: 0;
  filter: drop-shadow(0 0 1px rgba(0,0,0,0.2)) drop-shadow(0 0 1px rgba(0,0,0,0.15));
}

.detail-hero-text h2 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.detail-official {
  color: var(--text-muted);
  font-size: 0.9375rem;
  margin-bottom: 0.75rem;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ── Detail: Cards & Columns ── */
.detail-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.detail-card h3 {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
}

.detail-table tr + tr td {
  padding-top: 0.625rem;
}

.detail-table-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding-right: 1.5rem;
  white-space: nowrap;
  vertical-align: top;
}

.detail-table-value {
  font-weight: 500;
  font-size: 0.9375rem;
}

.detail-table-value code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875rem;
  background: var(--bg);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
}

/* ── Detail: National Day ── */
.detail-national-day {
  margin-bottom: 1.5rem;
  border-left: 4px solid var(--primary);
}

.national-day-content {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.national-day-date {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.national-day-name {
  font-size: 1rem;
  color: var(--text);
}

/* ── Detail: Sections ── */
.detail-section {
  margin-bottom: 2rem;
}

.detail-section h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary-bg);
}

/* ── Leader role columns ── */
.leaders-columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.leader-role-section h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--gold);
}

.former-heading {
  color: var(--text-muted);
  border-bottom-color: var(--border) !important;
}

/* ── Leader cards ── */
.leader-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  transition: box-shadow 0.15s;
}

.leader-card:hover { box-shadow: var(--shadow-md); }

.leader-photo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}

.leader-photo-placeholder {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.leader-info { flex: 1; min-width: 0; }

.leader-style {
  font-size: 0.75rem;
  font-variant: small-caps;
  text-transform: lowercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: -0.125rem;
}

.leader-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.125rem;
}

.leader-title {
  font-size: 0.8125rem;
  color: var(--primary);
  margin-bottom: 0.375rem;
}

.leader-dates {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.leader-country-row {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  margin-top: 0.25rem;
}

.leader-country-row img {
  width: 20px;
  height: 14px;
  object-fit: cover;
  border-radius: 2px;
}

/* ── Calendar ── */
/* ── Calendar: Nav ── */
.cal-nav {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0.375rem;
  margin-bottom: 2rem;
}

.cal-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.625rem 0.25rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all 0.15s;
  text-decoration: none;
}

.cal-nav-item span {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.2;
}

.cal-nav-item:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  text-decoration: none;
}

.cal-nav-empty {
  color: var(--text-muted);
  opacity: 0.4;
  pointer-events: none;
}

/* ── Calendar: Month ── */
.calendar-month {
  margin-bottom: 2.5rem;
}

.cal-month-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 3px solid var(--primary);
}

.cal-month-name {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text);
}

.cal-month-count {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ── Calendar: Days ── */
.cal-days {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cal-day-group {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.cal-day-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 3.5rem;
  padding: 0.5rem 0;
  flex-shrink: 0;
}

.cal-day-num {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--primary);
}

.cal-day-month {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.cal-day-entries {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.cal-entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  text-decoration: none;
  color: inherit;
}

.cal-entry:last-child { border-bottom: none; }
.cal-entry:hover { background: var(--primary-bg); text-decoration: none; }

.cal-flag {
  width: 32px;
  height: 24px;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.cal-entry-info { flex: 1; min-width: 0; }

.cal-entry-country {
  font-weight: 600;
  font-size: 0.9375rem;
}

.cal-entry-event {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Back link ── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.back-link:hover { color: var(--primary); text-decoration: none; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 0.75rem; }

/* ── Upcoming ── */
.upcoming-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.upcoming-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.upcoming-item:hover {
  box-shadow: var(--shadow);
  border-color: var(--primary-light);
  text-decoration: none;
}

.upcoming-date {
  min-width: 3.5rem;
  text-align: center;
  flex-shrink: 0;
}

.upcoming-date-month {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  font-weight: 600;
}

.upcoming-date-day {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.upcoming-info { flex: 1; min-width: 0; }
.upcoming-country { font-weight: 500; font-size: 0.875rem; }
.upcoming-event { font-size: 0.75rem; color: var(--text-muted); }

.upcoming-flag {
  width: 32px;
  height: 21px;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    text-align: center;
    padding: 0.75rem 1rem;
  }

  .nav-inner {
    justify-content: center;
  }

  .nav-link {
    padding: 0.625rem 0.875rem;
    font-size: 0.8125rem;
  }

  main { padding: 1rem; }

  .card-grid { grid-template-columns: 1fr; }

  .detail-hero {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.5rem;
  }

  .detail-hero-text h2 { font-size: 1.5rem; }

  .detail-meta { justify-content: center; }
  .detail-columns { grid-template-columns: 1fr; }

  .national-day-content {
    flex-direction: column;
    gap: 0.25rem;
  }

  .stats-row { grid-template-columns: repeat(2, 1fr); }

  .filter-bar { flex-direction: column; }
  .result-count { margin-left: 0; }

  .cal-nav { grid-template-columns: repeat(6, 1fr); }

  .cal-day-marker { min-width: 2.5rem; }
  .cal-day-num { font-size: 1.25rem; }

  .leaders-columns { grid-template-columns: 1fr; }
}
