/**
 * FLAZZA — صفحة اكتشاف (خلفية فاتحة، RTL، وصولية)
 */

:root {
  --hd-purple: #3d1d6b;
  --hd-purple-deep: #2b124d;
  --hd-purple-hover: #4f2a85;
  --hd-mint: #00c985;
  --hd-mint-dark: #059669;
  --hd-sun: #ffc800;
  --hd-sky: #2680eb;
  --hd-coral: #ff3355;
  --hd-bg: #eef0f6;
  --hd-surface: #ffffff;
  --hd-text: #16162a;
  --hd-muted: #5c5c76;
  --hd-line: #d8dce8;
  --hd-focus: #2680eb;
  --hd-radius: 12px;
  --hd-radius-lg: 18px;
  --hd-shadow: 0 6px 24px rgba(22, 22, 42, 0.07);
  --hd-shadow-hover: 0 14px 40px rgba(22, 22, 42, 0.11);
  --hd-max: 1180px;
  --hd-header-pad: max(12px, env(safe-area-inset-top));
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body.discover-body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Changa", "IBM Plex Sans Arabic", system-ui, sans-serif;
  font-size: 0.95rem;
  color: var(--hd-text);
  background: var(--hd-bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--hd-focus);
  outline-offset: 2px;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ─── Top bar ─── */
.hd-top {
  background: linear-gradient(135deg, var(--hd-purple-deep) 0%, var(--hd-purple) 52%, #4a2a7a 100%);
  color: #fff;
  padding: calc(12px + var(--hd-header-pad)) 0 14px;
  box-shadow: 0 4px 28px rgba(35, 18, 65, 0.38);
  position: sticky;
  top: 0;
  z-index: 100;
}

.hd-top__inner {
  max-width: var(--hd-max);
  margin: 0 auto;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 14px;
}

.hd-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  color: #fff;
  border-radius: var(--hd-radius);
}

.hd-logo:focus-visible {
  outline-color: #fff;
}

.hd-logo img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.hd-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.hd-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 13px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.8rem;
  border: 2px solid transparent;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
  white-space: nowrap;
  line-height: 1.2;
}

.hd-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  filter: brightness(1.02);
}

.hd-pill:active {
  transform: translateY(0);
}

.hd-pill--discover {
  background: var(--hd-mint);
  color: #064e3b;
}

.hd-pill--learn {
  background: var(--hd-sun);
  color: #422006;
}

.hd-pill--present {
  background: var(--hd-sky);
  color: #fff;
}

.hd-pill--make {
  background: var(--hd-coral);
  color: #fff;
}

.hd-pill--join {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
}

.hd-pill.is-active {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5);
}

/* بحث: في RTL يجب عكس الزوايا والترتيب البصري */
.hd-search {
  flex: 1 1 200px;
  min-width: 160px;
  max-width: 400px;
  display: flex;
  align-items: stretch;
  margin-inline-start: auto;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

.hd-search input {
  flex: 1;
  min-width: 0;
  border: none;
  padding: 12px 16px;
  font: inherit;
  background: #fff;
  color: var(--hd-text);
  outline: none;
  border-radius: 999px 0 0 999px;
}

.hd-search button {
  flex: 0 0 auto;
  border: none;
  border-radius: 0 999px 999px 0;
  padding: 0 16px;
  min-width: 48px;
  background: #fff;
  color: var(--hd-purple);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  transition: background 0.15s ease;
}

.hd-search button:hover {
  background: #f3f2f8;
}

[dir="rtl"] .hd-search input {
  border-radius: 0 999px 999px 0;
}

[dir="rtl"] .hd-search button {
  border-radius: 999px 0 0 999px;
}

.hd-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 17px;
  min-height: 44px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.8rem;
  border: 2px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.hd-btn:active {
  transform: scale(0.98);
}

.hd-btn--ghost {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.5);
}

.hd-btn--ghost:hover {
  background: rgba(255, 255, 255, 0.14);
}

.hd-btn--green {
  background: var(--hd-mint);
  color: #064e3b;
  border-color: transparent;
}

.hd-btn--green:hover {
  background: #00e699;
  color: #022c22;
}

.hd-btn--inline {
  display: inline-flex;
}

/* ─── Sub bar ─── */
.hd-sub {
  background: var(--hd-surface);
  border-bottom: 1px solid var(--hd-line);
  padding: 11px 0;
  box-shadow: 0 1px 0 rgba(22, 22, 42, 0.04);
}

.hd-sub__inner {
  max-width: var(--hd-max);
  margin: 0 auto;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.hd-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 15px;
  min-height: 38px;
  border-radius: 999px;
  background: #f8f9fc;
  border: 1px solid var(--hd-line);
  font-weight: 800;
  font-size: 0.78rem;
  color: var(--hd-muted);
  transition: border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s;
}

.hd-chip:hover {
  border-color: var(--hd-purple);
  color: var(--hd-purple);
  background: #f5f3ff;
  box-shadow: 0 2px 8px rgba(61, 29, 107, 0.08);
}

.hd-chip[style*="dashed"] {
  border-style: dashed;
  color: var(--hd-purple);
  background: #faf8ff;
}

