:root{
  --card:#ffffff;
  --text:#233044;
  --muted:#64748b;
  --blue:#2563eb;
  --sky:#0ea5e9;
  --purple:#7c3aed;
  --green:#16a34a;
  --border:#dbeafe;
  --soft:#eef6ff;
  --shadow:0 14px 34px rgba(37,99,235,.10);
  --radius:18px;
}

*{
  box-sizing:border-box;
  margin:0;
  padding:0;
}

html{
  scroll-behavior:smooth;
}

body{
  font-family:Arial, Helvetica, sans-serif;
  background:linear-gradient(135deg,#eff6ff,#f8fafc,#ecfeff);
  color:var(--text);
  line-height:1.7;
  overflow-x:hidden;
}

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


/* ===== Top Bar===== */
.top-alert{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  flex-wrap:wrap;
  width:100%;
  padding:8px 12px;
  margin-bottom:10px;
  border-radius:14px;
  background:linear-gradient(135deg,var(--blue),var(--sky));
  color:#fff;
  font-size:13px;
  font-weight:700;
  text-align:center;
}

.top-alert strong,
.top-alert em{
  background:rgba(255,255,255,.18);
  padding:4px 9px;
  border-radius:999px;
  font-style:normal;
  white-space:nowrap;
}

.top-alert a{
  color:#fff;
  text-decoration:underline;
  font-weight:900;
  white-space:nowrap;
}

@media (max-width:760px){
  .top-alert{
    font-size:11px;
    gap:6px;
    padding:7px 8px;
  }
}

/* ===== TOP HEADER (LOGO + NAV) ===== */

.top-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:20px;
  margin-bottom:18px;
}

/* LOGO */
.logo-wrap{
  display:flex;
  align-items:center;
}

.site-logo{

  min-width:200px;
 
  min-height:150px;
  object-fit:contain;
}

/* NAVBAR DESKTOP */
/* ===== COMPACT NAVBAR ===== */

.top-nav{
  display:flex;
  align-items:center;
  gap:6px;
   padding:6px 10px;                 /* spacing */
  border-radius:14px;

  background:linear-gradient(135deg,#ffffff,#eef6ff);  /* clean background */
  border:1px solid var(--border);

  box-shadow:0 8px 20px rgba(0,0,0,.08);
}

.top-nav a{
  font-size:11px;        /* smaller text */
  font-weight:800;

  padding:3px 8px;       /* LESS HEIGHT */
  line-height:1.1;       /* tighter */

  border-radius:999px;
  background:var(--soft);
  border:1px solid var(--border);
  color:var(--blue);
}

/* ===== TOGGLE ===== */

.menu-toggle{
  position:absolute;
  left:-9999px;
}

.menu-btn{
  display:none;
}

/* ===== MOBILE / TABLET ===== */

@media (max-width:1150px){

    .menu-btn{
    display:flex;
    align-items:center;
    justify-content:center;
    width:34px;
    height:34px;
    font-size:18px;
    font-weight:900;
    background:var(--blue);
    color:#fff;
    border-radius:8px;
    cursor:pointer;
  }

  .top-nav{
    display:none;
    position:absolute;
    top:105px;
    right:12px;
    width:185px;

    flex-direction:column;
    align-items:stretch;

    padding:8px;

    background:linear-gradient(135deg,#ffffff,#eef6ff);
    border:1px solid var(--border);
    border-radius:12px;

    box-shadow:0 10px 24px rgba(0,0,0,.18);

    z-index:99999;
  }

  .top-nav a{
    font-size:11px;
    font-weight:800;

    padding:5px 8px;
    margin-bottom:3px;

    border-radius:8px;
    color:var(--blue);
    background:transparent;
  }

  .top-nav a:hover{
    background:var(--soft);
    border:1px solid var(--border);
  }

  .top-nav a:last-child{
    margin-bottom:0;
  }

  /* RED CLOSE BUTTON */
  .menu-close{
    display:block;
    text-align:right;
    font-size:16px;
    font-weight:900;
    color:red;
    cursor:pointer;
    margin-bottom:6px;
  }

  /* OPEN MENU */
  #menuToggle:checked ~ .top-nav{
    display:flex;
  }
}
/* ===== MOBILE ===== */

@media (max-width:760px){

 

  .top-nav{
    top:160px;
    right:14px;
  }
}



/* ===== REQUIRED HTML TOGGLE INPUTS ===== */
.side-toggle,
.night-toggle,
.chapter-more-toggle,
.menu-toggle{
  position:fixed;
  left:-9999px;
}

/* ===== LEFT / RIGHT VISIBLE ARROW TABS ===== */
.side-tab{
  position:fixed;
  top:50%;
  transform:translateY(-50%);
  width:28px;
  height:58px;
  display:none;
  align-items:center;
  justify-content:center;
  color:#fff;
  font-size:24px;
  font-weight:900;
  z-index:9999999;
  cursor:pointer;
  box-shadow:0 8px 18px rgba(0,0,0,.28);
  
   touch-action:manipulation;
  user-select:none;
   
}

.left-tab{
  left:0;
  background:linear-gradient(135deg,var(--blue),var(--sky));
  border-radius:0 12px 12px 0;
}

.right-tab{
  right:0;
  background:linear-gradient(135deg,var(--purple),var(--blue));
  border-radius:12px 0 0 12px;
}

.left-tab::before{
  content:"›";
}

.right-tab::before{
  content:"‹";
}

#chaptersToggle:checked + .left-tab::before{
  content:"‹";
}

