/* Modern Responsive Enhancements */

/* Container and Layout Improvements */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* Fix Column Layout - Preserve Original Bootstrap Grid for Content Area */
.content.row-fluid {
  display: block; /* Don't use flexbox for main content area */
  position: relative;
  width: 100%;
  overflow: hidden; /* Contain floats */
}

.content.row-fluid:after {
  content: "";
  display: table;
  clear: both;
}

/* Restore original Bootstrap grid behavior for desktop */
@media (min-width: 768px) {
  .content.row-fluid .maincol {
    display: block;
    float: left;
    width: auto;
    position: relative;
  }

  .content.row-fluid .leftcol {
    display: block;
    float: left;
    width: auto;
    position: relative;
  }

  .content.row-fluid .rightcol {
    display: block;
    float: right;
    width: auto;
    position: relative;
  }

  /* Preserve original span calculations */
  .content.row-fluid .span3 { width: 23.404255319149%; }
  .content.row-fluid .span4 { width: 31.914893617021%; }
  .content.row-fluid .span6 { width: 48.936170212766%; }
  .content.row-fluid .span8 { width: 65.957446808511%; }
  .content.row-fluid .span9 { width: 74.468085106383%; }
  .content.row-fluid .span12 { width: 100%; }

  /* Restore original margin adjustments */
  .content.row-fluid .leftcol.span3 { margin-left: -74.5%; }
  .content.row-fluid .leftcol.span4 { margin-left: -99.95%; }
  .content.row-fluid .rightcol.span3 { margin: 0 !important; }
  .content.row-fluid .maincol.span6 { margin-left: 26%; }
  .content.row-fluid .maincol.span8 { margin-left: 34%; }
  .content.row-fluid .maincol.noleft.span8 { margin-left: 0%; }
}

/* Responsive fixes for main content area */
@media (max-width: 767px) {
  .content.row-fluid .leftcol,
  .content.row-fluid .rightcol,
  .content.row-fluid .maincol {
    float: none !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    position: relative !important;
    clear: both !important;
  }

  .content.row-fluid .maincol {
    order: 2;
  }

  .content.row-fluid .leftcol {
    order: 1;
    margin-bottom: 1rem;
  }

  .content.row-fluid .rightcol {
    order: 3;
    margin-top: 1rem;
  }
}

/* Keep flexbox for other row-fluid areas (header, footer, etc) */
.row-fluid:not(.content) {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -15px;
}

.row-fluid:not(.content) > [class*="span"] {
  flex: 1;
  padding: 0 15px;
  min-width: 0;
}

/* Responsive Grid System for non-content areas */
@media (max-width: 767px) {
  .row-fluid:not(.content) {
    flex-direction: column;
  }

  .row-fluid:not(.content) > [class*="span"] {
    width: 100%;
    flex: none;
    margin-bottom: 1rem;
  }
}

/* Modern Navigation */
.navbar {
  backdrop-filter: blur(10px);
  transition: var(--transition);
}

.navbar-fixed-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1030;
  box-shadow: var(--shadow);
}

/* Mobile Navigation Toggle */
.navbar-toggle {
  display: none;
  background: transparent;
  border: 2px solid var(--primary-color);
  border-radius: var(--radius);
  padding: 8px 12px;
  cursor: pointer;
  transition: var(--transition);
}

.navbar-toggle:hover {
  background: var(--primary-color);
  color: var(--white);
}

.navbar-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  margin: 3px 0;
  transition: var(--transition);
}

/* Clear desktop/mobile navigation behavior */

