/*
Theme Name: הנגרייה של רפי
Description: Custom Carpentry Catalog Theme
Version: 1.0
*/

/* --- 1. GENERAL SETTINGS --- */
:root {
  --wood: #5a3e2b;       /* Accent: dark walnut */
  --wood-hover: #432e20;
  --text-muted: #6b6259;
  /* Layout scales with the viewport; only caps out on very wide screens */
  --page-max: 1680px;
  --gutter: clamp(1rem, 4vw, 4rem);
  --sliver: clamp(3px, 0.3vw, 6px); /* Gap between photos in a gallery */
}

html {
  /* Fluid base size: 16px on phones, growing gently to 19px on large monitors */
  font-size: clamp(16px, 0.85rem + 0.25vw, 19px);
}

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

body {
  font-family: 'Heebo', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  color: #2b2b2b;
  background-color: #fffaf4;
  
  /* These 3 lines force the page to be full height */
  display: flex;
  flex-direction: column;
  min-height: 100vh; 
}
header, main {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
  width: 100%;
}

main {
  flex-grow: 1; /* This pushes the footer down */
}
/* --- 2. HEADER & NAVIGATION --- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #eee;
  padding-bottom: 1rem;
  margin-bottom: 2rem;
  margin-top: 2rem;
}

.site-title {
  color: inherit;
  text-decoration: none;
}

header nav a {
  margin-right: 1.5rem;
  text-decoration: none;
  color: #666;
  font-weight: 500;
}

header nav a.active {
  color: #000;
  border-bottom: 2px solid #000;
  padding-bottom: 0.2rem;
  font-weight: 700;
}

/* --- 3. GALLERIES (CATALOG AND CATEGORY PAGES) --- */
/* Gallery pages run edge to edge; their text keeps the usual page width */
main.gallery-page {
  max-width: none;
  padding: 0;
}

.gallery-page .page-intro,
.category-nav {
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.page-intro {
  margin-bottom: 1.25rem;
}

/* Phones: one photo per row, full width. Tile widths for larger screens are set below. */
.gallery {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sliver);
}

.tile {
  position: relative;
  display: block;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  background-color: #f0ebe2;
}

.tile img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transition: opacity 0.2s;
}

/* Title on the photo's top right corner */
.tile-title {
  position: absolute;
  top: 0;
  right: 0;
  max-width: 85%;
  padding: 0.5em 0.8em;
  color: #000;
  font-size: clamp(1.05rem, 0.85rem + 0.6vw, 1.5rem);
  font-weight: 500;
  line-height: 1.3;
  transition: color 0.2s;
}

.tile-photo {
  display: block;
  position: relative;
  z-index: 0; /* Keeps the slides' stacking order below the title */
  transition: opacity 0.2s;
}

.tile:hover .tile-photo {
  opacity: 0.88;
}

/* Catalog: extra photos a category tile fades through (script in index.html) */
.tile .tile-slide {
  position: absolute;
  inset: 0;
  height: 100%; /* Fill the tile; the first photo sets its size */
  opacity: 0;
  transition: opacity 1.4s ease-in-out; /* FADE_MS in index.html */
}

.tile .tile-slide.shown {
  opacity: 1;
}

/* A cycling tile's title fades between black and white along with the photos */
.tile.cycles .tile-title {
  transition: color 1.4s ease-in-out;
}

.tile:hover .tile-title {
  color: var(--wood);
}

/* Photos that are dark under the title get a white title (decided in build.py) */
.tile.on-dark .tile-title,
.tile.on-dark:hover .tile-title {
  color: #fff;
}

/* Tablets: rows of 2; with an odd count the last photo is full width */
@media (min-width: 600px) and (max-width: 1099px) {
  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-inline: var(--sliver);
  }

  .gallery > .wide-tablet {
    grid-column: 1 / -1;
  }
}

/* Desktop: rows of 3, or 2 bigger photos at the end so no row has a gap; a lone photo is 2/3 wide */
@media (min-width: 1100px) {
  .gallery {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    padding-inline: var(--sliver);
  }

  .gallery > .tile {
    grid-column: span 2;
  }

  .gallery > .half {
    grid-column: span 3;
  }

  .gallery > .solo {
    grid-column: 2 / span 4;
  }
}

/* Bottom of a category page: back to the catalog, and small photos of the other categories */
.category-nav {
  margin-top: clamp(2rem, 4vw, 3.5rem);
}

.category-nav-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding-top: 1rem;
  margin-bottom: 0.75rem;
  border-top: 1px solid #e6ddd2;
}

.category-nav-head h3 {
  font-size: 1.1rem;
  font-weight: 500;
}

.category-nav-head .back-link {
  margin-inline-start: auto; /* Far left, even when there's no heading */
}

.mini-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(100px, 14vw, 240px), 1fr));
  gap: var(--sliver);
}

.mini-tile .tile-title {
  max-width: 100%;
  font-size: 0.85rem;
  padding: 0.35em 0.6em;
}

