/*
 * Base Styles - Modern foundation using CSS variables
 * Overrides and modernizes existing table-based layout
 * while maintaining visual consistency
 */

/* ===== Reset & Base ===== */

* {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-primary);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  margin: 0;
  padding: var(--space-4) var(--space-6);
  max-width: var(--container-xl);
  margin-left: auto;
  margin-right: auto;
}

/* ===== Typography Enhancements ===== */

/* Override legacy FONT tags while maintaining sizes */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-primary);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-tight);
  margin-top: var(--space-6);
  margin-bottom: var(--space-4);
}

h1 {
  font-size: var(--font-size-3xl);
  color: var(--color-text);
}

h2 {
  font-size: var(--font-size-2xl);
}

h3 {
  font-size: var(--font-size-xl);
}

p {
  margin-top: var(--space-4);
  margin-bottom: var(--space-4);
  line-height: var(--line-height-relaxed);
}

/* Bold and italic from legacy markup */
b, strong {
  font-weight: var(--font-weight-bold);
}

i, em {
  font-style: italic;
}

/* ===== Links ===== */

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

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

a:visited {
  color: var(--color-link-visited);
}

a:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ===== Lists ===== */

ul, ol {
  padding-left: var(--space-8);
  margin-top: var(--space-4);
  margin-bottom: var(--space-4);
}

li {
  margin-bottom: var(--space-1);
  line-height: var(--line-height-normal);
}

/* Remove extra spacing from paragraphs inside list items */
li p {
  margin-top: 0;
  margin-bottom: 0;
}

/* ===== Tables (Legacy Support) ===== */

table {
  border-collapse: collapse;
  width: 100%;
}

td, th {
  vertical-align: top;
}

/* ===== Horizontal Rules ===== */

hr {
  border: 0;
  border-top: var(--border-width-thin) solid var(--color-border);
  margin: var(--space-8) 0;
}

/* ===== Images ===== */

img {
  max-width: 100%;
  height: auto;
  display: inline-block;
  vertical-align: middle;
}

/* SVG icons specific styling */
img[src$=".svg"] {
  display: inline-block;
  vertical-align: middle;
}

/* Professional photo - add white frame */
img[alt*="Natalia photo"],
img[alt*="photo"] {
  border: 8px solid white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  background: white;
}

/* Language flags styling - match all flag images */
img[src*="/flags/"],
img[alt*="flag"],
img[alt*="logo"][name*="flag"],
img[alt*="logo"][name*="RU"],
img[alt*="Nederlands"] {
  border-radius: var(--radius-sm);
  transition: opacity var(--transition-fast);
  /* Apply consistent padding to both active and inactive for alignment */
  padding: 3px;
  background: white;
  box-sizing: border-box;
}

/* Active language flag - blue border with white spacing */
img[src*="/flags/"]:not(a img),
img[alt*="flag"]:not(a img),
img[alt*="logo"][name*="RU"]:not(a img),
img[alt*="Nederlands"]:not(a img) {
  border: 2px solid var(--color-primary) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Inactive language flag - transparent border, slightly dimmed, with hover effect */
a img[src*="/flags/"],
a img[alt*="flag"],
a img[alt*="logo"][name*="RU"],
a img[alt*="Nederlands"] {
  opacity: 0.75;
  border: 2px solid transparent !important;
}

a img[src*="/flags/"]:hover,
a img[alt*="flag"]:hover,
a img[alt*="logo"]:hover,
a img[alt*="Nederlands"]:hover {
  opacity: 1;
}

/* ===== Contact Icons Enhancement ===== */

/* Contact paragraphs - display inline to keep phone and email on same line */
p:has(img[alt*="telephone"]),
p:has(img[alt*="email"]) {
  display: inline-block;
  margin-right: var(--space-4);
  margin-top: var(--space-2);
  margin-bottom: var(--space-2);
  font-size: var(--font-size-lg) !important;
}

/* Phone and email icons - display inline with text, scaled down */
img[alt*="telephone"],
img[alt*="email"] {
  display: inline-block !important;
  float: none !important;
  margin-right: var(--space-2);
  vertical-align: middle;
  height: 20px !important;
  width: auto;
}

/* Override large FONT SIZE tags in contact info */
p:has(img[alt*="telephone"]) font,
p:has(img[alt*="email"]) font {
  font-size: inherit !important;
}

/* PDF icons in lists */
img[alt*="PDF"] {
  margin-left: var(--space-2);
  vertical-align: middle;
  opacity: 0.9;
  transition: opacity var(--transition-fast);
}

a:hover img[alt*="PDF"] {
  opacity: 1;
}

/* ===== Utility Classes ===== */

.clearfix::after {
  content: '';
  display: table;
  clear: both;
}

/* ===== Accessibility ===== */

/* Skip to content link (for future implementation) */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-primary);
  color: white;
  padding: var(--space-2) var(--space-4);
  text-decoration: none;
  z-index: var(--z-modal);
}

.skip-link:focus {
  top: 0;
}

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ===== Print Styles ===== */

@media print {
  body {
    font-size: 12pt;
    line-height: 1.5;
    color: #000;
    background: #fff;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  /* Hide navigation in print */
  nav, .no-print {
    display: none !important;
  }

  /* Ensure proper page breaks */
  h1, h2, h3 {
    page-break-after: avoid;
  }

  table {
    page-break-inside: avoid;
  }

  img {
    max-width: 100%;
    page-break-inside: avoid;
  }
}

/* ===== Responsive Adjustments ===== */

@media (max-width: 768px) {
  body {
    font-size: var(--font-size-sm);
    padding: var(--space-3) var(--space-4);
  }

  h1 {
    font-size: var(--font-size-2xl);
  }

  h2 {
    font-size: var(--font-size-xl);
  }

  h3 {
    font-size: var(--font-size-lg);
  }

  /* Reduce spacing on mobile */
  p, ul, ol {
    margin-top: var(--space-3);
    margin-bottom: var(--space-3);
  }
}

@media (max-width: 480px) {
  body {
    padding: var(--space-2) var(--space-3);
  }
}