/* ─── Main ─── */
.disc-main {
  max-width: var(--hd-max);
  margin: 0 auto;
  padding: 26px max(16px, env(safe-area-inset-right)) 48px max(16px, env(safe-area-inset-left));
}

.disc-section {
  margin-bottom: 42px;
}

.disc-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.disc-section__head h2 {
  margin: 0;
  font-size: clamp(1.2rem, 2.2vw, 1.5rem);
  font-weight: 800;
  color: var(--hd-text);
  letter-spacing: -0.02em;
}

.disc-section__head a {
  font-weight: 800;
  font-size: 0.86rem;
  color: var(--hd-sky);
  padding: 6px 4px;
  border-radius: 8px;
}

.disc-section__head a:hover {
  text-decoration: underline;
  color: #1a6fd4;
}

/* ─── Horizontal scroll ─── */
.disc-scroll {
  --disc-scroll-fade: #f3f4f9;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 -2px;
  padding: 14px 12px 12px;
  border-radius: 22px;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.97) 0%, rgba(248, 249, 252, 0.92) 48%, rgba(241, 243, 249, 0.88) 100%);
  border: 1px solid rgba(216, 220, 232, 0.95);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.75) inset,
    0 10px 36px rgba(22, 22, 42, 0.06),
    0 2px 8px rgba(22, 22, 42, 0.03);
}

.disc-scroll__arrow {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  min-height: 0;
  align-self: center;
  border: 1px solid rgba(196, 181, 253, 0.45);
  border-radius: 999px;
  background: linear-gradient(165deg, #ffffff 0%, #f7f5ff 100%);
  color: var(--hd-purple);
  font-size: 1.28rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition:
    background 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease,
    transform 0.14s ease,
    opacity 0.18s ease;
  box-shadow:
    0 2px 10px rgba(61, 29, 107, 0.08),
    0 1px 0 rgba(255, 255, 255, 0.95) inset;
}

.disc-scroll__arrow:hover:not(:disabled) {
  background: linear-gradient(165deg, #faf8ff 0%, #ede9fe 100%);
  border-color: #a78bfa;
  box-shadow:
    0 6px 20px rgba(61, 29, 107, 0.12),
    0 1px 0 rgba(255, 255, 255, 0.98) inset;
  transform: translateY(-1px);
}

.disc-scroll__arrow:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
}

.disc-scroll__arrow:disabled {
  opacity: 0.34;
  cursor: default;
  border-color: var(--hd-line);
  background: #f4f4f6;
  color: var(--hd-muted);
  box-shadow: none;
}

@media (min-width: 720px) {
  .disc-scroll__arrow {
    display: flex;
  }
}

.disc-scroll__viewport {
  flex: 1;
  min-width: 0;
  position: relative;
  isolation: isolate;
}

.disc-scroll__viewport::before,
.disc-scroll__viewport::after {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 16px;
  width: 36px;
  z-index: 2;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.22s ease;
}

.disc-scroll__viewport::before {
  inset-inline-start: 0;
  background: linear-gradient(to right, var(--disc-scroll-fade), transparent);
}

[dir="rtl"] .disc-scroll__viewport::before {
  background: linear-gradient(to left, var(--disc-scroll-fade), transparent);
}

.disc-scroll__viewport::after {
  inset-inline-end: 0;
  background: linear-gradient(to left, var(--disc-scroll-fade), transparent);
}

[dir="rtl"] .disc-scroll__viewport::after {
  background: linear-gradient(to right, var(--disc-scroll-fade), transparent);
}

.disc-scroll__viewport.is-scroll-start::before {
  opacity: 0;
}

.disc-scroll__viewport.is-scroll-end::after {
  opacity: 0;
}

.disc-scroll__track {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 6px;
  scroll-behavior: smooth;
  padding: 6px 4px 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 92, 246, 0.35) rgba(216, 220, 232, 0.35);
}

.disc-scroll__track::-webkit-scrollbar {
  height: 6px;
}

.disc-scroll__track::-webkit-scrollbar-track {
  margin: 0 8px;
  background: rgba(216, 220, 232, 0.35);
  border-radius: 999px;
}

.disc-scroll__track::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, rgba(109, 40, 217, 0.45), rgba(61, 29, 107, 0.5));
  border-radius: 999px;
}

.disc-scroll__track::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(90deg, rgba(109, 40, 217, 0.65), rgba(61, 29, 107, 0.72));
}

.disc-scroll__slide {
  flex: 0 0 min(252px, calc(100vw - 56px));
  scroll-snap-align: start;
  scroll-snap-stop: normal;
}

.disc-scroll__slide .disc-card {
  height: 100%;
}

/* ─── Category cards ─── */
.disc-cat {
  flex: 0 0 min(272px, calc(100vw - 48px));
  scroll-snap-align: start;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 124px;
  border-radius: calc(var(--hd-radius-lg) + 2px);
  overflow: hidden;
  box-shadow: var(--hd-shadow);
  background: var(--hd-surface);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition:
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.22s ease,
    border-color 0.2s ease;
}

