/* ==========================================================================
   Factory Page Stylesheet - Designed for Linyi Mincai Stationery
   Consistent Wide Layout matching Design Mockup
   ========================================================================== */

:root {
  --factory-orange: #ff621f;
  --factory-orange-hover: #ee500e;
  --factory-dark: #10264f;
  --factory-border: #edf2f8;
  --factory-card-bg: #ffffff;
  --factory-text-muted: #7487a2;
}

.factory-page {
  background: #f7fbff;
  color: #243f70;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

/* ==========================================================================
   1. Factory Hero Banner Section - Single Image Banner
   ========================================================================== */
.factory-hero {
  position: relative;
  width: 100%;
  background: linear-gradient(180deg, #bceeff 0%, #ddf3ff 68%, #ffffff 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.factory-banner-img {
  display: block;
  width: 100%;
  max-width: 1920px;
  height: auto;
  margin: 0 auto;
}

/* ==========================================================================
   2. Factory Main Container & Grid
   ========================================================================== */
.factory-width {
  width: min(1480px, calc(100% - 64px));
  margin-inline: auto;
  padding: 48px 0 70px;
}

@media (min-width: 1680px) {
  .factory-width {
    width: min(1568px, calc(100% - 76px));
  }
}

.factory-list-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 22px;
}

/* 3. Factory Image Card */
.factory-image-card {
  border: 1.5px solid var(--factory-border);
  border-radius: 18px;
  overflow: hidden;
  background: var(--factory-card-bg);
  box-shadow: 0 4px 18px rgba(16, 38, 79, 0.04);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.factory-image-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 28px rgba(16, 38, 79, 0.09);
  border-color: #dbe7f5;
}

.factory-image-button {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 10px 10px 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  outline: none;
  color: inherit;
  font-family: inherit;
}

.factory-card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 12px;
  overflow: hidden;
  background: #eaf3fd;
}

.factory-card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.factory-image-card:hover .factory-card-media img {
  transform: scale(1.05);
}

.factory-card-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 6px 2px;
}

.factory-card-title {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--factory-dark);
  line-height: 1.3;
}

.factory-card-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff2ea;
  color: var(--factory-orange);
  font-size: 12px;
  flex-shrink: 0;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.factory-image-card:hover .factory-card-arrow {
  background: var(--factory-orange);
  color: #ffffff;
  transform: translateX(2px);
}

/* ==========================================================================
   4. Pagination matching Design Mockup
   ========================================================================== */
.factory-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 42px;
}

.factory-pagination button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid #e1e9f4;
  border-radius: 50%;
  background: #ffffff;
  color: #35476e;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
}

.factory-pagination button:hover:not(:disabled) {
  border-color: var(--factory-orange);
  color: var(--factory-orange);
  background: #fff8f4;
}

.factory-pagination button.active,
.factory-pagination button[aria-current='page'] {
  background: var(--factory-orange);
  color: #ffffff;
  border-color: var(--factory-orange);
  box-shadow: 0 4px 12px rgba(255, 98, 31, 0.3);
}

.factory-pagination button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.factory-pagination .page-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  color: #8c9eb4;
  font-weight: 700;
  user-select: none;
}

/* ==========================================================================
   5. Lightbox Dialog - Transparent Fullscreen Image Viewer
   ========================================================================== */
.factory-lightbox {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-sizing: border-box;
  z-index: 9999;
}

.factory-lightbox:not([open]) {
  display: none;
}

.factory-lightbox[open] {
  animation: lightboxFadeIn 0.22s ease-out;
}

@keyframes lightboxFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.factory-lightbox::backdrop {
  background: rgba(10, 22, 40, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Close Button Fixed in Top-Right Corner of the Window */
.lightbox-close {
  position: fixed;
  top: 24px;
  right: 28px;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  color: #ffffff;
  font-size: 20px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
  transition: all 0.22s ease;
}

.lightbox-close:hover {
  background: var(--factory-orange);
  border-color: var(--factory-orange);
  color: #ffffff;
  transform: rotate(90deg) scale(1.08);
  box-shadow: 0 6px 20px rgba(255, 98, 31, 0.45);
}

/* Floating Navigation Arrows Fixed at Left and Right */
.lightbox-arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10000;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  color: #ffffff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
  transition: all 0.22s ease;
}

.lightbox-arrow.arrow-prev {
  left: 28px;
}

.lightbox-arrow.arrow-next {
  right: 28px;
}

.lightbox-arrow:hover:not(:disabled) {
  background: var(--factory-orange);
  border-color: var(--factory-orange);
  color: #ffffff;
  transform: translateY(-50%) scale(1.12);
  box-shadow: 0 6px 22px rgba(255, 98, 31, 0.5);
}

.lightbox-arrow:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* Central Stage & Enlarged Image */
.lightbox-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 96px;
  box-sizing: border-box;
}

.lightbox-figure {
  margin: 0;
  max-width: 90vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: lightboxImageZoom 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes lightboxImageZoom {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.lightbox-figure img {
  display: block;
  max-width: 100%;
  max-height: calc(85vh - 56px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 2px 10px rgba(0, 0, 0, 0.3);
  background: #10264f10;
}

/* Floating Caption Bar */
.lightbox-caption-bar {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 6px 18px;
  border-radius: 50px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.lightbox-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.2px;
}

.lightbox-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 10px;
  border-radius: 50px;
  background: var(--factory-orange);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

body.factory-lightbox-open {
  overflow: hidden;
}

.factory-empty {
  text-align: center;
  padding: 60px 20px;
}

.factory-empty button {
  background: var(--factory-orange);
  color: #ffffff;
  border: none;
  border-radius: 24px;
  padding: 12px 28px;
  font-weight: 600;
  cursor: pointer;
}

/* Accessibility */
.factory-page [hidden] {
  display: none !important;
}

.factory-page a:focus-visible,
.factory-page button:focus-visible {
  outline: 3px solid #168cff;
  outline-offset: 3px;
}

/* ==========================================================================
   6. Responsive Layout Breakpoints
   ========================================================================== */
@media (max-width: 1200px) {
  .factory-list-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
  }
}

@media (max-width: 860px) {
  .factory-width {
    width: calc(100% - 36px);
    padding: 32px 0 50px;
  }
  .factory-list-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }
  .lightbox-close {
    top: 16px;
    right: 16px;
    width: 42px;
    height: 42px;
    font-size: 18px;
  }
  .lightbox-arrow {
    width: 44px;
    height: 44px;
    font-size: 16px;
  }
  .lightbox-arrow.arrow-prev { left: 14px; }
  .lightbox-arrow.arrow-next { right: 14px; }
  .lightbox-stage {
    padding: 30px 68px;
  }
}

@media (max-width: 540px) {
  .factory-list-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .factory-pagination button {
    width: 34px;
    height: 34px;
    font-size: 13px;
  }
  .lightbox-stage {
    padding: 24px 50px;
  }
  .lightbox-close {
    top: 12px;
    right: 12px;
    width: 38px;
    height: 38px;
    font-size: 16px;
  }
  .lightbox-arrow {
    width: 38px;
    height: 38px;
    font-size: 14px;
  }
  .lightbox-arrow.arrow-prev { left: 8px; }
  .lightbox-arrow.arrow-next { right: 8px; }
  .lightbox-figure img {
    max-height: calc(75vh - 56px);
    border-radius: 12px;
  }
  .lightbox-title {
    font-size: 14px;
  }
}
