/* ============================================================
   Mental Arifmetika Quiz — Enhanced UI/UX Stylesheet
   Custom scrollbars · Responsive · Mobile nav · Animations
   ============================================================ */

/* ── CUSTOM SCROLLBARS (WebKit) ─────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #00B341, #1877F2);
  border-radius: 20px;
  transition: background .2s;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #007A2B, #0D5EBF);
}
::-webkit-scrollbar-corner {
  background: transparent;
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: #00B341 transparent;
}

/* ── TAB SCROLLBAR (horizontal) ─────────────────────────────── */
.tabs::-webkit-scrollbar {
  height: 3px;
}
.tabs::-webkit-scrollbar-thumb {
  background: #00B341;
  border-radius: 10px;
}
.tabs {
  scrollbar-width: thin;
  scrollbar-color: #00B341 transparent;
}

/* ── BODY SCROLL FIX ─────────────────────────────────────────── */
html {
  -webkit-overflow-scrolling: touch;
  overflow-x: hidden;
}

/* Mobile: allow body scroll */
@media (max-width: 899px) {
  html, body {
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    min-height: 100%;
  }

  .page-wrap {
    padding-bottom: 80px !important; /* space for bottom nav */
    min-height: calc(100vh - 96px);
  }

  /* Prevent horizontal overflow globally */
  .card, .rules-box, .stats-card, .answer-card {
    overflow-x: hidden;
  }
}

/* ── ENHANCED TOPBAR ─────────────────────────────────────────── */
.topbar {
  background: linear-gradient(135deg, #00B341 0%, #007A2B 100%);
  box-shadow: 0 4px 20px rgba(0, 179, 65, .35);
  border-bottom: none !important;
  position: sticky;
  top: 0;
  z-index: 50;
}

/* ── TABS ENHANCED ───────────────────────────────────────────── */
.tabs {
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
  border-bottom: none !important;
  position: sticky;
  top: 58px;
  z-index: 40;
  -ms-overflow-style: none;
}
.tabs::-webkit-scrollbar { height: 0; }

.tab {
  position: relative;
  transition: color .2s, background .2s !important;
  border-radius: 10px 10px 0 0;
  padding: 11px 14px !important;
}
.tab.active {
  color: #00B341 !important;
  background: #f0fff4;
  border-bottom-color: transparent !important;
}
.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 12px; right: 12px;
  height: 3px;
  background: linear-gradient(90deg, #00B341, #1877F2);
  border-radius: 3px 3px 0 0;
}
.tab:hover:not(.active) {
  background: #f8f8f8;
  color: #555;
}

/* ── CARDS ENHANCED ──────────────────────────────────────────── */
.card {
  border-radius: 20px !important;
  box-shadow: 0 4px 16px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06) !important;
  border: 2px solid rgba(0,0,0,.07) !important;
  transition: box-shadow .2s, transform .15s;
}
.card:hover {
  box-shadow: 0 8px 28px rgba(0,0,0,.12), 0 2px 6px rgba(0,0,0,.08) !important;
}

/* ── LAUNCH BUTTON ENHANCED ──────────────────────────────────── */
.launch-btn {
  background: linear-gradient(135deg, #1877F2, #0D5EBF) !important;
  border: none !important;
  box-shadow: 0 8px 24px rgba(24,119,242,.4), 0 2px 0 rgba(0,0,0,.15) inset !important;
  border-radius: 18px !important;
  transition: all .2s !important;
  position: relative;
  overflow: hidden;
}
.launch-btn::before {
  content: '';
  position: absolute;
  top: -50%; left: -60%;
  width: 35%; height: 200%;
  background: rgba(255,255,255,.2);
  transform: skewX(-20deg);
  transition: left .4s;
}
.launch-btn:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 12px 32px rgba(24,119,242,.5) !important;
}
.launch-btn:hover::before { left: 120%; }
.launch-btn:active {
  transform: translateY(1px) !important;
  box-shadow: 0 4px 12px rgba(24,119,242,.3) !important;
}

/* ── BUTTONS GLOBAL POLISH ───────────────────────────────────── */
.ok-btn, .repeat-btn {
  border: none !important;
  box-shadow: 0 6px 18px rgba(0,179,65,.35) !important;
  border-radius: 16px !important;
  transition: all .2s !important;
}
.ok-btn:hover, .repeat-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}
.ok-btn:active, .repeat-btn:active {
  transform: translateY(1px) !important;
}

/* ── INPUT FIELDS ────────────────────────────────────────────── */
.answer-input {
  border-radius: 16px !important;
  border: 3px solid #e0e0e0 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.06) inset !important;
  transition: border-color .2s, box-shadow .2s !important;
}
.answer-input:focus {
  border-color: #1877F2 !important;
  box-shadow: 0 0 0 4px rgba(24,119,242,.12) inset !important;
}