#subtopicsToggle:checked + .right-tab::before{
  content:"›";
}

/* ===== NIGHT BUTTON ===== */
.night-btn{
  position:fixed;
  top:14px;
  right:14px;
  z-index:10000;
  background:#111827;
  color:#fff;
  padding:9px 14px;
  border-radius:999px;
  font-size:13px;
  font-weight:800;
  cursor:pointer;
  box-shadow:0 10px 20px rgba(0,0,0,.18);
}

body:has(.night-toggle:checked){
  --card:#111827;
  --text:#e5e7eb;
  --muted:#cbd5e1;
  --border:#334155;
  --soft:#1e293b;
  background:#020617;
}

/* ===== MAIN PAGE ===== */
.math-wrap{
  width:min(100% - 20px, 1440px);
  margin:auto;
  padding:18px 0 40px;
}

.math-hero{
  background:linear-gradient(135deg,var(--blue),var(--sky),var(--purple));
  color:#fff;
  border-radius:var(--radius);
  padding:34px 22px;
  box-shadow:var(--shadow);
  margin-bottom:18px;
}

.math-kicker{
  display:inline-flex;
  background:rgba(255,255,255,.18);
  border:1px solid rgba(255,255,255,.28);
  border-radius:999px;
  padding:6px 12px;
  font-size:13px;
  font-weight:800;
  margin-bottom:12px;
}

.math-hero h1{
  font-size:clamp(30px,5vw,54px);
  line-height:1.12;
  margin-bottom:12px;
}

.math-subtitle{
  max-width:900px;
  font-size:clamp(16px,2vw,20px);
}

.math-meta{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-top:18px;
}

.math-meta span{
  background:rgba(255,255,255,.16);
  border:1px solid rgba(255,255,255,.28);
  border-radius:999px;
  padding:7px 12px;
  font-size:13px;
  font-weight:800;
}

/* ===== DESKTOP LAYOUT ===== */
.math-layout{
  display:grid;
  grid-template-columns:300px minmax(0,1fr) 230px;
  gap:18px;
  align-items:start;
}

.math-sidebar,
.math-main,
.toc-sidebar{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
}

.math-sidebar{
  position:sticky;
  top:16px;
  padding:16px;
  max-height:calc(100vh - 32px);
  overflow:auto;
}

.toc-sidebar{
  position:sticky;
  top:16px;
  padding:16px;
}

.math-main{
  padding:16px;
  min-width:0;
}

