/*
 * Academia Newton 3.4.1
 * Camada consolidada de apresentação e responsividade.
 * O conteúdo permanece editável no Editor do Site e no Academia Newton Core.
 */

:root {
  --newton-header-breakpoint: 1120px;
  --newton-control-size: 42px;
}

body.newton-nav-open {
  overflow: hidden;
}

body.newton-nav-open .newton-contact-trigger,
body.newton-nav-open .newton-back-top {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

/* Ligações com fundo próprio conservam sempre o contraste, mesmo visitadas. */
.wp-element-button.has-white-color,
.wp-element-button.has-white-color:visited,
.has-newton-night-background-color.wp-element-button,
.has-newton-night-background-color.wp-element-button:visited {
  color: #fff !important;
}

/* Cabeçalho: identidade compacta e navegação numa linha. */
.newton-header__inner {
  flex-wrap: nowrap !important;
  gap: clamp(.75rem, 1.4vw, 1.5rem);
}

.newton-header .newton-logo,
.newton-footer .newton-logo {
  flex: 0 0 auto;
  margin: 0;
}

.newton-header .newton-logo img {
  display: block;
  height: auto;
  max-height: none;
  width: 54px;
}

.newton-primary-nav {
  flex: 1 1 auto;
  min-width: 0;
}

.newton-primary-nav .wp-block-navigation__container {
  flex-wrap: nowrap !important;
  gap: clamp(.1rem, .35vw, .45rem);
  justify-content: flex-end;
  white-space: nowrap;
}

.newton-header .wp-block-navigation-item__content {
  font-size: clamp(.8rem, .78vw, .92rem);
  padding-inline: clamp(.38rem, .55vw, .62rem);
}

.newton-header__action,
.newton-header__action .wp-element-button {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* O acesso ao Moodle dentro da navegação pertence apenas ao painel móvel. */
.newton-header .wp-block-navigation .newton-nav-student {
  display: none;
}

/* Títulos: largura editorial suficiente sem forçar linhas impossíveis. */
.newton-section-heading {
  max-width: 1180px;
}

.newton-method-track {
  align-items: start;
}

@media (min-width: 782px) {
  .newton-section-heading > .wp-block-heading {
    white-space: nowrap;
  }
}

/* Slideshow: altura estável e controlos coerentes. */
.newton-showcase {
  min-height: var(--newton-showcase-height, clamp(560px, 70svh, 720px));
}

.newton-showcase__slide {
  box-sizing: border-box;
  min-height: var(--newton-showcase-height, clamp(560px, 70svh, 720px));
}

.newton-showcase__controls {
  align-items: center;
  display: flex;
  flex-wrap: nowrap;
  gap: .5rem;
  left: max(clamp(1.25rem, 6vw, 6rem), calc((100% - 1440px) / 2 + 6rem));
  width: max-content;
}

.newton-showcase__controls > button,
.newton-showcase__dots button {
  appearance: none;
  -webkit-appearance: none;
  align-items: center;
  background: #fff;
  border: 1px solid var(--newton-line);
  border-radius: 999px;
  box-sizing: border-box;
  color: var(--newton-night);
  display: inline-flex;
  flex: 0 0 var(--newton-control-size);
  font: inherit;
  height: var(--newton-control-size);
  justify-content: center;
  line-height: 1;
  margin: 0;
  padding: 0;
  width: var(--newton-control-size);
}

.newton-showcase__controls > button:hover,
.newton-showcase__controls > button:focus-visible {
  background: var(--newton-mint);
  transform: translateY(-1px);
}

.newton-showcase__dots {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: .35rem;
}

.newton-showcase__dots button {
  background: #cfdbdf;
  border: 0;
  flex-basis: 22px;
  height: 7px;
  min-height: 7px;
  width: 22px;
}

.newton-showcase__dots button[aria-current="true"] {
  background: var(--newton-turquoise);
  flex-basis: 38px;
  width: 38px;
}

.newton-showcase__pause-icon {
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: -.08em;
}

/* Método Newton: todos os marcadores partem da mesma linha-base. */
.newton-method-track > * {
  margin-block-start: 0 !important;
}

.newton-method-step {
  border: 0;
  border-radius: var(--newton-radius-sm);
  min-width: 0;
  padding-block: 0 1rem;
  transition: background-color 180ms ease, transform 180ms var(--newton-ease);
}

.newton-method-step:hover,
.newton-method-step:focus-within {
  background: linear-gradient(180deg, rgba(31, 196, 194, .09), transparent);
  transform: translateY(-3px);
}

.newton-method-step::before {
  box-sizing: border-box;
}

/* Histórias: cartões editoriais, com ou sem imagem. */
.newton-story-stage {
  border-top: 1px solid rgba(255, 255, 255, .18);
  margin-top: var(--wp--preset--spacing--50);
  padding-top: 2.5rem;
}

.newton-stories {
  display: grid;
  gap: 1rem;
  grid-auto-flow: row;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: visible;
  padding: 1rem 0 0;
}

.newton-story-card {
  border: 1px solid rgba(31, 196, 194, .24);
  box-shadow: 0 14px 38px rgba(0, 0, 0, .1);
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 0;
  position: relative;
  transition: transform 180ms var(--newton-ease), box-shadow 180ms ease;
}

.newton-story-card:hover,
.newton-story-card:focus-within {
  box-shadow: 0 20px 46px rgba(0, 0, 0, .14);
  transform: translateY(-4px);
}

.newton-story-card::before {
  color: var(--newton-turquoise);
  content: "“";
  font-family: Georgia, serif;
  font-size: 4rem;
  left: 1.25rem;
  line-height: 1;
  position: absolute;
  top: 1rem;
}

.newton-story-card__media img {
  aspect-ratio: 16 / 9;
  border-radius: var(--newton-radius) var(--newton-radius) 0 0;
  display: block;
  object-fit: cover;
  width: 100%;
}

.newton-story-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 2.8rem 1.4rem 1.4rem;
}

.newton-story-card__media + .newton-story-card__body {
  padding-top: 2.6rem;
}

.newton-story-card blockquote {
  flex: 1;
  margin: 0 0 1.25rem;
}

.newton-story-card__identity {
  border-top: 1px solid var(--newton-line);
  margin: auto 0 0;
  padding-top: 1rem;
}

/* Chamada final: composição com imagem substituível no Editor do Site. */
.newton-contact-band__inner {
  align-items: stretch;
  background: var(--newton-paper);
  border: 1px solid rgba(15, 71, 97, .16);
  border-radius: var(--newton-radius-lg);
  box-shadow: var(--newton-shadow-soft);
  display: grid !important;
  gap: 0;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  overflow: hidden;
  padding: 0 !important;
}

/* Neutraliza a antiga caixa aplicada a cada filho. A moldura pertence agora
 * ao módulo completo, para texto e ações nunca parecerem blocos desligados. */
.newton-contact-band__inner > .wp-block-group {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  max-width: none;
}

/* Compatibilidade com páginas iniciais já guardadas pelo Editor do Site,
 * onde os botões eram irmãos da caixa de texto. */
.newton-contact-band__inner > .wp-block-buttons {
  align-self: center;
  justify-content: flex-end;
  margin: 0;
  padding: clamp(1.4rem, 3vw, 2.5rem);
  position: static;
}

.newton-contact-band__copy {
  padding: clamp(1.6rem, 4vw, 3.4rem);
}

.newton-contact-band__media {
  min-height: 360px;
  overflow: hidden;
  padding: 0 !important;
}

.newton-contact-band__media,
.newton-contact-band__media .wp-block-image {
  height: 100%;
  margin: 0;
}

.newton-contact-band__media img {
  display: block;
  height: 100%;
  object-fit: cover;
  transition: transform 650ms var(--newton-ease);
  width: 100%;
}

.newton-contact-band__inner:hover .newton-contact-band__media img {
  transform: scale(1.025);
}

/* Contacto persistente: contraste e estados de interação explícitos. */
.newton-contact-trigger {
  border: 2px solid #fff;
  box-shadow: 0 14px 34px rgba(8, 47, 73, .25);
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease, transform 180ms var(--newton-ease);
}

.newton-contact-trigger:hover,
.newton-contact-trigger:focus-visible {
  background: var(--newton-turquoise);
  border-color: var(--newton-night);
  color: var(--newton-night);
  transform: translateX(-4px);
}

/* Rodapé compacto e ícones sem formas sobrepostas. */
.newton-footer {
  padding-block: clamp(2.25rem, 4vw, 3.5rem) 1.25rem !important;
}

.newton-footer-grid {
  align-items: start;
  gap: clamp(1.4rem, 2.5vw, 2.5rem);
  grid-template-columns: minmax(170px, 1fr) repeat(2, minmax(140px, .72fr)) minmax(230px, 1.25fr);
}

.newton-footer-brand {
  display: block !important;
}

.newton-footer .newton-logo img {
  display: block;
  height: auto;
  margin-bottom: 1rem;
  width: 62px;
}

.newton-footer .wp-block-social-links {
  gap: .35rem;
}

.newton-footer .wp-social-link {
  background: transparent !important;
  border: 0;
  border-radius: 8px !important;
  height: 44px;
  width: 44px;
}

.newton-footer .wp-social-link a {
  padding: 10px;
}

.newton-footer .wp-social-link svg {
  height: 24px;
  width: 24px;
}

.newton-footer .wp-social-link:hover,
.newton-footer .wp-social-link:focus-within {
  background: rgba(31, 196, 194, .18) !important;
}

.newton-footer-meta {
  margin-top: 1.5rem;
}

/* O botão acompanha a navegação, surgindo apenas após deslocação. */
.newton-back-top {
  align-items: center;
  background: var(--newton-night);
  border: 2px solid #fff;
  border-radius: 50%;
  bottom: 1rem;
  box-shadow: 0 12px 30px rgba(8, 47, 73, .24);
  color: #fff;
  display: inline-flex;
  font-size: 1.25rem;
  height: 46px;
  justify-content: center;
  opacity: 0;
  padding: 0;
  pointer-events: none;
  position: fixed;
  right: 1rem;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease, background-color 180ms ease;
  visibility: hidden;
  width: 46px;
  z-index: 119;
}

.newton-back-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  visibility: visible;
}

