:root {
  --font-family-fallback: Arial, sans-serif;
  --font-family-lato: "Lato", var(--font-family-fallback);
  --font-family-playwrite: "Playwrite DE LA", var(--font-family-fallback);
  
  --background-color-body: #121212; 
  --section-background-color: #1e1e1e; 
  --section-background-color-opacity: rgba(30, 30, 30, 0.95); 
  
  --text-color: #ffffff;
  --text-color-muted: #c0c0c0; /* Improved from #b0b0b0 for better contrast */
  --accent-color-large: #d19a68; /* Brightened from #a67c53 for better contrast */
  --accent-color-small: #9e7945; /* Made slightly brighter for better contrast */
  --accent-color-hover: #e6b583; 
  
  --border-color: #555; /* Brightened for better visibility */
  --box-shadow-static: 0 2px 8px rgba(0, 0, 0, 0.6);
  --box-shadow-hoverable: 0 6px 15px rgba(0,0,0,0.7);

  --text-color-inverted: #ffffff; /* Ensured maximum contrast */
  --accent-color-light: #d4b99c; 
  --accent-color-very-light: #e8dccf;

  --header-height: 60px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family-lato);
  background-color: var(--background-color-body);
  background-image: url('dark_background.webp'); 
  background-size: cover;
  background-attachment: fixed; /* Apply fixed background to body for global parallax */
  background-position: center center;
  background-repeat: no-repeat;
  color: var(--text-color);
  line-height: 1.7;
  font-size: 16px; 
  overflow-x: hidden; /* Prevent horizontal scroll */
}

body::-webkit-scrollbar { width: 8px; }
body::-webkit-scrollbar-track { background: var(--background-color-body); }
body::-webkit-scrollbar-thumb { background-color: var(--accent-color-small); border-radius: 4px; }

.container {
  width: 100%;
  max-width: 1000px; 
  margin: 0 auto;
  padding: 0 1.5rem; /* Increased side padding */
}

.site-header {
  background-color: rgba(18, 18, 18, 0.85); 
  backdrop-filter: blur(5px);
  padding: 0 1.5rem;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between; /* This ensures title on left, menu on right */
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid var(--border-color);
  width: 100%;
  contain: layout size; /* Improve performance with CSS containment */
}

.site-title { 
  font-family: var(--font-family-playwrite);
  color: var(--accent-color-large);
  font-size: clamp(1.5rem, 5vw, 1.8rem);
  text-decoration: none;
}

.nav-container {
  display: flex;
  align-items: center;
}

.nav-toggle { 
  display: block;
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 1.8rem; 
  cursor: pointer;
  padding: 0.5rem;
  z-index: 1001;
  margin-left: auto; /* Push to the right edge */
}
.hamburger-icon { 
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--text-color);
  position: relative;
  transition: background-color 0.1s 0.2s ease;
}
.hamburger-icon::before,
.hamburger-icon::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--text-color);
  transition: transform 0.3s ease, top 0.3s ease, bottom 0.3s ease;
}
.hamburger-icon::before { top: -7px; }
.hamburger-icon::after { bottom: -7px; }

.nav-toggle.is-active .hamburger-icon {
  background-color: transparent; 
  transition-delay: 0s;
}
.nav-toggle.is-active .hamburger-icon::before {
  top: 0;
  transform: rotate(45deg);
}
.nav-toggle.is-active .hamburger-icon::after {
  bottom: 0;
  transform: rotate(-45deg);
}

.nav-menu {
  list-style: none;
  position: fixed;
  top: var(--header-height); 
  left: 0;
  width: 100%;
  height: calc(100vh - var(--header-height));
  background-color: rgba(25, 25, 25, 0.98); 
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  transform: translateX(100%); 
  transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
  z-index: 999;
  overflow-y: auto;
}
.nav-menu.is-active {
  transform: translateX(0); 
}
.nav-menu a {
  color: var(--text-color);
  text-decoration: none;
  font-size: 1.5rem; 
  font-weight: 300;
  padding: 0.5rem 1rem;
  transition: color 0.3s ease, background-color 0.3s ease;
  border-radius: 4px;
  position: relative; /* For pseudo-elements */
}
.nav-menu a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--accent-color-large);
  transition: width 0.3s ease;
}
.nav-menu a:hover::after, .nav-menu a:focus::after {
  width: 100%;
}
.nav-menu a:hover, .nav-menu a:focus {
  color: var(--accent-color-hover);
  background-color: rgba(255,255,255,0.05);
}

main { 
  padding-top: 4rem; /* Increased from 2.5rem to create more space below header */
  margin-bottom: 3rem;
}

