* {
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  padding: 0;
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
}

:root {
  --bg: #f7f7fb; /* Page background */
  --text: #1f2937; /* Primary text */
  --muted: #556072; /* Secondary color */
  --accent: #2f4a6d; /* Header and spinner color */
  --line: #e5e7eb; /* Hairline borders */
  --radius: 16px; /* Global corner rounding */
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08); /* Soft elevation on light bg */
}

/* ── Manual Dark Theme (html[data-theme="dark"]) ───────────────── */
:root[data-theme="dark"] {
  --bg: #0b1220;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #1b2a3a;
  --shadow: none; /* Reduce glow on dark surfaces */
}

/* ── System Dark (only if user hasn’t manually chosen) ─────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0b1220;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --accent: #1b2a3a;
    --shadow: none;
  }
}

header {
  margin-bottom: 0.5rem;
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: var(--accent);
  color: var(--line);
  display: flex;
  flex-direction: column;
}

header h1 {
  text-align: center;
  margin-bottom: 0.25rem;
}

header a {
  display: inline-block;
  transition:
    transform 0.2s ease,
    text-decoration 0.2s ease;
}

header a:hover {
  cursor: pointer;
  text-decoration: underline;
  transform: translateY(-1px);
}

.theme-toggle {
  position: absolute;
  top: 80px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background-color: inherit;
  color: var(--line);
  cursor: pointer;
  font-size: 14px;
  outline: none;
}

button {
  transition:
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

button:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

header nav {
  padding: 0.75rem;
}

header ul {
  display: flex;
  list-style: none;
  justify-content: start;
  gap: 0.5rem;
  padding: 0;
}

/* Row of search and select inputs */
#row {
  display: flex;
  justify-content: space-around;
  border-bottom: 1px solid var(--muted);
}

select {
  -webkit-appearance: none;
  appearance: none;
}

input[type="search"],
select,
input[type="search"]:focus,
select:focus {
  background-color: var(--bg);
  color: var(--text);
  width: 45%;
  /* height: 10%; */
  padding: 0.35rem;
  margin: 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--muted);
}

#countries-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  margin: 0.75rem;
}

.country-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border: 1px solid var(--muted);
  border-radius: var(--radius);
  padding: 0.5rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease;
}

.country-card:hover {
  transform: translateY(-2px);
}

.country-card img {
  display: block;
  margin: 0 auto;
}

.country-card figcaption {
  font-weight: 600;
  text-align: left;
  margin-top: 0.5rem;
}

p.muted,
input#favorite-check,
.country-card figure {
  margin: 0;
}

/* For Chrome, Edge, Safari */
details summary::-webkit-details-marker {
  margin-left: 0.5rem; /* adjust to push right */
}

/* For Firefox */
details summary::marker {
  margin-left: 0.5rem;
}

.muted {
  opacity: 0.9;
}

.bolder {
  font-weight: 600;
}

.borders {
  cursor: pointer;
  display: inline-block;
  width: fit-content;
  font-size: 0.65rem;
  text-align: center;
  border-radius: 999px;
  border: 1px solid var(--muted);
  opacity: 0.9;
  margin: 0.25rem;
}

button.borders:hover {
  opacity: 0.5;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid var(--muted);
  border-top-color: var(--accent);
  animation: spin 0.85s linear infinite;
}

/* Spinner animation */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--muted);
  backdrop-filter: blur(10px);
  padding: 12px 14px;
  border-radius: var(--radius);
  display: none;
  max-width: 360px;
  line-height: 1.35;
}

footer {
  margin: 0 auto;
  padding: 0.25rem;
  text-align: center;
  border-top: 1px solid var(--muted);
}

@media print {
  header,
  footer,
  #row {
    display: none !important;
  }

  /* even when dark mode is enabled, we want a light mode printing */
  :root[data-theme="dark"] {
    --bg: #f7f7fb;
    --text: #1f2937;
    --muted: #556072;
    --accent: #2f4a6d;
    --line: #e5e7eb;
    --radius: 16px;
    --shadow: none;
  }
  :root {
    --shadow: none; /* disable shodow in the light mode for better printing experience */
  }
}