.disc-cat:hover {
  transform: translateY(-4px);
  box-shadow: var(--hd-shadow-hover), 0 0 0 1px rgba(167, 139, 250, 0.25);
}

.disc-cat:focus-visible {
  outline: 3px solid var(--hd-focus);
  outline-offset: 3px;
}

.disc-cat__label {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1.3;
}

.disc-cat__label span {
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.92;
}

.disc-cat__visual {
  position: relative;
  background-size: cover;
  background-position: center;
  min-height: 100%;
}

.disc-cat__visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(270deg, rgba(0, 0, 0, 0.12), transparent 65%);
}

[dir="rtl"] .disc-cat__visual::after {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.12), transparent 65%);
}

.disc-cat__emoji {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.35rem;
  z-index: 1;
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.22));
}

/* ─── Quiz cards ─── */
.disc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 16px;
}

.disc-card {
  border-radius: var(--hd-radius-lg);
  overflow: hidden;
  background: var(--hd-surface);
  box-shadow: var(--hd-shadow);
  border: 1px solid var(--hd-line);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.disc-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--hd-shadow-hover);
  border-color: #d0d5e3;
}

.disc-card__cover {
  display: block;
  height: 124px;
  background-size: cover;
  background-position: center;
  position: relative;
  flex-shrink: 0;
}

.disc-card__cover::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 35%, rgba(0, 0, 0, 0.5));
}

.disc-card__body {
  padding: 13px 14px 15px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0;
}

.disc-card__body h3 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.4;
  color: var(--hd-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.disc-card__meta {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--hd-muted);
  margin-bottom: 12px;
  line-height: 1.35;
}

.disc-card__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: auto;
  padding: 9px 16px;
  min-height: 40px;
  border-radius: 999px;
  background: var(--hd-purple);
  color: #fff;
  font-weight: 800;
  font-size: 0.76rem;
  align-self: flex-start;
  transition: background 0.15s ease, transform 0.12s ease;
}

.disc-card__cta:hover {
  background: var(--hd-purple-hover);
}

.disc-card__cta:active {
  transform: scale(0.98);
}

/* ─── CTA panel ─── */
.disc-cta-card {
  text-align: center;
  padding: 26px 22px;
  background: var(--hd-surface);
  border-radius: var(--hd-radius-lg);
  border: 1px solid var(--hd-line);
  box-shadow: var(--hd-shadow);
}

.disc-cta-card__title {
  margin: 0 0 8px;
  font-weight: 800;
  font-size: 1.12rem;
  color: var(--hd-text);
}

.disc-cta-card__meta {
  margin: 0 0 18px;
  color: var(--hd-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

/* ─── Empty / alert ─── */
.disc-empty {
  text-align: center;
  color: var(--hd-muted);
  font-weight: 700;
  margin: 0;
  padding: 20px;
}

.disc-empty a {
  color: var(--hd-sky);
  font-weight: 800;
}

.disc-empty a:hover {
  text-decoration: underline;
}

.disc-alert {
  box-sizing: border-box;
  width: calc(100% - 32px);
  max-width: var(--hd-max);
  margin: 14px auto 0;
  padding: 14px 18px;
  border-radius: var(--hd-radius);
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-weight: 700;
}

/* ─── Footer ─── */
.disc-footer {
  max-width: var(--hd-max);
  margin: 0 auto;
  padding: 28px max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left));
  border-top: 1px solid var(--hd-line);
  text-align: center;
  color: var(--hd-muted);
  font-size: 0.84rem;
  background: linear-gradient(180deg, var(--hd-bg) 0%, #e8eaf2 100%);
}

.disc-footer__links {
  margin: 0 0 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
}

.disc-footer__sep {
  color: #b4b8c9;
  user-select: none;
}

.disc-footer a {
  color: var(--hd-sky);
  font-weight: 800;
  padding: 4px 6px;
  border-radius: 6px;
}

.disc-footer a:hover {
  text-decoration: underline;
  color: #1a6fd4;
}

.disc-footer__copy {
  margin: 0;
  font-weight: 600;
  color: #7a7d92;
}

/* ─── Responsive header ─── */
@media (max-width: 900px) {
  .hd-search {
    order: 10;
    flex: 1 1 100%;
    max-width: none;
    margin-inline-start: 0;
  }

  .hd-actions {
    margin-inline-start: auto;
  }
}

@media (max-width: 640px) {
  .hd-pills {
    width: 100%;
    justify-content: flex-start;
  }

  .hd-pill {
    font-size: 0.72rem;
    padding: 7px 10px;
  }

  .hd-btn {
    padding: 8px 14px;
    min-height: 42px;
    font-size: 0.76rem;
  }

  .disc-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }

  .disc-card__cover {
    height: 108px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .hd-pill,
  .disc-card,
  .disc-cat,
  .disc-card__cta,
  .hd-btn,
  .disc-scroll__arrow,
  .disc-scroll__viewport::before,
  .disc-scroll__viewport::after {
    transition: none;
  }

  .hd-pill:hover,
  .disc-card:hover,
  .disc-cat:hover,
  .disc-scroll__arrow:hover:not(:disabled) {
    transform: none;
  }
}
