/* ==========================================================================
   Hero / Carousel - Puunjalostusinsinöörit
   ==========================================================================
   Styles for hero sections and carousel slides.
   Requires brand.css to be loaded first for CSS variables.
   ========================================================================== */


/* ==========================================================================
   HERO TYPOGRAPHY
   ========================================================================== */

/* Hero H1 - Main headline */
.slide .carousel-title,
.slide h1,
.slide .hero-title {
  font-family: var(--font-primary);
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-extrabold);
  text-transform: uppercase;
  line-height: var(--line-height-tight);
  margin-bottom: var(--spacing-md);
}

@media screen and (min-width: 50em) {
  .slide .carousel-title,
  .slide h1,
  .slide .hero-title {
    font-size: var(--font-size-4xl);
  }
}

/* Hero Lead / Summary text */
.slide .carousel-summary,
.slide .hero-summary,
.slide .lead {
  font-family: var(--font-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-snug);
  margin-bottom: var(--spacing-lg);
  border-top: none;
  display: block;
}

@media screen and (min-width: 50em) {
  .slide .carousel-summary,
  .slide .hero-summary,
  .slide .lead {
    font-size: var(--font-size-lg);
  }
}


/* ==========================================================================
   CAROUSEL CONTENT POSITIONING & WIDTH
   ========================================================================== */

/* Main carousel container */
.main-carousel {
  position: relative;
  overflow: hidden;
}

/* Until slick runs, the slides are still in normal flow and stack to
   N x slide height, then collapse to one slide when it initializes — a
   full-viewport layout shift on every page load. Show only the first slide
   until then, so the container is the right height from first paint.
   slick.css only hides slides via .slick-slide, a class slick adds itself. */
.main-carousel:not(.slick-initialized) .slide ~ .slide {
  display: none;
}

.main-carousel.slick-slider {
  margin-bottom: 0;
}

.main-carousel .slick-list,
.main-carousel .slick-track {
  height: 600px;
}

/* Reduced-height hero (home global setting: reduce_height) */
.main-carousel--short .slick-list,
.main-carousel--short .slick-track {
  height: 440px;
}

@media (max-width: 49.99em) {
  .main-carousel .slick-list,
  .main-carousel .slick-track {
    height: 550px;
  }

  .main-carousel--short .slick-list,
  .main-carousel--short .slick-track {
    height: 420px;
  }
}

/* Remove margin when controls are present */
.main-carousel + .carousel-controls {
  margin-top: 0;
}

/* Controls container - prev, dots, next in a row.
   min-height matches the 20px arrow row so the space is already reserved
   before slick appends the arrows and dots into it. */
.carousel-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md) 0;
  min-height: 20px;
}

.carousel-controls .slick-prev {
  order: 1;
}

.carousel-controls .slick-dots {
  order: 2;
}

.carousel-controls .slick-next {
  order: 3;
}

/* Navigation dots */
.carousel-controls .slick-dots {
  position: relative;
  bottom: auto;
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  background-color: transparent;
  padding: 0;
  margin: 0;
  width: auto;
}

.carousel-controls .slick-dots li {
  margin: 0;
  width: auto;
  height: auto;
}

.carousel-controls .slick-dots li button {
  width: 12px;
  height: 12px;
  padding: 0;
}

.carousel-controls .slick-dots li button:before {
  font-size: 12px;
  width: 12px;
  height: 12px;
  line-height: 12px;
  color: var(--color-tertiary);
  opacity: 1;
}

.carousel-controls .slick-dots li.slick-active button:before {
  color: var(--color-primary);
  opacity: 1;
}

/* Prev/Next buttons */
.carousel-controls .slick-prev,
.carousel-controls .slick-next {
  position: static;
  display: inline-block;
  width: 20px;
  height: 20px;
  margin: 0;
  padding: 0;
  line-height: 20px;
  z-index: 10;
  background-color: transparent;
}