/* Which part of a cropped photo to keep (set per photo under "Photo framing" in the CMS) */
.focus-top    { object-position: 50% 0%; }
.focus-upper  { object-position: 50% 25%; }
.focus-lower  { object-position: 50% 75%; }
.focus-bottom { object-position: 50% 100%; }
.focus-left   { object-position: 0% 50%; }
.focus-right  { object-position: 100% 50%; }

/* --- 4. CONTACT PAGE --- */
.contact-container {
  max-width: 600px;
  margin: 0 auto; /* This centers the box perfectly */
  width: 100%; 
}

.contact-container .about {
  white-space: pre-wrap;
  margin: 1rem 0 1.5rem;
}

.contact-container .cta-button {
  margin-top: 1rem;
}

.contact-details {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: #fffaf4;
  border-right: 4px solid #333;
}

.contact-details p {
  margin-bottom: 0.8rem;
}

.contact-details a {
  color: var(--wood);
  text-decoration: none;
}

/* --- 5. SINGLE PRODUCT PAGE LAYOUT --- */
.product-details-container {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 3fr); /* Places the slideshow and text side-by-side */
  gap: clamp(1.5rem, 4vw, 4rem);
  margin-top: 1rem;
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
}

.back-link:hover {
  color: var(--wood);
}

.product-info h2 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
}

.project-category {
  display: inline-block;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.project-category:hover {
  color: var(--wood);
}

.product-info p {
  white-space: pre-wrap;
}

.cta-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

.cta-button {
  display: inline-block;
  padding: 0.8rem 1.5rem;
  background-color: var(--wood);
  color: #fffaf4;
  border: 2px solid var(--wood);
  text-decoration: none;
  border-radius: 4px;
  font-weight: 700;
  transition: background-color 0.2s, color 0.2s;
}

.cta-button:hover {
  background-color: var(--wood-hover);
  border-color: var(--wood-hover);
}

.cta-button.cta-secondary {
  background-color: transparent;
  color: var(--wood);
}

.cta-button.cta-secondary:hover {
  background-color: var(--wood);
  color: #fffaf4;
}

/* --- 6. SLIDESHOW COMPONENTS --- */
.slideshow-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  background-color: #f4f4f4;
}

.slide {
  display: none;
  width: 100%;
}

a.slide {
  cursor: zoom-in;
}

/* Full-screen gallery controls are laid out left-to-right (keeps the "1 / 3" counter readable) */
.pswp {
  direction: ltr;
}

.slide.active-slide {
  display: block;
  animation: fade 0.4s ease-in-out;
}

.slide img {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  max-height: 80vh; /* Never taller than the screen */
  object-fit: cover;
  display: block;
}

.slide-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background-color: transparent;
  color: white;
  border: none;
  padding: 1rem;
  font-size: 1.5rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.2s;
  z-index: 10;
}

.slide-arrow:hover {
  background-color: transparent;
  opacity: 0.8; 
}

.prev-arrow { right: 10px; }
.next-arrow { left: 10px; }

.slide-indicators {
  position: absolute;
  bottom: 15px;
  width: 100%;
  text-align: center;
  display: flex;
  justify-content: center;
  gap: 8px;
  z-index: 10;
}

.dot {
  height: 12px;
  width: 12px;
  background-color: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.dot.active-dot, .dot:hover {
  background-color: white;
}

@keyframes fade {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

/* --- 7. MOBILE RESPONSIVENESS --- */
/* Tablets: stack the product page before the text column gets cramped */
@media (max-width: 1024px) {
  .product-details-container {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 768px) {
/* Mobile Header Adjustments */
  header {
    flex-direction: column;
    gap: 1rem; /* Adds breathing room between the logo and the menu */
  }

  /* Centers the navigation links */
  header nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
  }

  header nav a {
    margin-right: 0; /* Removes the desktop side-spacing so they center perfectly */
    font-size: 1rem; /* Shrinks the menu font if needed */
  }
  .slide img {
    aspect-ratio: 4 / 3;
  }
}

/* --- 8. FOOTER --- */
.site-footer {
  background-color: rgb(240, 235, 226);
  border-top: 1px solid #eaeaea;
  padding: 3rem var(--gutter) 1.5rem; /* Adds generous room at the bottom of the page */
  margin-top: 4rem; /* Pushes the footer away from your main page content */
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: calc(var(--page-max) - 2 * var(--gutter)); /* Lines up with header content */
  margin: 0 auto 2rem;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.footer-logo h3 {
  font-size: 1.5rem;
  color: #333;
  margin: 0;
}

.footer-logo p {
  color: var(--text-muted);
}

.footer-social a {
  margin-right: 1.5rem; /* Spacing between links in RTL */
  color: #555;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.footer-social a:last-child {
  margin-right: 1.5rem;
}

.footer-social a:hover {
  color: #000;
}

/* Mobile Responsiveness for Footer */
@media (max-width: 768px) {
  .footer-content {
    flex-direction: column;
    text-align: center;
  }
  
  .footer-social {
    display: flex;
    justify-content: center;
    gap: 1rem;
  }

  .footer-social a {
    margin-right: 0;
  }
}