/* Base styles extracted from index.html. Design tokens are in variables.css */
html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

header {
  background-color: #000;
  padding: 1rem;
  text-align: center;
}

header h1 {
  font-size: 2rem;
  font-weight: bold;
  color: var(--primary-color);
  margin: 0;
  text-transform: uppercase;
}

/* iOS-like large title */
h1.large-title {
  font-weight: 700;
  font-size: clamp(24px, 3vw, 34px);
  margin: 16px 0;
  text-transform: none;
  letter-spacing: normal;
}
body.is-scrolled h1.large-title {
  font-size: clamp(18px, 2vw, 22px);
  margin: 8px 0;
  transition: font-size .2s ease, margin .2s ease;
}

/* Anchor offset for sticky nav */
.category-title {
  scroll-margin-top: 72px;
}

nav {
  background-color: var(--card-bg-color);
  padding: 0.5rem;
  position: sticky;
  top: 0;
  z-index: 1000;
}

nav ul {
  list-style-type: none;
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
}

nav li {
  margin: 0.3rem;
}

nav a {
  color: var(--text-color);
  text-decoration: none;
  font-size: 1rem;
  font-weight: bold;
  padding: 0.5rem 0.8rem;
  border-radius: 1.25rem;
  transition: background-color 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), color 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}

nav a:hover,
nav a.active {
  background-color: var(--primary-color);
  color: #000;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.category-title {
  font-size: clamp(20px, 2.4vw, 24px);
  font-weight: bold;
  margin: 2rem 0 1rem;
  color: var(--primary-color);
  border-left: 4px solid var(--primary-color);
  padding-left: 0.6rem;
  text-transform: none;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(184px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.link-card {
  background-color: var(--card-bg-color);
  border-radius: 8px;
  padding: 1.2rem 0.8rem;
  text-align: center;
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), background-color 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  position: relative;
  overflow: hidden;
}

.link-card a {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  text-decoration: none;
  z-index: 12;
  display: block;
  border-radius: inherit;
}

.link-card:hover {
  background-color: #1f1f1f;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.link-card:active {
  background-color: #1c1c1c;
  transform: translateY(-1px);
}

.link-card i {
  font-size: 1.8rem;
  margin-bottom: 0.7rem;
  color: var(--ios-tint);
  transition: transform 0.2s ease;
  position: relative;
  z-index: 11;
}

.link-card:hover i {
  transform: scale(1.1);
}

.link-card h3 {
  font-size: 0.9rem;
  margin: 0;
  color: var(--text-color);
  line-height: 1.3;
  font-weight: 500;
  max-width: 100%;
  height: 2.6em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
  white-space: normal;
  padding: 0 0.3rem;
  position: relative;
  z-index: 11;
}

footer {
  background-color: #000;
  color: #ccc;
  text-align: center;
  padding: 1rem;
  font-size: 0.75rem;
}

footer nav {
  margin-top: 0.6rem;
  background-color: transparent;
}

footer nav a {
  color: #ccc;
  margin: 0 0.6rem;
  font-size: 0.75rem;
}

@media (max-width: 1200px) {
  main {
    padding: 1rem;
    max-width: 95%;
  }

  .link-grid {
    grid-template-columns: repeat(auto-fill, minmax(184px, 1fr));
    gap: 1rem;
  }
}

@media (max-width: 768px) {
  html {
    font-size: 15px;
  }

  main {
    padding: 0.8rem;
  }

  .link-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.8rem;
  }

  nav {
    padding: 0.4rem;
  }

  nav a {
    padding: 0.4rem 0.7rem;
    font-size: 0.95rem;
  }

  .category-title {
    font-size: 1.4rem;
    margin: 1.8rem 0 1rem;
  }

  .link-card {
    padding: 1rem 0.6rem;
    min-height: 80px;
  }

  .link-card i {
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
  }

  .link-card h3 {
    font-size: 0.8rem;
    height: 2.4em;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  main {
    padding: 0.6rem;
  }

  .link-grid {
    grid-template-columns: repeat(auto-fill, minmax(144px, 1fr));
    gap: 0.7rem;
  }

  header h1 {
    font-size: 1.6rem;
  }

  nav li {
    margin: 0.25rem;
  }

  nav a {
    padding: 0.35rem 0.6rem;
    font-size: 0.9rem;
  }

  .category-title {
    font-size: 1.4rem;
    margin: 1.8rem 0 1rem;
  }

  .link-card {
    padding: 0.8rem 0.5rem;
    min-height: 70px;
  }

  .link-card i {
    font-size: 1.4rem;
    margin-bottom: 0.4rem;
  }

  .link-card h3 {
    font-size: 0.75rem;
    padding: 0 0.2rem;
    height: 2.4em;
  }

  footer {
    padding: 0.8rem;
  }

  footer nav a {
    margin: 0 0.4rem;
    font-size: 0.7rem;
  }
}

@media (max-width: 360px) {
  html {
    font-size: 13px;
  }

  .link-grid {
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
    gap: 0.6rem;
  }

  header h1 {
    font-size: 1.4rem;
  }

  .link-card {
    padding: 0.8rem 0.5rem;
    min-height: 70px;
  }

  .link-card i {
    font-size: 1.3rem;
    margin-bottom: 0.3rem;
  }

  .link-card h3 {
    font-size: 0.7rem;
    padding: 0 0.15rem;
    height: 2.2em;
  }
}