/* ==========================================================================
   RathiLabs India Civic Platform - Reading-Optimized Design System
   Designed for clarity, low cognitive load, accessible contrast, and speed.
   ========================================================================== */

:root {
  /* Warm Light Reading Palette (Default) */
  --bg-primary: #fbfbf9;
  --bg-surface: #ffffff;
  --bg-subtle: #f4f3ee;
  --bg-accent: #edebe4;
  --text-primary: #1c1917;
  --text-secondary: #44403c;
  --text-muted: #78716c;
  --border-color: #e7e5e0;
  --border-subtle: #f0eee9;
  
  --brand-primary: #1e3a8a;       /* Saffron/Navy Civic Accent */
  --brand-primary-hover: #172554;
  --brand-accent: #b45309;        /* Warm Amber */
  --accent-success: #15803d;
  --accent-warning: #b45309;
  --accent-danger: #b91c1c;
  
  --font-serif: Charter, 'Bitstream Charter', 'Sitka Text', Cambria, Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  
  --reading-font: var(--font-serif);
  --base-font-size: 17px;
  --line-height: 1.75;
  --reading-width: 760px;
  --container-width: 1200px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Sepia / Book Reading Theme */
[data-theme="sepia"] {
  --bg-primary: #f5eedb;
  --bg-surface: #fbf5e6;
  --bg-subtle: #eee5cf;
  --bg-accent: #e2d7be;
  --text-primary: #2d261e;
  --text-secondary: #4a3e31;
  --text-muted: #7a6a57;
  --border-color: #dfd3b9;
  --border-subtle: #e8deca;
  --brand-primary: #7c2d12;
  --brand-primary-hover: #451a03;
  --brand-accent: #92400e;
}

/* Dark / Night Reading Theme */
[data-theme="dark"] {
  --bg-primary: #121212;
  --bg-surface: #1e1e1e;
  --bg-subtle: #272727;
  --bg-accent: #333333;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --border-subtle: #1e293b;
  --brand-primary: #38bdf8;
  --brand-primary-hover: #7dd3fc;
  --brand-accent: #f59e0b;
}

/* Font Size Adjustments */
[data-font-size="small"] { --base-font-size: 15px; }
[data-font-size="medium"] { --base-font-size: 17px; }
[data-font-size="large"] { --base-font-size: 20px; }

/* Font Family Selection */
[data-font-family="sans"] { --reading-font: var(--font-sans); }
[data-font-family="serif"] { --reading-font: var(--font-serif); }

/* Global Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--base-font-size);
  scroll-behavior: smooth;
}

body {
  font-family: var(--reading-font);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* -------------------------------------------------------------
   Typography
   ------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.75rem;
  letter-spacing: -0.015em;
}

h1 { font-size: 2.1rem; }
h2 { font-size: 1.55rem; margin-top: 1.75rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.4rem; }
h3 { font-size: 1.25rem; margin-top: 1.25rem; }
h4 { font-size: 1.1rem; margin-top: 1rem; }

p {
  margin-bottom: 1.15rem;
  max-width: var(--reading-width);
}

a {
  color: var(--brand-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--brand-primary-hover);
}

strong {
  font-weight: 600;
  color: var(--text-primary);
}

/* -------------------------------------------------------------
   Layout & Container
   ------------------------------------------------------------- */
.site-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.reading-container {
  max-width: var(--reading-width);
  margin: 0 auto;
}

/* -------------------------------------------------------------
   Top Announcement / Emergency Ribbon
   ------------------------------------------------------------- */
.emergency-ribbon {
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
  font-family: var(--font-sans);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.emergency-badges {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.emergency-ribbon .badge-tag {
  padding: 0.12rem 0.4rem;
  font-size: 0.72rem;
  line-height: 1.25;
}

.badge-tag {
  background-color: var(--bg-accent);
  color: var(--text-secondary);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.badge-tag.emergency {
  background-color: #fee2e2;
  color: #991b1b;
}

[data-theme="dark"] .badge-tag.emergency {
  background-color: #7f1d1d;
  color: #fecaca;
}

/* -------------------------------------------------------------
   Main Header & Navigation
   ------------------------------------------------------------- */
.site-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 0;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-emblem {
  font-size: 1.6rem;
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  text-decoration: none;
}

.brand-subtitle {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Controls Bar (Language, Theme, Font Size) */
.header-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.15rem;
}

.btn-ctrl {
  background: none;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.1s ease;
}

.btn-ctrl:hover {
  color: var(--text-primary);
  background-color: var(--bg-accent);
}

.btn-ctrl.active {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* Single-click Theme Toggle */
.btn-theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-theme-toggle:hover {
  background-color: var(--bg-accent);
  color: var(--text-primary);
}

/* Display / Accessibility Dropdown (Aa) */
.dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.btn-display-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-display-toggle:hover {
  background-color: var(--bg-accent);
  color: var(--text-primary);
}

.dropdown-caret {
  font-size: 0.62rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

.dropdown-wrapper.active .dropdown-caret,
.nav-dropdown.active .dropdown-caret {
  transform: rotate(180deg);
}

.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 0.75rem;
  z-index: 250;
  min-width: 175px;
}

.dropdown-menu.active {
  display: block;
}

.dropdown-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

/* Simplified Navigation Tabs & Dropdown */
.site-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.site-nav::-webkit-scrollbar {
  display: none;
}

.nav-link {
  font-family: var(--font-sans);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nav-link:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.nav-link.active {
  background-color: var(--bg-accent);
  color: var(--brand-primary);
  font-weight: 700;
}

.nav-dropdown {
  position: relative;
  display: inline-flex;
}

.nav-dropdown-btn {
  background: none;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nav-dropdown-btn:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.nav-dropdown-btn.active {
  background-color: var(--bg-accent);
  color: var(--brand-primary);
  font-weight: 700;
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 0.3rem);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 0.4rem 0;
  z-index: 250;
  min-width: 225px;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.active .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.95rem;
  font-size: 0.84rem;
  color: var(--text-primary);
  text-decoration: none;
  transition: all 0.12s ease;
  white-space: nowrap;
}

.nav-dropdown-item:hover {
  background-color: var(--bg-subtle);
  color: var(--brand-primary);
}

.nav-dropdown-item.active {
  background-color: var(--bg-accent);
  color: var(--brand-primary);
  font-weight: 700;
}

/* -------------------------------------------------------------
   Hero & Universal Search Section
   ------------------------------------------------------------- */
.hero-section {
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  padding: 2.25rem 0;
  text-align: center;
}

.hero-title {
  font-size: 2.2rem;
  margin-bottom: 0.5rem;
}

.hero-lead {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 650px;
  margin: 0 auto 1.5rem auto;
  font-family: var(--font-sans);
}

.search-box-wrapper {
  max-width: 680px;
  margin: 0 auto;
  position: relative;
}

.search-input-group {
  display: flex;
  background-color: var(--bg-surface);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.search-input-group:focus-within {
  border-color: var(--brand-primary);
}

.search-icon {
  padding: 0 0.85rem;
  display: flex;
  align-items: center;
  color: var(--text-muted);
}

.search-input {
  flex: 1;
  border: none;
  background: none;
  padding: 0.85rem 0.5rem;
  font-size: 1rem;
  font-family: var(--font-sans);
  color: var(--text-primary);
  outline: none;
}

.search-btn {
  background-color: var(--brand-primary);
  color: #ffffff;
  border: none;
  padding: 0 1.25rem;
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.search-btn:hover {
  background-color: var(--brand-primary-hover);
}

/* Live Search Suggestions Dropdown */
.search-results-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 420px;
  overflow-y: auto;
  z-index: 110;
  display: none;
  text-align: left;
}

.search-result-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background-color 0.1s ease;
}

.search-result-item:hover {
  background-color: var(--bg-subtle);
}

.result-category {
  font-size: 0.7rem;
  font-family: var(--font-sans);
  text-transform: uppercase;
  color: var(--brand-accent);
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.result-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.result-snippet {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 0.2rem;
}

/* -------------------------------------------------------------
   Reading Mode Toolbar (Simple | Detailed | Legal Text)
   ------------------------------------------------------------- */
.reading-mode-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.breadcrumbs {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.breadcrumbs a {
  color: var(--text-secondary);
  text-decoration: none;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

.mode-pills {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.mode-pill {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.mode-pill:hover {
  background-color: var(--bg-accent);
  color: var(--text-primary);
}

.mode-pill.active {
  background-color: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
  font-weight: 600;
}

[data-theme="dark"] .mode-pill.active {
  color: #0f172a;
}

.mode-status-badge {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: all 0.2s ease;
  line-height: 1.3;
}

.mode-status-badge.mode-status-simple {
  border-color: #86efac;
  background-color: #f0fdf4;
  color: #166534;
}

.mode-status-badge.mode-status-detailed {
  border-color: #93c5fd;
  background-color: #eff6ff;
  color: #1e40af;
}

.mode-status-badge.mode-status-legal {
  border-color: #d8b4fe;
  background-color: #faf5ff;
  color: #6b21a8;
}

[data-theme="dark"] .mode-status-badge.mode-status-simple {
  border-color: #166534;
  background-color: rgba(22, 101, 52, 0.2);
  color: #86efac;
}

[data-theme="dark"] .mode-status-badge.mode-status-detailed {
  border-color: #1e40af;
  background-color: rgba(30, 64, 175, 0.2);
  color: #93c5fd;
}

[data-theme="dark"] .mode-status-badge.mode-status-legal {
  border-color: #6b21a8;
  background-color: rgba(107, 33, 168, 0.2);
  color: #d8b4fe;
}

.reading-depth-callout {
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  border-left: 4px solid var(--brand-primary);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.reading-depth-callout.callout-simple {
  border-left-color: #16a34a;
  background-color: var(--bg-surface);
}

.reading-depth-callout.callout-detailed {
  border-left-color: var(--brand-primary);
  background-color: var(--bg-surface);
}

.reading-depth-callout.callout-legal {
  border-left-color: #7c3aed;
  background-color: var(--bg-subtle);
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

/* -------------------------------------------------------------
   Content Layout & Grid Cards
   ------------------------------------------------------------- */
.main-content {
  flex: 1;
  padding: 1.75rem 0 3rem 0;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  margin-top: 1.25rem;
}

.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-badge {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--brand-accent);
  margin-bottom: 0.5rem;
}

.card-title {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.card-body {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
  margin-bottom: 0.75rem;
}

.card-footer {
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-family: var(--font-sans);
  color: var(--text-muted);
}

/* -------------------------------------------------------------
   Scenario Detail & Reader Elements
   ------------------------------------------------------------- */
.action-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--brand-primary);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
}

.action-box.rights {
  border-left-color: var(--accent-success);
}

.action-box.avoid {
  border-left-color: var(--accent-danger);
}

.action-box.warning {
  border-left-color: var(--accent-warning);
}

.action-box h4 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0;
  margin-bottom: 0.4rem;
}

.step-list {
  padding-left: 1.25rem;
  margin-bottom: 1rem;
}

.step-list li {
  margin-bottom: 0.5rem;
}

/* -------------------------------------------------------------
   Tables (Statutory Concordance, Glossary, Directory)
   ------------------------------------------------------------- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  margin: 1.25rem 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  text-align: left;
}

th, td {
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}

th {
  background-color: var(--bg-subtle);
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
}

tr:hover td {
  background-color: var(--bg-subtle);
}

/* -------------------------------------------------------------
   Forum & Contribution Styles
   ------------------------------------------------------------- */
.forum-topic {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.forum-topic-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  font-family: var(--font-sans);
  color: var(--text-muted);
}

.topic-replies {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.reply-item {
  background-color: var(--bg-subtle);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  outline: none;
}

.form-control:focus {
  border-color: var(--brand-primary);
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

.btn-primary {
  background-color: var(--brand-primary);
  color: #ffffff;
  border: none;
  padding: 0.65rem 1.25rem;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-primary:hover {
  background-color: var(--brand-primary-hover);
}

/* -------------------------------------------------------------
   Site Footer
   ------------------------------------------------------------- */
.site-footer {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 2.5rem 0 1.5rem 0;
  margin-top: auto;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.75rem;
  margin-bottom: 1.75rem;
}

.footer-col h5 {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.footer-col ul {
  list-style: none;
}

.footer-col ul li {
  margin-bottom: 0.4rem;
}

.footer-col a {
  color: var(--text-secondary);
  text-decoration: none;
}

.footer-col a:hover {
  color: var(--brand-primary);
  text-decoration: underline;
}

.footer-bottom {
  border-top: 1px solid var(--border-subtle);
  padding-top: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 0.5rem;
}


/* -------------------------------------------------------------
   Mobile-Friendly Components & Responsive System
   Optimized for 90%+ Mobile Users (Phones 320px - 768px)
   ------------------------------------------------------------- */

.mobile-header-actions {
  display: none;
  align-items: center;
  gap: 0.5rem;
}

.btn-mobile-ctrl {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
  min-height: 38px;
}

.btn-mobile-ctrl:hover,
.btn-mobile-ctrl:active {
  background: var(--bg-accent);
}

.btn-hamburger {
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.35rem 0.65rem;
}

/* Mobile Slide-out Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 86%;
  max-width: 360px;
  height: 100vh;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  z-index: 200;
  transform: translateX(-105%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
}

.btn-drawer-close {
  background: none;
  border: none;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
}

.btn-drawer-close:hover {
  color: var(--text-primary);
  background: var(--bg-accent);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem 3rem 1.25rem;
  -webkit-overflow-scrolling: touch;
}

.drawer-section {
  margin-bottom: 1.5rem;
}

.drawer-section-title {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.drawer-pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.drawer-pill-group .btn-ctrl {
  flex: 1 1 calc(50% - 0.4rem);
  text-align: center;
  padding: 0.55rem 0.5rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.drawer-pill-group .btn-ctrl.active {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}

.drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.drawer-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  color: var(--text-primary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  min-height: 44px;
  transition: background-color 0.12s ease;
}

.drawer-nav-item:hover,
.drawer-nav-item:active {
  background-color: var(--bg-subtle);
  color: var(--brand-primary);
}

.drawer-nav-item.active {
  background-color: var(--bg-accent);
  color: var(--brand-primary);
  font-weight: 700;
}

.drawer-nav-item .nav-icon {
  font-size: 1.15rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

/* Mobile Sticky Bottom Navigation Bar */
.mobile-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
  z-index: 150;
  justify-content: space-around;
  align-items: center;
  padding: 0 0.25rem;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 100%;
  color: var(--text-muted);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.35rem 0;
  transition: color 0.15s ease;
  font-family: var(--font-sans);
}

.bottom-nav-item:hover,
.bottom-nav-item:active {
  color: var(--brand-primary);
}

.bottom-nav-item.active {
  color: var(--brand-primary);
}

.bottom-nav-icon {
  font-size: 1.25rem;
  line-height: 1;
  margin-bottom: 0.15rem;
}

.bottom-nav-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* -------------------------------------------------------------
   Responsive Breakpoints & Mobile Polish
   ------------------------------------------------------------- */
@media (max-width: 768px) {
  html {
    font-size: 16px;
  }

  body {
    padding-bottom: 65px; /* Prevent bottom bar from covering content */
  }

  /* Header adjustments */
  .header-top {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0;
  }

  .header-controls {
    display: none; /* Hidden on mobile; cleanly accessible inside drawer */
  }

  .mobile-header-actions {
    display: flex;
  }

  .site-nav {
    display: none; /* Desktop scrolling tab-strip hidden on mobile in favor of bottom bar & drawer */
  }

  .mobile-bottom-bar {
    display: flex;
  }

  /* Emergency ribbon on mobile */
  .emergency-ribbon {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
    overflow-x: visible;
    white-space: normal;
    justify-content: center;
  }

  .emergency-ribbon::-webkit-scrollbar {
    display: none;
  }

  .emergency-badges {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem 0.3rem;
  }

  .emergency-ribbon .badge-tag {
    padding: 0.1rem 0.32rem;
    font-size: 0.68rem;
  }

  /* Hero & Search on mobile */
  .hero-section {
    padding: 1.5rem 0;
  }

  .hero-title {
    font-size: 1.6rem;
    line-height: 1.2;
  }

  .hero-lead {
    font-size: 0.95rem;
    margin-bottom: 1.2rem;
  }

  .search-input-group {
    border-width: 1.5px;
  }

  .search-input {
    font-size: 0.95rem;
    padding: 0.75rem 0.4rem;
  }

  .search-btn {
    padding: 0.6rem 0.9rem;
    font-size: 0.88rem;
  }

  .search-results-panel {
    max-height: 55vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Reading mode bar on mobile */
  .reading-mode-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.6rem 0;
  }

  .mode-pills {
    display: flex;
    width: 100%;
  }

  .mode-pill {
    flex: 1;
    text-align: center;
    padding: 0.45rem 0.5rem;
    font-size: 0.82rem;
    min-height: 38px;
  }

  /* Content Containers & Cards */
  .container {
    padding: 0 0.9rem;
  }

  .cards-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .card {
    padding: 1.15rem;
  }

  .card-title {
    font-size: 1.15rem;
  }

  .action-box {
    padding: 0.9rem 1rem;
    margin: 0.85rem 0;
  }

  /* Responsive Tables */
  .table-responsive {
    margin: 0.85rem 0;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
  }

  table {
    font-size: 0.82rem;
  }

  th, td {
    padding: 0.55rem 0.65rem;
  }

  /* Footer on mobile */
  .site-footer {
    padding: 1.75rem 0 1.25rem 0;
    margin-bottom: 10px;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
    gap: 0.75rem;
  }

  .footer-bottom div {
    text-align: center !important;
  }
}

@media (max-width: 480px) {
  .brand-title {
    font-size: 1.1rem;
  }

  .brand-subtitle {
    display: none;
  }

  .btn-mobile-ctrl {
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
  }

  .hero-title {
    font-size: 1.4rem;
  }
}

@media print {
  .site-header, .site-footer, .emergency-ribbon, .reading-mode-bar, .search-box-wrapper, .mobile-bottom-bar, .mobile-drawer, .drawer-backdrop, .bns-modal-backdrop {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
    padding-bottom: 0;
  }
  .container, .reading-container {
    max-width: 100%;
  }
}

/* =============================================================
   BNS SECTION EXPLORER & DETAIL MODAL
   ============================================================= */
.bns-filter-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.bns-filter-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.bns-search-input {
  flex: 1;
  min-width: 260px;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-body);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.bns-search-input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.bns-chapter-select {
  padding: 0.65rem 1rem;
  font-size: 0.92rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-body);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  max-width: 320px;
}

.bns-chips-wrapper {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.bns-chip {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.bns-chip:hover {
  background: var(--bg-surface);
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.bns-chip.active {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
  font-weight: 600;
}

.bns-section-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
}

.bns-section-card:hover {
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.bns-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.bns-pill-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.bns-sec-badge {
  background: var(--brand-primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
}

.bns-ipc-badge {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.bns-chapter-badge {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.bns-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0.35rem 0 0.5rem 0;
  line-height: 1.4;
}

.bns-card-summary {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.bns-card-punishment {
  font-size: 0.84rem;
  line-height: 1.5;
  background: rgba(220, 38, 38, 0.08);
  border-left: 3px solid #dc2626;
  color: var(--text-primary);
  padding: 0.45rem 0.75rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 0.75rem;
}

.bns-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.bns-class-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.bns-class-tag {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.bns-tag-cognizable {
  background: rgba(22, 101, 52, 0.12);
  color: #166534;
}

.bns-tag-nonbailable {
  background: rgba(153, 27, 27, 0.12);
  color: #991b1b;
}

.bns-tag-court {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

/* Modal styles */
.bns-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 2500;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.bns-modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.bns-modal-container {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-width: 860px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  animation: bnsModalSlideUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes bnsModalSlideUp {
  from {
    transform: translateY(18px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.bns-modal-header {
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-subtle);
}

.bns-modal-title-group h2 {
  font-size: 1.3rem;
  margin: 0;
  color: var(--text-primary);
  line-height: 1.3;
}

.bns-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.bns-modal-close {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.5rem;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.bns-modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}

.bns-modal-section-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.bns-modal-section-box h3 {
  font-size: 1.05rem;
  margin: 0 0 0.65rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.bns-section-fulltext {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  font-family: var(--font-body);
  font-size: 0.94rem;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
}

.bns-modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}


