/* =========================================================
   v2 — languages, rails, badges, hover cards, manga touches
   ========================================================= */

/* language-specific type: Arabic → Alexandria, English → Outfit, Japanese → Noto Sans JP (Latin glyphs stay Outfit) */
html[lang="en"] body { font-family: var(--font); }
html[lang="ja"] body { font-family: "Outfit", "Noto Sans JP", system-ui, sans-serif; line-height: 1.8; }
html[lang="en"] h1, html[lang="en"] h2, html[lang="en"] .hero__ar { letter-spacing: -0.025em; }
html[lang="ja"] h2, html[lang="ja"] .hero__ar { letter-spacing: 0.01em; line-height: 1.35; }
html[lang="en"] .hero__ar { font-size: clamp(2.4rem, 1.4rem + 4.2vw, 4.4rem); line-height: 1.05; }
html[lang="ja"] .hero__ar { font-size: clamp(2rem, 1.2rem + 3.6vw, 3.8rem); }

/* ---------- language switcher ---------- */
.nav__inner { gap: 1rem; }
.lang { position: relative; flex-shrink: 0; }
@media (max-width: 900px) { .lang { margin-inline-start: auto; } }
.lang__btn {
  display: inline-flex; align-items: center; gap: .45rem; height: 38px; padding: 0 .85rem; border-radius: 999px;
  background: rgba(244, 234, 192, .08); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--cream);
  font-family: var(--font); font-weight: var(--w-semi); font-size: .85rem;
  transition: background-color .2s, transform .12s var(--ease-out);
}
.lang__btn:hover { background: rgba(244, 234, 192, .14); }
.lang__btn:active { transform: scale(.95); }
.lang__current { min-width: 1.3em; text-align: center; }
.lang__menu {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; min-width: 160px; padding: 6px; border-radius: 14px; z-index: 60;
  background: rgba(22, 10, 13, .86); backdrop-filter: blur(24px) saturate(160%); -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow: inset 0 0 0 1px var(--line-2), 0 24px 50px -20px rgba(0,0,0,.8);
  transform: scale(.92); opacity: 0;
  transition: transform .32s var(--ease-spring), opacity .18s ease-out;
}
html[dir="ltr"] .lang__menu { transform-origin: top right; }
html[dir="rtl"] .lang__menu { transform-origin: top left; }
.lang__menu.is-open { transform: none; opacity: 1; }
.lang__menu button {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem .8rem; border-radius: 9px; font-size: .95rem; text-align: start;
}
.lang__menu button[lang="ar"] { font-family: var(--font-ar); }
.lang__menu button[lang="ja"] { font-family: "Noto Sans JP", var(--font); }
.lang__menu button:hover, .lang__menu button:focus-visible { background: rgba(244, 234, 192, .09); outline: none; }
.lang__menu button[aria-checked="true"]::after { content: ""; width: 16px; height: 16px; background: var(--crimson-2); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 24 24%27 fill=%27none%27 stroke=%27black%27 stroke-width=%272.4%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27%3E%3Cpath d=%27M5 12.5l4.3 4.3L19 7.2%27/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 24 24%27 fill=%27none%27 stroke=%27black%27 stroke-width=%272.4%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27%3E%3Cpath d=%27M5 12.5l4.3 4.3L19 7.2%27/%3E%3C/svg%3E") center / contain no-repeat; }

/* ---------- manga SFX: a big outlined Japanese word behind each section title ---------- */
.section__head[data-sfx] { position: relative; isolation: isolate; }
/* the words are pre-merged SVG outlines (overlapping glyph strokes unioned), so the stroke is one clean line */
.section__head[data-sfx]::before {
  content: ""; position: absolute; z-index: -1; top: -1.6rem; inset-inline-start: -.5rem; pointer-events: none;
  height: clamp(4.5rem, 3rem + 7vw, 8.5rem); width: 70%; max-width: 640px;
  background: var(--sfx) no-repeat; background-size: contain; background-position: left center;
  opacity: .14; transform: skewX(-8deg);
}
html[dir="rtl"] .section__head[data-sfx]::before { background-position: right center; }
.section--red .section__head[data-sfx]::before { opacity: .3; }
#airing { --sfx: url("/assets/sfx/airing.svg"); }
#news { --sfx: url("/assets/sfx/news.svg"); }
#trending { --sfx: url("/assets/sfx/trending.svg"); }
#birthdays { --sfx: url("/assets/sfx/birthdays.svg"); }
#movies { --sfx: url("/assets/sfx/movies.svg"); }
#trailers { --sfx: url("/assets/sfx/trailers.svg"); }
#free { --sfx: url("/assets/sfx/free.svg"); }
#deals { --sfx: url("/assets/sfx/deals.svg"); }
#steam { --sfx: url("/assets/sfx/steam.svg"); }
#games { --sfx: url("/assets/sfx/games.svg"); }

/* manga speed lines behind the 3D emblem */
.hero__visual { isolation: isolate; }
.hero__visual::before {
  content: ""; position: absolute; z-index: -1; left: 50%; top: min(220px, 41vw); width: min(760px, 150vw); aspect-ratio: 1; transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from 0deg, rgba(255, 236, 200, .08) 0deg .8deg, transparent .8deg 6deg);
  -webkit-mask-image: radial-gradient(closest-side, transparent 34%, #000 55%, transparent 100%);
          mask-image: radial-gradient(closest-side, transparent 34%, #000 55%, transparent 100%);
  pointer-events: none;
}

/* ink-offset shadow on hover, like a comic panel */
@media (hover: hover) {
  .card:hover, .poster:hover .poster__img, .game:hover, .movie:hover, .epic-card:hover, .row:hover {
    box-shadow: inset 0 0 0 1.5px rgba(244, 234, 192, .32), 5px 5px 0 rgba(200, 16, 46, .55);
  }
  html[dir="rtl"] .card:hover, html[dir="rtl"] .poster:hover .poster__img, html[dir="rtl"] .game:hover,
  html[dir="rtl"] .movie:hover, html[dir="rtl"] .epic-card:hover, html[dir="rtl"] .row:hover {
    box-shadow: inset 0 0 0 1.5px rgba(244, 234, 192, .32), -5px 5px 0 rgba(200, 16, 46, .55);
  }
  .section--red .card:hover, .section--red .poster:hover .poster__img, .section--red .epic-card:hover {
    box-shadow: inset 0 0 0 1.5px rgba(244, 234, 192, .5), 5px 5px 0 rgba(20, 6, 9, .55);
  }
}

/* ---------- rails (inside the content column, aligned with every other section) ---------- */
.rail { position: relative; }
.shelf {
  display: grid; grid-auto-flow: column; grid-auto-columns: calc((100% - 5 * 1rem) / 6); gap: 1rem;
  overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scroll-snap-type: x mandatory;
  padding: .25rem 0 .75rem; scroll-padding-inline: 0; scrollbar-width: none; -ms-overflow-style: none;
  cursor: grab; user-select: none;
}
.shelf::-webkit-scrollbar { display: none; }
.shelf.is-dragging { cursor: grabbing; scroll-snap-type: none; scroll-behavior: auto; }
.shelf.is-dragging a { pointer-events: none; }
@media (max-width: 1100px) { .shelf { grid-auto-columns: calc((100% - 4 * 1rem) / 5); } }
@media (max-width: 860px) { .shelf { grid-auto-columns: calc((100% - 3 * 1rem) / 4); } }
@media (max-width: 620px) { .shelf { grid-auto-columns: calc((100% - 1.5 * .85rem) / 2.5); gap: .85rem; } }
.rail__btn {
  position: absolute; top: calc(50% - 2.6rem); z-index: 3; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(18, 8, 11, .78); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: inset 0 0 0 1px var(--line-2), 0 10px 30px -10px rgba(0,0,0,.8); color: var(--cream);
  transition: opacity .25s, transform .15s var(--ease-out), background-color .2s;
}
.rail__btn:hover { background: var(--crimson); }
.rail__btn:active { transform: scale(.92); }
.rail__btn span { width: 10px; height: 10px; border-top: 2px solid currentColor; border-inline-end: 2px solid currentColor; }
.rail__btn--prev { inset-inline-start: -22px; }
.rail__btn--next { inset-inline-end: -22px; }
html[dir="ltr"] .rail__btn--prev span { transform: translateX(2px) rotate(-135deg); }
html[dir="ltr"] .rail__btn--next span { transform: translateX(-2px) rotate(45deg); }
html[dir="rtl"] .rail__btn--prev span { transform: translateX(2px) rotate(135deg); }
html[dir="rtl"] .rail__btn--next span { transform: translateX(-2px) rotate(-45deg); }
.rail.at-start .rail__btn--prev, .rail.at-end .rail__btn--next, .rail.no-overflow .rail__btn { opacity: 0; pointer-events: none; }
@media (hover: none), (max-width: 620px) { .rail__btn { display: none; } }
@media (min-width: 621px) and (max-width: 1290px) { .rail__btn--prev { inset-inline-start: -10px; } .rail__btn--next { inset-inline-end: -10px; } }

/* ---------- posters (trending + characters): no glow, solid readable badges, clear hierarchy ---------- */
.poster { scroll-snap-align: start; display: flex; flex-direction: column; gap: .5rem; min-width: 0; }
.poster__img {
  position: relative; aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden;
  background: var(--c, var(--surface-2)); box-shadow: inset 0 0 0 1px var(--line); transition: transform .25s var(--ease-out), box-shadow .25s;
}
.poster__img img { width: 100%; height: 100%; object-fit: cover; }
.badge {
  position: absolute; z-index: 1; display: inline-flex; align-items: center; gap: .25rem; height: 24px; padding: 0 .55rem; border-radius: 7px;
  font-family: var(--font); font-size: .74rem; font-weight: var(--w-bold); line-height: 1; white-space: nowrap; letter-spacing: .01em;
}
.badge--score { top: .5rem; inset-inline-start: .5rem; background: #0c0607; color: #f5c451; box-shadow: 0 2px 8px rgba(0,0,0,.45); }
.badge--ep { bottom: .5rem; inset-inline-start: .5rem; background: var(--cream); color: #4a0413; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.poster__title {
  margin: 0; font-weight: var(--w-semi); font-size: .92rem; line-height: 1.35; color: var(--text); text-align: start;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.poster__meta { margin: -.2rem 0 0; font-size: .74rem; font-weight: var(--w-regular); color: var(--text-3); text-align: start; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.char .poster__img img { object-position: top; }
.section--red .poster__img { background: rgba(20, 6, 9, .45); }
.section--red .poster__meta { color: rgba(246, 239, 220, .7); }
.skeleton--poster { aspect-ratio: 2 / 3; }

/* ---------- airing extras ---------- */
.tabs { align-items: center; }
.tabs__spacer { flex: 1 0 1rem; }
.tabs .chip { flex-shrink: 0; }
.ep__cover { width: 54px; height: 76px; border-radius: 10px; overflow: hidden; flex-shrink: 0; background: var(--surface-2); }
.ep__cover img { width: 100%; height: 100%; object-fit: cover; }
.ep__title { text-align: start; }
.ep__hot { font-size: .72rem; font-weight: var(--w-semi); color: #ffb347; }
.ep__live { font-size: .72rem; font-weight: var(--w-semi); color: #fff; background: var(--crimson); padding: .05rem .45rem; border-radius: 999px; }
.ep.is-hot { box-shadow: inset 0 0 0 1px rgba(255, 179, 71, .35); }
.next-ep__img { width: 48px; height: 66px; border-radius: 8px; overflow: hidden; flex-shrink: 0; background: var(--surface-2); }
.next-ep__img img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- fallbacks (only if every image source fails) ---------- */
.card__type { display: none; }
.card--type .card__media {
  display: grid; place-items: center; padding: 1.25rem;
  background: radial-gradient(120% 120% at 100% 0%, color-mix(in srgb, var(--c, var(--crimson)) 35%, transparent), transparent 60%), var(--surface-2);
}
.card--type .card__type { display: block; font-family: var(--font); font-weight: var(--w-bold); font-size: 1.4rem; color: var(--cream); text-align: center; line-height: 1.15; }
.game__mark { display: none; }
.game--type { display: grid; place-items: center; text-align: center; background: radial-gradient(120% 90% at 50% 0%, rgba(200,16,46,.55), var(--surface-2) 70%); }
.game--type .game__mark { display: block; font-family: var(--font); font-weight: var(--w-bold); font-size: 1.35rem; color: var(--cream); padding: 1rem; line-height: 1.1; }
.game__genre { margin: .15rem 0 0; font-size: .72rem; color: var(--text-3); text-align: start; }
.game__name, .row__name, .ep__native { text-align: start; }

/* ---------- hover card ---------- */
.hovercard {
  position: fixed; z-index: 80; width: 320px; max-width: calc(100vw - 24px); border-radius: 16px; overflow: hidden; pointer-events: none;
  background: rgba(20, 9, 12, .92); backdrop-filter: blur(26px) saturate(170%); -webkit-backdrop-filter: blur(26px) saturate(170%);
  box-shadow: inset 0 0 0 1px rgba(244, 234, 192, .16), 0 30px 70px -24px rgba(0,0,0,.9);
  opacity: 0; transform: scale(.94); transition: opacity .16s ease-out, transform .34s var(--ease-spring);
}
.hovercard.is-in { opacity: 1; transform: none; }
.hc__media { aspect-ratio: 16 / 7; overflow: hidden; background: var(--surface-2); }
.hc__media img { width: 100%; height: 100%; object-fit: cover; }
.hc__body { padding: .85rem 1rem 1rem; display: grid; gap: .4rem; }
.hc__body--row { grid-template-columns: 72px 1fr; gap: .85rem; align-items: start; }
.hc__body--tight { padding-top: 0; }
.hc__thumb { width: 72px; aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.hc__thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.hc__title { margin: 0; font-weight: var(--w-bold); font-size: 1rem; line-height: 1.3; color: var(--text); text-align: start; }
.hc__alt { margin: -.2rem 0 0; font-size: .8rem; color: var(--text-3); text-align: start; }
.hc__meta { margin: 0; font-family: var(--font); font-size: .76rem; color: var(--text-2); text-align: start; }
.hc__desc {
  margin: 0; font-size: .84rem; font-weight: var(--w-light); line-height: 1.6; color: var(--text-2); text-align: start;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
}
.hc__rows { margin: .1rem 0 0; display: grid; gap: .25rem; }
.hc__row { display: flex; justify-content: space-between; gap: 1rem; font-size: .8rem; }
.hc__row dt { color: var(--text-3); }
.hc__row dd { margin: 0; color: var(--text); font-family: var(--font); text-align: end; }
.hc__row s { color: var(--text-3); }
.hc__score { color: #f5c451; }
.hc__off { color: #fff; background: var(--crimson); padding: 0 .35rem; border-radius: 5px; font-weight: var(--w-bold); }
.hc__chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .15rem; }
.hc__chips span { font-family: var(--font); font-size: .7rem; font-weight: var(--w-semi); padding: .12rem .5rem; border-radius: 999px; background: rgba(244, 234, 192, .08); color: var(--text-2); }
.hc__hint { margin: .1rem 0 0; font-size: .72rem; color: var(--text-3); }

@media (prefers-reduced-motion: reduce) { .hovercard { transform: none; transition: opacity .15s; } .lang__menu { transform: none; } }
@media (prefers-reduced-transparency: reduce) { .hovercard, .lang__menu, .rail__btn { background: #1a0d10; backdrop-filter: none; -webkit-backdrop-filter: none; } }
