/* =============================================================
   ANIWEEK — cards.css  (anime episode cards + modal)
   ============================================================= */

/* ── ANIME CARD ──────────────────────────────────────────────── */
.anime-card {
  position: relative;
  border-radius: var(--r-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--base) var(--ease),
              border-color var(--base) var(--ease),
              box-shadow var(--base) var(--ease);
}
.anime-card:hover {
  transform: translateY(-3px) scale(1.01);
  border-color: var(--border-hi);
  box-shadow: 0 8px 30px rgba(0,0,0,.5), 0 0 0 1px var(--border-hi);
}
.anime-card.watchlisted {
  border-color: rgba(124,58,237,.4);
  box-shadow: 0 0 0 1px rgba(124,58,237,.2);
}

/* Cover image */
.card-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  overflow: hidden;
  background: var(--bg-raised);
}
.card-cover img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform var(--slow) var(--ease);
}
.anime-card:hover .card-cover img {
  transform: scale(1.06);
}
.cover-gradient {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 60%;
  background: linear-gradient(to top, var(--bg-card) 0%, transparent 100%);
}

/* Removal Animation */
.anime-card.removing {
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
}

/* Status badges */
.status-badges {
  position: absolute;
  top: 8px; left: 8px;
  display: flex; flex-direction: column; gap: 4px;
  z-index: 2;
}
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px; border-radius: 6px;
  font-size: 9px; font-weight: 800; letter-spacing: .4px;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.1);
  line-height: 1;
}
.badge-airing {
  background: rgba(16,185,129,.85);
  color: #fff;
  box-shadow: 0 0 12px var(--green-glow);
  animation: glow-pulse 2.5s ease-in-out infinite;
}
.badge-soon {
  background: rgba(245,158,11,.8);
  color: #fff;
}
.badge-ep {
  background: rgba(124,58,237,0.25);
  color: #d8b4fe;
  border-color: rgba(124,58,237,0.4);
}
.badge-score {
  background: rgba(251,191,36,0.15);
  color: #fbbf24;
  border-color: rgba(251,191,36,0.3);
}

/* Pin / watchlist button */
.pin-btn {
  position: absolute;
  bottom: 8px; right: 8px; z-index: 3;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(0,0,0,.6); backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.12);
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--fast) var(--ease);
  opacity: 0;
}
.anime-card:hover .pin-btn,
.anime-card.watchlisted .pin-btn { opacity: 1; }
.pin-btn:hover { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.3); }
.pin-btn.pinned { background: rgba(124,58,237,.85); color: #fff; border-color: var(--accent); opacity: 1; }
.pin-btn.pinned:hover { background: rgba(124,58,237,1); border-color: var(--accent); }
.pin-btn svg { width: 14px; height: 14px; }

/* Card body */
.card-body {
  padding: 10px 11px 12px;
}
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  height: 18px; /* Fixed height for consistency */
}
.card-time {
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
  color: var(--cyan);
}
.card-badges {
  display: flex;
  gap: 5px;
}
.card-title {
  font-size: 12.5px; font-weight: 700; color: var(--text);
  line-height: 1.35; margin-bottom: 5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 11px; color: var(--text-3);
  margin-bottom: 8px;
}
.card-meta-sep { opacity: .4; }

/* Countdown */
.card-countdown {
  font-size: 12px; font-weight: 700;
  color: var(--amber); letter-spacing: .2px;
  display: flex; align-items: center; gap: 5px;
}
.card-countdown.airing-now { color: var(--green); }
.card-countdown svg { flex-shrink: 0; }

/* Genre pills */
.card-genres {
  display: flex; gap: 4px; flex-wrap: wrap; margin-top: 7px;
  padding-right: 34px;
}
.genre-pill {
  padding: 2px 7px; border-radius: 999px;
  font-size: 10px; font-weight: 600;
  background: var(--bg-raised); color: var(--text-3);
  border: 1px solid var(--border);
}

/* Streaming links bar */
.stream-bar {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border);
  padding-right: 34px;
}
.stream-link {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: var(--r-sm);
  font-size: 10px; font-weight: 600; color: var(--text-2);
  background: var(--bg-raised); border: 1px solid var(--border);
  transition: all var(--fast) var(--ease);
}
.stream-link:hover { border-color: var(--accent); color: var(--accent-light); }
.stream-icon { width: 12px; height: 12px; border-radius: 2px; object-fit: contain; }

/* ── MODAL CONTENT ───────────────────────────────────────────── */
.modal-banner {
  width: 100%; height: 180px;
  object-fit: cover;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}
.modal-banner-fallback {
  width: 100%; height: 180px;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}
.modal-inner {
  padding: 20px 24px 28px;
}
.modal-top {
  display: flex; gap: 16px; align-items: flex-start;
  margin-top: -50px; position: relative; z-index: 1;
}
.modal-poster {
  width: 90px; height: 128px;
  border-radius: var(--r-md);
  object-fit: cover; flex-shrink: 0;
  border: 3px solid var(--bg-raised);
  box-shadow: 0 4px 20px rgba(0,0,0,.6);
}
.modal-title-block { padding-top: 56px; }
.modal-title {
  font-size: 19px; font-weight: 800; color: var(--text);
  line-height: 1.25; margin-bottom: 4px;
}
.modal-title-eng {
  font-size: 13px; color: var(--text-2); margin-bottom: 8px;
}
.modal-badges { display: flex; gap: 6px; flex-wrap: wrap; }

