/* ==========================================================================
   MINISTRY OF TRANSPORT — REPUBLIC OF SOUTH SUDAN
   Official Sovereign Civic Portal Design System
   Design Standard: Civic Modernism & High-Agency Institutional Clarity
   WCAG 2.2 AAA Accessibility Compliant
   ========================================================================== */

/* ---------- CSS Custom Properties (Design Tokens) ---------- */
:root {
  /* Institutional Sovereign Palette (Deep Obsidian Slate, Pure Canvas, Refined Ochre) */
  --navy-950:        #061325;
  --navy-900:        #0A1C33;
  --navy-850:        #0D233F;
  --navy-800:        #112D52;
  --navy-700:        #183D68;
  --navy-600:        #204E85;
  --navy-200:        #CBDCEE;
  --navy-100:        #E4EDF7;
  --navy-50:         #F3F7FC;

  /* Sovereign Accent (Refined Warm Ochre / Sun Gold) - Saturation < 80% */
  --gold-700:        #92400E;
  --gold-600:        #B45309;
  --gold-500:        #D97706;
  --gold-400:        #F59E0B;
  --gold-300:        #FCD34D;
  --gold-100:        #FEF3C7;
  --gold-50:         #FFFBEB;

  /* Civic & Semantic Status Accents */
  --emerald-700:     #047857;
  --emerald-600:     #059669;
  --emerald-500:     #10B981;
  --emerald-100:     #D1FAE5;
  --emerald-50:      #ECFDF5;

  --crimson-700:     #991B1B;
  --crimson-600:     #DC2626;
  --crimson-100:     #FEE2E2;
  --crimson-50:      #FEF2F2;

  --sky-700:         #0369A1;
  --sky-600:         #0284C7;
  --sky-100:         #E0F2FE;
  --sky-50:          #F0F9FF;

  /* Neutral Surface Architecture */
  --canvas:          #F8FAFC;
  --surface:         #FFFFFF;
  --surface-alt:     #F1F5F9;
  --surface-hover:   #F8FAFC;
  --surface-dark:    #061325;
  --surface-dark-card:#0A1C33;

  /* Typography Palette (WCAG 2.2 AAA Strict Contrast) */
  --text-heading:    #0A1C33;
  --text-primary:    #0F172A;
  --text-secondary:  #334155;
  --text-muted:      #64748B;
  --text-light:      #94A3B8;
  --text-on-dark:    #F8FAFC;
  --text-on-dark-muted: #94A3B8;

  /* Hairline Border System */
  --border-subtle:   rgba(10, 28, 51, 0.06);
  --border-default:  #E2E8F0;
  --border-strong:   #CBD5E1;
  --border-focus:    #D97706;
  --border-dark:     rgba(255, 255, 255, 0.1);
  --border-dark-strong: rgba(255, 255, 255, 0.18);

  /* Typography Stack */
  --font-display:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body:       'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:       'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Elevation & Diffusion Shadows */
  --shadow-xs:       0 1px 2px rgba(6, 19, 37, 0.04);
  --shadow-sm:       0 1px 3px rgba(6, 19, 37, 0.06), 0 1px 2px rgba(6, 19, 37, 0.03);
  --shadow-md:       0 4px 14px -2px rgba(6, 19, 37, 0.08), 0 2px 4px -1px rgba(6, 19, 37, 0.03);
  --shadow-lg:       0 12px 28px -4px rgba(6, 19, 37, 0.09), 0 4px 8px -2px rgba(6, 19, 37, 0.03);
  --shadow-xl:       0 20px 40px -8px rgba(6, 19, 37, 0.12);
  --shadow-bento:    0 20px 40px -15px rgba(6, 19, 37, 0.05);

  /* Precise Radii Scale */
  --radius-xs:       4px;
  --radius-sm:       8px;
  --radius-md:       12px;
  --radius-lg:       18px;
  --radius-xl:       24px;
  --radius-2xl:      32px;
  --radius-full:     9999px;

  /* Animation & Fluid Physics Curves */
  --ease-spring:     cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  --transition:      all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: all 0.45s cubic-bezier(0.16, 1, 0.3, 1);

  /* Layout Constrain */
  --max-width:       1320px;
  --header-height:   74px;
  --topbar-height:   38px;
}