/* ── SLIDERS ─────────────────────────────────────────────────── */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  height: 8px !important;
  background: linear-gradient(90deg, #00B341 var(--pct, 0%), #e0e0e0 var(--pct, 0%));
  border-radius: 10px;
  cursor: pointer;
  transition: background .1s;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  background: #fff;
  border: 3px solid #00B341;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,179,65,.4);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 3px 12px rgba(0,179,65,.5);
}
input[type=range]::-moz-range-thumb {
  width: 20px; height: 20px;
  background: #fff;
  border: 3px solid #00B341;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,179,65,.3);
}
input[type=range]::-moz-range-progress {
  background: #00B341;
  border-radius: 10px;
  height: 8px;
}

/* ── STATS BARS ──────────────────────────────────────────────── */
.stats-pct-bar, .progress-row {
  border-radius: 20px !important;
  border: none !important;
  background: #eee !important;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.08) inset;
}
.stats-pct-fill, .progress-fill {
  background: linear-gradient(90deg, #00B341, #1877F2) !important;
  box-shadow: 0 0 8px rgba(0,179,65,.4);
}

/* ── MAIN LANDING SCROLL FIX ─────────────────────────────────── */
#mainLanding {
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 899px) {
  #mainLanding {
    overflow-y: auto;
    max-height: none !important;
    height: auto !important;
  }
}

/* ── MASHQ PAGE SCROLL (mobile) ──────────────────────────────── */
@media (max-width: 899px) {
  #mainMashq {
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 100px;
  }
  #mashq-left, #mashq-right {
    overflow: visible !important;
  }
}

/* ── PDF/DARS/KABINET SCROLL ─────────────────────────────────── */
#mainPdf, #mainDars, #mainKabinet, #mainAdmin, #mainOyin {
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 899px) {
  #mainPdf, #mainDars, #mainKabinet, #mainAdmin, #mainOyin {
    overflow-y: auto !important;
    height: auto !important;
    max-height: none !important;
    padding-bottom: 80px;
  }
}

/* ── PAGE TRANSITION ANIMATION ───────────────────────────────── */
.page-wrap {
  animation: pageIn .25s ease;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── LAYER (FULLSCREEN OVERLAYS) ─────────────────────────────── */
.layer {
  -webkit-overflow-scrolling: touch;
}
.layer.active {
  display: flex;
  animation: layerIn .2s ease;
}
@keyframes layerIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── TABLET LAYOUT (600-899px) ───────────────────────────────── */
@media (min-width: 600px) and (max-width: 899px) {
  .page-wrap {
    max-width: 680px !important;
    padding: 16px 24px 90px !important;
  }

  #mainMashq {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 12px;
    padding: 14px 24px 90px;
    background: var(--bg);
  }
  #mashq-right { order: 0 !important; }
  #mashq-left  { order: 0 !important; }

  .op-tabs { flex-wrap: wrap; }
  .stats-card, .answer-card { max-width: 500px !important; }
}

/* ── MOBILE BOTTOM NAVIGATION ────────────────────────────────── */
#mobileBottomNav {
  display: none;
}

@media (max-width: 599px) {
  #mobileBottomNav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 64px;
    background: #fff;
    border-top: 1px solid rgba(0,0,0,.08);
    box-shadow: 0 -8px 30px rgba(0,0,0,.12);
    z-index: 45;
    align-items: stretch;
    padding: 0;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    background: rgba(255,255,255,.95);
  }

  .mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: none;
    cursor: pointer;
    color: #aaa;
    font-family: 'Nunito', sans-serif;
    font-size: 10px;
    font-weight: 700;
    transition: color .2s, background .2s;
    padding: 6px 2px;
    border-radius: 0;
    position: relative;
  }
  .mobile-nav-btn .nav-icon {
    font-size: 22px;
    line-height: 1;
    transition: transform .2s;
  }
  .mobile-nav-btn .nav-label {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .3px;
    white-space: nowrap;
  }
  .mobile-nav-btn.active {
    color: #00B341;
  }
  .mobile-nav-btn.active .nav-icon {
    transform: translateY(-3px) scale(1.15);
  }
  .mobile-nav-btn.active::before {
    content: '';
    position: absolute;
    top: 0; left: 20%; right: 20%;
    height: 3px;
    background: linear-gradient(90deg, #00B341, #1877F2);
    border-radius: 0 0 4px 4px;
  }
  .mobile-nav-btn:active {
    background: rgba(0,179,65,.06);
  }

  /* Hide top tab bar on mobile */
  .tabs {
    display: none !important;
  }

  /* Adjust topbar for mobile */
  .topbar {
    top: 0;
  }

  /* Extra bottom padding for bottom nav */
  .page-wrap {
    padding-bottom: 90px !important;
  }

  #mainMashq {
    padding-bottom: 90px !important;
  }
}

/* ── SMALL PHONE (<=380px) ───────────────────────────────────── */
@media (max-width: 380px) {
  .logo { font-size: 17px !important; }
  .topbar-right { gap: 6px !important; }
  .lang-select { font-size: 10px !important; padding: 3px 5px !important; }
  .auth-topbar-btn { font-size: 10px !important; padding: 4px 8px !important; }

  .card { padding: 14px !important; border-radius: 16px !important; }
  .section-title { font-size: 17px !important; }
  .launch-btn { font-size: 18px !important; padding: 13px !important; }
  .answer-input { font-size: 40px !important; }
}

