/* ============================================================
   GEORGIA ELECTIONS DASHBOARD — DESIGN SYSTEM
   Palette: Georgian flag red/white/black, 538-style editorial
   ============================================================ */

:root {
  --red:         #CC1720;   /* Georgian flag red */
  --red-hover:   #a8121a;   /* Darker red for hover */
  --red-light:   #fdf0f0;   /* Very light red tint */
  --dark:        #1a1a1a;   /* Near-black headings */
  --mid:         #3d3d3d;   /* Body text */
  --muted:       #717171;   /* Secondary/caption text */
  --border:      #e0e0e0;   /* Card/element borders */
  --bg:          #f7f7f7;   /* Page background */
  --card:        #ffffff;   /* Card background */
  --inner-bg:    #f9f9f9;   /* Accordion inner / subtle sections */
  --radius:      4px;       /* Minimal rounding — editorial feel */
  --shadow:      0 1px 3px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 14px rgba(0,0,0,0.12);
  --font-head:   'BPG Arial Caps', sans-serif;
  --font-body:   'BPG Arial', sans-serif;
}

/* ---- TYPOGRAPHY ---- */
h1, h2, h3, h4, h5 {
  font-family: var(--font-head);
  color: var(--dark);
  line-height: 1.3;
}

h1 { font-size: 1.9rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; }
h5 { font-size: 0.95rem; }

body, p, span, div, label, button, input, select {
  font-family: var(--font-body);
  color: var(--mid);
}

p { line-height: 1.6; }

/* ---- LAYOUT WIDTH (overrides wide theme's 100vw; controls header + page content together) ---- */
:root {
  --observablehq-max-width: 1200px;
}

/* ---- HEADER ---- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding-right: 1.5rem;
  background: var(--card);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2000;
  height: 60px;
}

.app-brand {
  font-size: 1.1rem;
  font-family: var(--font-head);
  font-weight: bold;
  color: var(--dark);
  flex: 0 0 500px;
  width: 500px;
  max-width: 500px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  overflow: hidden;
  white-space: nowrap;
}

/* Red vertical bar accent on brand */
.app-brand::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 28px;
  background: var(--red);
  border-radius: 2px;
  flex-shrink: 0;
}

.app-brand a {
  text-decoration: none;
  color: inherit;
  letter-spacing: 0.02em;
}

/* ---- NAVIGATION ---- */
.top-nav {
  display: flex;
  gap: 0;
  align-items: center;
}

.top-nav a {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius);
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  display: inline-block;
  text-align: center;
  white-space: nowrap;
}

.top-nav a:hover {
  color: var(--dark);
  border-bottom-color: var(--border);
}

.top-nav a.active {
  color: var(--red);
  border-bottom-color: var(--red);
}

/* ---- LANGUAGE BUTTON ---- */
.lang-btn {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--mid);
  transition: border-color 0.15s, color 0.15s;
  font-family: var(--font-body);
  white-space: nowrap;
}

.lang-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

/* ---- HAMBURGER (MOBILE) ---- */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
}

.menu-toggle svg {
  width: 24px;
  height: 24px;
  fill: var(--dark);
}

/* ---- CARDS ---- */
/* Observable Framework's .card override */
.observablehq .card,
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

/* Featured card: red left accent */
.card-featured {
  border-left: 4px solid var(--red);
}

/* ---- DATA CARDS (Download page) ---- */
.data-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}

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

.data-card h5 {
  margin: 0;
  font-size: 0.95rem;
}

.data-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ---- ANALYSIS CARDS ---- */
.analysis-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-top: 3px solid var(--border);
  padding: 1.25rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow);
  transition: border-top-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.analysis-card:hover {
  border-top-color: var(--red);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.analysis-card h5 {
  margin-top: 0;
  font-size: 1rem;
  color: var(--dark);
}

.analysis-card p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

/* ---- ELECTION CARDS (Index accordion) ---- */
.election-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}

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

.election-card h5 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
}

.election-card p {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 0.75rem;
}

/* ---- BUTTONS ---- */
.btn-group {
  display: flex;
  gap: 8px;
  margin-top: auto;
  flex-wrap: wrap;
}

/* Primary — red */
.btn-primary-outline {
  background: var(--card);
  border: 1.5px solid var(--red);
  color: var(--red);
  padding: 5px 12px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: var(--font-body);
}

.btn-primary-outline:hover {
  background: var(--red);
  color: white;
}

/* Secondary — dark */
.btn-secondary-outline {
  background: var(--card);
  border: 1.5px solid var(--mid);
  color: var(--mid);
  padding: 5px 12px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: var(--font-body);
}

.btn-secondary-outline:hover {
  background: var(--mid);
  color: white;
}

/* Solid primary — red fill */
.btn-primary-solid {
  background: var(--red);
  color: white;
  border: none;
  padding: 7px 18px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  width: fit-content;
  transition: background 0.15s;
  font-family: var(--font-body);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.btn-primary-solid:hover {
  background: var(--red-hover);
}

/* Small ghost button for election cards */
.btn-ghost {
  background: none;
  border: 1.5px solid var(--border);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  font-family: var(--font-body);
  align-self: flex-start;
}

.btn-ghost:hover {
  border-color: var(--red);
  color: var(--red);
}

/* ---- ACCORDIONS ---- */
details > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.9rem 1.25rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
  transition: background 0.15s;
}

details > summary::-webkit-details-marker { display: none; }

details > summary:hover {
  background: var(--inner-bg);
}

details[open] > summary {
  border-bottom: 1px solid var(--border);
  color: var(--red);
}

.acc-icon {
  display: inline-block;
  margin-right: 4px;
  transition: transform 0.2s;
  color: var(--muted);
  font-size: 0.75rem;
}

details[open] .acc-icon {
  transform: rotate(180deg);
  color: var(--red);
}

.accordion-inner {
  padding: 1rem 1.25rem;
  background: var(--inner-bg);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

/* ---- CANDIDATE PHOTO PLACEHOLDER ---- */
.candidate-photo-placeholder {
  width: 140px;
  height: 140px;
  background: var(--inner-bg);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  margin-bottom: 1rem;
  font-size: 0.8rem;
}

/* ---- FORM INPUT GROUPS ---- */
.input-group {
  margin-bottom: 1.1rem;
}

.input-group label {
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: 0.3rem;
}

/* ---- STAT / METRIC DISPLAY ---- */
.stat-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--dark);
  line-height: 1.1;
}

/* ---- DIVIDERS ---- */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

/* ---- HEADER OBSERVABLE OVERRIDE ---- */
#observablehq-header {
  border-bottom: none !important;
}

/* ---- ALIGN BODY CONTENT WITH HEADER PADDING ---- */
/* Applied per-page via wrapper classes below — see idx-page-wrap, dl-page, about-page */

/* ================================================================
   RESPONSIVE — MOBILE
   ================================================================ */
@media (max-width: 768px) {
  .app-brand {
    flex: 1 1 auto;
    width: auto;
    max-width: none;
    min-width: 0;
    font-size: 1rem;
  }

  .menu-toggle {
    display: block;
  }

  .top-nav {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--card);
    flex-direction: column;
    gap: 0;
    border-bottom: 2px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    z-index: 1999;
  }

  .top-nav.open {
    display: flex;
  }

  .top-nav a {
    width: 100%;
    min-width: auto;
    text-align: left;
    padding: 0.9rem 1.5rem;
    border-radius: 0;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid transparent;
  }

  .top-nav a.active {
    border-left-color: var(--red);
    border-bottom-color: var(--border);
    background: var(--red-light);
  }
}