/* ---------- CSS Reset & Base Setup ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  color: var(--text-secondary);
  background-color: var(--canvas);
  line-height: 1.58;
  overflow-x: hidden;
  letter-spacing: -0.011em;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1 0 auto;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

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

ul, ol {
  list-style: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

code, pre, kbd, samp {
  font-family: var(--font-body);
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* Tabular Numerals for Metrics, Dates, and Codes */
.tabular-nums,
[data-count],
.stat-number,
.badge-code,
.tender-ref,
.date-stamp,
.price-tag {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Accessibility Skip Link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1.5rem;
  background: var(--navy-950);
  color: #FFFFFF;
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  z-index: 99999;
  transition: top 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gold-500);
}
.skip-link:focus {
  top: 1.5rem;
}

/* Global Focus-Visible Replacement */
:focus-visible {
  outline: 2px solid var(--gold-500);
  outline-offset: 3px;
  border-radius: var(--radius-xs);
}

/* Heading Anchor Scroll-Margin */
[id] {
  scroll-margin-top: calc(var(--header-height) + var(--topbar-height) + 1.5rem);
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--text-heading);
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(3rem, 5vw, 4.5rem);
  font-weight: 600;
  letter-spacing: -0.065em;
  line-height: 1.02;
}

h2 {
  font-size: clamp(2.5rem, 4vw, 4rem);
  font-weight: 600;
  letter-spacing: -0.065em;
  line-height: 1.02;
}

h3 {
  font-size: clamp(1.5rem, 2.1vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.065em;
  line-height: 1.05;
}

h4 {
  font-size: 1.1rem;
  font-weight: 600;
}

p {
  color: var(--text-secondary);
  font-size: 1.125rem;
  line-height: 1.58;
  max-width: 68ch;
}

p.lead {
  font-size: 1.25rem;
  line-height: 1.58;
  color: var(--text-primary);
}

/* ---------- Layout System & Containers ---------- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

@media (min-width: 1400px) {
  .container {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

.section {
  padding: 5.5rem 0;
  position: relative;
}

.section-sm {
  padding: 3.5rem 0;
}

.section-lg {
  padding: 7.5rem 0;
}

.bg-white {
  background-color: var(--surface);
}

.bg-canvas {
  background-color: var(--canvas);
}

.bg-gray {
  background-color: var(--surface-alt);
}

.bg-navy {
  background-color: var(--navy-950);
  color: var(--text-on-dark);
}

.bg-navy h1, .bg-navy h2, .bg-navy h3, .bg-navy h4, .bg-navy strong {
  color: #FFFFFF;
}

.bg-navy p {
  color: rgba(248, 250, 252, 0.82);
}

/* Section Header Structure */
.section-header {
  margin-bottom: 3.5rem;
  position: relative;
}

.section-header.text-center {
  text-align: center;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

.section-header .badge {
  margin-bottom: 0.85rem;
}

.section-header h2 {
  margin-bottom: 0.85rem;
}

.section-header p {
  font-size: 1.05rem;
  color: var(--text-muted);
}

.section-header.text-center p {
  margin-left: auto;
  margin-right: auto;
}

.divider {
  width: 48px;
  height: 3px;
  background: var(--gold-500);
  border-radius: var(--radius-full);
  margin-top: 1.25rem;
}

.section-header.text-center .divider {
  margin-left: auto;
  margin-right: auto;
}

/* ---------- Grid Layouts (Strict CSS Grid) ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.75rem;
}

@media (min-width: 640px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) {
  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
  .grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ---------- TOP BAR (Civic & Multi-lingual) ---------- */
.top-bar {
  background: var(--navy-950);
  color: #FFFFFF;
  font-size: 0.8125rem;
  height: var(--topbar-height);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  position: relative;
  z-index: 1001;
}

.top-bar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.country-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #FFFFFF;
  font-size: 0.8rem;
}

.current-date, .live-clock {
  color: var(--text-on-dark-muted);
  font-size: 0.775rem;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.search-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.85);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-xs);
  font-size: 0.775rem;
  font-weight: 500;
  transition: var(--transition-fast);
}

