/* Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --text-primary: #1a1a1a;
  --text-secondary: #666;
  --background: #ffffff;
  --background-alt: #fafafa;
  --border: #e5e5e5;
  --accent: #000000;
  --accent-hover: #333;
  --nav-height: 70px;
  --carousel-gap: 2rem;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.2s ease;
  --transition-slow: 0.3s ease;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-full: 50%;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 12px 24px rgba(0, 0, 0, 0.06);
}

html {
  scroll-behavior: auto;
  scroll-snap-type: y mandatory;
  scroll-padding-top: var(--nav-height);
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--background);
  overscroll-behavior: none;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Focus Styles for Keyboard Navigation */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Smooth language transitions */
[data-i18n] {
  transition: opacity var(--transition-fast);
}

.container {
  max-width: min(1200px, 90vw);
  margin: 0 auto;
  padding: 0 2rem;
}

@media (min-width: 1400px) {
  .container {
    max-width: 95vw;
  }
}

.nav {
  position: sticky;
  top: 0;
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  padding: clamp(1.2rem, calc(1.2rem + (100vh - 750px) * 0.001), 1.5rem) 0;
}

.nav .container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.logo {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color var(--transition-normal);
  display: inline-block;
  width: 6rem;
  text-align: center;
}

.nav-links a:hover {
  color: var(--accent);
}

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-normal);
}

.theme-toggle:hover {
  background-color: var(--background-alt);
}

.theme-toggle img {
  width: 20px;
  height: 20px;
  display: block;
}

.sun-icon,
.moon-icon {
  transition: opacity 0.2s ease;
}

html[data-theme="light"] .sun-icon {
  display: none;
}

html[data-theme="dark"] .moon-icon {
  display: none;
}

.lang-toggle {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition-normal);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.5px;
  width: 3rem;
}

.lang-toggle:hover {
  background-color: var(--background-alt);
  border-color: var(--accent);
  color: var(--accent);
}

.section {
  min-height: calc(100vh - var(--nav-height));
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(0rem, calc((100vh - 900px) * 0.16), 3rem) 0;
}

.section .container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#projects {
  justify-content: flex-start;
  padding: clamp(0rem, calc((100vh - 750px) * 0.133), 3rem) 0;
}

#projects .container {
  justify-content: flex-start;
}

.section-alt {
  background-color: var(--background-alt);
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}

.section-title {
  font-size: clamp(2.2rem, min(5vw, calc((100vh - 750px) * 0.013 + 2.2rem)), 2.5rem);
  font-weight: 700;
  margin-bottom: clamp(0rem, calc((100vh - 750px) * 0.114), 2.5rem);
  letter-spacing: -1px;
  text-align: center;
  width: 100%;
}

.about-intro {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-secondary);
  max-width: 700px;
  margin: 0 auto 3rem;
  text-align: center;
}

.about-content {
  display: flex;
  flex-direction: column;
  gap: max(2vh, 1.5rem);
  max-width: 600px;
  margin: 0 auto;
}

.about-item {
  text-align: left;
}

.about-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.about-value {
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0;
}

.project-carousel-wrapper {
  position: relative;
  width: 100%;
}

.carousel-arrow {
  position: absolute;
  top: calc(50% + clamp(0rem, calc((100vh - 900px) * 0.08), 1.5rem));
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  width: 48px;
  height: 48px;
  padding-bottom: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 10;
  transition: all var(--transition-normal);
  opacity: 0;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
  font-size: 2.5rem;
  line-height: 0;
  color: var(--text-primary);
  font-weight: 300;
}

.project-carousel-wrapper:hover .carousel-arrow {
  opacity: 1;
  pointer-events: auto;
}

.carousel-arrow--prev {
  left: 1rem;
}

.carousel-arrow--next {
  right: 1rem;
}

.carousel-arrow:hover {
  background: rgba(255, 255, 255, 1);
  border-color: var(--accent);
  transform: translateY(-50%) scale(1.05);
}

.project-grid {
  display: flex;
  gap: var(--carousel-gap);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  padding-top: 0.5rem;
  padding-left: max(1rem, calc((100vw - 330px) / 2));
  padding-right: max(1rem, calc((100vw - 330px) / 2));
  scrollbar-width: none;
  width: 100%;
  align-self: stretch;
  overscroll-behavior-x: contain;
  cursor: grab;
  user-select: none;
}

.project-grid:active {
  cursor: grabbing;
}

.project-grid img {
  pointer-events: none;
  user-select: none;
}

.project-grid::-webkit-scrollbar {
  display: none;
}

.project-pagination {
  display: flex;
  justify-content: center;
  margin-top: 1.5rem;
}

.pagination-counter {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

.project-card {
  background-color: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-y: auto;
  color: inherit;
  transition: all var(--transition-slow);
  display: grid;
  grid-template-rows: 180px 1fr auto;
  flex: 0 0 300px;
  max-height: 480px;
  scroll-snap-align: center;
}

.project-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.project-image {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--background-alt);
  display: flex;
  align-items: center;
  justify-content: center;
}

.project-image picture {
  display: contents;
}

.project-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Temporary styling for WIP projects where I'm missing images */

.project-image--placeholder {
  position: relative;
  background-color: grey;
}

