/* ── Page hero (case-study / builder project pages)
   Solid background (--hero-bg). Desktop vs mobile images swap at 1024px. */

/* Subtitle removed site-wide — hide if cached HTML still includes it */
#heroDesc,
.page-hero-desc {
  display: none !important;
  height: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  visibility: hidden !important;
}

.page-hero-stack {
  display: none;
  flex-direction: column;
  align-items: stretch;
  flex-wrap: nowrap;
  width: calc(100vw - 48px);
  max-width: calc(100% - 48px);
  margin-left: calc(50% - 50vw + 24px);
  margin-top: 24px;
  margin-bottom: 0;
  position: sticky;
  top: 24px;
  z-index: 0;
  overflow: hidden;
  isolation: isolate;
}

body.project-page {
  overflow-x: hidden;
  max-width: 100%;
}

.page-hero {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-top: 0;
  margin-bottom: 0;
  height: calc(100vh - 48px);
  position: relative;
  top: auto;
  z-index: 0;
  overflow: hidden;
  background: var(--hero-bg, #334155);
  border-radius: 32px;
  border: none;
  outline: none;
  box-shadow: none;
  display: none;
  isolation: isolate;
  flex-shrink: 0;
}

/* When an image is set, don’t paint hero-bg behind it (avoids teal/green corner bleed) */
.page-hero.has-hero-visual {
  background: transparent;
}

.page-hero-bg-controls {
  display: none;
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 6;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.12);
  font-size: 0.72rem;
  font-weight: 600;
  color: #374151;
}

.page-hero.hero-editable .page-hero-bg-controls { display: flex; }
.page-hero-bg-controls-title { margin-right: 2px; }

.page-hero-color-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  color: #6b7280;
}

.page-hero-color-input {
  width: 36px;
  height: 30px;
  padding: 0;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  background: var(--color-white);
}

.page-hero-img {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: none;
  border: none;
  outline: none;
  border-radius: inherit;
}

.page-hero-img--desktop {
  display: none;
}

.page-hero-img--mobile {
  display: none;
}

@media (min-width: 1024px) {
  .page-hero.has-hero-visual .page-hero-img--desktop {
    display: block;
  }
}

@media (max-width: 1023px) {
  .page-hero.has-hero-visual .page-hero-img--mobile {
    display: block;
  }
}

.page-content-slide {
  position: relative;
  z-index: 1;
  background: var(--color-white);
  border-radius: 32px 32px 0 0;
  margin-top: 24px;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.12);
}

body:not(.project-page) .page-content-slide {
  position: static;
  background: transparent;
  border-radius: 0;
  margin-top: 0;
  box-shadow: none;
}

/* Hero title block — in normal flow by default; overlay only on desktop */
.page-hero-stack > .page-hero-text {
  position: static;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  pointer-events: none;
}

/* Edit mode: title block overlays hero on desktop — don’t block image change buttons */
.page-hero-stack:has(.page-hero.hero-editable) > .page-hero-text {
  pointer-events: none;
}

.page-hero-stack:has(.page-hero.hero-editable) > .page-hero-text .page-hero-title {
  pointer-events: auto;
}

@media (min-width: 1024px) {
  .page-hero-stack > .page-hero-text {
    position: absolute;
    bottom: 48px;
    left: 48px;
    right: 48px;
    max-width: calc(100% - 96px);
  }
}

/* Home: hero text sits inside #pageHero (no stack) */
.page-hero > .page-hero-text {
  position: absolute;
  bottom: 48px;
  left: 48px;
  right: 48px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100% - 96px);
  pointer-events: none;
}

.page-hero.hero-editable > .page-hero-text { pointer-events: auto; }

.page-hero-title {
  font-size: 3.2rem;
  font-weight: 700;
  color: var(--color-white);
  line-height: 1.1;
  letter-spacing: -0.03em;
  outline: none;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.2);
  overflow-wrap: break-word;
  max-width: 100%;
}

/* Project pages: wrap title at 70% width instead of full bleed */
body.project-page .page-hero-title {
  max-width: 70%;
}

.page-hero-img-input { display: none; }

