/* ============================================
   System Design Bangla - Main Stylesheet
   Aesthetic: Editorial · Bengali-typography-first · Deep teal accent
   ============================================ */

:root {
  /* Light theme */
  --bg: #faf7f2;
  --bg-elev: #ffffff;
  --bg-soft: #f3ede2;
  --ink: #1a1d1f;
  --ink-soft: #4a5158;
  --ink-mute: #8a8f95;
  --line: #e6dfd0;
  --line-soft: #efeadc;

  --accent: #0f766e;
  /* deep teal */
  --accent-2: #b45309;
  /* warm amber accent */
  --accent-soft: #ccfbf1;
  --accent-ink: #134e4a;

  --success: #15803d;
  --warning: #b45309;
  --danger: #b91c1c;
  --info: #0369a1;

  --note-bg: #fef9c3;
  --note-ink: #713f12;
  --tip-bg: #ccfbf1;
  --tip-ink: #134e4a;
  --warn-bg: #fee2e2;
  --warn-ink: #7f1d1d;

  --shadow-sm: 0 1px 2px rgba(20, 20, 20, .04), 0 1px 3px rgba(20, 20, 20, .06);
  --shadow-md: 0 4px 12px rgba(20, 20, 20, .06), 0 8px 24px rgba(20, 20, 20, .06);
  --shadow-lg: 0 12px 40px rgba(20, 20, 20, .10);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  /* Typography */
  --font-bn: 'Noto Sans Bengali', system-ui, sans-serif;
  --font-display: 'Crimson Pro', 'Noto Sans Bengali', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --container: 1200px;
  --reading: 720px;
}

[data-theme="dark"] {
  --bg: #0e1115;
  --bg-elev: #161b22;
  --bg-soft: #1c2128;
  --ink: #e6e6e6;
  --ink-soft: #b8bfc7;
  --ink-mute: #7a8290;
  --line: #2a3038;
  --line-soft: #1f242b;

  --accent: #2dd4bf;
  --accent-2: #f59e0b;
  --accent-soft: #134e4a;
  --accent-ink: #ccfbf1;

  --note-bg: #422006;
  --note-ink: #fcd34d;
  --tip-bg: #134e4a;
  --tip-ink: #99f6e4;
  --warn-bg: #450a0a;
  --warn-ink: #fca5a5;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .3);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding-top: 64px;
  font-family: var(--font-bn);
  font-size: 17px;
  line-height: 1.75;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .25s ease, color .25s ease;
  overflow-x: hidden;
  word-break: break-word;
}

img,
svg {
  max-width: 100%;
  display: block;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color .15s ease;
}

a:hover {
  color: var(--accent-2);
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ============= Layout ============= */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

@media (max-width: 640px) {
  .container {
    padding: 0 16px;
  }

  body {
    font-size: 16px;
  }
}

/* ============= Header ============= */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.nav-wrap {
  display: flex;
  align-items: center;
  gap: 32px;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -.01em;
}

.brand:hover {
  color: var(--ink);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
}

.brand-text em {
  font-style: italic;
  color: var(--accent);
  font-weight: 600;
}

@media (max-width: 480px) {

  .brand-text em,
  .brand em {
    display: none;
  }
}

.main-nav {
  display: flex;
  gap: 28px;
  margin-left: auto;
}

.main-nav a {
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 15px;
  position: relative;
}

.main-nav a:hover {
  color: var(--ink);
}

.main-nav a.active::after,
.main-nav a:hover::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -22px;
  height: 2px;
  background: var(--accent);
}

.nav-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  display: grid;
  place-items: center;
  transition: all .15s ease;
}

.theme-toggle:hover {
  background: var(--bg-soft);
}

.mobile-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  color: var(--ink);
  font-size: 22px;
}

@media (max-width: 880px) {
  .nav-wrap {
    gap: 12px;
    justify-content: space-between;
  }

  .nav-actions {
    margin-left: auto;
  }

  .brand-text {
    font-size: 15px;
  }

  .main-nav {
    display: none;
  }

  .mobile-toggle {
    display: grid;
    place-items: center;
  }

  .nav-actions .btn {
    display: none;
  }

  .main-nav.open {
    display: flex;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bg-elev);
    padding: 16px 24px;
    border-bottom: 1px solid var(--line);
    gap: 16px;
    box-shadow: var(--shadow-md);
  }
}

