/* ==========================================================================
   IMPORTANT
   This sub-theme inherits base structure from Tarapro.
   We selectively override layout to enforce our “mode” boundaries.
   ========================================================================== */

/* ==========================================================================
   TOKENS
   ========================================================================== */

:root {
  --site-max-width: clamp(1200px, 90vw, 1800px);
  --site-gutter: clamp(16px, 2vw, 32px);

  /* Editorial measure: long-form line length lock */
  --editorial-measure: 70ch; /* tune later (68–72ch) */

  /* SaaS dashboard max (wide data canvas inside full-bleed shell) */
  --saas-dashboard-max: 2200px;
}

/* ==========================================================================
   HEADER — LOGO SIZING (CSS only; do not touch image pixels)
   ========================================================================== */

:root {
  /* Header logo “visual size” (tune these numbers) */
  --header-logo-max-h: clamp(28px, 3.0vw, 44px);

  /* Optional: breathing room + spacing */
  --header-pad-y: clamp(10px, 1.1vw, 18px);
  --header-brand-gap: 12px;
}

/* Ensure header layout has predictable vertical rhythm */
.header .container {
  padding-block: var(--header-pad-y);
}

/* Align branding + right side */
.header .header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* Make the link behave (removes baseline weirdness) */
.header .site-branding__link {
  display: inline-flex;
  align-items: center;
  line-height: 0;
}

/* Size the logo via height; preserve aspect ratio */
.header img.site-branding__logo {
  height: var(--header-logo-max-h);
  width: auto;
  max-width: 100%;
  display: block;
  object-fit: contain;
}

/* Mobile: allow wrapping + slightly smaller logo */
@media (max-width: 767px) {
  .header .header-container {
    flex-wrap: wrap;
  }

  :root {
    --header-logo-max-h: clamp(26px, 6vw, 36px);
  }
}

/* Prevent the logo/brand column from shrinking to “invisible” at awkward widths */
.header .site-branding {
  flex: 0 0 auto;
  flex-shrink: 0;
}

.header .site-branding__link {
  flex-shrink: 0;
}

/* ==========================================================================
   SAFETY: prevent horizontal scroll from 100vw breakout utilities
   ========================================================================== */

html,
body {
  overflow-x: clip; /* use hidden if you need broader support */
}

/* ==========================================================================
   GLOBAL CONTAINER BEHAVIOR
   - Keep Tarapro containers full-width, only apply gutters here.
   ========================================================================== */

.container {
  box-sizing: border-box;
  width: 100%;
  padding-inline: var(--site-gutter);
}

/* Optional helper if you wrap specific regions in a centered canvas */
.site-canvas {
  max-width: var(--site-max-width);
  margin-inline: auto;
}

/* ==========================================================================
   FULL-WIDTH SHELL OVERRIDES (win vs Tarapro container caps)
   - Header/breadcrumb/footer should span the browser width.
   - Main content stays centered.
   ========================================================================== */

.header-top .container,
.header .container,
#breadcrumb .container,
#footer .container,
#highlighted .container {
  max-width: none !important;
  margin-inline: 0 !important;
}

/* Keep MAIN content canvas centered */
#main-wrapper > .container {
  max-width: var(--site-max-width) !important;
  margin-inline: auto !important;
}

/* ==========================================================================
   EDITORIAL CANVAS + SIDEBAR LAYOUT (non-SaaS)
   ========================================================================== */

.main-wrapper-inner:not(.has-saas-portal) {
  max-width: var(--site-max-width);
  margin-inline: auto;

  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}

/* Ensure the main content takes the lead */
.main-wrapper-inner:not(.has-saas-portal) #content {
  order: 1;
  flex: 1 1 66%;
  padding-right: 20px;
}

/* Sidebars scoped to editorial canvas only */
.main-wrapper-inner:not(.has-saas-portal) .sidebar-first,
.main-wrapper-inner:not(.has-saas-portal) .sidebar-second {
  order: 2;
  flex: 1 1 30%;
  margin-bottom: 20px;
}

