/* ==========================================================================
   PRODUCTS ARCHIVE PATTERN
   ========================================================================== */

/* Product grid - horizontal scroll */
.product-grid .wp-block-post-template,
.product-grid.wp-block-query .wp-block-post-template {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    gap: 1.5rem;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.product-grid .wp-block-post-template::-webkit-scrollbar {
    display: none;
}

.product-grid .wp-block-post-template > .wp-block-post,
.product-grid .product-card {
    flex: 0 0 calc((100% - 4.5rem) / 4) !important;
    scroll-snap-align: start;
    width: auto !important;
    max-width: none !important;
}

@media (max-width: 1024px) {
    .product-grid .wp-block-post-template > .wp-block-post,
    .product-grid .product-card {
        flex: 0 0 calc((100% - 3rem) / 3) !important;
    }
}

@media (max-width: 768px) {
    .product-grid .wp-block-post-template > .wp-block-post,
    .product-grid .product-card {
        flex: 0 0 calc((100% - 1.5rem) / 2) !important;
    }
}

@media (max-width: 480px) {
    .product-grid .wp-block-post-template > .wp-block-post,
    .product-grid .product-card {
        flex: 0 0 100% !important;
        width: 100% !important;
    }
}

/* Hide category terms on product cards */
.product-card .wp-block-post-terms {
    display: none;
}

/* See all mode - wrapped grid */
.product-grid .wp-block-post-template[style*="flex-wrap: wrap"] {
    flex-wrap: wrap !important;
    overflow-x: visible !important;
}

.product-grid .wp-block-post-template[style*="flex-wrap: wrap"] > .wp-block-post,
.product-grid .wp-block-post-template[style*="flex-wrap: wrap"] .product-card {
    flex: 0 0 calc((100% - 4.5rem) / 4) !important;
    margin-bottom: 1.5rem;
}

@media (max-width: 1024px) {
    .product-grid .wp-block-post-template[style*="flex-wrap: wrap"] > .wp-block-post,
    .product-grid .wp-block-post-template[style*="flex-wrap: wrap"] .product-card {
        flex: 0 0 calc((100% - 3rem) / 3) !important;
    }
}

@media (max-width: 768px) {
    .product-grid .wp-block-post-template[style*="flex-wrap: wrap"] > .wp-block-post,
    .product-grid .wp-block-post-template[style*="flex-wrap: wrap"] .product-card {
        flex: 0 0 calc((100% - 1.5rem) / 2) !important;
    }
}

@media (max-width: 480px) {
    .product-grid .wp-block-post-template[style*="flex-wrap: wrap"] > .wp-block-post,
    .product-grid .wp-block-post-template[style*="flex-wrap: wrap"] .product-card {
        flex: 0 0 100% !important;
    }
}

/* ==========================================================================
   FOOTER PATTERN
   ========================================================================== */

/* Footer desktop - hide on mobile */
.footer-desktop {
  display: flex;
}

.footer-desktop-wrapper {
  display: block;
}

.footer-mobile-wrapper {
  display: none;
}

/* Social icons top-aligned */
.footer-social {
  align-self: flex-start;
}

/* Switch at 840px */
@media (max-width: 840px) {
  .footer-desktop-wrapper {
    display: none;
  }
  .footer-mobile-wrapper {
    display: flex;
  }
}

.footer-desktop-wrapper,
.footer-mobile-wrapper {
  margin-bottom: -40px;
}

.footer-desktop-wrapper .wp-social-link,
.footer-mobile-wrapper .wp-social-link {
  background: none !important;
  color: #245E70 !important;
  padding: 0 !important;
  margin: none !important;
}

/* ==========================================================================
   Image mask block (alternating image and text block)
   ========================================================================== */
  
   /* Mobile: Always image first */
@media (max-width: 768px) {
  .alternating-image-text .wp-block-columns {
    flex-direction: column;
  }
  
  /* Force image column to appear first */
  .alternating-image-text .wp-block-column:has(.wp-block-image) {
    order: -1;
  }
}

/* ==========================================================================
   Employee profile pattern
   ========================================================================== */

/* Employee contact icons */
.employee-card .contact-email::before {
    content: "✉ ";
}

.employee-card .contact-phone::before {
    content: "☏ ";
}

/* Employee LinkedIn icon */
.employee-card .contact-linkedin a {
    text-decoration: none;
    font-weight: bold;
    font-size: 1.25rem;
    color: var(--wp--preset--color--contrast);
    transition: color 0.2s ease, transform 0.2s ease;
    display: inline-block;
}

.employee-card .contact-linkedin a::before {
    content: "in";
}

.employee-card .contact-linkedin a:hover,
.employee-card .contact-linkedin a:focus {
    color: var(--wp--preset--color--accent-1) !important;
    transform: scale(1.1);
}

/* Hide if empty */
.employee-card .contact-linkedin:empty {
    display: none;
}

/* Hide department terms on employee cards (needed for JS filtering) */
.employee-card .wp-block-post-terms {
    display: none;
}

/* ==========================================================================
   Gallery Block - Carousel variation
   ========================================================================== */

   /* Container for gallery + overlay */
.gallery-carousel-container {
  position: relative;
}

/* Carousel style: horizontal track */
.wp-block-gallery.is-style-carousel {
  display: flex !important;
  flex-wrap: nowrap !important;
  overflow: hidden;
  gap: 0 !important;
}

.wp-block-gallery.is-style-carousel .wp-block-image {
  min-width: 100%;
  flex-shrink: 0;
  margin: 0 !important;
}

.wp-block-gallery.is-style-carousel .wp-block-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Overlay - bottom of gallery */
.gallery-carousel-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 10;
}

