/* ==========================================================================
   MCQsExam – search, autocomplete, daily quiz, trending & exam pages
   Loaded after app.css. Uses the same design tokens.
   ========================================================================== */

/* ---------- Autocomplete ---------- */
.has-suggest { position: relative; }
.suggest-box {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 1060;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 6px; max-height: min(70vh, 520px); overflow-y: auto; text-align: left; min-width: 280px;
}
.header-search .suggest-box { min-width: min(92vw, 460px); }
.sg-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px 4px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sg-clear { border: 0; background: none; color: var(--brand); font-size: .75rem; font-weight: 600; text-transform: none; letter-spacing: 0; padding: 0; }
.sg-item { display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--ink-2); font-size: .93rem; line-height: 1.4; text-decoration: none; }
.sg-item:hover, .sg-item.active { background: var(--brand-50); color: var(--ink); text-decoration: none; }
.sg-item .bi { color: var(--muted); margin-top: 2px; flex: 0 0 auto; }
.sg-item.active .bi { color: var(--brand); }
.sg-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.sg-item small { flex: 0 0 auto; color: var(--muted); font-size: .76rem; margin-top: 2px; max-width: 40%; text-align: right; }
.sg-item mark, .search-results mark, .search-snippet mark { background: #fef08a; color: inherit; padding: 0 1px; border-radius: 3px; }

/* ---------- Search page ---------- */
.search-hero { background: linear-gradient(135deg, var(--brand-50), #ecfdf5); border: 1px solid var(--brand-100); border-radius: 18px; padding: 18px 18px 14px; margin-bottom: 16px; }
.search-hero .crumbs { margin-bottom: 10px; }
.search-big { position: relative; display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid #bbf7d0; border-radius: 14px; padding: 6px 6px 6px 14px; box-shadow: var(--shadow); }
.search-big > .bi { color: var(--muted); font-size: 1.1rem; }
.search-big input { flex: 1 1 auto; min-width: 0; border: 0; outline: 0; font-size: 1.05rem; padding: 8px 4px; background: transparent; color: var(--ink); }
.search-big input::-webkit-search-cancel-button { cursor: pointer; }
.search-big .btn { flex: 0 0 auto; }
.voice-btn { flex: 0 0 auto; width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--brand-600); display: inline-grid; place-items: center; }
.voice-btn:hover { background: var(--brand-50); }
.voice-btn.listening { background: #fee2e2; color: var(--bad); animation: mic-pulse 1.2s ease-in-out infinite; }
@keyframes mic-pulse { 50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, .18); } }
.search-tips { margin: 10px 2px 0; font-size: .85rem; color: var(--muted); }
.search-tips code, .search-help code { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--brand); font-size: .85em; }
.search-help { margin: 0 0 12px; display: grid; gap: 8px; }
.search-help dt { font-weight: 600; }
.search-help dd { margin: 0 0 4px; color: var(--ink-2); font-size: .9rem; }
kbd { background: var(--ink); color: #fff; border-radius: 5px; padding: 1px 6px; font-size: .8em; }

.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 14px; }
.fb-field { display: grid; gap: 3px; flex: 1 1 160px; min-width: 0; }
.fb-field label { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.fb-field .form-select { padding-top: .4rem; padding-bottom: .4rem; }
.fb-more { flex: 1 1 100%; }
.fb-more summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: .9rem; list-style: none; display: inline-flex; gap: 6px; align-items: center; }
.fb-more summary::-webkit-details-marker { display: none; }
.fb-more-body { display: flex; flex-wrap: wrap; gap: 14px 28px; padding-top: 10px; }
.fb-more fieldset { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.fb-more legend { float: none; width: auto; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin: 0 6px 0 0; }
.fb-more label { font-weight: 500; font-size: .9rem; display: inline-flex; gap: 6px; align-items: center; }
.filter-bar.js-auto .fb-apply { display: none; }
.filter-bar.js-auto .fb-more[open] ~ .fb-apply { display: none; }

.spell-note { background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; color: #78350f; }
.spell-note a { color: var(--brand); }
.result-count .took, .result-count .mode-note { color: var(--muted); font-size: .85rem; }
.active-filters { margin-bottom: 12px; align-items: center; }
.chip-remove { background: var(--brand-50); border-color: #bbf7d0; color: var(--brand); }
.chip-remove .bi { font-size: .7rem; margin-left: 4px; }
.chip-clear { font-size: .88rem; font-weight: 600; padding: 0 6px; }
.search-snippet { display: flex; gap: 8px; margin: -2px 0 12px; padding: 10px 12px; background: #f8fafc; border-left: 3px solid #86efac; border-radius: 8px; font-size: .9rem; color: var(--ink-2); line-height: 1.55; }
.search-snippet .bi { color: #ca8a04; margin-top: 2px; }
.link-list.cols-2 { columns: 2 220px; column-gap: 16px; }
.link-list.cols-2 li { break-inside: avoid; }

/* ---------- Share bar & MCQ statistics ---------- */
.share-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 16px 0; }
.share-label { font-weight: 700; font-size: .85rem; color: var(--ink-2); margin-right: 2px; }
.share-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-size: .85rem; font-weight: 600; text-decoration: none; }
.share-btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.share-btn.sh-wa { background: #25d366; border-color: #25d366; color: #fff; }
.share-btn.sh-fb { background: #1877f2; border-color: #1877f2; color: #fff; }
.share-btn.sh-x { background: #0f172a; border-color: #0f172a; color: #fff; }
.share-btn.sh-in { background: #0a66c2; border-color: #0a66c2; color: #fff; }
.share-btn.sh-wa:hover, .share-btn.sh-fb:hover, .share-btn.sh-x:hover, .share-btn.sh-in:hover { color: #fff; filter: brightness(1.06); }
@media (max-width: 575.98px) { .share-btn:not(.sh-copy) span { display: none; } .share-btn { width: 40px; padding: 0; justify-content: center; } .share-btn.sh-copy { width: auto; padding: 0 12px; } }
.mcq-statline { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: .86rem; margin: 10px 0 0; }
.mcq-statline .bi { margin-right: 4px; }
.mcq-stat { color: var(--ok); font-weight: 600; }

/* ---------- Discovery strip (home, sidebars) ---------- */
.discover-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); margin: 24px 0 8px; }
.discover-card { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 18px; border-radius: var(--radius); color: #fff; text-decoration: none; overflow: hidden; min-height: 150px; box-shadow: var(--shadow); }
.discover-card:hover { color: #fff; text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.discover-card .bi { font-size: 1.6rem; opacity: .95; }
.discover-card strong { font-size: 1.12rem; }
.discover-card span { opacity: .92; font-size: .92rem; line-height: 1.45; }
.discover-card em { margin-top: auto; font-style: normal; font-weight: 700; font-size: .88rem; }
.dc-quiz { background: linear-gradient(135deg, #166534, #65a30d); }
.dc-trend { background: linear-gradient(135deg, #14532d, #16a34a); }
.dc-exam { background: linear-gradient(135deg, #84cc16, #16a34a); }
.dc-test { background: linear-gradient(135deg, #10b981, #0d9488); }
.dc-sq { background: linear-gradient(135deg, #22c55e, #84cc16); }
.rank-list { list-style: none; margin: 0; padding: 0; counter-reset: rank; display: grid; gap: 8px; }
.rank-list li { counter-increment: rank; }
.rank-list a { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink-2); font-weight: 500; line-height: 1.45; }
.rank-list a::before { content: counter(rank); flex: 0 0 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: .85rem; background: var(--brand-50); color: var(--brand); }
.rank-list li:nth-child(-n+3) a::before { background: linear-gradient(135deg, #f59e0b, #ea580c); color: #fff; }
.rank-list a:hover { border-color: #bbf7d0; color: var(--brand); text-decoration: none; }
.rank-list small { display: block; color: var(--muted); font-size: .78rem; font-weight: 500; margin-top: 2px; }

/* ---------- Page heads for discovery pages ---------- */
.disc-hero { border-radius: 18px; padding: 22px; margin-bottom: 18px; color: #fff; position: relative; }
.disc-hero.is-quiz { --disc-bg: linear-gradient(135deg, #166534, #65a30d); }
.disc-hero.is-trend { --disc-bg: linear-gradient(135deg, #14532d, #16a34a); }
.disc-hero.is-exam { --disc-bg: linear-gradient(135deg, #4d7c0f, #15803d); }
/* decorative circle drawn as a background so the hero can let the autocomplete overflow */
.disc-hero { background-image: radial-gradient(circle at calc(100% + 50px) -50px, rgba(255, 255, 255, .09) 0 160px, transparent 161px), var(--disc-bg, linear-gradient(135deg, #15803d, #059669)); overflow: visible; }
.disc-hero .crumbs a, .disc-hero .crumbs li, .disc-hero .crumbs [aria-current] { color: rgba(255, 255, 255, .85); }
.disc-hero .crumbs li + li::before { color: rgba(255, 255, 255, .6); }
.disc-hero h1 { color: #fff; margin: 8px 0 6px; font-size: clamp(1.45rem, 1.2rem + 1vw, 2rem); }
.disc-hero p { color: rgba(255, 255, 255, .92); margin: 0; max-width: 70ch; }
.disc-hero .hero-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; font-size: .9rem; font-weight: 600; }
.disc-hero .btn-light { color: var(--brand); }
.tabs-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.tab-pill { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-weight: 600; font-size: .9rem; }
.tab-pill:hover { text-decoration: none; border-color: #bbf7d0; color: var(--brand); }
.tab-pill.active { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }

/* ---------- Daily quiz ---------- */
.quiz-board { position: sticky; top: calc(var(--header-h) + 8px); z-index: 50; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 12px 16px; margin-bottom: 14px; border-radius: 14px; background: rgba(255, 255, 255, .96); backdrop-filter: blur(6px); border: 1px solid var(--line); box-shadow: var(--shadow); }
.qb-stat { font-weight: 700; color: var(--ink); }
.qb-stat small { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.qb-progress { flex: 1 1 160px; height: 10px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.qb-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #f59e0b, #ea580c); border-radius: inherit; transition: width .35s ease; }
.quiz-list .mcq-card { scroll-margin-top: calc(var(--header-h) + 90px); }
.quiz-list, .ranked-list { counter-reset: qn; }
.quiz-list .mcq-card, .ranked-list .mcq-card { counter-increment: qn; }
.quiz-list .mcq-q::before, .ranked-list .mcq-q::before { content: counter(qn); display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 9px; background: linear-gradient(135deg, #f59e0b, #ea580c); color: #fff; font-weight: 800; font-size: .88rem; margin-right: 10px; vertical-align: 2px; }
.ranked-list .mcq-card:nth-child(n+4) .mcq-q::before { background: var(--brand-50); color: var(--brand); }
.quiz-list .mcq-card[dir="rtl"] .mcq-q::before, .ranked-list .mcq-card[dir="rtl"] .mcq-q::before { margin: 0 0 0 10px; }
.quiz-result { text-align: center; padding: 26px 18px; border-radius: 18px; margin: 18px 0; background: linear-gradient(135deg, #fff7ed, #fdf2f8); border: 1px solid #fed7aa; }
.quiz-result .qr-score { display: block; font-size: clamp(2.2rem, 1.8rem + 2vw, 3.2rem); font-weight: 800; letter-spacing: -.03em; color: #c2410c; }
.quiz-result .qr-msg { display: block; font-size: 1.15rem; font-weight: 700; margin: 4px 0; }
.quiz-result .qr-streak { display: inline-block; margin-top: 6px; padding: 4px 12px; border-radius: 999px; background: #fff; border: 1px solid #fdba74; font-weight: 700; color: #9a3412; }
.quiz-result .share-bar { justify-content: center; }
.countdown { font-variant-numeric: tabular-nums; }
.archive-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.archive-list a { display: block; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: .88rem; font-weight: 600; color: var(--ink-2); text-align: center; }
.archive-list a:hover, .archive-list a.active { border-color: #fdba74; color: #c2410c; background: #fff7ed; text-decoration: none; }

/* ---------- Exam index ---------- */
.exam-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); }
.exam-card { display: flex; flex-direction: column; gap: 4px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--ink); }
.exam-card:hover { border-color: #86efac; box-shadow: var(--shadow); text-decoration: none; color: var(--brand); }
.exam-card strong { font-size: 1.05rem; }
.exam-card small { color: var(--muted); }
.exam-card .bar { height: 6px; border-radius: 999px; background: var(--line-2); overflow: hidden; margin-top: 6px; }
.exam-card .bar span { display: block; height: 100%; background: linear-gradient(90deg, #84cc16, #16a34a); }

@media (max-width: 575.98px) {
  .search-big { padding-left: 10px; }
  .search-big .btn { padding: .5rem .8rem; }
  .filter-bar { padding: 10px; }
  .fb-field { flex-basis: calc(50% - 5px); }
  .quiz-board { gap: 8px 14px; padding: 10px 12px; }
}
@media print { .share-bar, .quiz-board, .filter-bar, .suggest-box { display: none !important; } }

/* ---------- Header: Explore menu ---------- */
.explore-menu { padding: 6px; min-width: 250px; }
.explore-menu .dropdown-item { display: flex; align-items: center; gap: 10px; border-radius: 8px; padding: 9px 12px; font-weight: 500; }
.explore-menu .dropdown-item .bi { color: var(--brand-600); }
.explore-menu .dropdown-item:hover { background: var(--brand-50); color: var(--brand); }
@media (max-width: 1439.98px) { .main-nav > a.nav-xl { display: none; } }
.search-compact { max-width: 620px; margin-top: 12px; box-shadow: var(--shadow-sm); border-color: var(--line); }
.search-compact input { font-size: .97rem; padding: 6px 4px; }

/* Let the home hero show the autocomplete list below its edge. */
.hero { overflow: visible; }
.hero .has-suggest, .disc-hero .has-suggest, .search-hero .has-suggest, .page-head .has-suggest { z-index: 20; }
