/* layout.css - Final canonical file
   Mobile: content 96% (header/footer remain 100%)
   - Single mobile @media block only
   - Target list explicit and narrow to avoid header/footer side effects
   - High-specificity overrides inside mobile block to ensure application
   Backup original before replacing */

/* ===== Base reset & box-sizing ===== */
html { box-sizing: border-box; }
*, *::before, *::after { box-sizing: inherit; margin: 0; padding: 0; }

/* ===== Image utilities ===== */
.layout-img,
.layout-image01 img,
.layout-image img,
.image img,
.gallery-row .gallery-thumb {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

/* ===== Default layout-flex01 (desktop behavior) ===== */
.layout-flex01 {
  display: flex;
  flex-direction: row;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 40px;
  width: 100%;
  position: static;
}

.layout-flex01 > .layout-text01,
.layout-flex01 > .text {
  order: 1;
  flex: 1 1 0%;
  min-width: 200px;
  padding-right: 12px;
  box-sizing: border-box;
}

.layout-flex01 > .layout-image01,
.layout-flex01 > .layout-image,
.layout-flex01 > .image,
.layout-flex01 > .col-image {
  order: 2;
  flex: 0 0 auto;
  min-width: 180px;
  box-sizing: border-box;
  display: block;
}

/* ===== Gallery defaults ===== */
.gallery-row {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 40px;
  flex-wrap: nowrap;
}
.gallery-row .gallery-thumb {
  flex: 0 0 32%;
  max-width: 32%;
  box-sizing: border-box;
}

/* ===== Rail visuals ===== */
.rail-block {
  width: 100%;
  box-sizing: border-box;
  margin: 10px 0;
  padding: 4px 0;
  position: relative;
}
.rail-block .rail-line {
  display: block;
  width: 100%;
  height: 2px;
  background: linear-gradient(to right, #333, #666, #333);
}
.sleeper-line {
  width: 100%;
  height: 8px;
  background-image: repeating-linear-gradient(to right, #8B4513 0, #8B4513 5px, transparent 5px, transparent 11px);
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.12);
  position: relative;
}
.sleeper-line::before,
.sleeper-line::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(to right, rgba(0,0,0,0.12), rgba(0,0,0,0.03));
}
.sleeper-line::before { top: -6px; }
.sleeper-line::after { bottom: -6px; }

/* ======================================================
   Desktop: pinned first row image (kept only for desktop)
   This block strictly targets desktop viewports
====================================================== */
@media screen and (min-width: 769px) {
  .layout-flex01:first-of-type {
    position: relative;
    padding-right: calc(380px + 20px);
  }

  .layout-flex01:first-of-type > .layout-image01.layout-image01--right,
  .layout-flex01:first-of-type > .layout-image01,
  .layout-flex01:first-of-type > .layout-image,
  .layout-flex01:first-of-type > .image,
  .layout-flex01:first-of-type > .col-image {
    position: absolute;
    top: 0;
    right: 0;
    width: 380px;
    max-width: 38%;
    z-index: 60;
    margin: 0;
    padding: 0;
    display: block;
    flex: 0 0 auto;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  }

  .layout-flex01:first-of-type > .layout-image01 img,
  .layout-flex01:first-of-type > .layout-image img,
  .layout-flex01:first-of-type > .image img,
  .layout-flex01:first-of-type > .col-image img {
    display: inline-block;
    width: auto;
    max-width: 100%;
    height: auto;
    margin: 0;
    float: none;
  }

  .layout-flex01:first-of-type > .layout-text01,
  .layout-flex01:first-of-type > .text {
    flex: 1 1 0%;
    min-width: 200px;
  }
}

/* Tablet: cancel pin earlier than mobile */
@media screen and (max-width: 1100px) {
  .layout-flex01:first-of-type > .layout-image01,
  .layout-flex01:first-of-type > .layout-image,
  .layout-flex01:first-of-type > .image,
  .layout-flex01:first-of-type > .col-image {
    position: static;
    width: auto;
    max-width: 100%;
    margin-left: auto;
    order: 99;
  }
  .layout-flex01:first-of-type {
    padding-right: 0;
    position: static;
  }
}

/* =======================================================
   MOBILE: single authoritative block
   - Ensure content wrappers take 96%
   - Header/footer explicitly excluded and forced 100%
   - High-specificity + !important used inside this block only
   - Remove any other mobile blocks elsewhere in the stylesheet
======================================================= */
@media screen and (max-width: 768px) {
  :root { --mobile-wrap-width: 96%; --mobile-pad: 0.5rem; }

  /* === TARGET: explicit content wrapper classes ONLY ===
     Keep list tight; add project-specific wrappers here if necessary.
  */
  body .layout-root,
  body .user_data_layout,
  body .content,
  body .page,
  body .main,
  body .container,
  body #contents,
  body .wrapper,
  body .l-wrapper,
  body .ec-page,
  body .site-main {
    width: var(--mobile-wrap-width) !important;
    max-width: var(--mobile-wrap-width) !important;
    margin-left: auto !important;
    margin-right: auto !important;
    box-sizing: border-box !important;
    padding-left: var(--mobile-pad) !important;
    padding-right: var(--mobile-pad) !important;
  }

  /* Ensure .layout-flex01 occupies the wrapper and stacks children */
  body .layout-flex01 {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 12px;
    margin-bottom: 20px;
    box-sizing: border-box !important;
  }
  body .layout-flex01 > .layout-text01,
  body .layout-flex01 > .text,
  body .layout-flex01 > .layout-image01,
  body .layout-flex01 > .layout-image,
  body .layout-flex01 > .image,
  body .layout-flex01 > .col-image {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    order: 0 !important;
    flex: 0 0 auto !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-sizing: border-box !important;
  }

  /* Images constrained to wrapper */
  body img,
  body .layout-image01 img,
  body .layout-image img,
  body .image img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  /* Reset pinned/absolute for first row to ensure stacking */
  body .layout-flex01:first-of-type,
  body .layout-flex01:first-of-type > .layout-image01,
  body .layout-flex01:first-of-type > .layout-image,
  body .layout-flex01:first-of-type > .image,
  body .layout-flex01:first-of-type > .col-image {
    position: static !important;
    right: auto !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    order: 0 !important;
  }

  /* Gallery adjustments */
  body .gallery-row { flex-wrap: wrap !important; gap: 12px !important; }
  body .gallery-row .gallery-thumb { flex: 0 0 100% !important; max-width: 100% !important; width: 100% !important; }

  /* === EXPLICIT: keep header/footer untouched at 100% ===
     Use narrow, high-specificity selectors so they retain 100%
  */
  body > header,
  header,
  body .site-header,
  body .ec-header,
  body .global-header,
  body > footer,
  footer,
  body .site-footer,
  body .ec-footer,
  body .global-footer {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-sizing: border-box !important;
  }

  /* Minimal safe named fallbacks only (add actual wrapper class names if needed) */
  body .page-wrapper,
  body .user-layout-wrapper {
    width: var(--mobile-wrap-width) !important;
    max-width: var(--mobile-wrap-width) !important;
    margin-left: auto !important;
    margin-right: auto !important;
    box-sizing: border-box !important;
  }
}

/* Override for banner_col to enable grid layout */
.banner_col {
  display: contents !important;
}