/* 
  SPACING SYSTEM (px)
  2 / 4 / 8 / 12 / 16 / 24 / 32 / 48 / 64 / 80 / 96 / 128

  FONT SIZE SYSTEM (px)
  10 / 12 / 14 / 16 / 18 / 20 / 24 / 30 / 36 / 44 / 52 / 62 / 74 / 86 / 98
*/

/* ============================================================
   ROOT VARIABLES
   ============================================================ */
:root {
  /* Light Mode */
  --color-bg: hsl(0, 0%, 98%);
  --color-elements: hsl(0, 100%, 100%);
  --color-text: hsl(200, 15%, 8%);
  --color-input: hsl(0, 0%, 52%);

  /* Typography */
  --ff-main: "Nunito Sans", sans-serif;
  --fw-300: 300;
  --fw-600: 600;
  --fw-800: 800;

  /* Layout */
  --max-width: 1200px;
  --section-padding-x: clamp(24px, 4vw, 80px);
}

/* 🌙 DARK MODE */
body.dark {
  --color-bg: hsl(207, 26%, 17%);
  --color-elements: hsl(209, 23%, 22%);
  --color-text: hsl(0, 0%, 100%);
  --color-input: hsl(0, 0%, 75%);
}

/* ============================================================
   RESET
   ============================================================ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

img {
  display: block;
  max-width: 100%;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
}

button:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 3px;
}

/* ============================================================
   BASE
   ============================================================ */
html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--ff-main);
  background-color: var(--color-bg);
  color: var(--color-text);
  transition:
    background 0.3s ease,
    color 0.3s ease;
  font-size: 14px;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--color-elements);
  color: var(--color-text);
  font-weight: var(--fw-600);
  font-size: 14px;
  padding: 10px 24px;
  border-radius: 5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: 0.2s ease;
}

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

.input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 5px;
  border: none;
  background: var(--color-elements);
  color: var(--color-text);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.input::placeholder {
  color: var(--color-input);
}

/* ============================================================
   NAVBAR
   ============================================================ */
.header {
  background: var(--color-elements);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px var(--section-padding-x);
}

.logo {
  font-weight: var(--fw-800);
  font-size: 14px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: var(--fw-600);
  color: var(--color-text);
}

/* ============================================================
   SEARCH SECTION
   ============================================================ */
.section__search {
  padding: 48px var(--section-padding-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.search {
  position: relative;
  width: 500px;
}

.search__icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-input);
}

.search input {
  padding-left: 45px;
}

/* REGION SELECT */
.region {
  position: relative;
  width: 200px;
}

.region__select {
  width: 100%;
  padding: 14px;
  border-radius: 5px;
  border: none;
  background: var(--color-elements);
  color: var(--color-text);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ============================================================
   COUNTRIES GRID
   ============================================================ */
.countries {
  padding: 20px var(--section-padding-x);
  max-width: var(--max-width);
  margin: auto;
}

.countries__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 40px;
}

/* CARD */
.country {
  background: var(--color-elements);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: 0.2s ease;
}

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

.country__flag {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.country__info {
  padding: 20px;
}

.country__name {
  font-weight: var(--fw-800);
  margin-bottom: 10px;
}

.country__info p {
  color: var(--color-input);
  margin-bottom: 5px;
}

.country__info strong {
  color: var(--color-text);
}

/* ============================================================
   BACK BUTTON
   ============================================================ */
.back__btn {
  padding: 40px var(--section-padding-x);
}

/* ============================================================
   DETAILS PAGE
   ============================================================ */
.details {
  padding: 20px var(--section-padding-x);
}

.details__container {
  display: flex;
  gap: 64px;
  align-items: center;
  flex-wrap: wrap;
}

/* LEFT */
.details__flag {
  flex: 1;
}

.details__flag img {
  width: 100%;
  border-radius: 6px;
}

/* RIGHT */
.details__info {
  flex: 1;
}

.details__title {
  font-size: 24px;
  font-weight: var(--fw-800);
  margin-bottom: 20px;
}

.details__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
}

.details__info p {
  margin-bottom: 8px;
  color: var(--color-input);
}

.details__info strong {
  color: var(--color-text);
}

/* ============================================================
   BORDER BUTTONS
   ============================================================ */
.borders {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.border-btn {
  padding: 6px 12px;
  border-radius: 4px;
  background: var(--color-elements);
  color: var(--color-text);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 49.125rem) {
  .section__search {
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
  }

  .search {
    width: 100%;
  }

  .region {
    width: 200px;
  }

  /* DETAILS PAGE */
  .details__container {
    flex-direction: column;
    gap: 40px;
  }

  .details__flag,
  .details__info {
    width: 100%;
  }

  .details__grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  /* NAV */
  .nav {
    padding: 10px 16px;
  }

  .logo {
    font-size: 10px;
  }
}

@media (max-width: 480px) {
  /* SEARCH */
  .section__search {
    padding: 24px 16px;
  }

  /* COUNTRIES GRID */
  .countries {
    padding: 20px 16px;
  }

  .countries__grid {
    gap: 24px;
  }

  /* CARD */
  .country__info {
    padding: 16px;
  }

  /* DETAILS */
  .details {
    padding: 20px 16px;
  }

  .details__title {
    font-size: 20px;
  }

  /* BORDER BUTTONS */
  .border-btn {
    font-size: 11px;
    padding: 5px 10px;
  }
}