.project-image--placeholder::after {
  content: "WIP";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.5rem;
  font-weight: 700;
  color: black;
  opacity: 0.3;
  letter-spacing: 0.5rem;
}

/* ================================== */

.project-content {
  padding: clamp(0.5rem, calc(0.5rem + (100vh - 750px) * 0.127), 2rem) 1rem 1rem 1rem;
}

.project-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: clamp(0.35rem, calc(0.35rem + (100vh - 750px) * 0.0013), 0.75rem);
  letter-spacing: -0.5px;
}

.project-description {
  color: var(--text-secondary);
  line-height: 1.5;
  font-size: 0.85rem;
}

.project-links {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
}

.project-link-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition-normal);
  color: var(--text-secondary);
}

.project-link-icon:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.project-link-icon img {
  width: 20px;
  height: 20px;
  display: block;
}

.project-link-demo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background-color: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition-normal);
}

.project-link-demo:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
}

.project-link-demo img {
  width: 16px;
  height: 16px;
  display: block;
  filter: invert(1);
}

.contact {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2rem;
  max-width: 400px;
  margin: 0 auto;
}

.contact-icon-link {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  transition: all var(--transition-normal);
  color: var(--text-secondary);
}

.contact-icon-link:hover {
  border-color: var(--accent);
  background-color: var(--background-alt);
  transform: translateY(-2px);
}

.contact-icon-link img {
  width: 28px;
  height: 28px;
  display: block;
}

.footer {
  background-color: var(--background-alt);
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  text-align: center;
}

.footer p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Short viewports horizontally */
@media (max-height: 700px) {
  .section {
    padding: 1.5rem 0;
  }
}

@media (max-height: 600px) {
  .section {
    padding: 1rem 0;
  }
}

/* Mobile */
@media (max-width: 768px) {
  html {
    scroll-snap-type: none;
  }

  .section {
    min-height: 100vh;
    padding: 2rem 0;
    scroll-snap-align: none;
  }

  .project-grid {
    overscroll-behavior-x: none;
    -webkit-overflow-scrolling: touch;
  }

  .carousel-arrow {
    display: none;
  }
}

/* Very narrow screens */
@media (max-width: 400px) {
  .project-card {
    flex: 0 0 280px;
  }

  .project-description {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
    font-size: 0.8rem;
  }
}

/* Tablet and small laptops */
@media (min-width: 769px) {
  .nav .container {
    flex-direction: row;
    justify-content: space-between;
  }

  .nav-right {
    gap: 2rem;
  }

  .nav-links {
    gap: 2rem;
  }

  .project-grid {
    padding-left: 0;
    padding-right: 0;
    scroll-snap-type: none;
  }

  .pagination-counter {
    display: none;
  }

  .project-card {
    /* Width controlled by JS */
    max-height: 520px;
    grid-template-rows: 200px 1fr auto;
  }

  .project-content {
    padding: clamp(0.5rem, calc(0.5rem + (100vh - 750px) * 0.127), 2rem) 1.5rem 1.5rem 1.5rem;
  }

  .project-description {
    font-size: 0.9rem;
    line-height: 1.6;
  }
}

/* Tall screens - allow cards to grow taller with more padding */
@media (min-height: 1000px) {
  .project-card {
    max-height: 750px;
    grid-template-rows: 230px 1fr auto;
  }

  .project-content {
    padding: clamp(0.5rem, calc(0.5rem + (100vh - 750px) * 0.127), 2em) 2rem 2rem 2rem;
  }

  .project-description {
    line-height: 1.8;
  }

  .project-links {
    padding: 1.75rem 2rem;
  }
}

@media (min-height: 1200px) {
  .project-card {
    max-height: 900px;
    grid-template-rows: 260px 1fr auto;
  }

  .project-content {
    padding: clamp(0.5rem, calc(0.5rem + (100vh - 750px) * 0.127), 2rem) 2.5rem 2.5rem 2.5rem;
  }

  .project-description {
    line-height: 2;
  }

  .project-links {
    padding: 2.25rem 2.5rem;
  }
}

html[data-theme="dark"] {
  --text-primary: #e5e5e5;
  --text-secondary: #a3a3a3;
  --background: #1a1a1a;
  --background-alt: #242424;
  --border: #333;
  --accent: #ffffff;
  --accent-hover: #e5e5e5;
  --shadow-md: 0 12px 24px rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"] .nav {
  background-color: rgba(26, 26, 26, 0.95);
}

html[data-theme="dark"] .project-card {
  background-color: #242424;
}

html[data-theme="dark"] .project-link-demo {
  background-color: var(--accent);
  color: #1a1a1a;
}

html[data-theme="dark"] .project-link-demo:hover {
  background-color: #e5e5e5;
}

html[data-theme="dark"] .project-link-demo img {
  filter: invert(0);
}

html[data-theme="dark"] .contact-icon-link:hover {
  background-color: #242424;
}

html[data-theme="dark"] .theme-toggle img,
html[data-theme="dark"] .project-link-icon img,
html[data-theme="dark"] .contact-icon-link img {
  filter: invert(1);
}

html[data-theme="dark"] .carousel-arrow {
  background: rgba(26, 26, 26, 0.9);
  border-color: var(--border);
}

html[data-theme="dark"] .carousel-arrow:hover {
  background: rgba(26, 26, 26, 1);
}