.carousel-controls .slick-prev:before,
.carousel-controls .slick-next:before {
  color: var(--color-primary);
  font-size: 20px;
  line-height: 20px;
  opacity: 1;
}

.carousel-controls .slick-prev:hover:before,
.carousel-controls .slick-next:hover:before {
  color: var(--color-tertiary);
}

/* Base slide - fixed height (slick fade mode requires it) */
.slide {
  position: relative;
  height: 600px;
  padding: var(--spacing-md);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.main-carousel--short .slide {
  height: 440px;
}

@media (max-width: 49.99em) {
  .slide {
    height: 550px;
  }

  .main-carousel--short .slide {
    height: 420px;
  }
}


@media screen and (min-width: 50em) {
  .slide {
    padding: var(--spacing-xl);
  }
}

/* The slide image, replacing the old .slide background-image so it can carry
   srcset/fetchpriority. z-index 0 keeps it below .slide's own overlays and
   .carousel-content. object-position matches the !important background-position
   in defaults.css. */
.slide__image {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

/* Container matches site width, centered horizontally and vertically */
.slide .carousel-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - var(--container-padding-mobile) * 2);
  max-width: var(--content-width);
  padding: 0;
}

@media screen and (min-width: 50em) {
  .slide .carousel-content {
    width: calc(100% - var(--container-padding) * 2);
  }
}

/* Text elements inside have constrained width */
.slide .carousel-content .carousel-title,
.slide .carousel-content .carousel-summary,
.slide .carousel-content p,
.slide .carousel-content h1,
.slide .carousel-content h2,
.slide .carousel-content h3 {
  max-width: 600px;
}


/* ==========================================================================
   CONTENT ALIGNMENT VARIANTS
   ==========================================================================
   Container is always centered. These classes control text alignment
   and which side the text elements are pushed to.
   ========================================================================== */

/* Left alignment (default) - text left aligned */
.slide .carousel-content,
.slide.content-left .carousel-content {
  text-align: left;
}

/* Right alignment - text right aligned, elements pushed right */
.slide.content-right .carousel-content {
  text-align: right;
}

.slide.content-right .carousel-content .carousel-title,
.slide.content-right .carousel-content .carousel-summary,
.slide.content-right .carousel-content p,
.slide.content-right .carousel-content h1,
.slide.content-right .carousel-content h2,
.slide.content-right .carousel-content h3 {
  margin-left: auto;
  margin-right: 0;
}

/* Bottom-left alignment */
.slide.content-bottom-left .carousel-content {
  top: auto;
  bottom: var(--spacing-xl);
  transform: translateX(-50%);
  text-align: left;
}

/* Bottom-right alignment */
.slide.content-bottom-right .carousel-content {
  top: auto;
  bottom: var(--spacing-xl);
  transform: translateX(-50%);
  text-align: right;
}

.slide.content-bottom-right .carousel-content .carousel-title,
.slide.content-bottom-right .carousel-content .carousel-summary,
.slide.content-bottom-right .carousel-content p,
.slide.content-bottom-right .carousel-content h1,
.slide.content-bottom-right .carousel-content h2,
.slide.content-bottom-right .carousel-content h3 {
  margin-left: auto;
  margin-right: 0;
}


/* ==========================================================================
   CENTERED CONTENT VARIANT
   ==========================================================================
   Use .content-center class on .slide for vertically and horizontally
   centered content.
   ========================================================================== */

.slide.content-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.slide.content-center .carousel-content {
  position: relative;
  top: auto;
  transform: none;
  text-align: center;
  padding: var(--spacing-xl);
  max-width: 900px;
}

/* Reset bottom positioning for centered slides */
.slide.content-center.content-bottom-left .carousel-content,
.slide.content-center.content-bottom-right .carousel-content {
  top: auto;
  transform: none;
}


/* ==========================================================================
   HERO BUTTONS
   ========================================================================== */

/* Multiple buttons container */
.slide .carousel-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
}

