/* Custom styles for GRIMdata website (grimdata.org) */

:root {
  --rainbow-gradient: linear-gradient(90deg,
    #e40303 0%,
    #ff8c00 16.67%,
    #ffed00 33.33%,
    #008026 50%,
    #24408e 66.67%,
    #732982 83.33%
  );
}

/* Custom header accent */
.md-header {
  position: relative;
}

.md-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--rainbow-gradient);
}

/* Card grid styling - target only ul/li elements, not all children */
.md-typeset .grid.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
  width: 100%;
  box-sizing: border-box;
  list-style: none;
  padding: 0;
}

/* Target only list items that are actual cards */
.md-typeset .grid.cards > li {
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 0.2rem;
  padding: 1.5rem;
  transition: all 0.2s;
  box-sizing: border-box;
  overflow: hidden;
  margin: 0;
}

.md-typeset .grid.cards > li:hover {
  border-color: var(--md-accent-fg-color);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}

/* Prevent grid cards from breaking layout */
.md-content .grid.cards {
  max-width: 100%;
  overflow-x: hidden;
}

/* Hide any empty list items */
.md-typeset .grid.cards > li:empty {
  display: none;
}

/* Ensure all cards have equal height in a row */
.md-typeset .grid.cards {
  align-items: stretch;
}

.md-typeset .grid.cards > li {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Remove any pseudo-elements that might create ghost boxes */
.md-typeset .grid.cards::before,
.md-typeset .grid.cards::after {
  display: none;
}

/* Fix icon alignment */
.md-typeset .grid.cards .twemoji,
.md-typeset .grid.cards .lg,
.md-typeset .grid.cards .middle {
  display: inline-block;
  vertical-align: middle;
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 0.25rem;
  text-transform: uppercase;
}

.badge-success {
  background: #4caf50;
  color: white;
}

.badge-info {
  background: #2196f3;
  color: white;
}

.badge-warning {
  background: #ff9800;
  color: white;
}

/* Scorecard indicator cards */
.indicator-card {
  background: var(--md-code-bg-color);
  border-left: 4px solid var(--md-accent-fg-color);
  padding: 1rem;
  margin: 1rem 0;
}

.indicator-card h3 {
  margin-top: 0;
  color: var(--md-accent-fg-color);
}

/* Rainbow divider */
.rainbow-divider {
  height: 4px;
  background: var(--rainbow-gradient);
  margin: 2rem 0;
  border: none;
}

/* Country cards for scorecard */
.country-card {
  background: var(--md-default-bg-color);
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 4px;
  padding: 1rem;
  margin: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.country-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transform: translateY(-1px);
}

.country-name {
  font-weight: bold;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.country-region {
  color: var(--md-default-fg-color--light);
  font-size: 0.9rem;
}

/* Stats display */
.stat-box {
  text-align: center;
  padding: 1.5rem;
  background: var(--md-code-bg-color);
  border-radius: 4px;
  margin: 1rem 0;
}

.stat-number {
  font-size: 2.5rem;
  font-weight: bold;
  color: var(--md-primary-fg-color);
  display: block;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--md-default-fg-color--light);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Code block enhancements */
.highlight {
  border-radius: 4px;
}

/* Button variations */
.md-button--rainbow {
  background: var(--rainbow-gradient);
  color: white !important;
  border: none;
}

.md-button--rainbow:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* Table styling */
.md-typeset table:not([class]) {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 1rem 0;
}

.md-typeset table:not([class]) th {
  background: var(--md-code-bg-color);
  font-weight: 600;
}

.md-typeset table:not([class]) td,
.md-typeset table:not([class]) th {
  padding: 0.75rem;
  border: 1px solid var(--md-default-fg-color--lightest);
  white-space: nowrap;
}

.md-typeset table:not([class]) tr:hover {
  background: var(--md-code-bg-color);
}

/* Wrapper for table scrolling */
.md-typeset__table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Breadcrumb navigation styling */
.md-path {
  color: var(--md-default-fg-color--light);
  font-size: 0.7rem;
  padding: 0.5rem 0;
}

.md-path a {
  color: var(--md-accent-fg-color);
  text-decoration: none;
}

.md-path a:hover {
  text-decoration: underline;
}

/* Home link in logo */
.md-header__button.md-logo {
  cursor: pointer;
}

.md-header__button.md-logo:hover {
  opacity: 0.8;
}

/* Navigation footer improvements */
.md-footer__link {
  padding: 1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .grid.cards {
    grid-template-columns: 1fr;
  }

  .stat-number {
    font-size: 2rem;
  }

  .md-typeset table:not([class]) td,
  .md-typeset table:not([class]) th {
    white-space: normal;
  }
}

/* Loading spinner for future dynamic content */
.spinner {
  border: 4px solid var(--md-default-fg-color--lightest);
  border-top: 4px solid var(--md-primary-fg-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 2rem auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Accessibility improvements */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}

/* Print styles */
@media print {
  .md-header,
  .md-sidebar,
  .md-footer {
    display: none;
  }

  .md-content {
    max-width: 100%;
  }
}
