/* Basic Reset and Layout */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  /* Use scrollbar-gutter to reserve space for scrollbar without shifting content */
  scrollbar-gutter: stable;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100%;
}

body {
  font-family: 'Roobert', 'Arial', sans-serif;
  background-color: #f8f9fa;
  color: #333;
  line-height: 1.6;
  margin: 0;
  padding: 0;
  /* Ensure body takes full width including scrollbar area */
  min-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Portfolio Section */
.portfolio-section {
  padding: 10px 0;
  flex-grow: 1;
}

.section-title {
  text-align: center;
  margin-bottom: 60px;
}

.section-title h2 {
  font-size: 2.5rem;
  font-weight: 300;
  color: #2c3e50;
  margin-bottom: 20px;
}

.section-title p {
  font-size: 1.1rem;
  color: #7f8c8d;
  max-width: 700px;
  margin: 0 auto;
}

/* Portfolio Grid - Masonry Layout */
.portfolio-grid {
  margin: 0 auto 40px auto;
  padding-left: 0;
  /* Switch to CSS Grid */
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  /* Keep page height stable when categories with few items are selected */
  min-height: 40vh;
  max-width: 100%;
  overflow: hidden;
}

.grid-sizer { display: none; }

.portfolio-card {
  background: transparent;
  overflow: hidden;
  box-shadow: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

/* grid layout: no nth-child margin rules required */


.card-image {
  position: relative;
  overflow: hidden;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Uniform 16:9 ratio */
  aspect-ratio: 16 / 9;
}

/* Remove size variants for uniform cards */
.card-image.small,
.card-image.medium,
.card-image.large,
.card-image.extra-large { height: auto; }

/* Remove Masonry random height variations */

.card-image.commercial {
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

.card-image.cultural {
  background: linear-gradient(135deg, #8e44ad 0%, #9b59b6 100%);
}

.card-image.education {
  background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
}

.card-image.housing {
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.card-image.urban {
  background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
}

.card-image.product {
  background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
}

.card-image.exhibition {
  background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

/* 画面幅が狭いときは列数を落とす */
@media (max-width: 1400px) {
  .portfolio-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1100px) {
  .portfolio-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .portfolio-grid { grid-template-columns: repeat(2, 1fr); }
}

.card-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 2rem;
  font-weight: bold;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.card-content {
  padding: 15px 20px 20px 20px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  line-height: 1em;
}

.card-title {
  font-family: 'Roobert', 'Arial', sans-serif;
  font-size: 12px;
  line-height: 1em !important;
  color: #333;
  font-weight: 400;
  margin: 0;
}

.card-year {
  font-family: 'Roobert', 'Arial', sans-serif;
  font-size: 12px;
  line-height: 1em !important;
  color: #333;
  font-weight: 400;
  margin: 0;
  padding: 0;
}

.card-client {
  font-family: 'Roobert', 'Arial', sans-serif;
  font-size: 12px;
  line-height: 1em !important;
  color: #333;
  font-weight: 400;
  margin: 0;
  padding: 0;
}

.card-type {
  font-family: 'Roobert', 'Arial', sans-serif;
  font-size: 12px;
  line-height: 1em !important;
  color: #333;
  font-weight: 400;
  margin: 0;
}

.card-area {
  font-family: 'Roobert', 'Arial', sans-serif;
  font-size: 12px;
  line-height: 1em !important;
  color: #333;
  font-weight: 400;
  margin: 0;
}

.card-credit {
  font-family: 'Roobert', 'Arial', sans-serif;
  font-size: 12px;
  line-height: 1em !important;
  color: #333;
  font-weight: 400;
  margin: 0;
  margin-top: 6px;
}

.card-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
}

/* Category Filter */
.filter-container {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 30px;
  margin-top: 20px;
  flex-wrap: wrap;
  gap: 10px;
  /* Align with portfolio grid left edge */
  margin-left: 0;
  padding-left: 0;
}

.filter-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 0;
  background-color: transparent;
  color: #666;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.3s ease;
  white-space: nowrap;
}

.filter-btn:first-child {
  padding-left: 0;
  margin-left: 0;
}

.filter-btn:hover {
  color: #2c3e50;
}

.filter-btn.active {
  color: #000;
}

.filter-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-toggle {
  background: none;
  border: none;
  color: #666;
  font-size: 16px;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.filter-toggle:hover {
  background: #f0f0f0;
  color: #2c3e50;
}

.filter-toggle.active {
  transform: rotate(45deg);
  color: #2c3e50;
}

.filter-accordion {
  display: none;
  flex-direction: column;
  gap: 0;
  margin-top: 10px;
}

.filter-accordion.active {
  display: flex;
}

/* Desktop: show all categories horizontally */
@media (min-width: 769px) {
  .filter-main {
    display: contents;
  }

  .filter-toggle {
    display: none;
  }

  .filter-accordion {
    display: flex;
    flex-direction: row;
    gap: 10px;
    margin-top: 0;
  }
}

/* Mobile responsive for category filter */
@media (max-width: 768px) {
  .filter-container {
    margin-bottom: 30px;
    margin-top: 15px;
    gap: 0;
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-main {
    width: 100%;
    justify-content: flex-start;
  }

  .filter-btn {
    padding: 12px 0;
    font-size: 0.9rem;
    width: 100%;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
  }

  .filter-btn:first-child {
    padding-left: 0;
  }

  .filter-btn:last-child {
    border-bottom: none;
  }

  .filter-accordion .filter-btn {
    border-bottom: 1px solid #e0e0e0;
    padding-left: 0;
    padding-right: 0;
    text-align: left;
    width: 100%;
  }

  .filter-accordion .filter-btn:last-child {
    border-bottom: none;
  }
}

@media (max-width: 480px) {
  .filter-container {
    margin-bottom: 25px;
  }

  .filter-btn {
    padding: 10px 0;
    font-size: 0.85rem;
  }
}

/* Mobile responsive for portfolio area */
@media (max-width: 768px) {
  .container {
    padding: 0 20px;
  }
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
}

.modal-content {
  position: relative;
  margin: auto;
  padding: 0;
  width: 45%;
  max-width: 600px;
  background: #fff;
  border-radius: 0;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: auto;
  top: 50%;
  transform: translateY(-50%);
}

.modal-header {
  position: relative;
  background: #fff;
  padding: 40px 30px 30px 30px;
  border-bottom: 1px solid #eee;
}

.modal-title {
  font-family: 'Roobert', 'Arial', sans-serif;
  font-size: 12px;
  font-weight: 400;
  color: #333;
  margin: 0;
  margin-bottom: 0;
  line-height: 1em !important;
  padding: 0;
}

.modal-year {
  font-family: 'Roobert', 'Arial', sans-serif;
  font-size: 12px;
  line-height: 1em !important;
  color: #333;
  font-weight: 400;
  margin: 0;
  padding: 0;
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: #333;
}

.modal-body {
  padding: 30px 40px 20px 40px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.modal-image {
  width: 90%;
  max-height: 60vh;
  object-fit: contain;
  object-position: center;
  display: block;
  flex-shrink: 0;
  margin: 0 auto;
}

.modal-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 25px;
}

.modal-info p {
  font-family: 'Roobert', 'Arial', sans-serif;
  font-size: 12px;
  line-height: 1em !important;
  color: #333;
  font-weight: 400;
  margin: 0;
  padding: 0;
}

.modal-credit {
  font-family: 'Roobert', 'Arial', sans-serif;
  font-size: 12px;
  line-height: 1em !important;
  color: #333;
  font-weight: 400;
  margin: 0;
  padding: 0;
}

.modal-credit:empty {
  display: none;
}

.modal-client {
  font-family: 'Roobert', 'Arial', sans-serif;
  font-size: 12px;
  line-height: 1em !important;
  color: #333;
  font-weight: 400;
  margin: 0;
  padding: 0;
}

.modal-type {
  font-family: 'Roobert', 'Arial', sans-serif;
  font-size: 12px;
  line-height: 1em !important;
  color: #333;
  font-weight: 400;
  margin: 0;
  padding: 0;
}

.modal-area {
  font-family: 'Roobert', 'Arial', sans-serif;
  font-size: 12px;
  line-height: 1em !important;
  color: #333;
  font-weight: 400;
  margin: 0;
  padding: 0;
}

.modal-area:empty {
  display: none;
}

.modal-caption {
  position: relative;
  background: #fff;
  color: #333;
  padding: 20px;
  border-top: 1px solid #eee;
}

.modal-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
}

/* Navigation arrows */
.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.9);
  border: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #333;
  transition: all 0.3s ease;
  z-index: 1001;
}

.modal-nav:hover {
  background: rgba(255, 255, 255, 1);
  transform: translateY(-50%) scale(1.1);
}

.modal-nav.prev {
  left: 20px;
}

.modal-nav.next {
  right: 20px;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .modal-content {
    width: 80%;
    margin: auto;
    top: 50%;
    transform: translateY(-50%);
  }
  
  .modal-header {
    padding: 25px 20px 20px 20px;
  }
  
  .modal-body {
    padding: 20px 25px 25px 25px;
  }
  
  .modal-image {
    max-height: 40vh;
  }
  
  .modal-nav {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }
  
  .modal-nav.prev {
    left: 10px;
  }
  
  .modal-nav.next {
    right: 10px;
  }
}