/* ── AUTH MODAL ENHANCED ─────────────────────────────────────── */
.auth-modal-box {
  border: none !important;
  box-shadow: 0 24px 80px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.15) !important;
  border-radius: 28px !important;
  padding: 36px 28px !important;
}
.auth-modal-btns a,
.auth-modal-btns button {
  border: none !important;
  box-shadow: none !important;
  border-radius: 14px !important;
  font-size: 15px !important;
  transition: all .2s !important;
}
.btn-register {
  background: linear-gradient(135deg, #00B341, #007A2B) !important;
  box-shadow: 0 6px 20px rgba(0,179,65,.35) !important;
}
.btn-register:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(0,179,65,.45) !important;
}
.btn-login {
  background: linear-gradient(135deg, #1877F2, #0D5EBF) !important;
  box-shadow: 0 6px 20px rgba(24,119,242,.3) !important;
}
.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(24,119,242,.4) !important;
}

/* ── RULE TOGGLES / OP-BTNS HOVER ───────────────────────────── */
.op-btn:hover:not(.op-add):not(.op-mul):not(.op-div) {
  background: #f5f5f5;
  transform: translateY(-1px);
}
.rule-toggle:hover:not(.active):not(.active-free) {
  background: #f5f5f5;
  transform: translateY(-1px);
}
.digit-btn:hover:not(.active) {
  background: #f0fff4;
  border-color: #00B341;
  color: #007A2B;
}

/* ── METER / SPEEDOMETER ─────────────────────────────────────── */
.meter-box svg {
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.12));
}

/* ── METHOD CARDS ────────────────────────────────────────────── */
.method-card {
  transition: transform .15s, box-shadow .15s !important;
}
.method-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,.12) !important;
}

/* ── INNER TABS ──────────────────────────────────────────────── */
.inner-tabs {
  background: rgba(0,0,0,.04) !important;
  border-radius: 14px !important;
  padding: 4px !important;
}
.inner-tab.active {
  background: #fff !important;
  box-shadow: 0 3px 12px rgba(0,0,0,.12) !important;
  color: #007A2B !important;
}

/* ── CONFETTI / STAR BURST ───────────────────────────────────── */
.confetti-p {
  border-radius: 4px;
}

/* ── PC (900px+) SCROLLBAR REFINEMENTS ──────────────────────── */
@media (min-width: 900px) {
  #mashq-left .card::-webkit-scrollbar { width: 5px; }
  #mashq-left .card::-webkit-scrollbar-track { background: transparent; }
  #mashq-left .card::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #00B34166, #1877F266);
    border-radius: 10px;
  }
  #mashq-left .card::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #00B341, #1877F2);
  }

  #mashq-right::-webkit-scrollbar { width: 5px; }
  #mashq-right::-webkit-scrollbar-track { background: transparent; }
  #mashq-right::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #00B34166, #1877F266);
    border-radius: 10px;
  }

  #mainPdf::-webkit-scrollbar,
  #mainLanding::-webkit-scrollbar,
  #mainOyin::-webkit-scrollbar,
  #mainDars::-webkit-scrollbar,
  #mainKabinet::-webkit-scrollbar,
  #mainAdmin::-webkit-scrollbar {
    width: 6px;
  }
  #mainPdf::-webkit-scrollbar-thumb,
  #mainLanding::-webkit-scrollbar-thumb,
  #mainOyin::-webkit-scrollbar-thumb,
  #mainDars::-webkit-scrollbar-thumb,
  #mainKabinet::-webkit-scrollbar-thumb,
  #mainAdmin::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #00B341, #1877F2);
    border-radius: 10px;
  }

  /* Sidebar areas */
  .layer::-webkit-scrollbar { width: 5px; }
  .layer::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.3);
    border-radius: 10px;
  }
}

/* ── SMOOTH SCROLL EVERYWHERE ────────────────────────────────── */
html {
  scroll-behavior: smooth;
}

/* ── TOUCH DEVICE IMPROVEMENTS ───────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  /* Larger tap targets on touch */
  .tab { padding: 13px 14px !important; min-width: 60px; }
  .rule-toggle { padding: 10px 16px; }
  .op-btn { padding: 12px 6px !important; }
  .digit-btn { height: 44px !important; }
  input[type=range]::-webkit-slider-thumb { width: 24px; height: 24px; }

  /* Remove hover effects that look bad on touch */
  .card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06) !important; }

  /* Better tap feedback */
  .op-btn:active, .rule-toggle:active, .digit-btn:active {
    opacity: .75;
  }
}

/* ── PRINT HIDE ──────────────────────────────────────────────── */
@media print {
  .topbar, .tabs, #mobileBottomNav, #authGateModal { display: none !important; }
  .page-wrap { padding: 0 !important; }
}
