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

html{
  scroll-behavior:smooth;
  max-width:100%;
  overflow-x:hidden;
  margin-top:0 !important; /* prevent Google Translate shift */
}

body{
  font-family:Arial, sans-serif;
  background:linear-gradient(180deg,#f0f4f8,#ffffff);
  color:#1f2937;
  line-height:1.7;
  overflow-x:hidden;
  max-width:100%;
  transition:background .3s ease, color .3s ease;
  top:0 !important;
  position:static !important; /* prevent Google Translate layout jump */
}

body.dark-mode{
  background:linear-gradient(180deg,#0f172a,#111827);
  color:#e5e7eb;
}

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

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

/* =========================================================
   LOGO / TOP LOGO BAR
========================================================= */
.header{
  position:sticky;
  top:0;
  /* z-index:9998; */
  display:flex;
  align-items:center;
  justify-content:flex-start;
  background:rgba(255,255,255,.92);
  backdrop-filter:blur(14px);
  border-bottom:1px solid rgba(148,163,184,.14);
  padding:0 12px;     /*  remove top/bottom padding */
}

.header .logo{
  display:flex;
  flex-direction:column; /* text under logo */
  align-items:flex-start;
  text-decoration:none;
  line-height:1;
  gap:2px;
}

.header .logo-image{
    /* Small screens → 140px
    Medium → scales with screen
    Large → max 260px */
  width:clamp(140px, 20vw, 260px); /* responsive width */
  height:auto;
  aspect-ratio:3 / 1;              /* keep shape */
  height:100px;
  display:block;
  flex-shrink:0;
}

.header .logo-image img{
  width:100%;
  height:100%;
  object-fit:contain;
  display:block;
}

.header .logo-text{
  display:flex;
  flex-direction:column;
  text-align:left;
  line-height:1.1;
  margin:0;
}

.header .logo-text strong{
  font-size:18px;
  font-weight:800;
  color:#2563eb;
}

.header .logo-text span{
  font-size:12px;
  color:#666;
}

/* =========================================================
   BACKGROUND DECOR
========================================================= */
.bg-decor{
  position:fixed;
  inset:0;
  overflow:hidden;
  z-index:-1;
  pointer-events:none;
}

.blob{
  position:absolute;
  border-radius:50%;
  filter:blur(80px);
  opacity:.22;
}

.b1{
  width:260px;
  height:260px;
  background:#38bdf8;
  top:60px;
  left:-70px;
}

.b2{
  width:300px;
  height:300px;
  background:#60a5fa;
  top:35%;
  right:-90px;
}

.b3{
  width:240px;
  height:240px;
  background:#a5b4fc;
  bottom:30px;
  left:25%;
}

/* =========================================================
   ACCESSIBILITY
========================================================= */
.skip-link{
  position:absolute;
  left:-9999px;
  top:auto;
}

.skip-link:focus{
  left:20px;
  top:20px;
  background:#111827;
  color:#fff;
  padding:10px 14px;
  border-radius:8px;
  z-index:9999;
}

/* =========================================================
   ANNOUNCEMENT BAR
========================================================= */
.announcement-bar{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  flex-wrap:wrap;
  padding:10px 16px;
  background:linear-gradient(90deg,#f1f5f9,#e2e8f0);
  border-bottom:1px solid rgba(0,0,0,.05);
  font-size:14px;
  text-align:center;
  position:relative;
  overflow:hidden;
  z-index:999;
}

.badge{
  background:linear-gradient(135deg,#f59e0b,#f97316);
  color:#fff;
  padding:4px 10px;
  border-radius:999px;
  font-weight:700;
  font-size:12px;
  display:inline-flex;
  align-items:center;
  gap:5px;
}

.announcement-bar p{
  margin:0;
  color:#111;
  font-weight:500;
}

.announcement-bar a{
  color:#2563eb;
  font-weight:800;
  font-size:16px;
}

/* =========================================================
   MAIN HEADER / NAV
========================================================= */
header{
  position:sticky;
  top:0;
  z-index:1000;
  background:rgba(255,255,255,.95);
  backdrop-filter:blur(12px);
  border-bottom:1px solid #e5e7eb;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  padding:12px 20px;
  min-height:auto;
}

body.dark-mode header{
  background:rgba(17,24,39,.95);
  border-bottom:1px solid rgba(255,255,255,.08);
}

.main-nav{
  display:flex;
  align-items:center;
}

.nav-links{
  list-style:none;
  display:flex;
  gap:18px;
  flex-wrap:wrap;
  align-items:center;
}

.nav-links li a{
  color:#1f2937;
  font-weight:600;
  transition:.3s ease;
}

body.dark-mode .nav-links li a{
  color:#e5e7eb;
}

.nav-links li a:hover{
  color:#2563eb;
}

/* =========================================================
   MOBILE MENU / SIDEBAR
========================================================= */
.menu-toggle{
  display:none;
  /* Remove outer space */
  margin:0;
   /* Remove inner space */
  padding:0;
  width:40px;
  height:40px;
  border-radius:50%;
  background:#2563eb;
  color:#fff;
   align-items:center;
  justify-content:center;
  cursor:pointer;
  box-shadow:0 10px 25px rgba(37,99,235,.25);
  border:none;
  flex-shrink:0;    /* Prevent shrinking */
   /* Smooth hover effect */
  transition:all .2s ease;
   /* Prevent mobile tap highlight */
  -webkit-tap-highlight-color:transparent;
               /* remove outer space */
  padding:0;             /*  remove inner space */
  margin-left:auto; /* push to right */
}

/* Smaller hamburger icon */
.menu-toggle i{
  font-size:14px;   /*  reduce size */
  margin:0;
  padding:0;
  line-height:1;         /*  prevent vertical stretch */
}

.sidebar{
  position:fixed;
  top:0;
  right:-320px;
  width:300px;
  height:100vh;
  background:#111827;
  color:#fff;
  padding:24px 20px;
  transition:.35s ease;
  z-index:2000;
  overflow-y:auto;
  box-shadow:-10px 0 30px rgba(0,0,0,.25);
}

.sidebar.active{
  right:0;
}

.close-btn{
  width:46px;
  height:46px;
  border-radius:50%;
  background:#2563eb;
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
  margin-left:auto;
  margin-bottom:22px;
  cursor:pointer;
  font-size:1.2rem;
}

.sidebar ul{
  list-style:none;
  margin-bottom:24px;
}

.sidebar ul li{
  margin-bottom:14px;
}

.sidebar ul li a{
  color:#fff;
  font-size:1rem;
}

.sidebar-social{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
}

.sidebar-social a{
  width:32px;
  height:32px;
  border-radius:50%;
  background:rgba(255,255,255,.1);
  display:flex;
  align-items:center;
  justify-content:center;
  color:#fff;
}

/* =========================================================
   MAIN LAYOUT
========================================================= */
main{
  width:100%;
}

.reader-section{
  padding:32px 18px 70px;
}

.reader-wrap{
  max-width:1400px;
  margin:0 auto;
  display:grid;
  grid-template-columns:300px 1fr;
  gap:24px;
  align-items:start;
}

/* =========================================================
   CHAPTER SIDEBAR / PANELS
========================================================= */
/* same chapter title style for desktop + mobile */
.chapter-sidebar .chapter-title,
.chapter-mobile-panel .chapter-title,
.chapter-title{
  padding:12px;
  background:#f1f5f9;
  border-radius:10px;
  font-weight:700;
  cursor:pointer;
}

body.dark-mode .chapter-sidebar .chapter-title,
body.dark-mode .chapter-mobile-panel .chapter-title,
body.dark-mode .chapter-title{
  background:#1e293b;
}

.chapter-sidebar .chapter-title.active-link,
.chapter-mobile-panel .chapter-title.active-link,
.chapter-title.active-link{
  background:#dbeafe;
  color:#1d4ed8;
}

.chapter-sidebar{
  background:rgba(255,255,255,.9);
  border:1px solid rgba(255,255,255,.7);
  border-radius:24px;
  box-shadow:0 20px 60px rgba(15,23,42,.08);
  padding:18px;
  position:sticky;
  top:110px;
  height:calc(100vh - 110px);
  overflow:hidden;
  display:flex;
  flex-direction:column;
}

body.dark-mode .chapter-sidebar{
  background:rgba(17,24,39,.92);
  border:1px solid rgba(255,255,255,.08);
}

.sidebar-title{
  font-size:1.2rem;
  margin-bottom:14px;
  color:#0f172a;
}

body.dark-mode .sidebar-title{
  color:#f8fafc;
}

.chapter-list{
  list-style:none;
  flex:1;
  overflow-y:auto;
  padding-right:6px;
}

.chapter-list li{
  margin-bottom:8px;
}

.chapter-list a{
  display:block;
  padding:11px 12px;
  border-radius:12px;
  color:#1f2937;
  background:#f8fafc;
  border:1px solid #e5e7eb;
  transition:.3s ease;
  font-weight:600;
}

body.dark-mode .chapter-list a{
  background:#0f172a;
  color:#e5e7eb;
  border:1px solid rgba(255,255,255,.06);
}

.chapter-list a:hover,
.chapter-list a.active-link{
  background:#dbeafe;
  color:#1d4ed8;
  border-color:#93c5fd;
}

.chapter-group{
  margin-bottom:10px;
}

.subchapter-list{
  list-style:none;
  padding-left:10px;
  margin-top:6px;
  display:none;
}

.subchapter-list.open{
  display:block;
}

.subchapter-list li a{
  display:block;
  padding:8px 10px;
  font-size:14px;
  color:#334155;
  border-radius:8px;
}

.chapter-mobile-panel,
.chapter-mobile-panel .chapter-list,
.chapter-mobile-panel .subchapter-list{
  max-width:100%;
  overflow-x:hidden;
}

.chapter-mobile-panel a,
.chapter-mobile-panel .chapter-title{
  white-space:normal;
  word-break:break-word;
}

/* active subchapter */
.subchapter-list a.active-sub{
  background:#d1fae5;
  color:#065f46;
  font-weight:700;
  border-radius:8px;
}

body.dark-mode .subchapter-list a.active-sub{
  background:#064e3b;
  color:#6ee7b7;
}

/* unified styled subchapter links */
.chapter-sidebar .subchapter-list a,
.chapter-mobile-panel .subchapter-list a{
  font-size:13px !important;
  color:#16a34a !important;
  display:block !important;
  padding:8px 12px !important;
  text-decoration:none !important;
  border-radius:8px !important;
}

.chapter-sidebar .subchapter-list a:hover,
.chapter-mobile-panel .subchapter-list a:hover{
  background:#ecfdf5 !important;
  color:#15803d !important;
}

.chapter-sidebar .subchapter-list a.active-sub,
.chapter-mobile-panel .subchapter-list a.active-sub{
  background:#d1fae5 !important;
  color:#065f46 !important;
  font-weight:700 !important;
}

body.dark-mode .chapter-sidebar .subchapter-list a,
body.dark-mode .chapter-mobile-panel .subchapter-list a{
  color:#4ade80 !important;
}

body.dark-mode .chapter-sidebar .subchapter-list a:hover,
body.dark-mode .chapter-mobile-panel .subchapter-list a:hover{
  background:#064e3b !important;
  color:#86efac !important;
}

body.dark-mode .chapter-sidebar .subchapter-list a.active-sub,
body.dark-mode .chapter-mobile-panel .subchapter-list a.active-sub{
  background:#065f46 !important;
  color:#bbf7d0 !important;
}

/* =========================================================
   READER CONTENT
========================================================= */
.reader-content{
  background:rgba(255,255,255,.9);
  border:1px solid rgba(255,255,255,.7);
  border-radius:26px;
  box-shadow:0 20px 60px rgba(15,23,42,.08);
  padding:28px 26px;
  width:100%;
  position:relative;
}

body.dark-mode .reader-content{
  background:rgba(17,24,39,.92);
  border:1px solid rgba(255,255,255,.08);
}

.book-subtitle{
  color:#475569;
  margin-bottom:24px;
  font-size:1rem;
}

body.dark-mode .book-subtitle{
  color:#cbd5e1;
}

.animated-title{
  background:linear-gradient(270deg,#2563eb,#10b981,#f59e0b,#ef4444);
  background-size:600% 600%;
  -webkit-background-clip:text;
  -webkit-text-fill-color:transparent;
  animation:gradientMove 5s ease infinite;
}

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

.reading-text{
  font-size:18px;
  transition:font-size .3s ease;
}

.reading-text p{
  margin-bottom:18px;
  color:inherit;
}

.chapter-block h2{
  font-size:1.55rem;
  margin-bottom:14px;
  color:#1d4ed8;
}

.chapter-block h3{
  font-size:1.12rem;
  margin:20px 0 10px;
  color:#0f172a;
}

body.dark-mode .chapter-block h3{
  color:#f8fafc;
}

/* =========================================================
   READER CONTROLS / MOBILE TOOLS
========================================================= */
.reader-controls{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:10px;
  margin-bottom:16px;
}

.control-btn{
  border:none;
  background:#2563eb;
  color:#fff;
  padding:10px 8px;
  border-radius:12px;
  font-size:.9rem;
  font-weight:700;
  cursor:pointer;
  transition:all .2s ease;
}

.mobile-reader-tools,
.chapter-toggle,
.chapter-mobile-panel{
  display:none;
}

/* =========================================================
   GOOGLE TRANSLATE
========================================================= */
.translate-wrap,
.top-translate-bar{
  width:100%;
  max-width:100%;
  min-width:0;
  margin:0 0 16px 0;
  padding:0;
  box-sizing:border-box;
}

#google_translate_element,
#google_translate_element_mobile_panel{
  width:100%;
  max-width:100%;
  min-width:0;
  display:block;
  margin:0 0 16px 0;
  padding:0;
  position:relative;
  box-sizing:border-box;
  overflow:visible;
  background:transparent;
  border:none;
  min-height:36px;
}

.skiptranslate{
  width:100% !important;
  max-width:100% !important;
  display:block !important;
}

.goog-te-gadget{
  width:100% !important;
  max-width:100% !important;
  display:block !important;
  font-size:13px !important;
  line-height:normal !important;
  color:#1f2937 !important;
  white-space:normal !important;
}

body.dark-mode .goog-te-gadget{
  color:#e5e7eb !important;
}

.goog-te-gadget .goog-te-combo{
  display:block !important;
  width:100% !important;
  max-width:100% !important;
  min-width:0 !important;
  height:36px !important;
  min-height:36px !important;
  padding:0 36px 0 12px !important;
  border:1px solid #cbd5e1 !important;
  border-radius:10px !important;
  background-color:#fff !important;
  color:#1f2937 !important;
  font-size:13px !important;
  line-height:1.2 !important;
  box-sizing:border-box !important;
  outline:none !important;
  box-shadow:none !important;
  cursor:pointer !important;
  appearance:auto !important;
  -webkit-appearance:menulist !important;
  -moz-appearance:menulist !important;
}

body.dark-mode .goog-te-gadget .goog-te-combo{
  background-color:#0f172a !important;
  color:#e5e7eb !important;
  border:1px solid rgba(255,255,255,.14) !important;
}

.goog-te-gadget img,
.goog-logo-link{
  display:none !important;
}

.goog-te-gadget .goog-te-combo + span{
  display:none !important;
}

.goog-te-banner-frame,
iframe.goog-te-banner-frame,
.skiptranslate iframe,
body > .skiptranslate,
.goog-te-ftab,
.goog-te-balloon-frame{
  display:none !important;
}

.goog-tooltip,
.goog-text-highlight{
  box-shadow:none !important;
  background:none !important;
}

/* =========================================================
   SEARCH
========================================================= */
.chapter-search-wrap{
  width:100%;
  margin:0 0 16px 0;
}

.chapter-search-box{
  position:relative;
  width:100%;
}

.chapter-search-box i{
  position:absolute;
  left:12px;
  top:50%;
  transform:translateY(-50%);
  color:#64748b;
  font-size:14px;
  pointer-events:none;
}

.chapter-search-input{
  width:100%;
  height:40px;
  padding:0 42px 0 38px;
  border:1px solid #cbd5e1;
  border-radius:10px;
  background:#fff;
  color:#1f2937;
  font-size:14px;
  outline:none;
}

.chapter-search-input:focus{
  border-color:#60a5fa;
  box-shadow:0 0 0 3px rgba(96,165,250,.18);
}

.chapter-search-clear{
  position:absolute;
  right:10px;
  top:50%;
  transform:translateY(-50%);
  width:34px;
  height:34px;
  border:none;
  border-radius:50%;
  background:#cbd5e1;
  color:#475569;
  font-size:12px;
  display:none;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  z-index:2;
  transition:all .2s ease;
}

.chapter-search-clear.show{
  display:flex;
}

.chapter-search-clear:hover{
  background:#94a3b8;
  color:#fff;
}

.search-mark{
  background:#fde68a;
  color:#111827;
  border-radius:3px;
  padding:0 2px;
}

.search-hidden{
  display:none !important;
}

body.dark-mode .chapter-search-input{
  background:#0f172a;
  color:#e5e7eb;
  border-color:rgba(255,255,255,.14);
}

body.dark-mode .chapter-search-box i{
  color:#cbd5e1;
}

body.dark-mode .chapter-search-clear{
  background:#475569;
  color:#e5e7eb;
}

body.dark-mode .chapter-search-clear:hover{
  background:#64748b;
  color:#fff;
}

/* =========================================================
   CHAPTER NAVIGATION BUTTONS
   Fixed Previous / Next button styles
========================================================= */
.chapter-nav{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  margin:18px 0;
  flex-wrap:wrap;
}

.chapter-btn{
  border:none;
  background:#2563eb;
  color:#fff;
  padding:11px 18px;
  border-radius:12px;
  font-size:.95rem;
  font-weight:700;
  cursor:pointer;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:110px;
  transition:background .2s ease, color .2s ease, opacity .2s ease, transform .2s ease;
  user-select:none;
  -webkit-tap-highlight-color:transparent;
}

.chapter-btn:hover{
  background:#1d4ed8;
}

.chapter-btn:focus{
  outline:none;
}

.chapter-btn:focus-visible{
  box-shadow:0 0 0 3px rgba(37,99,235,.25);
}

.chapter-btn:active{
  transform:scale(.98);
}

.chapter-btn.secondary{
  background:#0f172a;
}

.chapter-btn.secondary:hover{
  background:#1e293b;
}

.chapter-btn.disabled{
  background:#94a3b8 !important;
  color:#e2e8f0 !important;
  pointer-events:none;
  cursor:not-allowed;
  opacity:.85;
  box-shadow:none;
  transform:none;
}

.chapter-btn.disabled:hover{
  background:#94a3b8 !important;
  color:#e2e8f0 !important;
}

.chapter-btn.disabled:focus,
.chapter-btn.disabled:focus-visible{
  background:#94a3b8 !important;
  color:#e2e8f0 !important;
  box-shadow:none;
  outline:none;
}

.chapter-btn.disabled:active{
  transform:none;
}

.chapter-btn.disabled:link,
.chapter-btn.disabled:visited,
.chapter-btn.disabled:active{
  background:#94a3b8 !important;
  color:#e2e8f0 !important;
}

span.chapter-btn{
  display:inline-flex;
}

/* =========================================================
   FOOTER
========================================================= */
footer{
  background:#0f172a;
  color:#e5e7eb;
  padding:45px 20px 28px;
  margin-top:40px;
}

.footer-menu{
  max-width:1150px;
  margin:0 auto 28px;
  display:grid;
  grid-template-row:repeat(auto-fit,minmax(160px,1fr));
  gap:20px;
}

.footer-menu .column{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.footer-menu a{
  color:#cbd5e1;
}

.footer-social{
  display:flex;
  justify-content:center;
  gap:12px;
  flex-wrap:wrap;
  margin-bottom:16px;
}

.footer-social a{
  width:42px;
  height:42px;
  border-radius:50%;
  background:rgba(255,255,255,.08);
  display:flex;
  align-items:center;
  justify-content:center;
  color:#fff;
}

footer p{
  text-align:center;
  color:#94a3b8;
  font-size:.95rem;
}

/* =========================================================
   MEDIA QUERIES
========================================================= */
@media (max-width:1100px){
  .reader-wrap{
    grid-template-columns:1fr;
  }

  .chapter-sidebar{
    display:none;
  }

  .chapter-mobile-panel{
    display:block;
    position:fixed;
    top:0;
    left:0;
    width:85%;
    max-width:320px;
    height:100vh;
    background:#fff;
    color:#1f2937;
    padding:20px 16px;
    transition:transform .35s ease;
    z-index:2100;
    overflow-y:auto;
    overflow-x:hidden;
    box-shadow:10px 0 30px rgba(0,0,0,.18);
    transform:translateX(-100%);
  }

  body.dark-mode .chapter-mobile-panel{
    background:#111827;
    color:#e5e7eb;
  }

  .chapter-mobile-panel.active{
    transform:translateX(0);
  }

  .chapter-panel-close{
    width:46px;
    height:46px;
    border-radius:50%;
    background:#2563eb;
    color:#fff;
    display:flex;
    align-items:center;
    justify-content:center;
    margin-left:auto;
    margin-bottom:18px;
    cursor:pointer;
    font-size:1.2rem;
  }

  .mobile-reader-tools{
    display:flex;
    gap:12px;
    align-items:stretch;
    justify-content:space-between;
    margin-bottom:18px;
    flex-wrap:nowrap;
    width:100%;
  }

  .chapter-toggle{
    display:flex;
    width:40px;
    height:40px;
    min-width:52px;
    min-height:52px;
    border-radius:50%;
    background:#2563eb;
    color:#fff;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    border:none;
    flex-shrink:0;
  }

  .reader-controls{
    display:flex;
    align-items:center;
    justify-content:flex-start;
    gap:10px;
    margin-bottom:0;
    flex-wrap:nowrap;
    width:auto;
  }

  .control-btn{
    width:40px;
    height:40px;
    min-width:40px;
    min-height:40px;
    padding:0;
    border-radius:50%;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:0;
  }

  .control-btn i{
    font-size:0.9rem;
    margin:0;
  }

  .chapter-btn{
    min-width:100px;
  }
}

@media (max-width:992px){
  .main-nav{
    display:none;
  }

  .menu-toggle{
   display:flex;
   padding:0;             /*  remove inner space */
  }
}

@media (max-width:768px){
   .header{
    display:flex;
    align-items:center;
    justify-content:space-between; /* logo left, menu right */
    flex-wrap:nowrap;
  }

  .header .logo{
    align-items:center;
    width:auto;        /* allow space for menu */
  max-width:70%;     /* prevent overflow */
  }

  .header .logo-image{
    width:100%;
    height:auto;
    aspect-ratio:3 / 1;
        max-width:220px;
  }

  .header .logo-text{
    text-align:center;
  }

  .reader-section{
    padding:22px 12px 48px;
  }

  .reader-content{
    padding:18px 16px;
  }

  #google_translate_element,
  #google_translate_element_mobile_panel{
    min-height:34px;
    margin:0 0 14px 0;
  }

  .goog-te-gadget .goog-te-combo{
    height:34px !important;
    min-height:34px !important;
    font-size:12px !important;
    padding:0 32px 0 10px !important;
    border-radius:8px !important;
  }

  .chapter-nav{
    gap:10px;
  }

  .chapter-btn{
    padding:10px 16px;
    font-size:.9rem;
  }

  .footer-menu{
    grid-template-columns:repeat(2,1fr);
  }
}

@media (max-width:480px){
  .chapter-nav{
    flex-direction:column;
    align-items:stretch;
  }

  .chapter-btn{
    width:100%;
    min-width:0;
  }
}