/* This application is developed and managed by James Kaburu - an experienced developer, a lawyer, an economist and a Certified Fraud Examiner. Contact him on +254 710 496 209 (call or WhatsApp). */
/* ==========================================================================
   Responsive layer — loaded after main.css / dashboard.css on every layout.
   Mobile-first fixes plus the shared blocks used by the editable content
   sections (prose, chips, page sections). No build step, no dependencies.
   ========================================================================== */

/* ---------- 1. Base hardening ------------------------------------------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-x: hidden; }
img, svg, video, canvas, iframe { max-width: 100%; height: auto; }
/* Grid and flex children default to min-width:auto, which is what makes long
   words and wide tables blow a phone layout out of the viewport. */
.dash-main, .dash-body, .container, .hero-grid > *, .split-grid > *,
.services-grid > *, .steps-grid > *, .writers-grid > *, .footer-grid > *,
.stats-row > *, .charts-grid > *, .dash-card, .page-section { min-width: 0; }
h1, h2, h3, h4 { overflow-wrap: break-word; }
p, li, td, th, a { overflow-wrap: break-word; }
:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 2px;
}

/* Fluid headings: no more 38px headlines on a 360px screen. */
.hero h1 { font-size: clamp(28px, 5.4vw, 46px); }
.section-header h2 { font-size: clamp(22px, 3.6vw, 32px); }
.dash-banner h1, .dash-banner h2 { font-size: clamp(19px, 3.4vw, 24px); }