/* ===== SIDEBAR CONTENT ===== */
.side-title{
  background:linear-gradient(135deg,#eff6ff,#ecfeff);
  border:1px solid var(--border);
  border-radius:16px;
  padding:14px;
  margin-bottom:14px;
}

body:has(.night-toggle:checked) .side-title{
  background:#1e293b;
}

.side-title small,
.side-title span{
  display:block;
  color:var(--muted);
  font-size:12px;
}

.side-title strong{
  display:block;
  font-size:20px;
  color:var(--blue);
  margin:3px 0;
}

.math-sidebar h2,
.toc-sidebar h2{
  font-size:18px;
  margin-bottom:10px;
}

.chapter-list{
  list-style:none;
  display:grid;
  gap:8px;
}

.chapter-list a{
  display:grid;
  grid-template-columns:54px 1fr;
  gap:8px;
  align-items:center;
  padding:10px;
  border:1px solid var(--border);
  border-radius:14px;
  background:var(--soft);
  transition:.2s ease;
}

.chapter-list a:hover,
.chapter-list a.active{
  transform:translateY(-1px);
  border-color:var(--blue);
  background:#dbeafe;
}

body:has(.night-toggle:checked) .chapter-list a:hover,
body:has(.night-toggle:checked) .chapter-list a.active{
  background:#1d4ed8;
}

.chapter-list span{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:34px;
  border-radius:12px;
  background:#fff;
  color:var(--blue);
  font-size:12px;
  font-weight:900;
}

.chapter-list b{
  font-size:13px;
  line-height:1.25;
}

.hidden-chapter{
  display:none;
}

#chapterMoreToggle:checked ~ .chapter-list .hidden-chapter{
  display:list-item;
}

.show-more-label{
  display:inline-flex;
  justify-content:center;
  align-items:center;
  background:linear-gradient(135deg,var(--blue),var(--sky));
  color:#fff;
  border-radius:999px;
  padding:10px 14px;
  margin-top:12px;
  font-weight:900;
  cursor:pointer;
  width:100%;
}

.less-text{
  display:none;
}

#chapterMoreToggle:checked ~ .show-more-label .more-text{
  display:none;
}

#chapterMoreToggle:checked ~ .show-more-label .less-text{
  display:inline;
}

/* ===== RIGHT SUBTOPICS ===== */
.toc-sidebar a{
  display:block;
  padding:10px;
  border-radius:12px;
  color:var(--blue);
  font-weight:900;
  border:1px solid transparent;
  font-size:13px;
}

.toc-sidebar a:hover{
  background:var(--soft);
  border-color:var(--border);
}

/* ===== CONTENT ===== */
.chapter-nav-bar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px;
  border-radius:14px;
  background:var(--soft);
  border:1px solid var(--border);
  margin-bottom:14px;
}

.chapter-nav-bar span{
  font-size:13px;
  font-weight:900;
  color:var(--muted);
  text-align:center;
}

.nav-btn{
  background:#fff;
  border:1px solid var(--border);
  color:var(--blue);
  padding:8px 12px;
  border-radius:999px;
  font-weight:900;
  font-size:13px;
}

.nav-btn.disabled{
  opacity:.55;
  pointer-events:none;
}

.chapter-ad{
  border:1px dashed #93c5fd;
  background:#f8fafc;
  border-radius:14px;
  min-height:110px;
  padding:10px;
  display:grid;
  place-items:center;
  color:var(--muted);
  margin-bottom:14px;
}

body:has(.night-toggle:checked) .chapter-ad{
  background:#0f172a;
}

.content-card{
  border:1px solid var(--border);
  border-radius:var(--radius);
  background:var(--card);
  padding:clamp(16px,2vw,24px);
  margin-bottom:14px;
}

.content-card h2{
  color:var(--blue);
  font-size:clamp(24px,3vw,34px);
  line-height:1.2;
  margin-bottom:10px;
}

.content-card h3{
  color:var(--purple);
  font-size:20px;
  margin:16px 0 6px;
}

.content-card p{
  margin:8px 0;
}

.subchapter-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:10px;
  margin-top:12px;
}

.subchapter-grid a{
  background:var(--soft);
  border:1px solid var(--border);
  border-radius:14px;
  padding:12px;
  color:var(--blue);
  font-weight:900;
}

