:root {
  --text-dark: hsl(141, 41%, 5%);
  --text-light: hsl(141, 41%, 95%);
  --bg-light: hsl(51, 100%, 5%);
  --bg-dark: #000;
  --water-400: hsl(210, 58%, 71%);
  --nature-200: hsl(159, 27%, 63%);
  --nature-300: hsl(159, 27%, 53%);
  --nature-400: hsl(159, 27%, 43%);
  --nature-500: hsl(159, 27%, 43%);
  --nature-600: hsl(159, 27%, 33%);
  --infra-200: hsl(0, 0%, 79%);
  --urban-300: hsl(345, 43%, 83%);
  --urban-400: hsl(345, 43%, 73%);
  --urban-500: hsl(345, 43%, 63%);
  --agriculture-300: hsl(51, 100%, 90%);
  --agriculture-350: hsl(51, 100%, 85%);
  --agriculture-400: hsl(51, 100%, 80%);
  --agriculture-450: hsl(51, 100%, 75%);
  --agriculture-500: hsl(51, 100%, 70%);
  --agriculture-600: hsl(51, 100%, 60%);
  --agriculture-650: hsl(51, 100%, 55%);
  --agriculture-700: hsl(51, 100%, 50%);
  --agriculture-750: hsl(51, 100%, 45%);
  --agriculture-775: hsl(51, 100%, 42%);
  --agriculture-800: hsl(51, 100%, 40%);
  --agriculture-825: hsl(51, 100%, 38%);
  --agriculture-850: hsl(51, 100%, 35%);
  --agriculture-900: hsl(51, 100%, 30%);
  --agriculture-920: hsl(51, 100%, 28%);
  --agriculture-950: hsl(51, 100%, 25%);
  --bare-200: hsl(0, 0%, 85%);
  --bare-300: hsl(0, 0%, 75%);
  --bare-400: hsl(0, 0%, 65%);
  --bare-500: hsl(0, 0%, 55%);
}

* {
  box-sizing: border-box;
}

html {
  background: linear-gradient(to bottom, var(--bg-dark), var(--bg-light));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-light);
}

html,
body {
  min-height: 100%;
  min-width: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  gap: 12px;
}

h1 {
  margin: 0;
  font-size: 32px;
  text-align: center;
}

h2 {
  margin: 0;
  font-size: 24px;
  text-align: center;
}

.homepage-header,
#countryHeader {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 900px;
  padding: 0 20px;
}

.toggle-button,
.back-button {
  background: var(--bg-dark);
  border: 2px solid rgba(255, 255, 255, 0.2);
  color: var(--text-light);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 120px;
}

.toggle-button:hover,
.back-button:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

.toggle-button:active,
.back-button:active {
  transform: scale(0.98);
}

.toggle-button:focus,
.back-button:focus {
  outline: none;
  border-color: var(--text-light);
}

/* Text variants for responsive design */
.back-text-short,
.toggle-text-short,
.title-short {
  display: none;
}

.back-text-full,
.toggle-text-full,
.title-full,
.title-prefix {
  display: inline;
}

svg {
  padding: 25px;
  max-width: 800px;
  margin: auto;
}

a {
  text-decoration: underline;
  color: var(--text-light);
}

.hexagon {
  stroke: var(--bg-light);
  stroke-width: 0.1px;
  cursor: pointer;
}

.hexagon.highlight {
  stroke-width: 1px;
}

.legend-item.dimmed {
  opacity: 0.4;
}

/* Homepage grid styles */
.homepage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  padding: 20px 40px;
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
}

.country-card {
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 320px;
}

.country-card:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.country-card-title {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  color: var(--text-light);
  margin-bottom: 8px;
  min-height: 28px;
}

.country-preview {
  width: 100%;
  height: auto;
  border-radius: 8px;
  aspect-ratio: 1 / 1;
}

.hexagon-preview {
  pointer-events: none;
}

/* Loading state */
.country-card.loading {
  cursor: default;
  pointer-events: none;
}

