/* ===== PRODUCT PAGE STYLES ===== */

/* ===== CART BADGE ===== */
#cart-badge {
  position: absolute;
  top: var(--margin-outer);
  right: var(--margin-outer);
  z-index: 10;
}

#cart-badge a {
  color: #000;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s ease;
}

#cart-badge a:active {
  color: #999;
}

@media (hover: hover) {
  #cart-badge a:hover {
    color: #999;
  }
}

/* ===== MAIN CONTENT ===== */
.container {
  flex: 1;
  padding: clamp(4rem, 8vw, 8rem) var(--margin-outer) 2rem var(--margin-outer);
  box-sizing: border-box;
}

.product-layout {
  display: grid;
  grid-template-columns: 1fr 1fr; /* True 50/50 split */
  gap: var(--gutter);
  max-width: none;
  align-items: start;
}

/* ===== GALLERY ===== */
.gallery-wrapper {
  position: relative;
  width: 100%; /* Fill the 50% column */
  margin-top: 0; /* Top-align with product title */
  height: 90vh; /* Fixed height window - shows more of second image */
  overflow-y: auto; /* Scroll within container */
  overflow-x: hidden;
}

/* Hide nav arrows for vertical gallery */
.gallery-wrapper > .gallery-nav {
  display: none !important;
}

.gallery-section {
  display: flex;
  flex-direction: column; /* Vertical stack */
  gap: var(--gutter); /* Standard spacing between images */
}

.gallery-image {
  width: 100%; /* Fill the gallery wrapper */
  flex-shrink: 0; /* Don't compress images */
  cursor: pointer; /* Indicate clickable for lightbox */
  background: #fff;
}

.gallery-image img {
  width: 100%; /* Fill the column width */
  height: auto; /* Maintain aspect ratio */
  display: block;
  object-fit: contain; /* Ensure image fits without distortion */
}

.gallery-placeholder {
  width: 100%;
  min-height: 400px;
  background: #bdbdbd;  /* Disabled gray - lightest in system */
}

/* ===== PRODUCT INFO ===== */
.product-info {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-width: 0;
  position: sticky;
  top: 8rem;
  align-self: start;
}

.product-info h1 {
  margin: 0 0 0.25em 0;
  font-weight: normal;
  font-size: inherit;
  text-transform: uppercase;
}

.price,
.color-selector,
.product-info-rows {
  margin-bottom: 2rem; /* Double space between major sections */
}

.price {
  margin-top: 0; /* Tightly coupled - matches downloads page product-dimensions */
  font-variant-numeric: tabular-nums;
}

.info-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0; /* No margin - stack with natural line-height (paragraph spacing) */
}

.description {
  margin-bottom: 4rem; /* Space before Gallery section */
}

.description p {
  margin: 0;
}

.color-options-container {
  display: block;
  overflow-x: scroll;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  white-space: nowrap;
  padding: 4px;  /* Prevents box-shadow clipping on all sides */
  margin-bottom: 0; /* No bottom margin needed */
}

.color-options-container::-webkit-scrollbar {
  display: none;
}

.color-options {
  display: inline-block;
  width: fit-content;
  white-space: nowrap;
}

.color-option {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
  position: relative;
  vertical-align: top;
  margin-right: 1rem;
}

.color-option:last-child {
  margin-right: 0;
}

.color-option input[type="radio"] {
  display: none;
}

.color-circle {
  width: 8rem;
  height: 5.2rem;
  cursor: pointer;
  border: var(--line-thickness) solid transparent;
}

.color-circle.brown {
  background-color: #4E3B31; /* RAL 8014 */
}

.color-circle.white {
  background-color: #F1F0EA; /* RAL 9016 */
}

.color-option input[type="radio"]:checked + .color-circle {
  box-shadow: 0 0 0 var(--line-thickness) #fff, 0 0 0 calc(var(--line-thickness) * 2) #000;
}

.color-name {
  pointer-events: none;
}

.status-value {
  color: #666; /* Gray for status text - line-height inherited from shared.css */
}