/* DESKTOP: Wide screens (992px+) - Always show full menu */
@media (min-width: 992px) {
  .navbar-toggle {
    display: none !important;
  }

  .nav.menu {
    display: block !important;
    position: static !important;
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  .nav.menu li {
    width: auto !important;
    display: inline-block !important;
    float: none !important;
  }

  .nav.menu li a {
    padding: 0.5rem 1rem !important;
    border-bottom: none !important;
    display: inline-block !important;
  }
}

/* MOBILE/TABLET: Narrow screens (991px and below) - Hamburger menu only */
@media (max-width: 991px) {
  .navbar-toggle {
    display: block !important;
    visibility: visible !important;
  }

  /* Force hide menu by default on ALL mobile/tablet sizes */
  .nav.menu,
  ul.nav.menu,
  .nav ul.menu,
  ul.menu.nav,
  .navbar .nav.menu,
  .navbar ul.menu,
  .navbar-collapse .nav.menu,
  #navbar-menu .nav.menu,
  .masthead .nav.menu {
    display: none !important;
    visibility: hidden !important;
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    background: var(--white) !important;
    box-shadow: var(--shadow) !important;
    border-radius: 0 0 var(--radius) var(--radius) !important;
    z-index: 1000 !important;
    width: 100% !important;
    float: none !important;
  }

  /* Only show when explicitly toggled */
  .nav.menu.show,
  ul.nav.menu.show,
  .nav ul.menu.show,
  ul.menu.nav.show,
  .navbar .nav.menu.show,
  .navbar ul.menu.show,
  .navbar-collapse .nav.menu.show,
  #navbar-menu .nav.menu.show,
  .masthead .nav.menu.show {
    display: block !important;
    visibility: visible !important;
  }

  /* Force mobile menu item styling */
  .nav.menu li,
  ul.nav.menu li,
  .nav ul.menu li,
  ul.menu.nav li,
  .navbar .nav.menu li,
  .navbar ul.menu li {
    width: 100% !important;
    float: none !important;
    display: block !important;
    clear: both !important;
  }

  .nav.menu li a,
  ul.nav.menu li a,
  .nav ul.menu li a,
  ul.menu.nav li a,
  .navbar .nav.menu li a,
  .navbar ul.menu li a {
    padding: 1rem !important;
    border-bottom: 1px solid var(--border-color) !important;
    display: block !important;
    width: 100% !important;
    float: none !important;
  }

  /* Hide any dropdown indicators on mobile */
  .nav.menu .dropdown-toggle:after,
  .nav.menu .caret {
    display: none !important;
  }

  /* Override any Bootstrap or template CSS that might show the menu */
  .navbar-nav,
  .nav-pills,
  .nav-tabs {
    display: none !important;
  }

  .navbar-nav.show,
  .nav-pills.show,
  .nav-tabs.show {
    display: block !important;
  }
}

/* Modern Card Layout */
.module {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: var(--transition);
}

.module:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Modern Forms */
input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  font-family: var(--font-family);
  transition: var(--transition);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(186, 161, 116, 0.1);
}

/* Modern Buttons */
.btn,
.button,
button[type="submit"] {
  background: var(--primary-color);
  color: var(--white);
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-family: var(--font-family);
  font-weight: 500;
  text-decoration: none;
  display: inline-block;
  transition: var(--transition);
  cursor: pointer;
}

.btn:hover,
.button:hover,
button[type="submit"]:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

/* Responsive Images */
img {
  max-width: 100%;
  height: auto;
}

/* Modern Table */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

table th,
table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

table th {
  background: var(--bg-color);
  font-weight: 600;
}

/* Responsive Table */
@media (max-width: 768px) {
  table {
    font-size: 0.875rem;
  }

  table th,
  table td {
    padding: 0.5rem;
  }
}

/* Restored Original Typography */
h1, h1.contentheading {
  font-family: var(--font-family);
  padding: 0;
  margin: 0;
  font-size: clamp(1.25rem, 1vw, 2rem);
  font-weight: 700;
  vertical-align: bottom;
  color: #215DB6;
  text-align: left;
  width: 100%;
  text-transform: uppercase;
  line-height: 1.3;
}

h2 {
  font-family: var(--font-family);
  font-weight: normal;
  line-height: 1.3;
  margin: 0 0 1rem 0;
  color: #215DB6;
}

h3 {
  font-family: var(--font-family);
  width: 97%;
  margin: 0;
  line-height: 1.3;
  padding: clamp(0.25rem, 1vw, 0.75rem) 10px 0 0;
  font-size: clamp(0.875rem, 1vw, 1.25rem);
  color: #215DB6;
  text-align: left;
  font-weight: 700;
  overflow: hidden;
  text-transform: uppercase;
}

h4, h5, h6 {
  font-family: var(--font-family);
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 1rem 0;
  color: #215DB6;
}

h4 { font-size: 1.1rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.9rem; }

/* Preserve original showcase h3 styles */
.showcase h3 {
  margin: 0 0 10px 0;
  padding: 0;
  font-size: 1rem;
}

