/*
  Mobile responsive safety layer.
  Mantem a logica original e corrige largura, empilhamento e areas visuais
  para telas de 1024px, 768px, 480px e 360px.
*/

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  min-width: 0;
}

img,
video,
canvas,
svg,
iframe,
model-viewer {
  max-width: 100%;
}

button,
input,
select,
textarea {
  max-width: 100%;
  font: inherit;
}

main,
section,
.container,
.header-inner,
.hero-slider,
.hero-slide,
.about-grid,
.story-grid,
.works-carousel,
.works-grid,
.services-grid,
.contact-grid,
.sk-layout,
.sk-chart-section,
.sk-chart-card,
.cenario-3d-wrap,
.cenario-3d-viewer {
  min-width: 0;
}

.container {
  width: min(1180px, calc(100% - 32px));
}

/* Evita que divisores em 100vw criem rolagem lateral em navegadores mobile. */
.section-divider {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
}

.btn,
.service-btn,
.works-expand-btn,
.nav a,
.nav-dropdown-toggle {
  min-height: 44px;
  overflow-wrap: anywhere;
  text-align: center;
}

.hero-copy,
.section-label,
h1,
h2,
h3,
p,
li,
a,
span {
  overflow-wrap: anywhere;
}

/* Protecoes genericas para telas que tenham formularios, tabelas, mapas ou modais. */
form,
fieldset,
.form-grid,
.form-row,
.field-row,
.fields-row {
  min-width: 0;
  max-width: 100%;
}

fieldset {
  margin-inline: 0;
}

