/* --- Reset & base --- */
*, *::before, *::after { box-sizing: border-box; }
html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
  /* Custom scrollbar (viewport) */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
html::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
html::-webkit-scrollbar-track {
  background: transparent;
}
html::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
html::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
  background-clip: padding-box;
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh; /* full viewport on mobile (ignores browser chrome) */
  height: 100%;
  display: flex;
  flex-direction: column;
  font-family: "Outfit", system-ui, sans-serif;
  font-weight: 400;
  background: #08080a;
  color: #f4f4f5;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0.06);
}

.skip-link {
  position: absolute;
  top: -3rem;
  left: 1rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: #08080a;
  background: #f4f4f5;
  border-radius: 6px;
  text-decoration: none;
  z-index: 1001;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 1rem;
  outline: 2px solid #81a1c1;
  outline-offset: 2px;
}

/* --- Mobile: base spacing & safe area --- */
@media (max-width: 599px) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

/* --- Header --- */
.header {
  flex-shrink: 0;
  padding: 4rem 1.5rem 2rem;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}
@media (max-width: 599px) {
  .header {
    padding: 2.5rem 1rem 1.5rem;
  }
  .header__title {
    font-size: 1.5rem;
  }
  .header__tagline {
    font-size: 0.8125rem;
  }
}
.header__title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: #f4f4f5;
  background: linear-gradient(135deg, #f4f4f5 0%, #a1a1aa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.header__tagline {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  font-weight: 300;
  color: #71717a;
}

/* --- Search --- */
.search-wrap {
  position: relative;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem 1.25rem;
}
.search-icon {
  position: absolute;
  left: 1.55rem;
  /* align with input center: padding-top + half line-height (0.875rem × 1.5) */
  top: calc(0.625rem + 0.875rem * 0.75);
  transform: translateY(-50%);
  color: #52525b;
  pointer-events: none;
}
.search-icon svg {
  display: block;
}
.search-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.search-input {
  width: 100%;
  max-width: 320px;
  padding: 0.625rem 0.875rem 0.625rem 3.3rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 400;
  color: #f4f4f5;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.search-input::placeholder {
  color: #52525b;
}
.search-input:hover {
  background: rgba(0, 0, 0, 0.45);
  border-color: rgba(255, 255, 255, 0.07);
}
.search-input:focus {
  outline: none;
  border-color: rgba(129, 161, 193, 0.5);
  box-shadow: 0 0 0 3px rgba(129, 161, 193, 0.15);
}
.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}
@media (max-width: 599px) {
  .search-wrap {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .search-input {
    max-width: none;
    min-height: 44px;
    padding: 0.75rem 0.875rem 0.75rem 3.4rem;
    font-size: 16px; /* prevents iOS zoom on focus */
  }
  .search-icon {
    left: 1.65rem;
    /* match input center: 0.75rem padding + half line-height (16px × 1.5) */
    top: calc(0.75rem + 1rem * 0.75);
    transform: translateY(-50%);
  }
}
.search-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: #3f3f46;
}
.no-results {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 400;
  color: #71717a;
  text-align: center;
}
.no-results[hidden] {
  display: none !important;
}

/* --- Main & grid --- */
.main {
  flex: 1;
  padding: 0 1.5rem 4rem;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}
@media (max-width: 599px) {
  .main {
    padding: 0 1rem 3rem;
  }
}
.sites-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 0;
}
@media (min-width: 520px) {
  .sites-grid { grid-template-columns: repeat(2, 1fr); gap: 0.625rem; }
}
@media (min-width: 800px) {
  .sites-grid { grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
}
@media (max-width: 599px) {
  .no-results {
    padding: 1.5rem 1rem;
  }
}

/* --- Cards --- */
.site-card {
  display: block;
  width: 100%;
  padding: 1.125rem 1.25rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  animation: cardIn 0.4s ease backwards;
  animation-delay: var(--card-delay, 0ms);
}
.site-card:hover,
.site-card:focus {
  background: rgba(0, 0, 0, 0.5);
  border-color: rgba(255, 255, 255, 0.07);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  outline: none;
}
.site-card:hover {
  transform: translateY(-2px);
}
.site-card:focus-visible {
  background: rgba(0, 0, 0, 0.45);
  border-color: rgba(129, 161, 193, 0.35);
  box-shadow: 0 0 0 2px rgba(129, 161, 193, 0.2);
}
@media (max-width: 599px) {
  .site-card {
    min-height: 44px;
    padding: 1rem 1rem;
  }
  .site-card__name {
    font-size: 0.9375rem;
  }
}
.site-card__name {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 500;
  color: #e4e4e7;
}
.site-card__url {
  display: block;
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  font-weight: 300;
  color: #52525b;
}
.site-card__desc {
  display: block;
  margin: 0.4rem 0 0;
  font-size: 0.8125rem;
  font-weight: 300;
  color: #3f3f46;
  line-height: 1.4;
}
@media (prefers-reduced-motion: reduce) {
  .site-card {
    animation: none;
  }
  .site-card:hover {
    transform: none;
  }
}
@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Footer --- */
.footer {
  flex-shrink: 0;
  padding: 2.5rem 1.5rem 3rem;
  padding-bottom: calc(3rem + env(safe-area-inset-bottom));
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.25rem;
}
@media (max-width: 599px) {
  .footer {
    padding: 2rem 1rem;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    gap: 1rem;
  }
}
.footer__link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 44px;
  min-width: 44px;
  padding: 0.25rem;
  justify-content: center;
  color: #71717a;
  text-decoration: none;
  transition: color 0.15s ease;
}
.footer__link:hover {
  color: #a1a1aa;
}
.footer__link:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.2);
  outline-offset: 3px;
}
.footer__icon {
  flex-shrink: 0;
}
.footer__discord-handle {
  font-size: 0.8125rem;
  font-weight: 400;
}

