/* Modern CSS Layout System - Optimized */

/* CSS Custom Properties (Enhanced) */
:root {
  /* Layout */
  --container-max-width: min(900px, 95vw);
  --content-width: min(840px, calc(100% - 60px));
  --header-height: clamp(120px, 16.2rem, 180px);
  
  /* Typography */
  --font-primary: "Trebuchet MS", system-ui, Arial, sans-serif;
  --font-secondary: "Segoe UI", Verdana, Arial, sans-serif;
  --font-size-base: clamp(14px, 1.6vw, 16px);
  --line-height-base: 1.5;
  
  /* Colors */
  --color-text: #7d7d7d;
  --color-text-dark: #323232;
  --color-text-light: #eaeff7;
  --color-border: #969696;
  --color-border-light: #c8c8c8;
  --color-bg-light: #f0f0f0;
  --color-bg-hover: #d2d2d2;
  --color-bg-nav: #e1e1e1;
  --color-bg-dropdown: #ededed;
  --color-link-primary: #467aa7;
  --color-link-hover: #2a5a8a;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-xxl: 3rem;
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
}

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

/* Base Styles */
html {
  font-size: 62.5%; /* 1rem = 10px for easier calculations */
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-primary);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-text-dark);
  background-color: #fff;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Modern Layout Container */
