/* CSS Variables for Theming */
:root {
    --primary-color: #007bff;
    --primary-hover-color: #0056b3;
    --bg-color: #f8f9fa;
    --text-color: #343a40;
    --heading-color: #212529;
    --card-bg-color: #ffffff;
    --header-bg: #ffffff;
    --header-shadow: 0 2px 4px rgba(0,0,0,0.05);
    --hero-bg: #343a40;
    --hero-text: #fff;
    --hero-subtext: #e9ecef;
    --footer-bg: #343a40;
    --footer-text: #f8f9fa;
    --border-color: #ccc;
    --focus-shadow: 0 0 0 2px rgba(0,123,255,.25);
}

body.dark-mode {
    --primary-color: #0d6efd;
    --primary-hover-color: #3385fd;
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --heading-color: #ffffff;
    --card-bg-color: #1e1e1e;
    --header-bg: #1e1e1e;
    --header-shadow: 0 2px 4px rgba(0,0,0,0.3);
    --hero-bg: #000000;
    --hero-text: #fff;
    --hero-subtext: #adb5bd;
    --footer-bg: #1e1e1e;
    --footer-text: #e0e0e0;
    --border-color: #444;
    --focus-shadow: 0 0 0 2px rgba(13, 110, 253, .5);
}

/* General Body & Typography */
html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
}

/* Header and Navigation */
header {
    background: var(--header-bg);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    box-shadow: var(--header-shadow);
    transition: background-color 0.3s, box-shadow 0.3s;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

nav ul {
    padding: 0;
    margin: 0;
    list-style: none;
}

nav ul li {
    display: inline;
    margin: 0 20px;
}

nav a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: bold;
    font-size: 1rem;
    transition: color 0.3s ease;
}

nav a:hover {
    color: var(--primary-color);
}

/* Main Content & Sections */
main {
    /* No extra padding needed as sections have it */
}

section {
    padding: 80px 20px;
    max-width: 1100px;
    margin: 0 auto;
    text-align: center;
}

section:nth-of-type(even) {
    background-color: var(--card-bg-color);
}

h1, h2, h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--heading-color);
}

h1 {
    font-size: 3.5rem;
}

h2 {
    font-size: 2.5rem;
    border-bottom: 3px solid var(--primary-color);
    display: inline-block;
    padding-bottom: 10px;
    margin-bottom: 40px;
}

/* Hero Section */
#hero {
    position: relative; /* Needed for the overlay */
    background: url('resources/banner.webp') no-repeat center center/cover;
    color: var(--hero-text);
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0 20px;
    z-index: 1; /* To keep content above the overlay */
}

#hero::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.5); /* Dark overlay */
    z-index: -1; /* Position overlay behind the content */
}

#hero h1 {
    font-size: 4rem;
    margin-bottom: 10px;
    color: var(--hero-text);
}

#hero p {
    font-size: 1.5rem;
    margin-bottom: 30px;
    max-width: 600px;
    color: var(--hero-subtext);
}

/* Button Styles */
.button {
    display: inline-block;
    background: var(--primary-color);
    color: #fff;
    padding: 15px 30px;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    transition: background-color 0.3s ease, transform 0.2s ease;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.button:hover {
    background: var(--primary-hover-color);
    transform: translateY(-2px);
}

/* Services Section */
#services ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    text-align: left;
}

#services li {
    background: var(--card-bg-color);
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
    flex-basis: calc(33.333% - 40px);
    min-width: 280px;
    border-left: 4px solid var(--primary-color);
}

/* Portfolio Section */
.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 40px;
    text-align: left;
}

.portfolio-item {
    background: var(--card-bg-color);
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden; /* To contain child elements */
    display: flex;
    flex-direction: column;
}

.portfolio-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.portfolio-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.portfolio-item-content {
    padding: 20px;
    flex-grow: 1;
}

.portfolio-item-content h3 {
    margin-top: 0;
    color: var(--heading-color);
    font-size: 1.5rem;
}

.portfolio-item a {
    display: block;
    padding: 15px 20px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    font-weight: bold;
    text-align: center;
    transition: background-color 0.3s ease;
    margin-top: auto;
}

.portfolio-item a:hover {
    background-color: var(--primary-hover-color);
}

/* Contact Section */
#contact form {
    margin-top: 30px;
    display: grid;
    gap: 20px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
}

#contact input,
#contact textarea {
    width: 100%;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-family: inherit;
    font-size: 1rem;
    box-sizing: border-box;
    background-color: var(--card-bg-color);
    color: var(--text-color);
}

#contact input:focus,
#contact textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--focus-shadow);
}

#contact textarea {
    resize: vertical;
    min-height: 150px;
}

#contact button {
    width: auto;
    justify-self: center;
}

/* Footer */
footer {
    background: var(--footer-bg);
    color: var(--footer-text);
    text-align: center;
    padding: 20px 0;
    margin-top: 60px;
}

/* Theme Toggle Switch */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Theme toggle icons */
.sun-icon, .moon-icon {
    /* Position icons inside the label */
    position: absolute;
    top: 9px;
    pointer-events: none; /* Clicks pass through to the input */
    transition: transform 0.4s ease, opacity 0.4s ease;
    z-index: 1; /* Ensure icons are on top of the slider handle */
    color: var(--primary-color);
}

.sun-icon {
    left: 9px;
    opacity: 1;
    transform: rotate(0deg);
}

.moon-icon {
    left: 9px;
    opacity: 0;
    transform: rotate(90deg);
}

/* Move and swap icons on toggle */
input:checked ~ .sun-icon {
    opacity: 0;
    transform: translateX(26px) rotate(90deg);
}

input:checked ~ .moon-icon {
    opacity: 1;
    transform: translateX(26px) rotate(0deg);
    color: var(--primary-color); /* Use primary color for the icon in dark mode */
}

.slider:before {
    background-color: white;
}

input:checked + .slider:before {
    pointer-events: none; /* Allow clicks to pass through to the slider */
}