/* --- Modal --- */
.modal {
  position: fixed;
  inset: 0;
  inset: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s;
}
.modal[hidden] {
  display: none !important;
}
.modal.modal--open {
  opacity: 1;
  visibility: visible;
}
.modal.modal--open[hidden] {
  display: flex !important;
}

.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 8, 10, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
}

.modal__panel {
  position: relative;
  width: 100%;
  max-width: 880px;
  max-height: 90vh;
  background: #0c0c0e;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  transform: scale(0.98);
  transition: transform 0.2s ease;
}
@media (max-width: 599px) {
  .modal {
    padding: 0;
    align-items: stretch;
  }
  .modal__panel {
    max-height: none;
    height: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .modal.modal--open .modal__panel {
    transform: none;
  }
}
@media (min-width: 600px) {
  .modal.modal--open .modal__panel {
    transform: scale(1);
  }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.875rem 1.125rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
@media (max-width: 599px) {
  .modal__header {
    padding: 1rem;
    flex-wrap: wrap;
  }
  .modal__title {
    order: 3;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.8125rem;
  }
  .modal__actions {
    flex: 1;
    justify-content: flex-end;
    gap: 0.35rem;
  }
  .modal__btn {
    min-height: 44px;
    padding: 0.5rem 0.75rem;
  }
  .modal__close {
    min-width: 44px;
    min-height: 44px;
  }
}
.modal__title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 400;
  color: #a1a1aa;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.modal__btn {
  padding: 0.4rem 0.65rem;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 400;
  color: #a1a1aa;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.modal__btn:hover {
  color: #f4f4f5;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}
.modal__btn:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.2);
  outline-offset: 2px;
}
.modal__btn--copy.modal__btn--copied {
  color: #86efac;
  border-color: rgba(134, 239, 172, 0.3);
}
.modal__open-link {
  font-size: 0.8125rem;
  font-weight: 400;
  color: #81a1c1;
  text-decoration: none;
}
.modal__open-link:hover {
  color: #94b8d9;
}
.modal__loading {
  position: absolute;
  inset: 0 1.125rem 1.125rem 1.125rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: #08080a;
  border-radius: 6px;
  z-index: 1;
  transition: opacity 0.2s ease, visibility 0.2s;
}
.modal__loading[aria-hidden="true"] {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.modal__spinner {
  width: 28px;
  height: 28px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-top-color: #81a1c1;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.modal__loading-text {
  font-size: 0.8125rem;
  font-weight: 300;
  color: #71717a;
}
@media (prefers-reduced-motion: reduce) {
  .modal__spinner {
    animation: none;
    border-top-color: #81a1c1;
  }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.modal__close {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: #a1a1aa;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.modal__close:hover {
  color: #f4f4f5;
  background: rgba(255, 255, 255, 0.06);
}
.modal__close:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.15);
  outline-offset: 2px;
}

.modal__frame-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 0 1.125rem 1.125rem;
}
.modal__frame {
  width: 100%;
  height: 60vh;
  min-height: 300px;
  border: none;
  border-radius: 6px;
  background: #08080a;
}
@media (max-width: 599px) {
  .modal__frame-wrap {
    padding: 0 0.75rem 0.75rem;
  }
  .modal__frame {
    height: 65vh;
    min-height: 240px;
    border-radius: 6px;
  }
  .modal__loading {
    inset: 0 0.75rem 0.75rem 0.75rem;
  }
}
.modal__frame.modal__frame--loaded {
  opacity: 1;
}
.modal__frame:not(.modal__frame--loaded) {
  opacity: 0;
  transition: opacity 0.2s ease;
}