/* Navigation (arrows + counter) */
.gallery-carousel-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  padding: 12px;
}

.gallery-carousel-nav .wp-block-button__link {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: unset;
  background: transparent;
  border: 2px solid var(--wp--preset--color--accent-5, #FCFBF6);
  color: var(--wp--preset--color--accent-5, #FCFBF6);
}

.gallery-carousel-nav .wp-block-button__link:hover {
  background: var(--wp--preset--color--accent-5, #FCFBF6);
  color: var(--wp--preset--color--contrast, #245E70);
}

.gallery-carousel-nav .carousel-count {
  color: var(--wp--preset--color--accent-5, #FCFBF6);
  font-size: var(--wp--preset--font-size--small, 14px);
  font-weight: 600;
  min-width: 40px;
}

/* Badge */
.gallery-carousel-badge {
  color: var(--wp--preset--color--accent-5, #FCFBF6);
  font-size: var(--wp--preset--font-size--large, 24px);
  font-weight: 600;
  padding: 12px 20px;
  pointer-events: auto;
}

/* RESPONSIVE */

@media (max-width: 480px) {
  .gallery-carousel-nav {
    padding: 8px;
    gap: 6px;
  }
  
  .gallery-carousel-nav .wp-block-button__link {
    width: 28px;
    height: 28px;
  }
  
  .gallery-carousel-badge {
    padding: 8px 12px;
    font-size: var(--wp--preset--font-size--medium, 16px);
  }
}

/* ===========================================
   NORFRA – MEDIA OVERLAY - FACTORY HERO PATTERN
   Buttons bottom-left, text bottom-right
   =========================================== */

/* OUTER WRAPPER
   Controls spacing above / below the whole block ONLY */
.norfra-factorywrapper {
  padding-top: var(--wp--preset--spacing--40);
  padding-bottom: var(--wp--preset--spacing--40);
}

/* Use WP spacing preset (falls back to 12px if not defined) */
.norfra-mediaOverlay {
  --norfra-overlay-pad: var(--wp--preset--spacing--small, 12px);
}

/* Overlay layer fills the image area */
.norfra-mediaOverlay_ui {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;

  display: flex;
  justify-content: space-between;
  align-items: flex-end;

  z-index: 10;
  pointer-events: none;

  /* Keep the same distance from bottom for BOTH sides */
  padding-bottom: var(--norfra-overlay-pad);
}

/* Left side (arrows) flush to edge: no padding */
.norfra-mediaOverlay_ui > :first-child {
  padding-left: 0 !important;
  margin-left: 0 !important;
}

/* Right side (text) padded from right edge using theme spacing */
.norfra-mediaOverlay_ui > :last-child {
  padding: 0 1rem 1rem 0;
  margin-right: 0 !important;
  text-align: right;
}

/* TEMP: placeholder state for overlay controls */
.norfra-mediaOverlay__left {
  opacity: 0.4;
}



/* ===========================================
   MAKE LIST BLOCK "RESPONSIVE"
   =========================================== */

/* Default: one column */
ul.norfra-listResponsive,
ol.norfra-listResponsive {
  display: block !important;
  column-count: 1;
  column-gap: 1.5rem;
}

ul.norfra-listResponsive li,
ol.norfra-listResponsive li {
  break-inside: avoid;
}

/* When there is room → split */
@media (min-width: 600px) {
  ul.norfra-listResponsive,
  ol.norfra-listResponsive {
    column-count: 2;
  }
}

@media (min-width: 900px) {
  ul.norfra-listResponsive,
  ol.norfra-listResponsive {
    column-count: 3;
  }
}

/* ========================================
   MAP SECTION - Arctic Origin
   ======================================== */

.map-section {
  position: relative;
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  max-width: 1440px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--wp--preset--color--background);
  overflow: hidden;
}

.map-container {
  position: relative;
  width: 100%;
  max-width: 700px;
  margin-left: auto;
}

.map-svg-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 591.534 / 922.348;
}

.map-svg-wrapper img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.map-button.is-active .wp-block-button__link {
  background: var(--wp--preset--color--contrast);
  color: var(--wp--preset--color--base);
}

/* Desktop text */
.map-text-content--desktop {
  position: absolute;
  top: 60px;
  left: max(40px, calc((100% - var(--wp--style--global--wide-size)) / 2));
  z-index: 10;
  max-width: 380px;
}

/* Mobile text */
.map-text-content--mobile {
  display: none !important;
}

/* Factory buttons */
.map-button {
  position: absolute;
  z-index: 5;
  white-space: nowrap;
}

.map-button--torsvaagbruket {
  top: 30%;
  left: 65%;
  transform: translateX(-105%);
}

.map-button--nordvaagen {
  top: 23%;
  left: 70%;
}

.map-button--nichaug {
  top: 48%;
  left: 28%;
  transform: translateX(-105%);
}

/* Modal */
.map-modal {
  position: absolute;
  bottom: 300px;
  left: max(40px, calc((100% - var(--wp--style--global--wide-size)) / 2));
  z-index: 20;
  max-width: 320px;
}

/* Tablet and below */
@media (max-width: 920px) {
  .map-section {
    max-width: var(--wp--style--global--wide-size);
    margin-inline: auto;
    left: auto;
    transform: none;
    width: 100%;
  }
  
  .map-container {
    position: relative;
    max-width: 100%;
  }
  
  .map-text-content--desktop {
    display: none !important;
  }
  
  .map-text-content--mobile {
    display: flex !important;
    position: absolute;
    top: auto;
    bottom: 20px;
    left: auto;
    right: 20px;
    max-width: 50vw;
    align-items: flex-end;
  }
  
  .map-text-content--mobile h2,
  .map-text-content--mobile p {
    text-align: right;
  }
  
  .map-modal {
    position: absolute;
    bottom: 20px;
    left: 20px;
    margin: 0;
    max-width: 320px;
  }
}

/* Arctic circle line */

/* Arctic Circle */
.arctic-circle {
  display: none;
  position: absolute;
  pointer-events: none;
  z-index: 1;
}

@media (min-width: 781px) {
  .arctic-circle {
    display: block;
    top: 40%;
    left: -40%;
    width: 150%;
    transform: translateY(-50%);
  }

  .arctic-circle img {
    width: 100%;
    height: auto;
    transform-origin: 50% 50%;
  }
}

/* ================================
   FRONT-PAGE HERO SECTION
   ================================ */

/* Hero Image Section */
.hero-image-section {
  position: relative;
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  max-width: 1920px;
  left: 50%;
  transform: translateX(-50%);
  margin-top: -74.5px !important;
}

/* Text Container */
.hero-image-text {
  position: absolute;
  bottom: 0;
  left: max(20px, calc((100% - var(--wp--style--global--wide-size)) / 2));
  z-index: 10;
  max-width: 35%;
}

/* Heading - one word per line */
.hero-image-heading {
  word-spacing: 100vw;
}

/* Image Container */
.hero-image-container {
  margin-left: auto;
  width: 55%;
}

.hero-image-container .hero-image {
  margin: 0;
}

.hero-image-container .hero-image img {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
}

/* Large desktop */
@media (max-width: 1360px) {
  .hero-image-text {
    left: max(32px, calc((100% - var(--wp--style--global--wide-size)) / 2));
    max-width: 40%;
  }
}

/* Tablet landscape */
@media (max-width: 920px) {
  .hero-image-text {
    left: max(40px, calc((100% - var(--wp--style--global--wide-size)) / 2));
    max-width: 45%;
  }
}

/* Mobile (<768px) */
@media (max-width: 767px) {
  .hero-image-section {
    display: flex;
    flex-direction: column;
    max-width: 100%;
    left: auto;
    transform: none;
    width: 100%;
    margin-top: 20px !important;
  }
  
  .hero-image-container {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    order: 1;
  }
  
  .hero-image-container .hero-image {
    max-height: 350px;
    width: auto;
  }
  
  .hero-image-container .hero-image img {
    height: 100%;
    width: auto;
    max-height: 350px;
  }
  
  .hero-image-text {
    position: relative;
    bottom: auto;
    left: auto;
    max-width: 60%;
    width: 100%;
    margin-left: 0;
    margin-right: auto;
    padding-left: 40px;
    order: 2;
    transform: translateY(var(--hero-text-overlap, -50px));
    margin-bottom: var(--hero-text-overlap, -50px);
  }
}

/* ==========================================================================
   GRAND NORD HEADER
   ========================================================================== */

.grand-nord-header {
  position: relative;
  z-index: 100;
  padding-bottom: 63px; /* match desktop extension */
}

/* extend background downward from the colored group */
.header-bg {
  overflow: visible;
}

/* pseudo-element background extension (desktop) */
.header-bg::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -63px; /* desktop SVG alignment */
  height: 63px;
  background: inherit;
  z-index: -1;
}

/* site logo above SVG */
.grand-nord-header .wp-block-site-logo {
  position: relative;
  z-index: 10;
}

/* centered Grand Nord SVG (desktop) */
.grand-nord-brand-center {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 55%);
  z-index: 5;
}

.grand-nord-brand-center img {
  height: 160px;
  width: auto;
  display: block;
}

/* tablet */
@media (max-width: 768px) {
  .grand-nord-header {
    padding-bottom: 48px; /* match tablet extension */
  }

  .grand-nord-brand-center img {
    height: 120px;
  }

  /* pseudo-element background extension (tablet) */
  .header-bg::after {
    bottom: -48px; /* tablet SVG alignment */
    height: 48px;
  }
}

/* small mobile */
@media (max-width: 480px) {
  .grand-nord-header {
    padding-bottom: 72px; /* match mobile extension */
  }

  /* pseudo-element background extension (mobile) */
  .header-bg::after {
    bottom: -72px; /* mobile SVG alignment */
    height: 72px;
  }

  /* SVG breathing room (percentage only) */
  .grand-nord-brand-center {
    transform: translate(-50%, 75%);
  }
}

/* ==========================================================================
   GRAND NORD SEARCH BUTTON
   ========================================================================== */

:root {
  /* sizing */
  --trace-radius: 8px;
  --trace-border-width: 2px;
  --trace-max-width: 340px; /* make it wider here */

  /* colors */
  --trace-bg: #ffffff;
  --trace-border: #245E70;
  --trace-button-hover: rgba(0, 52, 61, 0.12);

  /* typography */
  --trace-input-weight: 400;
  --trace-button-weight: 600;
}

/* IMPORTANT: allow this block area to exceed the theme content width if needed */
.trace,
.trace-inner {
  max-width: none;
  width: 100%;
}

/* form */
.trace-form {
  display: flex;
  align-items: stretch;

  width: 100%;
  max-width: var(--trace-max-width);
  margin-inline: auto;

  background-color: var(--trace-bg);
  border: var(--trace-border-width) solid var(--trace-border);
  border-radius: var(--trace-radius);
  overflow: hidden;
}

/* input */
.trace-input {
  flex: 1 1 auto;
  min-width: 0;

  border: 0;
  outline: none;
  background: transparent;

  padding: 0.85em 1em;
  font: inherit;
  font-weight: var(--trace-input-weight);
  color: inherit;
}

.trace-input::placeholder {
  opacity: 0.55;
}

/* button */
.trace-btn {
  border: 0;
  background: transparent;
  cursor: pointer;

  padding: 0.85em 1.1em;
  white-space: nowrap;

  font: inherit;
  font-weight: var(--trace-button-weight);
  color: inherit;

  border-left: var(--trace-border-width) solid var(--trace-border);
  transition: background-color 0.2s ease;
}

.trace-btn:hover {
  background-color: var(--trace-button-hover);
}

/* no focus ring at all */
.trace-form:focus-within {
  box-shadow: none;
}

/* remove native focus rings */
.trace-input:focus,
.trace-btn:focus {
  outline: none;
}