/* ---------- 2. Editable content blocks (admin-managed) ------------------- */
.prose-section {
  max-width: 880px;
  margin: 0 auto;
  color: #334155;
  font-size: 15.5px;
  line-height: 1.8;
}
.prose-section h2 { font-size: clamp(21px, 3vw, 27px); color: #0b2545; margin: 30px 0 12px; }
.prose-section h3 { font-size: clamp(17px, 2.4vw, 20px); color: #0b2545; margin: 24px 0 10px; }
.prose-section p { margin-bottom: 14px; }
.prose-section ul, .prose-section ol { margin: 0 0 16px 20px; }
.prose-section li { margin-bottom: 7px; }
.prose-section a { color: #1d4ed8; text-decoration: underline; }
.prose-section strong { color: #0b2545; }
.prose-section blockquote {
  border-left: 4px solid #f59e0b;
  background: #fffbeb;
  padding: 12px 18px;
  margin: 18px 0;
  border-radius: 0 8px 8px 0;
}

.chip-grid { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 940px; margin: 0 auto; }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid #dbe3ee;
  background: #f8fafc;
  color: #0b2545;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.chip:hover { background: #eff6ff; border-color: #93c5fd; transform: translateY(-1px); }

.edit-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.edit-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.edit-card span { font-size: 22px; display: block; margin-bottom: 8px; }
.edit-card strong { display: block; color: #0b2545; font-size: 14.5px; margin-bottom: 6px; }
.edit-card p { font-size: 13px; color: #64748b; line-height: 1.6; margin: 0; }

.link-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  justify-content: center;
  margin-top: 28px;
  font-size: 14px;
}
.link-strip a { color: #1d4ed8; font-weight: 600; text-decoration: none; border-bottom: 1px solid transparent; }
.link-strip a:hover { border-bottom-color: currentColor; }

.page-sections-inner { max-width: 900px; }
.page-section { margin-bottom: 44px; }
.page-section-kicker {
  display: inline-block;
  color: #f97316;
  font-weight: 700;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}
.page-section-title { font-size: clamp(21px, 3vw, 27px); font-weight: 800; color: #0b2545; margin: 0 0 14px; }
.page-section-image { width: 100%; border-radius: 14px; margin: 2px 0 18px; max-height: 360px; object-fit: cover; }

/* ---------- 3. Public site on tablets and phones ------------------------ */
@media (max-width: 992px) {
  .edit-card-grid { grid-template-columns: 1fr; }
  .section-py { padding: 56px 0; }
  .achievements-card { margin-top: 0; }
  .blog-layout, .blog-card { grid-template-columns: 1fr !important; }
}

@media (max-width: 768px) {
  /* Header: logo + one clear action + hamburger. */
  .header-wrap { gap: 10px; }
  .header-cta .btn-header-order { display: none; }
  .hamburger { display: flex; width: 42px; height: 42px; }

  /* Drawer: full-height, scrollable, thumb-sized rows. */
  .drawer-menu { width: min(88vw, 360px); padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .drawer-menu a, .drawer-menu .drawer-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    font-size: 15px;
  }
  body.drawer-open { overflow: hidden; }

  /* Content: readable measure, no horizontal overflow. */
  .container { padding: 0 16px; }
  .prose-section { font-size: 15px; line-height: 1.75; }
  .section-header { margin-bottom: 30px; }
  .hero-actions .btn { width: 100%; justify-content: center; }
  .quote-card { padding: 20px 16px; }
  .calc-price-bar { flex-wrap: wrap; gap: 6px; }

  /* Tables scroll instead of squeezing. */
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-responsive table { min-width: 560px; }

  /* Forms: 16px stops iOS from zooming the whole page on focus. */
  input, select, textarea, .form-control { font-size: 16px; }
  .form-group { margin-bottom: 14px; }

  /* Images and embeds. */
  .writer-photo, .blog-card-img { height: auto; max-height: 260px; object-fit: cover; }

  /* Keep the sticky mobile action bar from covering the footer. */
  body.has-mobile-cta { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
}

@media (max-width: 480px) {
  .section-py { padding: 44px 0; }
  .chip { font-size: 13px; padding: 8px 13px; }
  .link-strip { gap: 8px 14px; font-size: 13.5px; }
  .page-section { margin-bottom: 34px; }
}

/* Between the drawer breakpoint and a wide desktop four extra links do not
   fit; the two newest public features stay in the drawer instead. */
@media (max-width: 1280px) {
  .nav-links { gap: 16px; font-size: 14px; }
}
@media (max-width: 1160px) {
  .nav-links .nav-secondary { display: none; }
}

/* ---------- 4. Sticky mobile action bar --------------------------------- */
/* The sticky bar's height, published for anything that has to sit above it.
   A fixed offset went wrong the moment the bar wrapped to two lines; this is
   measured by the toast script and falls back to the real single-line height. */
:root { --mobile-cta-h: 66px; }

.mobile-cta-bar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 900;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(8px);
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.08);
}
.mobile-cta-bar a {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}
.mobile-cta-bar .cta-order { background: #f97316; color: #fff; }
.mobile-cta-bar .cta-whatsapp { background: #25d366; color: #06381a; }
.mobile-cta-bar .cta-call { background: #eff6ff; color: #1d4ed8; flex: 0 0 52px; }
@media (max-width: 768px) {
  .mobile-cta-bar { display: flex; }
}

/* ---------- 5. Dashboards (admin / client / writer) --------------------- */
@media (max-width: 992px) {
  /* Tablets: the base stylesheet still asks for a 550px table. */
  .dash-table { min-width: 100%; }
  .dash-table th, .dash-table td { white-space: normal; overflow-wrap: anywhere; }
  .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .dash-sidebar { overscroll-behavior: contain; }
  .dash-menu { padding: 12px 10px calc(24px + env(safe-area-inset-bottom)); }
  .dash-menu a { min-height: 44px; }
  .dash-topbar { padding-left: max(12px, env(safe-area-inset-left)); }
}

@media (max-width: 600px) {
  .stats-row { grid-template-columns: 1fr !important; }
}

@media (max-width: 768px) {
  .dash-body { padding: 16px 14px calc(20px + env(safe-area-inset-bottom)); }
  .dash-card-header form,
  .dash-card-header .btn { width: 100%; }
  .dash-card-header > * { min-width: 0; }
  .dash-banner { gap: 12px; }
  .dash-banner-user { width: 100%; }
  .dash-banner-avatar { width: 46px; height: 46px; }
  .table-responsive { box-shadow: inset -8px 0 8px -8px rgba(15, 23, 42, 0.18); }
  .dash-table th, .dash-table td { padding: 10px 12px; }
  /* Tabs and filter bars scroll sideways instead of wrapping into a wall. */
  .dash-tabs, .dash-filters, .filter-row {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .dash-tabs > *, .dash-filters > * { flex: 0 0 auto; }
  .modal-dialog, .modal-content { max-width: 100% !important; margin: 10px !important; }
}

/* ---------- 6. Grouped dashboard menu (admin) --------------------------- */
.dash-menu-group { margin-top: 10px; }
.dash-menu-group > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  color: #7d8ea3;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
}
.dash-menu-group > summary::-webkit-details-marker { display: none; }
.dash-menu-group > summary::after {
  content: '▾';
  font-size: 11px;
  transition: transform 0.2s ease;
}
.dash-menu-group[open] > summary::after { transform: rotate(180deg); }
.dash-menu-group > summary:hover { background: rgba(255, 255, 255, 0.06); color: #e2e8f0; }
.dash-menu-group[open] > summary { color: #e2e8f0; }
.dash-menu-group .dash-menu-items { display: flex; flex-direction: column; gap: 3px; margin-top: 2px; }

/* ---------- 7. Motion and print ---------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .reveal, .reveal-left, .reveal-right, .reveal-scale {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

@media print {
  .dash-sidebar, .dash-topbar, .mobile-cta-bar, .main-header, .drawer-menu, .drawer-backdrop { display: none !important; }
  .dash-main, .dash-body { padding: 0 !important; }
  body { background: #fff; }
}