.modal-meta-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin: 18px 0;
}
.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; }
.meta-value { font-size: 14px; font-weight: 600; color: var(--text); }

.modal-synopsis {
  font-size: 13.5px; line-height: 1.7; color: var(--text-2);
  margin-bottom: 18px;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
}
.modal-synopsis.expanded { -webkit-line-clamp: unset; }
.read-more-btn {
  font-size: 12px; color: var(--accent-light); font-weight: 600;
  display: block; margin-bottom: 16px; cursor: pointer; background: none; border: none; padding: 0;
}

/* ── MODAL ACTION BUTTONS (mab) ───────────────────────────────── */
.modal-actions {
  display: flex; gap: 7px; flex-wrap: nowrap; margin-top: 4px;
  align-items: center;
}
/* Base pill */
.mab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px;
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  text-decoration: none; border: none;
  transition: opacity var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.mab:hover  { opacity: .85; transform: translateY(-1px); }
.mab:active { transform: scale(.97); opacity: 1; }

/* AniList — brand purple, stretches to fill space */
.mab-anilist {
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
  color: #fff;
  box-shadow: 0 2px 10px rgba(124,58,237,.4);
  flex: 1; justify-content: center;
}
/* Watchlist — ghost border */
.mab-pin {
  background: var(--bg-raised);
  border: 1px solid var(--border-hi) !important;
  color: var(--text-2);
}
.mab-pin.pinned {
  background: rgba(124,58,237,.18);
  border-color: rgba(124,58,237,.5) !important;
  color: var(--accent-light);
}
/* Streaming — tinted brand color */
.mab-stream {
  background: color-mix(in srgb, var(--stream-color, var(--bg-raised)) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--stream-color, var(--border)) 35%, transparent) !important;
  color: var(--text);
}
.mab-stream img { display: inline-block; vertical-align: middle; }

/* ── MOBILE: HORIZONTAL CARD ─────────────────────────────────── */
@media (max-width: 768px) {
  /* Compact horizontal card — image left, info right */
  .anime-card {
    display: flex;
    flex-direction: row;
    height: 115px;
  }
  .anime-card:hover {
    transform: translateX(2px);  /* subtle nudge instead of scale */
  }
  .card-cover {
    width: 80px;
    min-width: 80px;
    height: 115px;
    aspect-ratio: auto;
    border-radius: var(--r-lg) 0 0 var(--r-lg);
    flex-shrink: 0;
  }
  .cover-gradient {
    /* gradient goes right-to-left for horizontal layout */
    height: 100%;
    width: 40%;
    top: 0; left: auto; right: 0;
    background: linear-gradient(to left, var(--bg-card) 0%, transparent 100%);
  }
  .status-badges {
    top: 6px; left: 6px;
    flex-direction: row; flex-wrap: wrap; gap: 3px;
  }
  .badge { font-size: 9px; padding: 2px 5px; }
  .pin-btn {
    top: auto; bottom: 8px; right: 8px;
    width: 24px; height: 24px;
    opacity: 1;  /* always visible on touch */
  }
  .pin-btn svg { width: 12px; height: 12px; }
  .card-body {
    flex: 1; min-width: 0;
    padding: 8px 10px 8px 10px; /* text can span full width at top */
    display: flex; flex-direction: column; justify-content: center;
    gap: 3px;
  }
  .card-header-row { margin-bottom: 4px; height: 16px; padding-right: 10px; }
  .card-time { font-size: 10.5px; }
  .card-badges { gap: 4px; }
  .card-title {
    font-size: 13px; font-weight: 700;
    color: #fff;
    line-height: 1.3;
    -webkit-line-clamp: 2; margin-bottom: 2px;
    height: auto;
    min-height: 1.3em;
  }
  .card-meta { font-size: 10.5px; margin-bottom: 2px; gap: 4px; color: var(--text-3); padding-right: 28px; }
  .card-countdown { font-size: 11px; padding-right: 28px; }
  /* Hide extras to keep card compact */
  .card-genres { display: none; }
  .stream-bar  { display: none; }
}

/* ── MOBILE: BOTTOM-SHEET MODAL ──────────────────────────────── */
@media (max-width: 640px) {
  /* Overlay aligns to bottom */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  /* Modal slides up from bottom */
  .modal-box {
    width: 100%;
    max-width: 100%;
    max-height: 88vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    animation: slide-up-sheet var(--base) var(--ease);
  }
  /* Drag handle pill */
  .modal-box::before {
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: var(--border-hi);
    border-radius: 999px;
    margin: 10px auto 0;
  }
  .modal-close-btn { top: 10px; right: 14px; }
  /* Shorter banner */
  .modal-banner,
  .modal-banner-fallback {
    height: 120px;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }
  .modal-inner { padding: 14px 18px 28px; }
  .modal-top { margin-top: -38px; gap: 12px; }
  .modal-poster { width: 72px; height: 100px; border-width: 2px; }
  .modal-title-block { padding-top: 46px; }
  .modal-title { font-size: 16px; }
  .modal-title-eng { font-size: 12px; }
  .modal-meta-grid { gap: 8px; margin: 12px 0; }
  .meta-value { font-size: 13px; }
  .modal-synopsis { font-size: 13px; margin-bottom: 12px; }
  /* Keep action buttons on one row, sleek on mobile */
  .modal-actions { flex-wrap: nowrap; gap: 6px; }
  .mab { padding: 8px 12px; font-size: 12px; }
  .mab-anilist { flex: 1; }
}

@keyframes slide-up-sheet {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