.search-trigger-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.3);
}

.kbd-shortcut {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--gold-400);
  font-family: var(--font-mono);
  font-size: 0.675rem;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
}

.top-bar-right a {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.785rem;
  font-weight: 500;
}

.top-bar-right a:hover {
  color: #FFFFFF;
}

/* Flag Stripe Header Accent */
.flag-strip {
  display: flex;
  width: 100%;
  height: 3px;
  position: relative;
  z-index: 1000;
}

.flag-strip .s1 { flex: 1; background: #000000; }
.flag-strip .s2 { flex: 1; background: #DC2626; }
.flag-strip .s3 { flex: 1; background: #16A34A; }
.flag-strip .s4 { flex: 1; background: #2563EB; }
.flag-strip .s5 { flex: 1; background: #D97706; }

/* ---------- HEADER & NAVIGATION ---------- */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border-default);
  position: sticky;
  top: 0;
  z-index: 999;
  transition: var(--transition);
}

.header.scrolled {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom-color: rgba(226, 232, 240, 0.85);
  box-shadow: var(--shadow-sm);
}

.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
}

.logo-emblem {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  transition: transform 0.25s var(--ease-spring);
}

.logo:hover .logo-emblem {
  transform: scale(1.04);
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.ministry-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--navy-950);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.country-name {
  font-size: 0.725rem;
  font-weight: 700;
  color: var(--gold-600);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 1px;
}

/* Nav Menu Desktop */
.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-item {
  position: relative;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.8875rem;
  font-weight: 600;
  color: var(--navy-950);
  border-radius: var(--radius-xs);
  transition: var(--transition-fast);
  position: relative;
}

.nav-link:hover {
  color: var(--gold-600);
  background: var(--surface-alt);
}

.nav-link.active {
  color: var(--gold-600);
  font-weight: 700;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0.85rem;
  right: 0.85rem;
  height: 2px;
  background: var(--gold-500);
  border-radius: var(--radius-full);
}

/* Dropdown Menu */
.dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 250px;
  background: var(--surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: var(--transition);
  z-index: 100;
}

.nav-item:hover .dropdown,
.nav-item:focus-within .dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  border-radius: var(--radius-xs);
  transition: var(--transition-fast);
}

.dropdown a:hover {
  background: var(--surface-alt);
  color: var(--gold-600);
  padding-left: 1.05rem;
}

/* Mobile Toggle */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 28px;
  height: 20px;
  padding: 0;
}

.menu-toggle span {
  display: block;
  height: 2.5px;
  width: 100%;
  background: var(--navy-950);
  border-radius: var(--radius-full);
  transition: var(--transition);
}

.menu-toggle.active span:nth-child(1) {
  transform: translateY(8.5px) rotate(45deg);
}
.menu-toggle.active span:nth-child(2) {
  opacity: 0;
}
.menu-toggle.active span:nth-child(3) {
  transform: translateY(-8.5px) rotate(-45deg);
}

@media (max-width: 1080px) {
  .menu-toggle {
    display: flex;
  }

  .nav {
    position: fixed;
    top: calc(var(--header-height) + var(--topbar-height) + 3px);
    left: 0;
    width: 100%;
    height: calc(100dvh - var(--header-height) - var(--topbar-height) - 3px);
    background: var(--surface);
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    padding: 1.5rem;
    overflow-y: auto;
    border-top: 1px solid var(--border-default);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-xl);
  }

  .nav.mobile-open {
    transform: translateX(0);
  }

  .nav-link {
    font-size: 1rem;
    padding: 0.75rem 1rem;
  }

  .dropdown {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    background: var(--surface-alt);
    margin-left: 1rem;
    margin-bottom: 0.5rem;
  }
}