/* Disabled color option styling */
.color-option.disabled .color-circle {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (hover: hover) {
  .color-circle:hover {
    box-shadow: 0 0 0 var(--line-thickness) #fff, 0 0 0 calc(var(--line-thickness) * 2) #000;
  }

  .color-option.disabled:hover .color-circle {
    box-shadow: none;
  }
}

.color-option.disabled input[type="radio"]:checked + .color-circle {
  box-shadow: none;
}

/* Out of stock button styling - outline disabled state */
.add-to-cart-btn:disabled {
  background: transparent;
  border-color: #bdbdbd;
  color: #bdbdbd;
  cursor: not-allowed;
}

.product-details {
  margin-bottom: 2rem;
}

.product-details p {
  margin: 0 0 1rem 0;
}

.add-to-cart-btn {
  width: max(280px, 30vw); /* Proportional: min 280px, grows with viewport */
}

/* ===== GALLERY NAV BUTTONS ===== */
.gallery-wrapper .gallery-nav,
.lifestyle-carousel-wrapper .gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 3rem;
  height: 5rem;
  padding: 0;
  margin: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  cursor: pointer;
  /* Remove button styling */
  background-color: rgba(0, 0, 0, 0);
  border: 0;
  outline: 0;
  font-size: 0;
  color: transparent;
  /* Remove tap effects (iOS/Android) */
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.gallery-wrapper .gallery-nav:focus,
.gallery-wrapper .gallery-nav:active,
.lifestyle-carousel-wrapper .gallery-nav:focus,
.lifestyle-carousel-wrapper .gallery-nav:active {
  outline: 0;
  background-color: rgba(0, 0, 0, 0);
}

.gallery-nav::before {
  content: '';
  position: absolute;
  width: 0.75rem;
  height: 2.5rem;
  border: var(--line-thickness) solid #808080;
  background: transparent;
  transition: border-color 0.2s;
  pointer-events: none;
}

.gallery-nav.prev {
  left: 0;
  justify-content: flex-start;
  padding-left: 1rem;
}

.gallery-nav.prev::before {
  border-right: none;
  border-radius: 0.4rem 0 0 0.4rem;
}

.gallery-nav.next {
  right: 0;
  justify-content: flex-end;
  padding-right: 1rem;
}

.gallery-nav.next::before {
  border-left: none;
  border-radius: 0 0.4rem 0.4rem 0;
}

/* ===== LIFESTYLE CAROUSEL (Interior/Exterior) ===== */
/* Gallery header aligns with left edge of content (at margin line) */
.gallery-header {
  margin-left: 0; /* Aligned with content (container provides outer margin) */
  margin-bottom: 2rem; /* Double space to carousel */
  margin-top: 0; /* Override shared.css default 3em top margin */
}

.lifestyle-carousel-wrapper {
  position: relative;
  width: 100%; /* Obeys margins (container provides outer margin) */
  margin-top: 0; /* Header provides spacing */
  margin-bottom: 2rem;
}

.lifestyle-carousel-wrapper .gallery-nav.prev {
  left: 0;
}

.lifestyle-carousel-wrapper .gallery-nav.next {
  right: 0;
}

.lifestyle-carousel {
  display: flex;
  flex-direction: row;
  overflow-x: scroll;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-behavior: smooth;
}

.lifestyle-carousel::-webkit-scrollbar {
  display: none;
}

.lifestyle-image {
  flex-shrink: 0;
  height: max(280px, 28vw); /* Proportional: min 280px, grows with viewport */
  width: auto; /* Variable width - keeps proportions */
  display: flex;
  align-items: flex-end; /* Bottom align images */
  cursor: pointer; /* Indicate clickable */
  margin-right: 1rem; /* Space between images */
}

.lifestyle-image:last-child {
  margin-right: 0; /* No margin after last image */
}

.lifestyle-image img {
  height: 100%; /* Fill container height */
  width: auto; /* Proportional width */
  object-fit: contain;
  object-position: bottom;
  display: block;
}

/* ===== CART MODAL ===== */
#cart-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#cart-modal.show {
  display: flex;
}

.modal-content {
  background: #fff;
  padding: 2rem;
  max-width: clamp(350px, 45vw, 550px);
  width: calc(100% - 1rem);
  margin: 0 0.5rem;
  position: relative;
  border: var(--line-thickness) solid #000;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.modal-close {
  position: absolute;
  top: 2rem;
  right: 2rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: #000;
  line-height: 1;
  font-size: 1.5rem;
  transition: color 0.2s;
}

#modal-message {
  margin: 0 3rem 1rem 0;
  word-wrap: break-word;
}

#modal-message .product-name,
#modal-message .product-color {
  text-transform: uppercase;
}

.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
}

.modal-button {
  background: transparent;
  color: #000;
  border: var(--line-thickness) solid #000;
  border-radius: var(--button-radius);
  text-decoration: none;
  text-align: center;
  display: block;
  padding: 0.8rem 2rem;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.modal-link {
  text-align: left;
}

.modal-link a {
  color: #000;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s ease;
  /* Underline styles centralized in shared.css */
}

.modal-close:active {
  color: #999;
  background: none;
}

.modal-button:active {
  background: #999;
  border-color: #999;
  color: #fff;
}

.modal-link a:active {
  color: #999;
}

@media (hover: hover) {
  .modal-close:hover {
    color: #999;
    background: none;
  }

  .modal-button:hover {
    background: #999;
    border-color: #999;
    color: #fff;
  }

  .modal-link a:hover {
    color: #999;
  }
}

/* ===== ALERT MODAL ===== */
#alert-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#alert-modal.show {
  display: flex;
}

.alert-content {
  background: #fff;
  padding: 2rem;
  max-width: clamp(300px, 40vw, 450px);
  width: calc(100% - 2rem);
  margin: 0 1rem;
  position: relative;
  border: var(--line-thickness) solid #000;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#alert-message {
  margin: 0 0 1.5rem 0;
  word-wrap: break-word;
}