.newton-back-top:hover,
.newton-back-top:focus-visible {
  background: var(--newton-turquoise);
  color: var(--newton-night);
}

/* Tablet e menu sobre toda a área visível. */
@media (max-width: 1120px) {
  .newton-header {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .newton-header,
  .newton-header__inner,
  .newton-primary-nav {
    overflow: visible !important;
  }

  .newton-header .wp-block-navigation__responsive-container-open {
    display: flex !important;
  }

  .newton-header .wp-block-navigation__responsive-container:not(.is-menu-open) {
    display: none !important;
  }

  .newton-header .wp-block-navigation__responsive-container.is-menu-open {
    align-items: stretch;
    background: rgba(8, 47, 73, .62) !important;
    box-sizing: border-box;
    color: var(--newton-ink);
    display: flex;
    height: 100dvh;
    inset: 0 !important;
    justify-content: flex-end;
    max-height: none;
    overflow: hidden;
    padding: 0 !important;
    position: fixed !important;
    width: 100vw;
    z-index: 100000;
  }

  .newton-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-dialog {
    background: #fff;
    border-left: 4px solid var(--newton-turquoise);
    box-shadow: -18px 0 46px rgba(8, 47, 73, .25);
    box-sizing: border-box;
    height: 100dvh;
    margin: 0 0 0 auto;
    max-width: 420px;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    padding: clamp(1.25rem, 5vw, 2.25rem);
    position: relative;
    width: min(88vw, 420px);
  }

  .newton-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
    align-items: stretch !important;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: .35rem;
    justify-content: flex-start !important;
    min-height: 100%;
    padding-top: 4rem;
    width: 100%;
  }

  .newton-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container {
    align-items: stretch !important;
    flex-direction: column;
    gap: 0;
    justify-content: flex-start !important;
    margin: 0;
    max-width: none;
    width: 100%;
  }

  .newton-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item {
    align-items: stretch !important;
    display: block !important;
    width: 100%;
  }

  .newton-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content {
    background: transparent;
    border-bottom: 1px solid var(--newton-line);
    border-left: 4px solid transparent;
    border-radius: 0;
    box-sizing: border-box;
    color: var(--newton-ink) !important;
    display: block;
    font-size: clamp(1rem, 3.5vw, 1.25rem);
    padding: .95rem 1rem;
    text-align: left;
    transform: none;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
    white-space: normal;
    width: 100%;
  }

  .newton-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content:hover,
  .newton-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content:focus-visible,
  .newton-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content:active,
  .newton-header .wp-block-navigation__responsive-container.is-menu-open .current-menu-item > .wp-block-navigation-item__content {
    background: var(--newton-mint);
    border-left-color: var(--newton-turquoise);
    color: var(--newton-night) !important;
    outline: none;
    transform: none;
  }

  .newton-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content:focus-visible {
    box-shadow: inset 0 0 0 2px var(--newton-turquoise);
  }

  .newton-header .wp-block-navigation__responsive-container-close {
    align-items: center;
    background: var(--newton-paper);
    border-radius: 50%;
    display: flex !important;
    height: 44px;
    justify-content: center;
    position: absolute;
    right: clamp(1.25rem, 5vw, 2.25rem);
    top: clamp(1.25rem, 5vw, 2.25rem);
    width: 44px;
    z-index: 2;
  }

  .newton-header .wp-block-navigation .newton-nav-student {
    display: block;
  }

  .newton-header__action {
    display: none;
  }

  .newton-footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .newton-stories {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Telemóvel: regras isoladas para não alterarem a composição de computador. */
@media (max-width: 781px) {
  .newton-header {
    padding-block: .45rem !important;
  }

  .newton-header__inner {
    flex-wrap: nowrap !important;
  }

  .newton-header .newton-logo img {
    width: 46px;
  }

  .newton-section-heading {
    max-width: none;
  }

  .newton-section-heading > .wp-block-heading {
    white-space: normal;
  }

  .newton-showcase,
  .newton-showcase__slide {
    min-height: var(--newton-showcase-height, 0);
  }

  .newton-showcase__slide {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    padding: 0;
  }

  .newton-showcase__content {
    min-height: 330px;
    order: 1;
    padding: 2.2rem 1.25rem 5.2rem;
  }

  .newton-showcase__content h1,
  .newton-showcase__content h2 {
    font-size: clamp(2.35rem, 12vw, 3.5rem);
  }

  .newton-showcase__media {
    height: clamp(220px, 62vw, 280px);
    min-height: 0;
    order: 2;
  }

  .newton-showcase__controls {
    bottom: 1rem;
    left: 50%;
    max-width: calc(100% - 2rem);
    transform: translateX(-50%);
  }

  .newton-method-step:hover,
  .newton-method-step:focus-within {
    transform: none;
  }

  .newton-mode-panel .wp-block-image,
  .newton-mode-media,
  .newton-hub-media,
  .newton-price-spotlight__visual,
  .newton-mission-intro__media .wp-block-image,
  .newton-contact-band__media {
    height: clamp(220px, 64vw, 280px);
    min-height: 0;
  }

  .newton-mode-copy,
  .newton-hub-copy,
  .newton-price-spotlight__copy {
    padding: clamp(1.4rem, 6vw, 2.2rem);
  }

  .newton-contact-band__inner {
    border-radius: var(--newton-radius);
    grid-template-columns: minmax(0, 1fr);
  }

  .newton-contact-band__copy {
    order: 1;
  }

  .newton-contact-band__copy .wp-block-buttons {
    border-top: 1px solid rgba(15, 71, 97, .18);
    margin-top: 1.35rem;
    padding-top: 1.15rem;
  }

  .newton-contact-band__inner > .wp-block-buttons {
    border-top: 1px solid rgba(15, 71, 97, .18);
    justify-content: flex-start;
    padding: 1.15rem clamp(1.25rem, 6vw, 1.75rem) clamp(1.25rem, 6vw, 1.75rem);
    width: 100%;
  }

  .newton-contact-band__media {
    order: 2;
  }

  .newton-stories {
    grid-template-columns: minmax(0, 1fr);
  }

  .newton-footer-grid {
    gap: 1.8rem;
    grid-template-columns: minmax(0, 1fr);
  }

  .newton-footer .newton-logo img {
    width: 54px;
  }

  .newton-contact-trigger {
    border-radius: 999px;
    bottom: .75rem;
    font-size: .88rem;
    left: .75rem;
    padding: .65rem .85rem;
    right: auto;
    transform: none;
  }

  .newton-contact-trigger:hover,
  .newton-contact-trigger:focus-visible {
    transform: translateY(-2px);
  }

  .newton-back-top {
    bottom: .75rem;
    right: .75rem;
  }
}

@media (max-width: 390px) {
  :root {
    --newton-control-size: 38px;
  }

  .newton-showcase__dots {
    gap: .25rem;
  }

  .newton-showcase__dots button {
    flex-basis: 14px;
    width: 14px;
  }

  .newton-showcase__dots button[aria-current="true"] {
    flex-basis: 26px;
    width: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .newton-contact-band__media img,
  .newton-contact-trigger,
  .newton-back-top,
  .newton-story-card,
  .newton-method-step {
    transition: none;
  }
}
