* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  touch-action: manipulation;
}

html.menu-open, html.menu-open body {
  overflow: hidden;
  height: 100%;
  position: fixed;
  width: 100%;
}

body {
  font-family: 'Hanabi', Noto Serif SC, Georgia, 'Times New Roman', Times, serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--bs-body-color);
  background: var(--bs-body-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
  font-variation-settings: 'slnt' 0, 'MONO' 0;
  font-feature-settings: "dlig",'liga','kern','onum';
  hanging-punctuation: first;
}

a {
  text-decoration: none;
  color: var(--bs-body-color);
  transition: color 0.2s;
}

/* Sidebar Navigation */

.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 15%;
  height: 100vh;
  background: var(--bs-body-bg);
  z-index: 100;
  padding: 2rem 0.8rem;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Name Section - Centered in available space */

.sidebar-header {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
}

.sidebar h2 {
  font-size: 2.6rem;
  font-weight: 300;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0;
}

.sidebar h2 a {
  color: var(--bs-secondary);
}

.sidebar h2 a.active {
  color: var(--bs-link-hover-color);
}

.sidebar h2 a:hover {
  color: var(--bs-link-hover-color);
}

/* Nav Section - Pushed to bottom */

.sidebar-nav-container {
  flex-shrink: 0;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* CV Link - Standalone */

.cv-link {
  font-size: 1.3rem;
  display: block;
  border-bottom: 1px solid var(--bs-border-color);
  margin-bottom: 0.8rem;
  padding-bottom: 0.5rem;
  width: fit-content;
}

.sidebar-nav-container a.active {
  color: var(--bs-link-hover-color);
}

.sidebar-nav-container a:hover {
  color: var(--bs-link-hover-color);
}

/* Project Paragraph Style */

.project-list {
  font-size: 1.1rem;
  line-height: 1.6;
}

.project-list a {
  display: inline;
  border-bottom: none;
  padding: 0;
}

/* The Bullet Separator */

.project-list a:not(:last-child)::after {
  content: " • ";
  margin: 0 4px;
  color: var(--bs-secondary);
}

.project-list a.active {
  color: var(--bs-link-hover-color);
}

.project-list a:hover {
  color: var(--bs-link-hover-color);
}

/* RESPONSIVE MOBILE SIDEBAR */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    border-left: none;
    padding-top: calc(80px + env(safe-area-inset-top));
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    z-index: 2000;
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    overscroll-behavior: none;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.4s ease, visibility 0.4s ease;
  }
}

@media (max-width: 768px) {
  .sidebar.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
}

@media (max-width: 768px) {
  .sidebar h2 {
    font-size: 2.5rem;
  }
}

/* Hide scrollbar but keep functionality */

.sidebar::-webkit-scrollbar {
  width: 0px;
}

/* --- CIRCULAR MENU TOGGLE --- */

.menu-toggle {
  display: none;
}

@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: calc(14.8rem + env(safe-area-inset-top));
    right: 1.2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    color: var(--bs-body-color);
    cursor: pointer;
    z-index: 2005;
    background-color: rgba(var(--bs-body-bg), 0.5);
    background-color: rgb(from var(--bs-body-bg) r g b / 50%);
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    border: none;
    box-shadow: 0 4px 12px rgba(var(--bs-body-color), 0.1);
    box-shadow: 0 4px 12px rgb(from var(--bs-body-color) r g b / 10%);
    transition: background-color 0.3s ease;
  }
}

@media (max-width: 768px) {
  .menu-toggle span {
    font-size: 24px;
    line-height: 1;
    display: block;
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  }
}

/* When menu is active (class added by JS) */

@media (max-width: 768px) {
  .menu-toggle.toggled span {
    transform: rotate(180deg);
  }
}

/* Main content area */

main {
  width: 85%;
  padding: 0.8rem;
  min-height: 100vh;
}

@media (max-width: 768px) {
  main {
    width: 100%;
    padding: 0.8rem;
  }
}

/* Portfolio grid - Homepage */

.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.8rem;
}

@media (max-width: 768px) {
  .portfolio-grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }
}

.thumbnail img {
  width: 100%;
  height: auto;
  display: block;
  background: #f5f5f5;
}

.thumbnail {
  position: relative;
  overflow: hidden;
  background: transparent;
}

.thumbnail a {
  display: block;
}

.thumb_image {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  aspect-ratio: 4/5;
  background-color: rgba(0, 0, 0, 0.03);
}

@media (max-width: 768px) {
  .thumb_image {
    height: auto;
  }
}

.thumb_image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* --- Mobile Portfolio Item --- */

@media (max-width: 768px) {
  .thumbnail {
    margin-bottom: 0;
  }
}

@media (max-width: 768px) {
  .thumb_image.in-view {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 768px) {
  .thumbnail .title {
    position: relative;
    opacity: 1;
    transform: none;
    background: none;
    color: var(--text-color);
    padding: 0.8rem 0 0 0;
    font-size: 1.5rem;
    pointer-events: auto;
    width: 100%;
  }
}

@media (max-width: 768px) {
  .thumbnail .title span {
    display: block;
    border-bottom: 1px solid transparent;
    width: fit-content;
    transition: border-color 0.3s;
  }
}

/* Hover Effect Desktop */

@media (min-width: 769px) {
  .thumbnail .title {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 1.5rem;
    color: #fff;
    font-size: 3.5rem;
    font-weight: 400;
    font-style: normal;
    text-align: left;
    line-height: 1.2;
    opacity: 0;
    transition: all 0.4s ease;
    z-index: 2;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.5), transparent);
    pointer-events: none;
  }
}

@media (max-width: 768px) {
  .thumbnail:hover .title {
    opacity: 1;
  }
}

.thumbnails .title span {
  display: inline-block;
}