@media (max-width: 400px) {
  .nav-wrap {
    padding: 0 8px;
    gap: 8px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .brand-text {
    font-size: 13px;
    letter-spacing: -0.02em;
  }
}

/* ============= Buttons ============= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 15px;
  border: 1px solid transparent;
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease;
  cursor: pointer;
  text-decoration: none;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 14px;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 17px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent);
}

.btn-primary:hover {
  background: var(--accent-ink);
  color: #fff;
  transform: translateY(-1px);
}

[data-theme="dark"] .btn-primary {
  color: #04201d;
}

[data-theme="dark"] .btn-primary:hover {
  color: #04201d;
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn-ghost:hover {
  background: var(--bg-soft);
  color: var(--ink);
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}

.btn-outline:hover {
  background: var(--accent);
  color: #fff;
}

/* ============= Section titles ============= */
.section-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 700;
  letter-spacing: -.02em;
  margin: 0 0 16px;
  color: var(--ink);
}

.section-sub {
  color: var(--ink-soft);
  font-size: 17px;
  margin: 0 0 40px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 12px;
}

/* ============= Notes / Callouts ============= */
.note,
.tip,
.warn {
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 24px 0;
  border-left: 4px solid;
  font-size: 16px;
}

.note {
  background: var(--note-bg);
  color: var(--note-ink);
  border-color: var(--warning);
}

.tip {
  background: var(--tip-bg);
  color: var(--tip-ink);
  border-color: var(--accent);
}

.warn {
  background: var(--warn-bg);
  color: var(--warn-ink);
  border-color: var(--danger);
}

.note strong,
.tip strong,
.warn strong {
  font-weight: 700;
}

/* ============= Code ============= */
code {
  font-family: var(--font-mono);
  font-size: .9em;
  background: var(--bg-soft);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-2);
}

pre {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  max-width: 100%;
}

pre code {
  background: transparent;
  padding: 0;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ============= Tables ============= */
.table-wrap {
  overflow-x: auto;
  margin: 24px 0;
}

table.compare {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  background: var(--bg-elev);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

table.compare th,
table.compare td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

table.compare thead th {
  background: var(--bg-soft);
  font-weight: 700;
  color: var(--ink);
}

table.compare tr:last-child td {
  border-bottom: none;
}

/* ============= Ad slots ============= */
.ad-slot {
  margin: 32px auto;
  text-align: center;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-leaderboard {
  max-width: 728px;
}

.ad-rectangle {
  max-width: 336px;
  min-height: 280px;
}

.ad-sticky {
  position: sticky;
  top: 96px;
}

.ad-placeholder {
  display: block;
  width: 100%;
  padding: 28px;
  background: var(--bg-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--ink-mute);
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

/* ============= Footer ============= */
.site-footer {
  background: var(--bg-elev);
  border-top: 1px solid var(--line);
  margin-top: 80px;
  padding: 56px 0 24px;
}

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

.footer-brand {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.footer-brand em {
  color: var(--accent);
  font-style: italic;
}

.footer-tag {
  color: var(--ink-soft);
  font-size: 14px;
}

.site-footer h4 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .1em;
  margin: 0 0 16px;
  color: var(--ink-mute);
}

.site-footer a {
  display: block;
  color: var(--ink-soft);
  font-size: 14px;
  padding: 4px 0;
}

.site-footer a:hover {
  color: var(--accent);
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  margin-top: 40px;
  padding-top: 24px;
  font-size: 13px;
  color: var(--ink-mute);
}

@media (max-width: 720px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }

  .footer-bottom {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}

/* ============= Utilities ============= */
.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gap-1 {
  gap: 8px;
}

.gap-2 {
  gap: 16px;
}

.gap-3 {
  gap: 24px;
}

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

.mt-2 {
  margin-top: 16px;
}

.mt-4 {
  margin-top: 32px;
}

.hidden {
  display: none !important;
}

/* ============= Animations ============= */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-up {
  animation: fadeUp .5s ease both;
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ============= Focus styles ============= */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============= Image Lightbox ============= */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.lightbox-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  transform: scale(0.95);
  transition: transform 0.3s ease;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.lightbox-overlay.active .lightbox-img {
  transform: scale(1);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.chapter-content img {
  cursor: zoom-in;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border-radius: var(--radius-sm);
}

.chapter-content img:hover {
  transform: scale(1.01);
  box-shadow: var(--shadow-sm);
}

/* ============= Floating Actions ============= */
.floating-actions-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 999;
}

.float-btn {
  display: flex;
  align-items: center;
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 50px;
  text-decoration: none;
  box-shadow: var(--shadow-md);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  width: 50px;
  height: 50px;
}

.float-icon {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.float-btn:hover {
  width: 155px;
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.float-text {
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateX(-10px);
}

.float-btn:hover .float-text {
  opacity: 1;
  transform: translateX(0);
}

[data-theme="dark"] .float-btn:hover {
  color: #04201d;
}

@media (max-width: 640px) {
  .floating-actions-wrapper {
    bottom: 16px;
    right: 16px;
  }
}