.country-card.loading:hover {
  transform: none;
  box-shadow: none;
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.loading-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 0%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.loading-text {
  font-size: 14px;
  text-align: center;
  color: var(--text-light);
  opacity: 0.6;
  margin-top: 8px;
}

/* Mobile responsive styles */
@media (max-width: 1200px) {
  .homepage-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    padding: 20px 30px;
  }
}

@media (max-width: 768px) {
  header {
    padding: 16px 12px;
  }

  .homepage-header,
  #countryHeader {
    padding: 0 12px;
  }

  h1 {
    font-size: 20px;
  }

  h2 {
    font-size: 18px;
  }

  #countryHeader {
    gap: 12px;
  }

  .homepage-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    padding: 16px 20px;
  }

  .country-card {
    min-height: 280px;
  }

  .country-card-title {
    font-size: 16px;
    min-height: 24px;
  }

  .toggle-button,
  .back-button {
    font-size: 14px;
    padding: 7px 12px;
    min-width: 80px;
  }

  .back-text-full,
  .toggle-text-full {
    display: none;
  }

  .back-text-short,
  .toggle-text-short {
    display: inline;
    font-size: 16px;
  }

  .back-button {
    min-width: 44px;
    padding: 7px 10px;
  }
}

@media (max-width: 480px) {
  header {
    padding: 14px 8px;
  }

  .homepage-header,
  #countryHeader {
    padding: 0 8px;
    gap: 8px;
  }

  h1 {
    font-size: 18px;
  }

  h2 {
    font-size: 16px;
  }

  .title-prefix {
    display: none;
  }

  .title-full {
    display: none;
  }

  .title-short {
    display: inline;
  }

  .homepage-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px 16px;
  }

  .country-card {
    min-height: 300px;
  }

  .country-card-title {
    font-size: 14px;
    min-height: 22px;
  }

  .toggle-button {
    font-size: 13px;
    padding: 6px 10px;
    min-width: 70px;
  }

  .back-button {
    font-size: 14px;
    padding: 6px 8px;
    min-width: 40px;
  }

  .back-text-short,
  .toggle-text-short {
    font-size: 15px;
  }
}

/* Rankings info section */
.rankings-info {
  max-width: 900px;
  margin: 32px auto 48px auto;
  padding: 0 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.ranking-badge {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 8px 12px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0.85;
}

.ranking-badge:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
  opacity: 1;
  transform: translateY(-1px);
}

.ranking-badge a {
  color: var(--text-light);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ranking-position-number {
  font-weight: bold;
  font-size: 18px;
  min-width: 28px;
  text-align: center;
}

.ranking-position-number.top-rank {
  color: hsl(51, 100%, 65%);
}

.ranking-position-number.bottom-rank {
  color: hsl(345, 43%, 68%);
}

.ranking-badge-content {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ranking-badge-category {
  font-size: 13px;
  font-weight: 500;
}

.ranking-badge-label {
  font-size: 10px;
  opacity: 0.6;
}

@media (max-width: 768px) {
  .rankings-info {
    padding: 0 12px;
    gap: 8px;
    margin: 24px auto 40px auto;
  }

  .ranking-badge {
    padding: 7px 10px;
  }

  .ranking-position-number {
    font-size: 16px;
    min-width: 24px;
  }

  .ranking-badge-category {
    font-size: 12px;
  }

  .ranking-badge-label {
    font-size: 9px;
  }
}

@media (max-width: 480px) {
  .rankings-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 20px auto 36px auto;
  }

  .ranking-badge {
    justify-content: center;
    padding: 6px 8px;
  }

  .ranking-position-number {
    font-size: 15px;
  }

  .ranking-badge-category {
    font-size: 11px;
  }
}

/* Page footer */
.page-footer {
  padding: 20px;
  margin-top: 40px;
  text-align: center;
}

.footer-content {
  font-size: 12px;
  color: var(--text-light);
  opacity: 0.7;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-content a {
  color: var(--text-light);
  text-decoration: underline;
  transition: opacity 0.2s;
}

.footer-content a:hover {
  opacity: 0.8;
}

@media (max-width: 768px) {
  .page-footer {
    padding: 16px;
    margin-top: 32px;
  }

  .footer-content {
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .page-footer {
    padding: 14px;
    margin-top: 24px;
  }

  .footer-content {
    font-size: 10px;
  }
}
