/* ==========================================================================
       1. CSS RESET & NORMALIZE (Modern best practices)
========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body,
h1,
h2,
h3,
h4,
p,
ul,
li,
figure,
figcaption,
blockquote,
dl,
dd {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  /* Modern typographic foundation */
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.6;
}

ul[class],
ol[class] {
  list-style: none;
}

a:not([class]) {
  text-decoration-skip-ink: auto;
}

img {
  max-width: 100%;
  display: block;
  font-style: italic; /* If image fails to load, alt text is italicized */
}

/* ==========================================================================
       2. DESIGN VARIABLES & FLUID TYPOGRAPHY (W3C Modern Specs)
========================================================================== */
:root {
  /* Colors */
  --primary-text: #111827;
  --secondary-text: #4b5563;
  --accent-color: #001d5c;
  --hover-color: #2563eb;
  --bg-color: #ffffff;
  --focus-outline: #080153;

  /* Layout */
  --max-width: 800px;

  /* Fluid Typography (clamp: min, preferred, max) */
  --font-size-base: clamp(1rem, 0.95vw + 0.8rem, 1.125rem); /* ~16px to 18px */
  --font-size-h1: clamp(2rem, 4vw + 1rem, 3rem);
  --font-size-h2: clamp(1.35rem, 2vw + 0.9rem, 1.75rem);
  --font-size-h3: clamp(1.15rem, 1.5vw + 0.8rem, 1.35rem);
  --font-size-h4: clamp(1.05rem, 1vw + 0.8rem, 1.15rem);
}

/* ==========================================================================
       3. BASE TYPOGRAPHY & LAYOUT
========================================================================== */
body {
  /* Advanced modern system font stack prioritizing variable fonts */
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI Variable',
    'Segoe UI',
    Roboto,
    'Helvetica Neue',
    Arial,
    sans-serif;
  font-optical-sizing: auto; /* Leverages variable fonts capabilities */
  font-size: var(--font-size-base);
  color: var(--primary-text);
  background-color: var(--bg-color);
  padding: 3rem 1.5rem;
  word-wrap: break-word;
}

/* STRICT 1-COLUMN FOR MAIN CONTENT */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  display: block;
}

section {
  width: 100%;
  margin-bottom: 2.5rem;
}

article {
  margin-bottom: 2rem;
}

/* ==========================================================================
       4. HEADER STYLES
========================================================================== */
.header-container {
  margin-bottom: 3rem;
  border-bottom: 2px solid var(--primary-text);
  padding-bottom: 2rem;
  display: flex;
  flex-direction: column; /* Stack vertically */
}

.header-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}

h1,
h2,
h3,
h4 {
  text-wrap: balance; /* W3C modern feature: prevents orphaned words in headings */
}

h1 {
  font-size: var(--font-size-h1);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: -0.025em;
}

.role-title {
  font-size: var(--font-size-h3);
  font-weight: 600;
  color: var(--secondary-text);
  margin-bottom: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.language-switcher {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
}

.lang-btn {
  padding: 0.5rem 1rem;
  border: 2px solid var(--primary-text);
  background: transparent;
  color: var(--primary-text);
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 0.25rem;
}

.lang-btn:hover {
  background: var(--primary-text);
  color: white;
}

.lang-btn.active {
  background: var(--primary-text);
  color: white;
}

.header-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2.5rem;
}

.profile-photo {
  width: 160px;
  height: 160px;
  border-radius: 0.75rem;
  object-fit: cover;
  flex-shrink: 0;
  background-color: #f3f4f6;
}

.contact-info {
  flex: 1;
}

/* Contact Block inside Header */
address {
  font-style: normal;
  margin-bottom: 1rem;
  color: var(--secondary-text);
}

/* Interactive Links (Hover Effects Added) */
address a,
.social-links a,
.project-link-box a {
  color: var(--accent-color);
  text-decoration: underline;
  text-decoration-color: var(--accent-color);
  text-underline-offset: 3px; /* Better typographic spacing for underlines */
  display: inline-block;
  margin-bottom: 0.25rem;
  transition:
    color 0.2s ease,
    text-decoration-color 0.2s ease;
}

address a:hover,
.social-links a:hover,
.project-link-box a:hover {
  color: var(--hover-color);
  text-decoration-color: transparent;
}

.social-links {
  display: flex;
  justify-content: flex-start;
  gap: 1rem;
  list-style: none;
  margin-left: 0;
}

.social-links li {
  margin-bottom: 0.25rem;
}

/* ==========================================================================
       5. CONTENT TYPOGRAPHY
========================================================================== */
h2 {
  font-size: var(--font-size-h2);
  font-weight: 700;
  text-transform: uppercase;
  border-bottom: 1px solid #d1d5db; /* Lighter border for sections */
  padding-bottom: 0.5rem;
  margin-bottom: 1.25rem;
  color: var(--primary-text);
}

h3 {
  font-size: var(--font-size-h3);
  font-weight: 700;
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

h4 {
  font-size: var(--font-size-h4);
  font-weight: 600;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
  color: var(--primary-text);
}

p {
  margin-bottom: 1rem;
  text-wrap: pretty; /* Modern CSS: prevents typographic orphans at the end of paragraphs */
}

/* Regular Lists */
section ul {
  list-style-type: disc;
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

section li {
  margin-bottom: 0.35rem;
  text-wrap: pretty;
}

.date-location {
  display: block;
  color: var(--secondary-text);
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.project-link-box {
  margin-top: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
}

/* ==========================================================================
       6. ACCESSIBILITY (a11y)
========================================================================== */
a:focus-visible {
  outline: 3px solid var(--focus-outline);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ==========================================================================
       7. RESPONSIVE DESIGN (Mobile)
========================================================================== */
@media (max-width: 640px) {
  body {
    padding: 1.5rem 1rem;
  }

  .header-bottom {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
  }

  .header-top {
    text-align: center;
  }

  .social-links {
    justify-content: center;
  }
}

/* ==========================================================================
       8. PRINT STYLES (For PDF generation / physical printing)
========================================================================== */
@media print {
  @page {
    margin: 1.5cm;
  }

  :root {
    /* Reset to static sizes for consistent physical printing */
    --font-size-base: 11pt;
    --font-size-h1: 24pt;
    --font-size-h2: 16pt;
    --font-size-h3: 13pt;
    --font-size-h4: 11pt;
  }

  body {
    padding: 0;
    background-color: transparent;
  }

  .header-container {
    border-bottom: 2px solid #000;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
  }

  h1,
  h2,
  h3,
  h4,
  p,
  li,
  a {
    color: #000 !important; /* Force true black for crisp printing */
  }

  a {
    text-decoration: none; /* Hide underlines in print */
  }

  /* Avoid breaking sections or projects across pages */
  article,
  section {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  h2 {
    border-bottom-color: #000;
  }

  /* Print URLs explicitly next to social and projects links if needed */
  .social-links a::after,
  .project-link-box a::after {
    content: ' (' attr(href) ')';
    font-size: 0.9em;
    font-weight: normal;
  }

  .language-switcher {
    display: none !important; /* Hide language switcher in print */
  }
}