.page-hero-change-stack {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 4;
  display: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.page-hero.hero-editable .page-hero-img {
  pointer-events: none;
}

.page-hero.hero-editable .page-hero-change-stack,
.page-hero-stack:has(.page-hero.hero-editable) > .page-hero-change-stack {
  display: flex;
  z-index: 30;
}

.page-hero.hero-editable .page-hero-change-btn,
.page-hero-stack:has(.page-hero.hero-editable) > .page-hero-change-stack .page-hero-change-btn {
  pointer-events: auto;
}

/* Desktop: controls sit on stack (above title overlay), not inside low z-index hero */
.page-hero-stack > .page-hero-change-stack {
  position: absolute;
  bottom: 20px;
  right: 20px;
}

.page-hero-change-btn {
  background: rgba(0, 0, 0, 0.65);
  color: var(--color-white);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 99px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.15s;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

@media (max-width: 1023px) {
  .page-hero-change-btn--desktop {
    display: none !important;
  }
}

@media (min-width: 1024px) {
  .page-hero-change-btn--mobile {
    display: none !important;
  }
}

.page-hero-change-btn:hover { background: rgba(0, 0, 0, 0.85); }

.page-hero-save-status {
  margin: 6px 0 0;
  padding: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: #6b7280;
  text-align: right;
  min-height: 1em;
}

.page-hero-save-status.is-ok {
  color: #15803d;
}

.page-hero-save-status.is-error {
  color: #b91c1c;
}

.page-hero-stack > .page-hero-save-status {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 31;
  margin: 0;
  max-width: min(280px, 55vw);
}

@media (max-width: 1023px) {
  .page-hero-stack {
    display: none; /* shown as flex via JS */
    flex-direction: column !important;
    align-items: stretch !important;
    flex-wrap: nowrap !important;
    position: relative;
    top: auto;
    width: calc(100% - 32px) !important;
    max-width: 100% !important;
    margin-left: 16px !important;
    margin-right: 16px !important;
    margin-top: 8px;
    overflow: hidden;
  }

  body.project-page #sidebar.topnav-back-row {
    position: static;
    top: auto;
    left: auto;
    z-index: auto;
    width: auto;
    max-width: 100%;
    margin: 0 0 16px;
    padding: 0;
    box-sizing: border-box;
    flex: 0 0 auto;
    align-self: flex-start;
    pointer-events: none;
  }

  body.project-page #sidebar.topnav-back-row .topnav-back {
    display: inline-flex;
    width: auto;
    max-width: 100%;
    height: auto;
    min-height: 0;
    padding: 0;
    gap: 6px;
    pointer-events: auto;
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-radius: 0;
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-black);
    justify-content: flex-start;
  }

  body.project-page #sidebar.topnav-back-row .topnav-back:hover,
  body.project-page #sidebar.topnav-back-row .topnav-back:focus-visible {
    background: transparent;
    color: var(--color-black);
    border: none;
    box-shadow: none;
    outline: none;
  }

  body.project-page #sidebar.topnav-back-row .topnav-back:hover img,
  body.project-page #sidebar.topnav-back-row .topnav-back:focus-visible img {
    transform: none;
    filter: none;
  }

  .page-hero {
    height: auto;
    aspect-ratio: 4 / 5;
    max-height: min(85vh, 560px);
    min-height: 260px;
    overflow: hidden;
    flex: 0 0 auto;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0;
    margin-top: 0;
    position: relative;
    border-radius: 24px;
    border: none;
    outline: none;
    box-shadow: none;
    background: transparent;
  }

  .page-hero.has-hero-visual .page-hero-img--mobile {
    border-radius: 0;
    border: none;
    outline: none;
    min-height: 0;
  }

  body.project-page .page-hero-text,
  .page-hero-stack > .page-hero-text,
  #canvasItems > .page-hero-text {
    position: static !important;
    inset: auto !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    max-width: 100% !important;
    width: 100% !important;
    flex: 0 0 auto;
    box-sizing: border-box;
    padding: 32px 0 32px;
    pointer-events: none;
  }

  .page-hero-stack:has(.page-hero.hero-editable) > .page-hero-text,
  .builder-page.is-editing #canvasItems > .page-hero-text {
    pointer-events: none;
  }

  .page-hero-stack:has(.page-hero.hero-editable) > .page-hero-text .page-hero-title {
    pointer-events: auto;
  }

  .page-hero-title {
    font-size: 2rem;
    color: var(--color-black);
    text-shadow: none;
  }

  body.project-page .page-hero-title {
    max-width: 100%;
  }

  .page-content-slide {
    position: static;
    z-index: auto;
    margin-top: 0;
    border-radius: 0;
    box-shadow: none;
    overflow-x: clip;
    max-width: 100%;
  }

  #canvasItems > .page-hero-text {
    flex: 1 0 100%;
    max-width: 100%;
  }

  .page-hero > .page-hero-text {
    position: static !important;
    padding: 32px 0 32px;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .page-hero {
    height: 400px;
    aspect-ratio: unset;
    max-height: 400px;
    min-height: 400px;
  }

  .page-hero.has-hero-visual .page-hero-img--mobile {
    display: none;
  }

  .page-hero.has-hero-visual .page-hero-img--desktop {
    display: block;
  }

  .page-hero-change-btn--desktop {
    display: inline-flex !important;
  }

  .page-hero-change-btn--mobile {
    display: none !important;
  }

  body.project-page .page-hero-text,
  .page-hero-stack > .page-hero-text,
  #canvasItems > .page-hero-text {
    position: static !important;
    inset: auto !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    max-width: 100% !important;
    width: 100% !important;
    flex: 0 0 auto;
    box-sizing: border-box;
    padding: 32px 0 12px;
    pointer-events: none;
    padding-left: 30px;
    padding-right: 30px;
  }
}

/* Project pages on small screens: stop full-bleed 100vw breakout in canvas */
@media (max-width: 767px) {
  body.project-page .canvas-h3-full-bleed,
  body.project-page .canvas-projects-full-bleed:has(.canvas-projects-grid.cols-2) {
    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;
  }

  body.project-page .canvas-projects-full-bleed:not(:has(.canvas-projects-grid.cols-2)),
  body.project-page .canvas-testimonials-bleed,
  body.project-page .canvas-full-image-wrap {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  body.project-page .builder-page,
  body.project-page .builder-canvas {
    overflow-x: clip;
    max-width: 100%;
  }
}
