/* ==========================================================================
   Karuta Dyes Tool
   ========================================================================== */

.dye-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, 150px);
  gap: 16px;
  justify-content: center;
}

.dye-card {
  position: relative;
  width: 150px;
  aspect-ratio: 1 / 1;

  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(0, 0, 0, .35);

  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}

.dye-card:hover,
.dye-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, .42);
}

.dye-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.dye-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, var(--dye-color), rgba(0, 0, 0, .62));
  pointer-events: none;
  z-index: 0;
}

.dye-card img {
  width: 100%;
  display: block;
  position: relative;
  z-index: 1;
}

.favorite-toggle {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  width: 28px;
  height: 28px;
  min-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 8px;
  background: rgba(10, 10, 10, .72);
  color: white;
  font-size: .88rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity .14s ease, transform .14s ease, background .18s ease;
}

.favorite-toggle:hover {
  background: rgba(10, 10, 10, .96);
}

.dye-card:hover .favorite-toggle,
.dye-card.favorite-flash .favorite-toggle,
.favorite-toggle:focus-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.favorite-toggle.active {
  color: #f37aa5;
}

.dye-card.favorite-flash .favorite-toggle {
  color: #f37aa5;
}

.dye-card.favorite-flash .favorite-toggle i {
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
}

/* Interaction: Touch / coarse pointer */
@media (hover: none), (pointer: coarse) {
  .dye-card:hover .favorite-toggle {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
  }

  .dye-card.favorite-flash .favorite-toggle {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }
}

.favorites-filter[hidden] {
  display: none;
}

.name,
.code-row,
.owner,
.mystic-badge {
  position: absolute;
  z-index: 2;
  text-shadow: 0 0 3px black, 0 0 6px black;
}

.name {
  bottom: 34px;
  left: 8px;
  max-width: 66%;
  font-size: clamp(14px, 7%, 14px);
  font-weight: 700;
  line-height: 1.15;
  word-break: break-word;
}

.code-row {
  bottom: 18px;
  left: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: 66%;
}

.code {
  font-size: clamp(11px, 5.5%, 11px);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.charge-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  border: 1.5px solid white;
  flex-shrink: 0;
  box-shadow: 0 0 4px rgba(0, 0, 0, .7);
}

.charge-dot.filled {
  background: white;
}

.owner {
  bottom: 4px;
  left: 8px;
  font-size: clamp(10px, 5%, 10px);
  color: #ddd;
}

.mystic-badge {
  top: 8px;
  left: 8px;
  background: #a855f7;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 7px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}

.copy-badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 4;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: .72rem;
  font-weight: 800;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .16s ease, transform .16s ease;
  pointer-events: none;
  text-shadow: none;
}

.dye-card.copied .copy-badge {
  opacity: 1;
  transform: translateY(0);
}

/* Viewport: narrow shared layout */
@media (max-width: 768px) {
  .container {
    padding-top: 24px;
  }

  .logo {
    width: 64px;
  }

  .home-container {
    padding-top: 24px;
  }

  .home-logo {
    width: 160px;
  }

  h1 {
    font-size: 1.9rem;
  }

  .home-page h1 {
    font-size: 3rem;
  }

  .site-title-button h1,
  .site-home h1 {
    margin-bottom: 14px;
    margin-left: -5px;
  }

  .navbar {
    gap: 14px;
    margin-bottom: 40px;
  }

  .nav-link {
    font-size: 1rem;
    padding: 12px 18px;
  }

  h2 {
    font-size: 1.7rem;
  }

  .featured img {
    height: 220px;
  }

  .social-btn {
    width: 68px;
    height: 68px;
    font-size: 1.8rem;
  }

  .review-shell {
    grid-template-columns: 1fr;
  }

  .review-sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    border-right: 0;
    border-bottom: 1px solid rgba(179, 18, 75, .32);
  }

  .review-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .review-frame-panel,
  .review-frame-panel iframe {
    min-height: 70vh;
    height: 70vh;
  }

  .filter-pair {
    flex-wrap: wrap;
  }

  .dye-grid {
    grid-template-columns: repeat(auto-fit, 136px);
    justify-content: center;
  }

  .dye-card {
    width: 136px;
  }
}

@media (max-width: 320px) {
  .dye-grid {
    grid-template-columns: 150px;
  }

  .dye-card {
    width: 150px;
  }
}

.cards-container {
  padding-left: clamp(8px, 2vw, 32px);
  padding-right: clamp(8px, 2vw, 32px);
}
