/* ===========================================================================
   EkiAnime — web stylesheet
   Theme: dark neon (magenta primary + cyan secondary), derived from the
   anidb.app layout but re-skinned for EkiAnime.
   Tailwind (Play CDN) provides the utility classes; this file defines the
   component layer + base reset that Tailwind does not.
   =========================================================================== */

:root {
  --accent: #ff00ff;
  --accent-hover: #ff4dff;
  --accent-soft: #ff00ff22;
  --cyan: #00ffff;
  --bg: #0f0f0f;
  --card: #1a1a1a;
  --elevated: #252525;
  --bd: #2e2e2e;
  --faint: #a0a0a0;
  --muted: #666666;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

/* Hide Alpine `x-cloak` elements from the very first paint (before Alpine's
   own style injection), preventing a flash of dropdowns/menus. */
[x-cloak] {
  display: none !important;
}

body {
  padding-top: 64px;
  background: var(--bg);
  color: #fafafa;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

.brand-lockup { gap: 0.55rem; }
.register-popup {
  position: relative;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.03);
}
.brand-alpha {
  align-self: center;
  text-align: center;
  color: #f4f4f4;
  border: 1px solid #555;
  border-radius: 0.35rem;
  padding: 0.18rem 0.38rem;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.discord-join-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 1rem;
  border-radius: 0.65rem;
  background: #fff;
  color: #1d1d1d;
  font-size: 0.875rem;
  font-weight: 800;
  transition: background 0.2s ease, color 0.2s ease;
  white-space: nowrap;
}
.discord-join-btn svg { width: 1.15rem; height: 1.15rem; }
.discord-join-btn:hover { background: #5865f2; color: #fff; }
.join-discord { border-radius: 1rem; }
@media (max-width: 420px) {
  .brand-logo { max-width: 112px; }
  .brand-alpha { font-size: 0.55rem; padding: 0.15rem 0.3rem; }
}

/* Nicer, on-brand scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: #3a3a3a transparent;
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-thumb {
  background: #3a3a3a;
  border-radius: 8px;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--accent);
  color: #fff;
  border-radius: 0.75rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.625rem 1rem;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 20px -6px rgba(255, 0, 255, 0.45);
  white-space: nowrap;
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 10px 26px -6px rgba(255, 0, 255, 0.6);
}
.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--elevated);
  color: #fafafa;
  border: 1px solid var(--bd);
  border-radius: 0.75rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.625rem 1rem;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  white-space: nowrap;
}
.btn-secondary:hover {
  background: #2c2c2c;
  border-color: #3a3a3a;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: transparent;
  color: #ff4d4d;
  border: 1px solid #ff4d4d;
  border-radius: 0.75rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.625rem 1rem;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-logout:hover {
  background: rgba(255, 77, 77, 0.12);
}

/* ---------------------------------------------------------------------------
   Badges
   --------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 0.375rem;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.badge-accent,
span.badge-accent {
  background: var(--accent) !important;
  color: #fff !important;
}
.badge-green,
span.badge-green {
  background: #16a34a !important;
  color: #fff !important;
}
.badge-gray,
span.badge-gray {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #d4d4d4 !important;
}

/* ---------------------------------------------------------------------------
   Filter chips (genre/theme pills)
   --------------------------------------------------------------------------- */
.filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border-radius: 0.5rem;
  background: var(--elevated);
  border: 1px solid var(--bd);
  color: var(--faint);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.filter-chip:hover {
  color: #fff;
  border-color: var(--accent);
}

/* ---------------------------------------------------------------------------
   Inputs
   --------------------------------------------------------------------------- */
.inp {
  width: 100%;
  background: var(--elevated);
  border: 1px solid var(--bd);
  color: #fff;
  border-radius: 0.75rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.inp::placeholder {
  color: var(--muted);
}
.inp:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 0, 255, 0.15);
}
select.inp {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23a0a0a0' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  background-size: 1rem;
  padding-right: 2rem;
}

/* ---------------------------------------------------------------------------
   Custom themed dropdown (replaces native <select> in the browse filters)
   --------------------------------------------------------------------------- */
.dd {
  position: relative;
}
.dd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--elevated);
  border: 1px solid var(--bd);
  color: #fff;
  border-radius: 0.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  min-width: 120px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}
.dd-btn:hover {
  border-color: var(--accent);
}
.dd-btn .dd-chevron {
  transition: transform 0.15s ease;
  color: var(--muted);
}
.dd.open .dd-chevron {
  transform: rotate(180deg);
}
.dd-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 0.375rem);
  z-index: 30;
  min-width: 100%;
  max-height: 16rem;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 0.75rem;
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.7);
  padding: 0.25rem;
  display: none;
}
.dd-menu.dd-grid {
  width: 480px;
  max-width: calc(100vw - 24px);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.25rem;
  padding: 0.5rem;
}
@media (max-width: 640px) {
  .dd-menu.dd-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); width: 340px; max-width: calc(100vw - 24px); }
}
.dd.open .dd-menu {
  display: block;
}
.dd.open .dd-menu.dd-grid {
  display: grid;
}
.dd-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border-radius: 0.5rem;
  color: var(--faint);
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dd-option:hover {
  color: #fff;
  background: var(--elevated);
}
.dd-option.selected {
  color: var(--accent);
}

/* ---------------------------------------------------------------------------
   Anime card grid + poster card
   --------------------------------------------------------------------------- */