/* Preserve original module color variations */
.module.red h3 { color: #c44742; }
.module.blue h3 { color: #003399; }
.module.orange h3 { color: #e1962d; }
.module.green h3 { color: #52a452; }
.module.cyan h3 { color: #429db8; }

.row2 h3 { color: #666; }

/* Modern Links */
a {
  color: var(--primary-color);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* Accessibility Improvements */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus styles for better accessibility */
*:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Mobile Text Contrast Improvements */
@media (max-width: 768px) {
  body {
    color: var(--text-color-mobile);
  }

  p, li, td, div, span {
    color: var(--text-color-mobile);
    font-weight: 400;
  }

  /* Ensure module text is readable */
  .module,
  .module p,
  .module li,
  .module div {
    color: var(--text-color-mobile) !important;
  }

  /* Make sure links are still visible */
  a {
    color: var(--primary-color);
    font-weight: 500;
  }

  /* Improve content readability */
  .content,
  .content p,
  .content div,
  .content li {
    color: var(--text-color-mobile) !important;
    text-shadow: none;
  }

  /* Better contrast for small text */
  small,
  .small,
  .date,
  .meta {
    color: #555 !important;
    font-weight: 500;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --text-color: #000;
    --text-color-mobile: #000;
    --border-color: #000;
  }

  body {
    color: #000;
  }

  .module {
    border: 2px solid #000;
  }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --text-color: #e0e0e0;
    --bg-color: #1a1a1a;
    --white: #2a2a2a;
    --border-color: #404040;
  }

  /* Fix transparent PNG images with black lines in dark mode */
  .leftcol img,
  .rightcol img,
  .module img {
    /* Add white background to make black lines visible */
    background-color: rgba(255, 255, 255, 0.9);
    padding: 4px;
    border-radius: 4px;
  }

  /* Alternative: Invert dark images to make them light */
  .leftcol img[src*=".png"],
  .rightcol img[src*=".png"] {
    filter: invert(1) hue-rotate(180deg);
    background-color: transparent;
    padding: 0;
  }

  /* Keep photos and colored images normal */
  .leftcol img[alt*="photo"],
  .leftcol img[alt*="color"],
  .rightcol img[alt*="photo"],
  .rightcol img[alt*="color"],
  .content img {
    filter: none;
    background-color: transparent;
    padding: 0;
  }
}

/* Fix jawnav module hamburger menu auto-expansion on tablets and medium screens */
@media (min-width: 992px) {
  /* Force desktop behavior for jawnav on large screens */
  #jawnav {
    width: auto !important;
  }

  #jawnav ul {
    width: auto !important;
  }

  #jawnav > ul > li,
  #jawnav.align-center > ul > li,
  #jawnav.align-right > ul > li {
    float: left !important;
    display: inline-block !important;
  }

  #jawnav ul li,
  #jawnav ul ul li,
  #jawnav ul li:hover > ul > li {
    width: auto !important;
    height: auto !important;
  }

  #jawnav ul li a,
  #jawnav ul ul li a {
    width: auto !important;
  }

  /* Hide submenus by default */
  #jawnav ul ul,
  #jawnav ul ul ul {
    position: absolute !important;
    left: 0 !important;
    right: auto !important;
    width: auto !important;
    margin: 0 !important;
    display: none !important;
  }

  /* Show submenus only on hover */
  #jawnav ul li:hover > ul {
    display: block !important;
  }

  #jawnav > ul > li.has-sub > a::after,
  #jawnav ul ul li.has-sub > a::after {
    display: block !important;
  }

  #jawnav #menu-button {
    display: none !important;
  }

  #jawnav .submenu-button {
    display: none !important;
  }
}

/* Override jawnav's complex media query that affects medium screens */
@media only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 992px) and (max-width: 1024px),
       only screen and (min--moz-device-pixel-ratio: 2) and (min-width: 992px) and (max-width: 1024px),
       only screen and (-o-min-device-pixel-ratio: 2/1) and (min-width: 992px) and (max-width: 1024px),
       only screen and (min-device-pixel-ratio: 2) and (min-width: 992px) and (max-width: 1024px),
       only screen and (min-resolution: 192dpi) and (min-width: 992px) and (max-width: 1024px),
       only screen and (min-resolution: 2dppx) and (min-width: 992px) and (max-width: 1024px) {

  /* Force desktop behavior on high-DPI medium screens */
  #jawnav {
    width: auto !important;
  }

  #jawnav ul {
    width: auto !important;
  }

  #jawnav > ul > li,
  #jawnav.align-center > ul > li,
  #jawnav.align-right > ul > li {
    float: left !important;
    display: inline-block !important;
  }

  #jawnav ul li,
  #jawnav ul ul li,
  #jawnav ul li:hover > ul > li {
    width: auto !important;
    height: auto !important;
  }

  #jawnav ul ul,
  #jawnav ul ul ul {
    position: absolute !important;
    left: 0 !important;
    right: auto !important;
    width: auto !important;
    margin: 0 !important;
    display: none !important;
  }

  #jawnav ul li:hover > ul {
    display: block !important;
  }

  #jawnav #menu-button {
    display: none !important;
  }

  #jawnav .submenu-button {
    display: none !important;
  }
}

/* Mobile-specific dark mode image fixes */
@media (max-width: 768px) and (prefers-color-scheme: dark) {
  .leftcol img,
  .rightcol img,
  .module img {
    /* Stronger contrast for mobile dark mode */
    background-color: rgba(255, 255, 255, 0.95);
    padding: 6px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  }

  /* Force visibility with backdrop */
  .leftcol img[src*=".png"],
  .rightcol img[src*=".png"] {
    backdrop-filter: blur(0px);
    background-color: rgba(255, 255, 255, 0.9) !important;
    filter: none;
  }
}

/* Print styles */
@media print {
  .navbar,
  .module:not(.content),
  .footer {
    display: none !important;
  }

  body {
    background: white !important;
    color: black !important;
    font-size: 12pt;
    line-height: 1.4;
  }

  .container {
    max-width: none;
    padding: 0;
  }
}