label,
.error,
.form-error,
.field-error,
.help-text {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

input,
select,
textarea {
  width: 100%;
}

textarea {
  resize: vertical;
}

.table-responsive,
.table-wrapper,
.data-table-wrapper,
.responsive-table {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  max-width: 100%;
  border-collapse: collapse;
}

.modal,
.popup,
.dialog,
[role="dialog"],
dialog {
  width: min(100%, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
}

.modal-content,
.popup-content,
.dialog-content {
  max-width: 100%;
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
}

.map,
.map-area,
.map-container,
[id*="map"],
[class*="mapa"],
.leaflet-container,
.cenario-3d-viewer {
  width: 100%;
  max-width: 100%;
}

@media (hover: none), (pointer: coarse) {
  body.site-custom-cursor,
  body.site-custom-cursor * {
    cursor: auto !important;
  }

  .site-cursor {
    display: none !important;
  }
}

@media (max-width: 1024px) {
  .section {
    padding-block: 72px;
  }

  .site-header {
    z-index: 100;
  }

  .site-header .container {
    width: 100%;
    padding-inline: 16px;
  }

  .header-inner {
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 88px;
    gap: 12px;
  }

  .logo {
    max-width: 100%;
    gap: 8px;
  }

  .logo-icon {
    width: 58px;
    height: 64px;
  }

  .logo-wordmark {
    width: clamp(138px, 32vw, 220px);
  }

  .cta-btn {
    display: none;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    justify-self: end;
  }

  .menu-toggle span {
    flex: 0 0 auto;
  }

  .nav {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 8px);
    z-index: 40;
    width: 100%;
    max-height: calc(100dvh - 112px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg);
    box-shadow: 0 12px 24px rgba(20, 22, 25, 0.16);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
  }

  .site-header.menu-open .nav {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .nav a,
  .nav-dropdown-toggle {
    display: inline-flex;
    width: 100%;
    justify-content: center;
    white-space: normal;
  }

  .nav-dropdown {
    width: 100%;
  }

  .nav-submenu {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
    margin-top: 8px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }

  .hero-slide.is-active {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(390px, 52svh) auto;
    min-height: 0;
  }

  .hero-slide::after {
    display: none;
  }

  .main-panel,
  .side-panel {
    min-width: 0;
  }

  .side-panel {
    width: min(100%, 720px);
    height: auto;
    min-height: 0;
    aspect-ratio: 1 / 1;
    justify-self: center;
    border-left: 0;
    border-top: 0;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center top !important;
    box-shadow:
      inset 0 8px 0 var(--accent),
      0 -1px 0 rgba(255, 255, 255, 0.22);
  }

  .side-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 18px;
    background: linear-gradient(
      to bottom,
      rgba(123, 30, 43, 0.98) 0,
      rgba(123, 30, 43, 0.78) 48%,
      rgba(123, 30, 43, 0) 100%
    );
    pointer-events: none;
    z-index: 1;
  }

  /* Usa copias quadradas 1080x1080 para o painel lateral no formato post Instagram. */
  .hero-slide:nth-child(1) .side-panel {
    background-image: url("_portifolio-insta.png?v=1") !important;
    background-position: center center !important;
  }

  .hero-slide:nth-child(2) .side-panel {
    background-image: url("11-insta.png?v=1") !important;
    background-position: center center !important;
  }

  .hero-slide:nth-child(3) .side-panel {
    background-image: url("12-insta.png?v=1") !important;
    background-position: center top !important;
  }

  .hero-copy {
    left: clamp(18px, 5vw, 40px);
    right: clamp(18px, 5vw, 40px);
    top: 24px;
    bottom: 54px;
    max-width: none;
  }

  .hero-actions {
    align-items: stretch;
  }

  .hero-actions .btn {
    flex: 1 1 180px;
  }

  /* No modo compacto, as setas navegam o sidebar quadrado sem cobrir o texto. */
  .hero-arrow {
    display: grid;
    top: calc(max(390px, 52svh) + min(100vw, 720px) / 2);
    z-index: 8;
    width: 40px;
    height: 40px;
    transform: translateY(-50%);
  }

  .hero-arrow:hover {
    transform: translateY(-50%) scale(1.03);
  }

  .hero-arrow,
  .hero-arrow:hover {
    background: var(--accent);
    border-color: var(--accent);
  }

  .hero-arrow::before,
  .hero-arrow:hover::before {
    border-top-color: #fff;
    border-right-color: #fff;
  }

  .hero-arrow.prev {
    left: max(10px, calc((100vw - 720px) / 2 + 12px));
  }

  .hero-arrow.next {
    right: max(10px, calc((100vw - 720px) / 2 + 12px));
  }

  .about-grid,
  .story-grid,
  .services-grid,
  .contact-grid,
  .sk-layout {
    grid-template-columns: 1fr;
  }

  .sk-layout {
    margin-top: 56px;
  }

  .sk-panel {
    position: static;
    order: -1;
  }

  .works-grid {
    grid-template-columns: repeat(2, minmax(0, 320px));
    width: 100%;
  }

  .cenario-3d-viewer {
    height: clamp(340px, 55svh, 560px);
    border-radius: 18px;
  }

  .floating-ad {
    display: none;
  }
}

@media (max-width: 768px) {
  .container {
    width: min(calc(100% - 28px), 680px);
  }

  .section {
    padding-block: 56px;
  }

  h1 {
    font-size: clamp(1.8rem, 9vw, 2.8rem);
  }

  h2 {
    font-size: clamp(1.55rem, 7.5vw, 2.35rem);
  }

  .header-inner {
    min-height: 82px;
  }

  .nav {
    max-height: calc(100dvh - 104px);
  }

  .logo-icon {
    width: 52px;
    height: 58px;
  }

  .logo-wordmark {
    width: clamp(128px, 38vw, 190px);
  }

  .hero-slide.is-active {
    grid-template-rows: minmax(360px, 50svh) auto;
  }

  .hero-arrow {
    top: calc(max(360px, 50svh) + min(100vw, 720px) / 2);
  }

  .hero-copy {
    bottom: 50px;
  }

  .hero-actions .btn,
  .service-btn,
  .works-expand-btn {
    width: 100%;
  }

  .about-icons,
  .story-steps,
  .services-grid {
    gap: 10px;
  }

  .about-icons article,
  .story-steps article,
  .service-card {
    padding: 18px;
    border-radius: 12px;
  }

  .service-top {
    align-items: flex-start;
  }

  .works-carousel {
    position: relative;
    gap: 8px;
  }

  .works-grid {
    grid-template-columns: 1fr;
    width: min(100%, 330px);
  }

  .work-card {
    border-width: 3px;
  }

  .work-center-badge {
    width: clamp(102px, 32vw, 124px);
    height: clamp(102px, 32vw, 124px);
  }

  .sk-section {
    padding-block: 72px 88px;
  }

  .sk-chart-card {
    margin-top: 0;
    padding-inline: 8px;
  }

  .sk-chart {
    height: 360px;
  }

  .sk-bars {
    gap: 5px;
  }

  .sk-bar {
    padding-inline: 5px;
  }

  .sk-bar-icon {
    width: 32px;
    height: 32px;
    font-size: 0.86rem;
  }

  .sk-bar-name {
    font-size: 0.62rem;
    letter-spacing: 0;
  }

  .sk-sprite-wrap,
  .sk-sprite {
    width: 210px;
    height: 210px;
  }

  .sk-sprite {
    max-width: none;
    transform: translateY(34px) scale(1.08) !important;
  }

  .sk-panel-list li {
    padding-inline: 14px;
  }

  .cenario-3d-viewer {
    height: clamp(320px, 52svh, 460px);
    margin-inline: 0;
  }

  .footer-inner {
    justify-content: center;
    text-align: center;
  }

  .footer-copy {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0 6px;
    max-width: 100%;
    line-height: 1.5;
  }

  form .form-grid,
  form .form-row,
  form .field-row,
  form .fields-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 480px) {
  .container {
    width: calc(100% - 24px);
  }

  .section {
    padding-block: 46px;
  }

  .site-header .container {
    padding-inline: 12px;
  }

  .header-inner {
    min-height: 74px;
  }

  .logo {
    gap: 6px;
  }

  .logo-icon {
    width: 46px;
    height: 50px;
  }

  .logo-wordmark {
    width: clamp(112px, 42vw, 156px);
    transform: translateY(-5px);
  }

  .logo-wordmark::after {
    opacity: 0.28;
  }

  .menu-toggle {
    width: 42px;
    height: 42px;
  }

  .nav {
    max-height: calc(100dvh - 92px);
    padding: 10px;
    gap: 8px;
  }

  .nav-submenu {
    grid-template-columns: 1fr;
  }

  .hero-slide.is-active {
    grid-template-rows: minmax(360px, 50svh) auto;
  }

  .side-panel {
    width: 100%;
    max-width: none;
    box-shadow:
      inset 0 6px 0 var(--accent),
      0 -1px 0 rgba(255, 255, 255, 0.22);
  }

  .side-panel::before {
    height: 14px;
  }

  .hero-arrow {
    top: calc(max(360px, 50svh) + 50vw);
  }

  .hero-copy {
    left: 16px;
    right: 16px;
    top: 16px;
    bottom: 36px;
    justify-content: center;
  }

  .hero-copy h1 {
    font-size: clamp(1.42rem, 8.2vw, 1.9rem);
    line-height: 1.08;
    margin-bottom: 10px;
  }

  .hero-copy p {
    font-size: 0.9rem;
    line-height: 1.45;
    margin-bottom: 8px;
  }

  .kicker {
    font-size: 0.78rem;
    letter-spacing: 0.08em;
  }

  .hero-actions {
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
  }

  .hero-actions .btn {
    flex-basis: auto;
    min-height: 42px;
    padding-block: 9px;
    padding-inline: 12px;
    font-size: 0.86rem;
  }

  .hero-arrow {
    width: 38px;
    height: 38px;
  }

  .hero-arrow.prev {
    left: 8px;
  }

  .hero-arrow.next {
    right: 8px;
  }

  .hero-dots {
    bottom: 18px;
  }

  .section-divider {
    height: 72px;
  }

  .about-icons article,
  .story-steps article,
  .service-card {
    padding: 16px;
  }

  .about-icons span {
    width: 60px;
    height: 60px;
    margin-bottom: 12px;
  }

  .story-steps ul {
    padding-left: 16px;
  }

  .works-carousel {
    display: block;
    padding-inline: 34px;
  }

  .works-grid {
    width: 100%;
    max-width: 100%;
  }

  .works-arrow {
    position: absolute;
    top: 50%;
    width: 30px;
    height: 30px;
    transform: translateY(-50%);
  }

  .works-arrow-prev {
    left: 0;
  }

  .works-arrow-next {
    right: 0;
  }

  .work-card {
    border-width: 2px;
    border-radius: 12px;
  }

  .work-center-badge {
    width: 98px;
    height: 98px;
    padding: 8px;
  }

  .work-center-badge span {
    font-size: 0.74rem;
  }

  .sk-layout {
    margin-top: 34px;
  }

  .sk-panel {
    order: 0;
    margin-top: 14px;
  }

  .sk-chart-card {
    overflow: visible;
    padding: 0 4px;
  }

  .sk-chart {
    display: flex;
    align-items: flex-end;
    height: clamp(300px, 52svh, 360px);
    min-height: 300px;
  }

  .sk-bars {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 100%;
  }

  .sk-bar {
    min-height: 106px;
    padding: 0 4px 8px;
    border-radius: 10px 10px 0 0;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0;
  }

  .sk-bar-icon {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 28px;
    font-size: 0.78rem;
  }

  .sk-bar-name {
    text-align: center;
    font-size: 0.54rem;
    line-height: 1.14;
    letter-spacing: 0;
    overflow-wrap: anywhere;
  }

  .sk-sprite-wrap,
  .sk-sprite {
    display: block !important;
    width: 170px;
    height: 170px;
  }

  .sk-sprite {
    max-width: none;
  }

  .sk-baseline {
    display: block;
  }

  .sk-panel {
    border-radius: 14px;
  }

  .sk-panel-list li {
    padding: 10px 12px;
  }

  .cenario-3d-viewer {
    height: 320px;
    border-radius: 14px;
    box-shadow: 0 10px 24px rgba(31, 63, 95, 0.18);
  }

  .cenario-3d-status {
    left: 10px;
    right: 10px;
    bottom: 10px;
    font-size: 0.72rem;
  }

  .contact-list li {
    overflow-wrap: anywhere;
  }

  .footer-inner,
  .footer-links {
    flex-direction: column;
    align-items: center;
  }

  .site-footer {
    padding: 28px 0 30px;
  }

  .footer-inner {
    gap: 18px;
  }

  .footer-links {
    width: 100%;
    gap: 8px;
  }

  .footer-links a {
    display: flex;
    justify-content: center;
    width: min(100%, 220px);
    padding: 8px 12px;
    border: 1px solid rgba(236, 236, 236, 0.45);
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.2;
  }

  .footer-copy {
    width: min(100%, 320px);
    padding-top: 16px;
    border-top: 1px solid rgba(236, 236, 236, 0.28);
    flex-direction: column;
    gap: 4px;
    font-size: 0.86rem;
    line-height: 1.45;
  }

  .footer-separator {
    display: none;
  }
}

@media (max-width: 360px) {
  .container {
    width: calc(100% - 20px);
  }

  .section {
    padding-block: 40px;
  }

  .site-header .container {
    padding-inline: 10px;
  }

  .header-inner {
    min-height: 68px;
    gap: 8px;
  }

  .logo-icon {
    width: 40px;
    height: 44px;
  }

  .logo-wordmark {
    width: 104px;
  }

  .menu-toggle {
    width: 40px;
    height: 40px;
  }

  .nav {
    max-height: calc(100dvh - 84px);
  }

  .nav a,
  .nav-dropdown-toggle {
    padding-inline: 10px;
    font-size: 0.88rem;
  }

  .hero-slide.is-active {
    grid-template-rows: minmax(340px, 50svh) auto;
  }

  .side-panel {
    width: 100%;
    max-width: none;
  }

  .hero-arrow {
    top: calc(max(340px, 50svh) + 50vw);
    width: 36px;
    height: 36px;
  }

  .hero-copy {
    left: 14px;
    right: 14px;
    top: 14px;
    bottom: 30px;
  }

  .hero-copy h1 {
    font-size: 1.34rem;
  }

  .hero-copy p {
    font-size: 0.82rem;
  }

  .btn {
    padding-inline: 10px;
  }

  .works-carousel {
    padding-inline: 30px;
  }

  .works-arrow {
    width: 28px;
    height: 28px;
  }

  .work-center-badge {
    width: 86px;
    height: 86px;
  }

  .work-center-badge span {
    font-size: 0.66rem;
  }

  .service-top {
    flex-direction: column;
  }

  .sk-chart {
    height: 280px;
    min-height: 280px;
  }

  .sk-bars {
    gap: 6px;
  }

  .sk-bar {
    min-height: 94px;
    padding: 0 3px 7px;
  }

  .sk-bar-icon {
    width: 24px;
    height: 24px;
    font-size: 0.72rem;
    top: 7px;
  }

  .sk-bar-name {
    font-size: 0.49rem;
  }

  .sk-sprite-wrap,
  .sk-sprite {
    width: 142px;
    height: 142px;
  }

  .cenario-3d-viewer {
    height: 280px;
  }

  .modal,
  .popup,
  .dialog,
  [role="dialog"],
  dialog {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
  }
}