/* Add specific styling for the first section (Om mig) */
main section:first-of-type {
  margin-top: 1.5rem; /* Additional top margin for the first section */
}
section {
  background-color: var(--section-background-color-opacity);
  box-shadow: var(--box-shadow-static);
  padding: 2.5rem 2rem; /* Increased padding */
  margin-bottom: 2.5rem; /* More space between sections */
  border-radius: 8px;
  position: relative; /* For parallax effect */
  z-index: 2; /* Ensure sections are above background */
}
section.project {
  transition: transform 0.3s ease-out, box-shadow 0.3s ease-out;
}
section.project:hover {
  transform: translateY(-5px);
  box-shadow: var(--box-shadow-hoverable);
}

section h2 {
  font-family: var(--font-family-lato);
  color: var(--accent-color-large);
  font-size: clamp(1.6rem, 6vw, 2rem);
  margin-bottom: 1rem;
  font-weight: 700;
}
p {
  margin-bottom: 1rem;
  color: var(--text-color-muted);
  font-weight: 300;
}
p strong {
    font-weight: 700;
    color: var(--text-color);
}
a { 
  color: var(--accent-color-large);
  text-decoration: none;
  font-weight: 400;
  transition: color 0.2s ease-in-out;
}
a:hover { 
  color: var(--accent-color-hover);
  text-decoration: underline;
}

.meta {
  font-size: 0.9rem;
  font-style: italic;
  margin-bottom: 1rem;
  color: var(--accent-color-small);
}
.meta a { color: var(--accent-color-small); font-weight: 400; }
.meta a:hover { color: var(--accent-color-large); }
ul { list-style: none; padding-left: 0; }
section ul { margin-top: 0.5rem; }
li {
  margin-bottom: 0.7rem;
  padding-left: 1.2rem; 
  position: relative;
  font-weight: 300;
  color: var(--text-color-muted);
}
li::before { 
  content: "•";
  color: var(--accent-color-large);
  font-weight: bold;
  position: absolute;
  left: 0;
  top: 0;
}

.parallax-bg {
  background-image: url('dark_background.webp');
  min-height: 380px;
  background-attachment: fixed; /* Changed from scroll to fixed for proper parallax */
  background-position: center center; 
  background-repeat: no-repeat;
  background-size: cover;
  position: relative; 
  color: var(--text-color-inverted); 
  display: flex; 
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}
.parallax-bg::before { 
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0, 0, 0, 0.55); 
  border-radius: 8px; 
  z-index: 1;
}
.parallax-bg > * { 
  position: relative;
  z-index: 2;
  padding: 1rem; 
}
.parallax-bg h2 { color: #fff; }
.parallax-bg .meta, .parallax-bg ul, .parallax-bg p { color: var(--text-color-inverted); }
.parallax-bg a { color: var(--accent-color-light); border-bottom: 1px dashed var(--accent-color-light); }
.parallax-bg a:hover { color: var(--accent-color-very-light); border-bottom-color: var(--accent-color-very-light); }

/* Language toggle styles */
.lang-toggle-container {
  display: flex;
  margin-right: 1rem;
}

.lang-toggle {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-color); /* Improved from text-color-muted for contrast */
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}

.lang-toggle:first-child {
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
  border-right: none;
}

.lang-toggle:last-child {
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}

.lang-toggle.active {
  background-color: var(--accent-color-small);
  color: var(--text-color);
  border-color: var(--accent-color-small);
}

.lang-toggle:hover:not(.active) {
  background-color: rgba(255, 255, 255, 0.05);
}

@media (min-width: 768px) {
  .container { padding: 0 2.5rem; } /* Increased padding */
  .site-header { padding: 0 2.5rem; } /* Increased padding */
  .site-title { font-size: clamp(1.8rem, 3vw, 2.2rem); }
  .nav-menu {
    position: fixed; /* Changed from static to fixed */
    flex-direction: column; /* Keep the menu as a column */
    height: calc(100vh - var(--header-height));
    width: 100%;
    background-color: rgba(25, 25, 25, 0.98);
    backdrop-filter: blur(8px);
    transform: translateX(100%); /* Keep the transform for slide-in effect */
    gap: 1.5rem;
    overflow-y: auto;
    top: var(--header-height);
    left: 0;
  }
  .nav-menu a { font-size: 1.5rem; font-weight: 300; padding: 0.5rem 1rem; }
  .nav-menu a:hover, .nav-menu a:focus { 
    color: var(--accent-color-hover);
    background-color: rgba(255,255,255,0.05);
  }

  main { 
    padding-top: 6rem; /* Increased from 4rem for larger screens */
    margin-bottom: 4rem;
  }
  
  main section:first-of-type {
    margin-top: 2rem; /* More margin on larger screens */
  }
  
  section { 
    padding: 3rem 3.5rem; /* Increased padding */
    margin-bottom: 3.5rem; /* Increased margin */ 
  }
  .parallax-bg { min-height: 480px; }
  .parallax-bg > * { padding: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}