.alert-ok-btn {
  background: transparent;
  color: #000;
  border: var(--line-thickness) solid #000;
  border-radius: var(--button-radius);
  padding: 0.8rem 2rem;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  width: 100%;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.alert-ok-btn:active {
  background: #999;
  border-color: #999;
  color: #fff;
}

@media (hover: hover) {
  .alert-ok-btn:hover {
    background: #999;
    border-color: #999;
    color: #fff;
  }
}

/* ===== IMAGE LIGHTBOX ===== */
#image-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  display: none;
  z-index: 2000; /* Above cart modal */
  overscroll-behavior: contain; /* Prevent swipe-back gesture */
}

.lightbox-close {
  position: fixed;
  top: 2rem;
  right: 2rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 1rem; /* Larger clickable area */
  margin: -1rem; /* Negative margin keeps visual position same */
  color: #fff;
  line-height: 1;
  font-size: 2rem;
  z-index: 2001;
  transition: color 0.2s;
}

.lightbox-close:focus {
  outline: none;
  background: none;
}

.lightbox-close:active {
  outline: none;
  background: none;
  color: #999;
}

@media (hover: hover) {
  .lightbox-close:hover {
    color: #999;
    background: none; /* Prevent gray box on hover */
  }
}

.lightbox-carousel {
  display: flex;
  flex-direction: row;
  overflow-x: scroll;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-behavior: smooth;
  height: 100vh;
  width: 100vw;
  overscroll-behavior-x: contain; /* Prevent swipe-back on first image */
}

.lightbox-carousel::-webkit-scrollbar {
  display: none;
}

.lightbox-image {
  flex-shrink: 0;
  width: 100vw;
  height: 100vh;
  scroll-snap-align: start;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer; /* Indicate click to advance */
}

.lightbox-image img {
  max-width: 95vw;
  max-height: 95vh;
  width: auto;
  height: auto;
  object-fit: contain;
  pointer-events: none; /* Let clicks pass through to wrapper */
}

/* ===== TABLET (769px - 1024px) ===== */
/* Tablet uses same proportional scaling as desktop - no special overrides needed */
/* The max() values naturally scale down at smaller viewports */

/* ===== MOBILE ===== */
@media (max-width: 768px) {
  #cart-badge {
    position: absolute;  /* scrolls with content */
    top: var(--margin-outer-mobile);
    right: var(--margin-outer-mobile);
  }

  .container {
    padding: 4rem var(--margin-outer-mobile) 2rem;
  }

  .product-layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .product-info {
    position: static;
  }

  /* Mobile: horizontal carousel (width-based sizing) */
  .gallery-wrapper {
    width: 100%;
    height: auto;
    overflow: hidden;  /* Contain the horizontal scroll */
  }

  .gallery-section {
    flex-direction: row;
    align-items: flex-end;  /* Bottom-align images */
    gap: 0;  /* Reset desktop gap - use margin-right instead */
    overflow-x: scroll;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .gallery-section::-webkit-scrollbar {
    display: none;
  }

  .gallery-image {
    flex-shrink: 0;
    width: max(280px, 85%);  /* Proportional: min 280px, 85% of container */
    aspect-ratio: 4 / 3;  /* Reserve space before images load (all product photos are 4:3) */
    margin-right: var(--margin-outer-mobile);  /* Match viewport margins */
  }

  .gallery-image:last-child {
    margin-right: 0;
  }

  .gallery-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;  /* Fill the 4:3 container */
  }

  /* Mobile placeholder matches gallery image dimensions */
  .gallery-placeholder {
    min-height: auto;
    width: max(280px, 85%);
    aspect-ratio: 4 / 3;
  }

  /* Show nav buttons on mobile */
  .gallery-wrapper > .gallery-nav {
    display: flex !important;
  }

  /* Mobile: Gallery header aligns with MEL at 1rem */
  .gallery-header {
    margin-left: 0; /* On mobile, container padding is 1rem which matches MEL position */
  }

  /* Mobile: lifestyle carousel shows 2-3 images at once */
  /* Carousel now obeys margins on all screen sizes */

  .lifestyle-image {
    height: max(200px, 30vw);  /* Proportional: min 200px, grows with viewport */
    width: auto;  /* Variable width - keeps proportions */
    margin-right: var(--margin-outer-mobile);  /* Match viewport margins */
  }

  .lifestyle-image:last-child {
    margin-right: 0;
  }

  .lifestyle-image img {
    height: 100%; /* Fill container height */
    width: auto; /* Proportional width */
    object-fit: contain;
  }

  .add-to-cart-btn {
    width: 100%;
  }

  .modal-content {
    padding: 1.5rem;
  }

  .modal-close {
    top: 1rem;
    right: 1rem;
  }

  #modal-message {
    margin-right: 2rem;
  }
}

/* ===== ERROR PAGES ===== */
/* Styling for 404 and error pages */

body.error-page {
  background-color: #F1F0EA;  /* Match product page background */
}

.error-content {
  text-align: center;
  padding-top: 20vh;
  padding-bottom: 20vh;
  flex: 1;
}

/* Remove h1 underline on error pages */
.error-content h1::after {
  display: none;
}