/* Tablet: keep sidebars right but adjust proportions */
@media (max-width: 991px) and (min-width: 768px) {
  .main-wrapper-inner:not(.has-saas-portal) #content {
    flex: 1 1 60%;
  }

  .main-wrapper-inner:not(.has-saas-portal) .sidebar-first,
  .main-wrapper-inner:not(.has-saas-portal) .sidebar-second {
    flex: 1 1 40%;
  }
}

/* Mobile: disable flex so everything stacks naturally */
@media (max-width: 767px) {
  .main-wrapper-inner:not(.has-saas-portal) {
    display: block;
  }

  .main-wrapper-inner:not(.has-saas-portal) #content {
    padding-right: 0;
  }
}

/* ==========================================================================
   EDITORIAL MEASURE LOCK (text only, not layout components)
   - Targets typical node body children (not your styleguide <section> wrappers).
   ========================================================================== */

.main-wrapper-inner:not(.has-saas-portal)
  .node-content
  .field--name-body > :is(p, ul, ol, blockquote, pre, h1, h2, h3, h4, h5, h6) {
  max-width: var(--editorial-measure);
  margin-inline: auto;
}

/* Explicit test harness for styleguide */
.editorial-prose > :is(p, ul, ol, blockquote, pre, h1, h2, h3, h4, h5, h6) {
  max-width: var(--editorial-measure);
  margin-inline: auto;
}

/* ==========================================================================
   FULL-BLEED BREAKOUT UTILITY
   - Apply to a wrapper INSIDE the centered main canvas to escape it.
   - Use for SaaS shells, full-width bands, etc.
   ========================================================================== */

.full-bleed {
  width: 100vw;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
}

/* ==========================================================================
   SAAS PORTAL REGION LOGIC
   - Base wrapper can be used in both centered and full-bleed modes.
   ========================================================================== */

.saas-portal-outer-wrapper {
  width: 100%;
  background-color: #f8f9fa;
}

/* When full-bleed, we add site gutters + some vertical air */
.saas-portal-outer-wrapper.full-bleed {
  padding-inline: var(--site-gutter);
  padding-block: 24px;
}

/* Wide dashboard canvas inside SaaS shell */
.saas-portal-outer-wrapper .saas-dashboard-canvas {
  max-width: var(--saas-dashboard-max);
  margin-inline: auto;
}

/* Measure-locked prose inside SaaS pages */
.saas-portal-outer-wrapper .saas-prose {
  max-width: var(--editorial-measure);
  margin-inline: auto;
}

/* Optional: “centered SaaS card” mode (non-full-bleed) */
.saas-portal-outer-wrapper:not(.full-bleed) {
  padding: 20px;
}

/* 5K / VERY WIDE SCREENS */
@media (min-width: 2000px) {
  /* Let editorial column breathe (measure stays locked by rules above) */
  .main-wrapper-inner:not(.has-saas-portal) #content {
    max-width: none;
    margin-right: 0;
  }

  /* If you want dashboard canvas to grow a bit on 5K, do it here */
  .saas-portal-outer-wrapper .saas-dashboard-canvas {
    max-width: 2400px; /* optional bump; or remove */
  }
}

/* Special background for ServiceWorx-specific blocks */
.saas-section {
  background-color: #002b36;
  color: #ffffff;
}

/* ==========================================================================
   Z-PATTERN (Hardened - grid areas)
   ========================================================================== */

.z-pattern > .z-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas: "text image";
  column-gap: clamp(24px, 4vw, 60px);
  row-gap: 24px;
  align-items: center;

  max-width: 1200px;
  margin-inline: auto;
  padding-block: clamp(24px, 4vw, 48px);
}

.z-pattern > .z-row .z-text  { grid-area: text;  min-width: 0; }
.z-pattern > .z-row .z-image { grid-area: image; min-width: 0; }

.z-pattern > .z-row:nth-of-type(even) {
  grid-template-areas: "image text";
}

@media (max-width: 767px) {
  .z-pattern > .z-row {
    grid-template-columns: 1fr;
    grid-template-areas:
      "text"
      "image";
    gap: 24px;
  }
}