.example-box,
.rule-box{
  background:linear-gradient(135deg,#eff6ff,#ecfeff);
  border-left:5px solid var(--blue);
  border-radius:14px;
  padding:14px;
  margin:14px 0;
}

body:has(.night-toggle:checked) .example-box,
body:has(.night-toggle:checked) .rule-box{
  background:#1e293b;
}

.rule-box ul{
  padding-left:20px;
}

.number-line{
  display:grid;
  grid-template-columns:repeat(11,1fr);
  gap:4px;
  background:var(--soft);
  border:1px solid var(--border);
  border-radius:16px;
  padding:12px;
  margin:14px 0;
  text-align:center;
  font-weight:900;
}

.number-line span{
  background:#fff;
  color:var(--blue);
  border-radius:10px;
  padding:8px 4px;
  border:1px solid var(--border);
}

.practice-list{
  padding-left:24px;
}

.practice-list li{
  padding:10px 0;
  border-bottom:1px solid var(--border);
}

.answer{
  display:block;
  margin-top:4px;
  font-weight:900;
  color:var(--green);
}

/* ===== TABLET + MOBILE REAL TOGGLE SIDE PANELS ===== */
@media (max-width:1150px){

  .side-tab{
    display:flex;
  }

  .math-layout{
    display:block;
  }

  .math-main{
    width:100%;
    padding:14px;
  }

  .math-sidebar{
    position:fixed;
    top:0;
    left:0;
    width:290px;
    max-width:84vw;
    height:100vh;
    max-height:100vh;
    overflow:auto;
    z-index:999999;
    border-radius:0 18px 18px 0;
    transform:translateX(-100%);
    transition:transform .28s ease;
    font-size:12px;
  }

  .toc-sidebar{
    position:fixed;
    top:24%;
    right:0;
    width:220px;
    max-width:78vw;
    max-height:54vh;
    overflow:auto;
    z-index:999999;
    border-radius:18px 0 0 18px;
    transform:translateX(100%);
    transition:transform .28s ease;
    padding:12px;
    font-size:12px;
  }

  .toc-sidebar h2{
    font-size:14px;
    margin-bottom:6px;
  }

  .toc-sidebar a{
    font-size:12px;
    padding:7px;
    line-height:1.25;
  }

  .chapter-list a{
    padding:8px;
    grid-template-columns:46px 1fr;
  }

  .chapter-list span{
    font-size:11px;
    min-height:30px;
  }

  .chapter-list b{
    font-size:12px;
  }

  #chaptersToggle:checked ~ .math-wrap .math-sidebar{
    transform:translateX(0);
  }

  #subtopicsToggle:checked ~ .math-wrap .toc-sidebar{
    transform:translateX(0);
  }

  #chaptersToggle:checked + .left-tab{
    left:290px;
  }

  #subtopicsToggle:checked + .right-tab{
    right:220px;
  }

  .subchapter-grid{
    grid-template-columns:1fr;
  }
}

/* ===== SMALL PHONES ===== */
@media (max-width:760px){

  .math-wrap{
    width:100%;
    padding:10px;
  }

  .math-hero{
    padding:28px 16px;
  }

  .math-main{
    padding:10px;
  }

  .math-sidebar{
    width:260px;
  }

  .toc-sidebar{
    width:200px;
    top:26%;
    max-height:50vh;
  }

  .side-tab{
    width:24px;
    height:48px;
    font-size:20px;
    /* page not  jump */
    touch-action: manipulation;
  }

  #chaptersToggle:checked + .left-tab{
    left:260px;
  }

  #subtopicsToggle:checked + .right-tab{
    right:200px;
  }

  .chapter-nav-bar{
    flex-direction:column;
  }

  .number-line{
    font-size:12px;
    gap:2px;
    padding:8px;
  }

  .number-line span{
    padding:6px 2px;
  }

  .night-btn{
    top:auto;
    bottom:14px;
  }
}

/* ===== FOOTER FINAL FIXED ===== */

.site-footer{
  margin-top:40px;
  padding:20px 30px;
  background:#0f172a;
  color:#ccc;
  border-radius:18px;
  position:relative;
  z-index:10;
  text-align:center;
  font-size:11px;
}