.anime-grid {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem 1rem;
}
@media (min-width: 480px) {
  .anime-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (min-width: 768px) {
  .anime-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
@media (min-width: 1024px) {
  .anime-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
@media (min-width: 1280px) {
  .anime-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.anime-card {
  width: 100%;
  min-width: 0;
}

/* Episode picker grid inside the player column */
.episode-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.5rem;
}
.ep-btn {
  padding: 0.5rem 0.15rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
/* Bigger episode buttons on phones */
@media (max-width: 480px) {
  .episode-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
  }
  .ep-btn {
    font-size: 0.9375rem;
    padding: 0.65rem 0.15rem;
  }
}

/* ---------------------------------------------------------------------------
   Navbar blur
   --------------------------------------------------------------------------- */
.navbar-blur {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Line clamp fallback (Tailwind's line-clamp needs the plugin; supply it) */
.line-clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Skeleton shimmer for loading states */
.skeleton {
  background: linear-gradient(90deg, #1f1f1f 25%, #2a2a2a 50%, #1f1f1f 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 0.75rem;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Carousel / row arrows */
.carousel-arrow {
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background: var(--elevated);
  border: 1px solid var(--bd);
  color: var(--faint);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
  cursor: pointer;
}
.carousel-arrow:hover {
  color: #fff;
  border-color: var(--accent);
}
.carousel-arrow:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.home-row-rail {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  scroll-behavior: smooth;
}
.home-row-rail::-webkit-scrollbar { display: none; }
.home-row-track {
  display: flex;
  gap: 1rem;
  width: max-content !important;
}
.home-row-track > .swiper-slide {
  width: 150px !important;
  flex: 0 0 150px;
}

/* Hero swiper pagination on-brand */
.hero-swiper .swiper-pagination-bullet {
  background: rgba(255, 255, 255, 0.45);
  opacity: 1;
  width: 8px;
  height: 8px;
}
.hero-swiper .swiper-pagination-bullet-active {
  background: var(--accent);
  width: 22px;
  border-radius: 4px;
}

/* ---------------------------------------------------------------------------
   Search results loading dots (three-dot jump while results load)
   --------------------------------------------------------------------------- */
.search-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 1rem;
}
.search-loading span {
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: var(--accent);
  animation: search-bounce 1s infinite ease-in-out;
}
.search-loading span:nth-child(2) { animation-delay: 0.15s; }
.search-loading span:nth-child(3) { animation-delay: 0.3s; }
@keyframes search-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------------------------------------------------------------------------
   Watched episode buttons (browser-local watch history — no account needed)
   --------------------------------------------------------------------------- */
.ep-btn.ep-watched {
  background: var(--elevated);
  color: var(--muted);
  border-color: var(--bd);
  opacity: 0.5;
}
.ep-btn.ep-watched:hover {
  opacity: 0.75;
  color: #fff;
  border-color: var(--accent);
}

/* ===========================================================================
   Profile / library / settings — shared components
   =========================================================================== */
.avatar-ring {
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 24px rgba(255, 0, 255, 0.25);
}
.eki-nav-avatar {
  display: block;
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 2.25rem;
  border-radius: 50%;
  overflow: hidden;
  object-fit: cover;
}
.avatar-edit-hint {
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.15s;
  cursor: pointer;
  letter-spacing: 0.02em;
}
.avatar-wrap:hover .avatar-edit-hint { opacity: 1; }
.progress-track {
  height: 6px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  transition: width 0.3s ease;
}
.lib-tab {
  padding: 0.5rem 0.9rem;
  border-radius: 0.6rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--faint);
  border: 1px solid var(--bd);
  background: var(--elevated);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}
.lib-tab:hover { color: #fff; border-color: var(--accent); }
.lib-tab.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 6px 18px -6px rgba(255, 0, 255, 0.5);
}
.stat-tile {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 0.9rem;
  padding: 0.9rem 1rem;
}
.stat-tile .stat-value { font-size: 1.35rem; font-weight: 800; line-height: 1; color: #fff; }
.stat-tile .stat-key {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.3rem;
}
.rank-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(255, 0, 255, 0.35);
}
.profile-settings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  color: var(--faint);
  border: 1px solid var(--bd);
  border-radius: 0.65rem;
  background: var(--elevated);
  transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.15s;
}
.profile-settings-btn:hover {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: rotate(18deg);
}
.profile-settings-btn svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

/* Toggle switch */
.switch {
  position: relative;
  display: inline-flex;
  width: 2.6rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--bd);
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(1.5rem - 8px);
  height: calc(1.5rem - 8px);
  border-radius: 9999px;
  background: #fff;
  transition: transform 0.2s;
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(1.1rem); }

/* Segmented control */
.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 0.7rem;
  background: var(--elevated);
  border: 1px solid var(--bd);
  gap: 2px;
}
.segmented button {
  padding: 0.4rem 0.8rem;
  border-radius: 0.55rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--faint);
  transition: color 0.15s, background 0.15s;
}
.segmented button.on { color: #fff; background: var(--accent); }

/* Library remove control — white circle with black X. Hidden on desktop until
   hover, always visible on touch devices. */
.lib-remove {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 10;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 9999px;
  background: #ffffff;
  color: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.group:hover .lib-remove { opacity: 1; }
.lib-remove:hover { transform: scale(1.08); }
@media (max-width: 767px) {
  .lib-remove { opacity: 1; }
}

/* Share buttons */
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border-radius: 0.75rem;
  background: var(--elevated);
  border: 1px solid var(--bd);
  color: var(--faint);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}
.share-btn:hover { color: #fff; border-color: var(--accent); }
.share-btn svg { width: 1.1rem; height: 1.1rem; flex-shrink: 0; }
.share-btn img { width: 1.1rem; height: 1.1rem; flex-shrink: 0; object-fit: contain; }
@media (max-width: 639px) {
  .share-label { display: none; }
  .share-btn { padding: 0.6rem; }
}