.slide.content-right .carousel-buttons {
  justify-content: flex-end;
}

.slide.content-bottom-right .carousel-buttons {
  justify-content: flex-end;
}

.slide.content-center .carousel-buttons {
  justify-content: center;
}


/* ==========================================================================
   DARK OVERLAY FOR BETTER TEXT READABILITY
   ========================================================================== */

/* Full overlay */
.slide.with-overlay::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1;
}

.slide.with-overlay .carousel-content {
  z-index: 2;
}

/* Gradient overlay - default fades from left (dark) to right (transparent) */
.slide.with-gradient-overlay::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.6) 0%,
    rgba(0, 0, 0, 0.4) 30%,
    rgba(0, 0, 0, 0.1) 50%,
    transparent 70%
  );
  z-index: 1;
}

.slide.with-gradient-overlay .carousel-content {
  z-index: 2;
}

/* Gradient overlay for right-aligned content - fades from right to left */
.slide.with-gradient-overlay.content-right::before,
.slide.with-gradient-overlay.content-bottom-right::before {
  background: linear-gradient(
    to left,
    rgba(0, 0, 0, 0.6) 0%,
    rgba(0, 0, 0, 0.4) 30%,
    rgba(0, 0, 0, 0.1) 50%,
    transparent 70%
  );
}

/* ==========================================================================
   TEXTURED SLIDE VARIANT (carousel item option: display_background)
   ==========================================================================
   Replaces the dark gradient overlay with a brown 20% tint + paper texture
   fading in from the left. Forces dark text (image is optional/decorative).
   ========================================================================== */

/* Full-slide overlay with brown tint underneath and paper texture on top.
   Desktop: fades in from the left. Mobile: fades in from the bottom over ~half
   the slide so the top half of the image stays visible. */
.slide.slide--textured.with-gradient-overlay::before,
.slide.slide--textured::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--color-secondary-light);
  pointer-events: none;
  z-index: 1;
  -webkit-mask-image: linear-gradient(to top, black 0%, black 55%, transparent 75%);
  mask-image: linear-gradient(to top, black 0%, black 55%, transparent 75%);
}

.slide.slide--textured::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url('../img/card-bg.png');
  background-size: cover;
  background-position: center;
  pointer-events: none;
  z-index: 2;
  -webkit-mask-image: linear-gradient(to top, black 0%, black 55%, transparent 75%);
  mask-image: linear-gradient(to top, black 0%, black 55%, transparent 75%);
}

@media (min-width: 50em) {
  .slide.slide--textured.with-gradient-overlay::before,
  .slide.slide--textured::before,
  .slide.slide--textured::after {
    -webkit-mask-image: linear-gradient(to right, black 0%, black 30%, transparent 60%);
    mask-image: linear-gradient(to right, black 0%, black 30%, transparent 60%);
  }
}

/* Mobile: push text down over the tinted band */
@media (max-width: 49.99em) {
  .slide.slide--textured .carousel-content,
  .slide.slide--textured.content-left .carousel-content,
  .slide.slide--textured.content-right .carousel-content {
    top: auto;
    bottom: var(--spacing-lg);
    transform: translateX(-50%);
    text-align: left;
  }
}

.slide.slide--textured .carousel-content,
.slide.slide--textured.with-gradient-overlay .carousel-content {
  z-index: 3;
  color: var(--color-black);
}

.slide.slide--textured .carousel-content .carousel-title,
.slide.slide--textured.white-text .carousel-content .carousel-title,
.slide.slide--textured .carousel-content h1,
.slide.slide--textured .carousel-content h2,
.slide.slide--textured .carousel-content h3 {
  color: var(--color-primary);
  text-shadow: none;
}

.slide.slide--textured .carousel-content .carousel-summary,
.slide.slide--textured.white-text .carousel-content .carousel-summary,
.slide.slide--textured .carousel-content p {
  color: var(--color-black);
  text-shadow: none;
}