/* Animated Brand */
.brand{
  font-weight:bold;
  position:relative;
  display:inline-block;
  overflow:hidden;
  background:linear-gradient(90deg,#00c6ff,#0072ff,#6a11cb,#00c6ff);
  background-size:300%;
  -webkit-background-clip:text;
  background-clip:text;
  -webkit-text-fill-color:transparent;
  animation:gradientMove 6s linear infinite;
}

@keyframes gradientMove{
  0%{background-position:0%;}
  100%{background-position:300%;}
}

.brand::after{
  content:"";
  position:absolute;
  top:0;
  left:-75%;
  width:50%;
  height:100%;
  background:linear-gradient(120deg,transparent,rgba(255,255,255,.6),transparent);
  transform:skewX(-20deg);
  animation:shine 3s infinite;
}

@keyframes shine{
  0%{left:-75%;}
  100%{left:125%;}
}

/* LOGO TOP */
.footer-top{
  display:flex;
  justify-content:center;
  align-items:center;
  margin-bottom:16px;
}

.footer-brand{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  color:#fff;
  font-weight:900;
  font-size:16px;
}

.footer-brand img{
  width:120px;
  height:80px;
  border-radius:8px;
  object-fit:contain;
  background:#fff;
  padding:4px;
  box-shadow:0 6px 16px rgba(0,0,0,.25);
  transition:.2s;
}

.footer-brand:hover img{
  transform:translateY(-2px);
}

/* GRID */
.footer-grid{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:10px;
}

.footer-col h3{
  font-size:14px;
  margin-bottom:8px;
}

.footer-col a{
  display:block;
  font-size:12px;
  margin-bottom:4px;
  color:#cbd5e1;
  line-height:1.3;
  text-decoration:none;
}

.footer-col a:hover{
  color:#fff;
}

/* SVG SOCIAL */
.footer-social{
  display:flex;
  justify-content:center;
  flex-wrap:wrap;
  gap:10px;
  margin-top:18px;
}

.footer-social a{
  width:34px;
  height:34px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:#1e293b;
  border-radius:8px;
  transition:.2s;
}

.footer-social svg{
  width:16px;
  height:16px;
  fill:#fff;
}

.footer-social a:hover{
  transform:translateY(-2px);
}

/* COPYRIGHT */
.footer-bottom{
  margin-top:16px;
  text-align:center;
}

.footer-copy{
  font-size:14px;
  color:#94a3b8;
}

/* TABLET */
@media (max-width:900px){
  .footer-grid{
    grid-template-columns:repeat(2,1fr);
  }
}

/* MOBILE */
@media (max-width:600px){
  .site-footer{
    padding:16px 10px;
  }

  .footer-grid{
    grid-template-columns:repeat(3,1fr);
    gap:8px;
  }

  .footer-brand{
    font-size:13px;
  }

  .footer-brand img{
    width:36px;
    height:36px;
  }

  .footer-col h3{
    font-size:11px;
    margin-bottom:5px;
  }

  .footer-col a{
    font-size:10px;
    margin-bottom:3px;
  }

  .footer-social a{
    width:30px;
    height:30px;
  }

  .footer-social svg{
    width:14px;
    height:14px;
  }

  .footer-copy{
    font-size:11px;
  }
}



/* GO TO TOP BUTTON */
#goTopBtn{
  position:fixed;
  bottom:80px;
  right:20px;
  z-index:999;
  width:42px;
  height:42px;
  border:none;
  border-radius:10px;
  background:linear-gradient(135deg,#00c6ff,#0072ff);
  color:#fff;
  font-size:18px;
  cursor:pointer;
  display:none;
  box-shadow:0 6px 18px rgba(0,0,0,.3);
  transition:.3s;
}

/* hover effect */
#goTopBtn:hover{
  transform:translateY(-3px) scale(1.05);
}

/* show animation */
#goTopBtn.show{
  display:block;
  animation:fadeInUp .4s ease;
}

@keyframes fadeInUp{
  from{
    opacity:0;
    transform:translateY(20px);
  }
  to{
    opacity:1;
    transform:translateY(0);
  }
}