.page-container {
  max-width: var(--container-max-width);
  margin: var(--space-md) auto;
  border: 1px solid var(--color-border);
  background: #fff;
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* Header Layout - Modern Flexbox */
.header {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.header-top {
  height: 8rem;
  background: var(--color-bg-light) url(../img/bg_head_top.jpg) no-repeat;
  background-size: cover;
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 var(--space-xl);
}

.header-middle {
  height: var(--header-height);
  background: #e6e6e6 url(../img/bg_head_middle.jpg) no-repeat;
  background-size: cover;
  background-position: center;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
  overflow: hidden;
}

/* Logo and Site Name - Modern Positioning */
.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  z-index: 2;
}

.sitelogo {
  width: 6rem;
  height: 4rem;
  background: url(../img/bg_head_top_logo.jpg) no-repeat;
  background-size: contain;
  flex-shrink: 0;
}

.sitename {
  flex: 1;
  min-width: 0; /* Allow text truncation */
}

.sitename h1 {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  line-height: 1.1;
  margin: 0;
}

.sitename h2 {
  color: var(--color-text);
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  margin: var(--space-xs) 0 0;
  font-weight: normal;
}

.sitename a {
  text-decoration: none;
  color: inherit;
  transition: color var(--transition-fast);
}

.sitename a:hover {
  color: var(--color-text-dark);
}

/* Site Message - Modern Positioning */
.sitemessage {
  flex: 1;
  max-width: 40rem;
  color: var(--color-text-light);
  text-align: right;
  z-index: 2;
}

.sitemessage h1 {
  font-size: clamp(1.6rem, 3.5vw, 2.3rem);
  line-height: 1.1;
  margin: 0;
}

.sitemessage h2 {
  font-size: clamp(1.2rem, 2.8vw, 1.6rem);
  line-height: 1.2;
  margin: var(--space-sm) 0 0;
  font-weight: normal;
}

.sitemessage h3 {
  font-size: clamp(1rem, 2.2vw, 1.4rem);
  margin: var(--space-md) 0 0;
  font-weight: normal;
}

.sitemessage a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.sitemessage a:hover {
  color: var(--color-text-dark);
}

/* Navigation - Modern Flexbox Layout */
.nav-container {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-xl);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.nav0,
.nav1 {
  display: flex;
  justify-content: flex-end;
}

.nav0 ul,
.nav1 ul {
  display: flex;
  list-style: none;
  gap: var(--space-sm);
  align-items: center;
}

.nav0 a {
  display: flex;
  align-items: center;
  transition: transform var(--transition-fast);
}

.nav0 a:hover {
  transform: scale(1.1);
}

.nav0 img {
  height: 1.4rem;
  width: auto;
}

.nav1 a {
  padding: var(--space-xs) var(--space-sm);
  color: var(--color-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.2rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.nav1 a:hover {
  color: var(--color-text-dark);
  background: rgba(255, 255, 255, 0.2);
}

/* Main Navigation - Modern Dropdown */
.nav2 {
  background: var(--color-bg-nav) url(../img/bg_head_bottom_nav.jpg) no-repeat;
  background-size: cover;
  border-top: 1px solid var(--color-border-light);
  position: relative;
}

.nav2 ul {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav2 > ul > li {
  position: relative;
  border-right: 1px solid #afafaf;
}

.nav2 > ul > li:last-child {
  border-right: none;
}

.nav2 a {
  display: block;
  padding: var(--space-lg) var(--space-xl);
  text-decoration: none;
  font-weight: 600;
  color: #646464;
  font-size: 1.3rem;
  transition: background-color var(--transition-fast);
}

.nav2 > ul > li:hover > a {
  background-color: var(--color-bg-hover);
}

/* Modern Dropdown Menu */
.nav2 ul ul {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  background: var(--color-bg-dropdown);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--transition-base);
  z-index: 100;
}

.nav2 li:hover ul {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nav2 ul ul a {
  padding: var(--space-sm) var(--space-lg);
  border-bottom: 1px solid var(--color-border-light);
  font-weight: normal;
  color: var(--color-text-dark);
  font-size: 1.2rem;
}

.nav2 ul ul li:last-child a {
  border-bottom: none;
}

.nav2 ul ul a:hover {
  background-color: var(--color-bg-hover);
}

/* Breadcrumbs - Modern Layout */
.header-breadcrumbs {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-xl);
  background: #fff url(../img/bg_head_breadcrumbs.jpg) repeat-y;
  border-top: 1px solid var(--color-border-light);
}

.header-breadcrumbs ul {
  display: flex;
  list-style: none;
  flex-wrap: wrap;
  gap: var(--space-sm);
  font-family: var(--font-secondary);
}

.header-breadcrumbs li {
  display: flex;
  align-items: center;
  font-weight: 600;
  color: var(--color-text);
  font-size: 1rem;
}

.header-breadcrumbs li:not(:first-child)::before {
  content: "→";
  margin-right: var(--space-sm);
  color: var(--color-border);
}

.header-breadcrumbs a {
  color: var(--color-link-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.header-breadcrumbs a:hover {
  color: var(--color-link-hover);
  text-decoration: underline;
}

/* Search Form - Modern Styling */
.searchform {
  display: flex;
  gap: var(--space-sm);
}

.searchform input[type="text"] {
  padding: var(--space-sm);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  font-family: var(--font-secondary);
  font-size: 1.2rem;
  min-width: 150px;
  transition: border-color var(--transition-fast);
}

.searchform input[type="text"]:focus {
  outline: none;
  border-color: var(--color-link-primary);
  box-shadow: 0 0 0 2px rgba(70, 122, 167, 0.2);
}

.searchform input[type="submit"] {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-light);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-secondary);
  color: var(--color-text);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.searchform input[type="submit"]:hover {
  border-color: #505050;
  background: var(--color-bg-hover);
  color: #505050;
}

/* Main Content - Modern Grid/Flexbox */
.main {
  background: url(../img/bg_main_withoutnav.jpg) repeat-y;
  background-size: 100% auto;
  min-height: 400px;
}

.main-content {
  width: var(--content-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-md);
}

/* Column Layout - Modern Grid */
.column-container {
  display: grid;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.column1-unit {
  grid-template-columns: 1fr;
}

.column2-unit {
  grid-template-columns: 1fr 1fr;
}

.column3-unit {
  grid-template-columns: repeat(3, 1fr);
}

/* Individual Column Styles */
.column-unit {
  background: rgba(255, 255, 255, 0.9);
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* Footer - Modern Layout */
.footer {
  background: var(--color-bg-nav) url(../img/bg_foot.jpg) no-repeat;
  background-size: cover;
  padding: var(--space-lg);
  text-align: center;
  border-top: 1px solid var(--color-border-light);
}

.footer p {
  color: var(--color-text);
  font-weight: 600;
  font-size: 1.1rem;
  line-height: 1.3;
  margin: 0;
}

.footer .credits {
  font-weight: normal;
  margin-top: var(--space-sm);
}

.footer a {
  color: var(--color-text);
  text-decoration: underline;
  transition: color var(--transition-fast);
}

.footer a:hover {
  color: #000;
  text-decoration: none;
}

/* Responsive Design */
@media (max-width: 768px) {
  :root {
    --container-max-width: 100%;
    --space-xl: 1rem;
  }
  
  .page-container {
    margin: 0;
    border-radius: 0;
  }
  
  .header-middle {
    flex-direction: column;
    text-align: center;
    padding: var(--space-md);
    gap: var(--space-md);
  }
  
  .header-brand {
    justify-content: center;
  }
  
  .sitemessage {
    text-align: center;
    max-width: none;
  }
  
  .nav-container {
    position: static;
    align-items: center;
  }
  
  .nav2 ul {
    flex-direction: column;
    width: 100%;
  }
  
  .nav2 > ul > li {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #afafaf;
  }
  
  .nav2 ul ul {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    background: rgba(255, 255, 255, 0.1);
  }
  
  .header-breadcrumbs {
    flex-direction: column;
    gap: var(--space-md);
    align-items: stretch;
  }
  
  .column2-unit,
  .column3-unit {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .header-breadcrumbs ul {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .searchform {
    flex-direction: column;
  }
  
  .searchform input[type="text"] {
    min-width: auto;
  }
}

/* Modern Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus Styles */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--color-link-primary);
  outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  :root {
    --color-border: #000;
    --color-text: #000;
    --shadow-sm: none;
    --shadow-md: none;
  }
}

/* Print Styles */
@media print {
  .nav-container,
  .nav2,
  .searchform {
    display: none;
  }
  
  .page-container {
    box-shadow: none;
    border: none;
  }
  
  * {
    background: none !important;
    box-shadow: none !important;
  }
}