.thumbnails .thumbnail:hover .title {
  opacity: 1;
}

body.mobile .thumbnails .thumbnail:hover .title {
  opacity: 0;
}

/* --- MOBILE & TABLET Hover (< 768px) --- */

@media (pointer:coarse) {
  .thumbnails .thumbnail .title {
    opacity: 1;
  }
}

@media (pointer:coarse) {
  .thumbnails .title {
    font-size: 2.3rem;
    font-weight: 400;
    font-style: normal;
    text-align: left;
    line-height: 1.2;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.5), transparent);
  }
}

@media (pointer:coarse) {
  .thumbnails .thumbnail .title {
    padding: 1rem;
    margin: 0rem;
    color: rgba(255, 255, 255, 1);
    display: block;
    align-content: flex-start;
    width: 100%;
    position: absolute;
    left: 0rem;
    right: 0rem;
    bottom: 0rem;
    z-index: 9;
    white-space: normal;
    overflow-wrap: break-word;
  }
}

/* CV Grid */

.cv-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.8rem;
}

@media (max-width: 768px) {
  .cv-grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }
}

.gallery-grid {
  display: flex;
  gap: 0.8rem;
}

.column-left, .column-right {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Gallery images - Project pages */

.gallery-image {
  display: inline-block;
  width: 100%;
  height: auto;
  cursor: zoom-in;
  break-inside: avoid;
  margin: 0 0 0.8rem 0;
  -webkit-column-break-inside: avoid;
}

.gallery-image img {
  width: 100%;
  height: auto;
  display: block;
}

/* Language switch */

.lang-switch {
  max-width: 900px;
  font-size: 2rem;
  padding-top: 2rem;
}

.lang-switch button {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  color: var(--bs-body-color);
  padding: 0;
}

.lang-switch button.active {
  color: var(--bs-link-hover-color);
}

.thumbnails .lang-margin {
  margin-top: 6rem;
}

/* Language visibility */

[data-lang] {
  display: none;
}

[data-lang].active {
  display: inline;
}

/* CV Typography */

.thumbnails .section-margin {
  margin-top: 4rem;
}

.cv-header {
  padding-bottom: 1.5rem;
}

@media (max-width: 768px) {
  .cv-header {
    padding-bottom: 1rem;
  }
}

.cv-grid h1 {
  font-size: 3.2rem;
  font-weight: 400;
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .cv-grid h1 {
    font-size: 2.6rem;
    font-weight: 400;
    margin-bottom: 1rem;
  }
}

.cv-grid h2 {
  font-size: 2.2rem;
  font-weight: 400;
  margin-bottom: 10px;
}

@media (max-width: 768px) {
  .cv-grid h2 {
    font-size: 1.8rem;
    font-weight: 400;
    margin-bottom: 10px;
  }
}

.cv-grid h3 {
  font-size: 1.3rem;
  font-weight: 300;
  line-height: 1.6;
  margin-bottom: 10px;
  letter-spacing: 0.03em;
}

@media (max-width: 768px) {
  .cv-grid h3 {
    font-size: 1.1rem;
    font-weight: 300;
    line-height: 1.6;
    margin-bottom: 10px;
    letter-spacing: 0.03em;
  }
}

hr {
  background: var(--bs-border-color);
  border: 0;
  height: 1px;
  display: block;
  opacity: 1!important;
  margin: 0 0 0.7rem 0;
}

.cv .h1, .h2, .h3, .h4, .h5, .h6, h1, h2, h3, h4, h5, h6 {
  color: var(--bs-secondary-color);
}

.cv p {
  margin-bottom: 8px;
  line-height: 1.7;
}

.cv-entry {
  margin-bottom: 25px;
}

.cv-entry-title {
  font-size: 16px;
  margin-bottom: 5px;
}

.cv-entry-location {
  font-size: 15px;
  color: #666;
}

.education-entry {
  margin-bottom: 25px;
}

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

ul li {
  margin-bottom: 8px;
}

main.cv-main {
  max-width: 900px;
}

/* Lightbox */

.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

.lightbox.active {
  display: flex;
}

.lightbox-content {
  position: relative;
  max-width: 90%;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 90vh;
  width: auto;
  height: auto;
  display: block;
}

.lightbox-close {
  position: fixed;
  top: 20px;
  right: 30px;
  font-size: 40px;
  color: #fff;
  cursor: pointer;
  background: none;
  border: none;
  z-index: 3001;
  line-height: 1;
  padding: 10px;
}

.lightbox-close:hover {
  opacity: 0.7;
}

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  font-size: 60px;
  color: #fff;
  cursor: pointer;
  background: none;
  border: none;
  padding: 20px;
  z-index: 3001;
  line-height: 1;
}

.lightbox-nav:hover {
  opacity: 0.7;
}

.lightbox-prev {
  left: 30px;
}

.lightbox-next {
  right: 30px;
}

.lightbox-counter {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 16px;
  border-radius: 20px;
  z-index: 3001;
}

@media (max-width: 768px) {
  .lang-toggle {
    bottom: 20px;
    left: 20px;
  }
}

@media (max-width: 768px) {
  .lightbox-close {
    font-size: 30px;
    top: 15px;
    right: 15px;
  }
}

@media (max-width: 768px) {
  .lightbox-nav {
    font-size: 40px;
    padding: 15px;
  }
}

@media (max-width: 768px) {
  .lightbox-prev {
    left: 15px;
  }
}

@media (max-width: 768px) {
  .lightbox-next {
    right: 15px;
  }
}

@media (max-width: 768px) {
  .lightbox-counter {
    bottom: 20px;
    font-size: 12px;
  }
}

/* full-screen backdrop */

.menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.0);
  z-index: 1999;
  display: none;
}

.menu-backdrop.active {
  display: block;
}