/* ---------- PAGE HERO (Inner Pages) ---------- */
.page-hero {
  background: var(--navy-950);
  color: var(--text-on-dark);
  padding: 4.5rem 0 4rem;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.page-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 18%;
  height: 100%;
  background: rgba(217, 119, 6, 0.10);
  border-right: 1px solid rgba(217, 119, 6, 0.35);
  pointer-events: none;
}

.page-hero .breadcrumb {
  margin-bottom: 1.25rem;
}

.page-hero h1 {
  color: #FFFFFF;
  margin-bottom: 0.85rem;
}

.page-hero p {
  color: rgba(248, 250, 252, 0.82);
  font-size: 1.15rem;
  line-height: 1.65;
  max-width: 65ch;
}

/* Breadcrumb Component */
.breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--text-on-dark-muted);
}

.breadcrumb a {
  color: rgba(255, 255, 255, 0.75);
}

.breadcrumb a:hover {
  color: var(--gold-400);
}

.breadcrumb .sep {
  opacity: 0.4;
}

.breadcrumb .current {
  color: var(--gold-400);
  font-weight: 600;
}

/* Light Breadcrumb */
.breadcrumb-light {
  color: var(--text-muted);
}
.breadcrumb-light a {
  color: var(--navy-800);
}
.breadcrumb-light a:hover {
  color: var(--gold-600);
}
.breadcrumb-light .current {
  color: var(--text-primary);
}

/* ---------- FOOTER ---------- */
.footer {
  background: var(--navy-950);
  color: var(--text-on-dark);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.9rem;
}

.footer-top {
  padding: 5rem 0 3.5rem;
}

.footer-top .container {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1.2fr;
  gap: 3.5rem;
}

@media (max-width: 1024px) {
  .footer-top .container {
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
  }
}

@media (max-width: 640px) {
  .footer-top .container {
    grid-template-columns: 1fr;
    gap: 2.25rem;
  }
}

.footer-brand p {
  color: rgba(248, 250, 252, 0.75);
  font-size: 0.875rem;
  line-height: 1.65;
  margin: 1.15rem 0 1.5rem;
}

.footer-social {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.footer-social a {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.85);
  transition: var(--transition-fast);
}

.footer-social a:hover {
  background: var(--gold-500);
  border-color: var(--gold-500);
  color: #FFFFFF;
  transform: translateY(-2px);
}

.footer-social svg {
  width: 18px;
  height: 18px;
}

.footer-col h2,
.footer-col h4 {
  color: #FFFFFF;
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1.25rem;
  position: relative;
  padding-bottom: 0.5rem;
}

.footer-col h2::after,
.footer-col h4::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 24px;
  height: 2px;
  background: var(--gold-500);
  border-radius: var(--radius-full);
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.footer-links a {
  color: rgba(248, 250, 252, 0.72);
  font-size: 0.86rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: var(--transition-fast);
}

.footer-links a:hover {
  color: var(--gold-400);
  transform: translateX(3px);
}

.footer-contact p {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  color: rgba(248, 250, 252, 0.75);
  font-size: 0.85rem;
  margin-bottom: 0.85rem;
}

.footer-contact .icon {
  color: var(--gold-400);
  flex-shrink: 0;
  margin-top: 2px;
}

.footer-contact svg {
  width: 16px;
  height: 16px;
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1.5rem 0;
  font-size: 0.8125rem;
  color: rgba(248, 250, 252, 0.6);
}

.footer-bottom .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-bottom a {
  color: rgba(248, 250, 252, 0.75);
}

.footer-bottom a:hover {
  color: var(--gold-400);
}

/* ---------- BACK TO TOP ---------- */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--navy-950);
  color: #FFFFFF;
  border: 1px solid var(--gold-500);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: var(--transition);
  z-index: 900;
  font-size: 1.1rem;
  font-weight: 700;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--gold-500);
  border-color: var(--gold-600);
  transform: translateY(-2px);
}

/* ---------- PREFERS REDUCED MOTION (WCAG Compliance) ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
