/*
 * auth.css
 *
 * Mapa de leitura (na ordem da cascata):
 * 01. Visibilidade e estrutura de autenticação
 * 02. Formulário de acesso
 * 03. Mensagens de autenticação
 * 04. Transição de entrada
 * 05. Animações
 * 06. Responsividade e preferências de movimento
 * 07. Etapa 1: referência aprovada do login contínuo e central.
 * 08. Identidade aprovada: g de dois traços com ponto laranja.
 * 09. Ajuste óptico da assinatura: símbolo e palavra mais próximos.
 * 10. Palavra vetorizada da referência, com ponto final circular.
 * 11. Os spans do carregamento participam do flex; a seta normal continua absoluta.
 * 12. Pontos na base da palavra, como reticências.
 * 13. Moldura compartilhada: campos de 350px dentro de uma superfície de vidro.
 * 14. Compatibilidade do navegador
 *
 * A ordem das regras, declarações e ajustes posteriores é intencional.
 * Consulte docs/interface/ORGANIZACAO-CSS.md antes de mover blocos.
 */

/* === Visibilidade e estrutura de autenticação === */
body:has(.auth-screen:not([hidden])) {
  min-height: 100vh;
  background: #f3f6f2;
}
.auth-screen[hidden],
.app-shell[hidden],
[hidden] {
  display: none !important;
}
.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(310px, 0.92fr) minmax(440px, 1.08fr);
}
.auth-brand-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
  padding: 42px clamp(30px, 6vw, 90px);
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(ellipse at 10% 92%, rgba(218, 151, 89, 0.22), transparent 35%),
    linear-gradient(145deg, #173d32, #24644f 72%, #2c755e);
}
.auth-brand-panel::after {
  position: absolute;
  right: -160px;
  bottom: -215px;
  width: 500px;
  height: 500px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 50%;
  box-shadow:
    0 0 0 45px rgba(255, 255, 255, 0.025),
    0 0 0 90px rgba(255, 255, 255, 0.02);
  content: '';
  pointer-events: none;
}
.auth-brand {
  position: relative;
  z-index: 1;
  margin: 0;
  color: #fff;
}
.auth-brand .brand-mark {
  color: #21614f;
  background: #fff;
}
.auth-brand .brand-dot {
  color: #efbd83;
}
.auth-brand-copy {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: auto 0;
  padding: 70px 0;
}
.auth-kicker {
  color: #b9d6c9;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.8px;
}
.auth-brand-copy h1 {
  max-width: 500px;
  margin: 18px 0 16px;
  font:
    700 clamp(32px, 4vw, 52px) / 1.12 Manrope,
    sans-serif;
  letter-spacing: -1.8px;
}
.auth-brand-copy p {
  max-width: 390px;
  color: rgba(255, 255, 255, 0.77);
  font-size: 15px;
  line-height: 1.7;
}
.auth-brand-footer {
  position: relative;
  z-index: 1;
  color: rgba(255, 255, 255, 0.65);
  font-size: 11px;
}
.auth-form-panel {
  display: grid;
  place-items: center;
  padding: 48px 28px;
}

/* === Formulário de acesso === */
.auth-card {
  width: min(100%, 410px);
  padding: 8px 0;
}
.auth-mobile-brand {
  display: none;
}
.auth-card > .eyebrow {
  display: block;
  margin-bottom: 9px;
  color: var(--green);
}
.auth-card h2 {
  margin: 0;
  color: var(--ink);
  font:
    700 30px Manrope,
    sans-serif;
  letter-spacing: -1px;
}
.auth-intro {
  margin: 9px 0 28px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.auth-card label {
  display: block;
  margin: 16px 0 7px;
  color: #4e5e55;
  font-size: 12px;
  font-weight: 600;
}
.auth-card input {
  width: 100%;
  height: 46px;
  border: 1px solid #dfe6df;
  border-radius: 9px;
  background: #fff;
  padding: 0 13px;
  color: var(--ink);
  font:
    13px 'DM Sans',
    sans-serif;
  outline: none;
}
.auth-card input:focus {
  border-color: #8db5a0;
  box-shadow: 0 0 0 3px rgba(67, 134, 103, 0.1);
}
.auth-card input::placeholder {
  color: #a4afa7;
}
.auth-password-wrap {
  position: relative;
}
.auth-password-wrap input {
  padding-right: 70px;
}
.auth-password-wrap button {
  position: absolute;
  top: 0;
  right: 7px;
  height: 46px;
  border: 0;
  background: none;
  color: var(--green);
  font:
    600 11px 'DM Sans',
    sans-serif;
  cursor: pointer;
}
.auth-submit {
  position: relative;
  width: 100%;
  min-height: 46px;
  justify-content: center;
  margin-top: 23px;
  font-size: 13px;
}
.auth-submit span {
  position: absolute;
  right: 17px;
}
.auth-demo-note {
  display: grid;
  gap: 4px;
  margin-top: 22px;
  padding: 13px 14px;
  border: 1px solid #e4ece5;
  border-radius: 9px;
  background: #f7faf7;
  color: #66766c;
  font-size: 11px;
}
.auth-demo-note strong {
  margin-bottom: 2px;
  color: #426352;
  font-size: 11px;
}
.auth-disclaimer {
  margin: 14px 0 0;
  color: #909a93;
  font-size: 10px;
  line-height: 1.55;
}

/* === Mensagens de autenticação === */
.auth-error {
  margin: 10px 0 0;
  color: #a23e38;
  font-size: 11px;
}
.auth-screen.is-exiting {
  animation: authExit 0.22s ease-in forwards;
  pointer-events: none;
}
.auth-button-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-top-color: #fff;
  border-radius: 50%;
  animation: authSpin 0.7s linear infinite;
}

/* === Transição de entrada === */
.brand-motion-screen {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #fff;
  opacity: 1;
  isolation: isolate;
}
.brand-motion-screen::before {
  position: absolute;
  z-index: 0;
  top: 50%;
  left: 50%;
  width: min(108vmin, 780px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(40, 116, 95, 0.3) 0%,
    rgba(40, 116, 95, 0.2) 29%,
    rgba(40, 116, 95, 0.1) 52%,
    rgba(40, 116, 95, 0.025) 68%,
    transparent 76%
  );
  content: '';
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.55);
}
.brand-motion-screen.is-leaving {
  animation: motionCurtainOut 0.42s ease-in forwards;
}
.brand-motion-lockup {
  position: relative;
  z-index: 1;
  width: 280px;
  height: 72px;
}
.brand-motion-g {
  position: absolute;
  top: 6px;
  left: calc(50% - 29px);
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 16px;
  background: #28745f;
  color: #fff;
  font:
    800 42px/1 Manrope,
    sans-serif;
  letter-spacing: -3px;
  opacity: 0;
}
.brand-motion-word {
  position: absolute;
  top: 50%;
  left: 82px;
  display: block;
  width: 180px;
  height: 68px;
  padding-bottom: 10px;
  overflow: visible;
  color: #202a27;
  font:
    800 42px/58px Manrope,
    sans-serif;
  letter-spacing: -2.5px;
  clip-path: inset(0 100% 0 0);
  opacity: 0;
  white-space: nowrap;
  transform: translateY(-50%);
}
.brand-motion-word span {
  color: #d99052;
}
.brand-motion-screen.is-playing::before {
  animation: radialBloom 1.6s cubic-bezier(0.16, 0.68, 0.24, 1) 0.06s both;
}
.brand-motion-screen.is-playing .brand-motion-g {
  animation: logoRise 0.8s cubic-bezier(0.2, 0.78, 0.2, 1) 0.05s forwards;
}
.brand-motion-screen.is-playing .brand-motion-word {
  animation: wordReveal 0.78s cubic-bezier(0.18, 0.72, 0.22, 1) 0.62s forwards;
}

/* === Animações === */
@keyframes authSpin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes authExit {
  to {
    opacity: 0;
    transform: translateY(-5px);
  }
}
@keyframes radialBloom {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.55);
  }
  38% {
    opacity: 1;
  }
  100% {
    opacity: 0.82;
    transform: translate(-50%, -50%) scale(1.08);
  }
}
@keyframes logoRise {
  0% {
    left: calc(50% - 29px);
    top: 12px;
    transform: translateY(28px) scale(0.88);
    opacity: 0;
  }
  35% {
    opacity: 1;
  }
  100% {
    left: 0;
    top: 6px;
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}
@keyframes wordReveal {
  from {
    clip-path: inset(0 100% 0 0);
    opacity: 0;
    transform: translate(12px, -50%);
  }
  to {
    clip-path: inset(0 0 0 0);
    opacity: 1;
    transform: translate(0, -50%);
  }
}
@keyframes motionCurtainOut {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

/* === Responsividade e preferências de movimento === */
@media (prefers-reduced-motion: reduce) {
  .auth-screen.is-exiting,
  .auth-button-spinner,
  .brand-motion-screen.is-leaving,
  .brand-motion-screen.is-playing::before,
  .brand-motion-screen.is-playing .brand-motion-g,
  .brand-motion-screen.is-playing .brand-motion-word {
    animation-duration: 0.01ms;
    animation-delay: 0ms;
  }
}
@media (max-width: 760px) {
  .auth-screen {
    grid-template-columns: 1fr;
  }
  .auth-brand-panel {
    display: none;
  }
  .auth-form-panel {
    min-height: 100vh;
    padding: 30px 24px;
  }
  .auth-card {
    max-width: 430px;
  }
  .auth-mobile-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 52px;
    color: var(--ink);
    font:
      800 23px Manrope,
      sans-serif;
    letter-spacing: -1.3px;
  }
  .auth-mobile-brand .brand-mark {
    color: white;
  }
  .auth-submit span {
    right: 24px;
    margin-left: 0;
  }
}

/* Etapa 1: referência aprovada do login contínuo e central. */
body:has(.auth-screen:not([hidden])) {
  background: var(--canvas);
}
.auth-screen {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--canvas);
  overflow: hidden;
  min-height: 100svh;
}
.auth-page-brand {
  position: absolute;
  z-index: 3;
  left: 44px;
  top: 30px;
  margin: 0;
  font-size: 29px;
}
.auth-watermark {
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 22px;
  white-space: nowrap;
  opacity: 0.035;
  color: var(--green);
  font:
    800 clamp(140px, 21vw, 340px) / 1 Manrope,
    sans-serif;
  letter-spacing: -0.06em;
  pointer-events: none;
}
.auth-watermark-mark {
  display: grid;
  place-items: center;
  width: 1.05em;
  height: 1.05em;
  background: var(--green);
  color: var(--paper);
  border-radius: 0.22em;
  font-size: 0.8em;
  padding-bottom: 0.08em;
}
.auth-grid-detail {
  position: absolute;
  z-index: 0;
  top: 0;
  right: 0;
  width: clamp(240px, 36vw, 520px);
  height: 410px;
  background-image:
    linear-gradient(to right, #28745f24 1px, transparent 1px),
    linear-gradient(to bottom, #28745f24 1px, transparent 1px);
  background-size: 72px 58px;
  mask-image: radial-gradient(ellipse at top right, #000 10%, transparent 72%);
  pointer-events: none;
}
.auth-form-panel {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  padding: 110px 24px 55px;
}
.auth-card {
  max-width: 350px;
  padding: 0;
  background: transparent;
}
.auth-mobile-brand {
  display: none !important;
}
.auth-point {
  display: block;
  width: 9px;
  height: 9px;
  background: var(--orange);
  border-radius: 50%;
  box-shadow: 0 0 0 7px #d990521a;
  margin: 0 auto 26px;
}
.auth-card h2 {
  text-align: center;
  font-size: 30px;
  line-height: 1.25;
  letter-spacing: -1px;
}
.auth-intro {
  text-align: center;
  margin: 10px 0 30px;
  font-size: 13px;
}
.auth-card label {
  font-size: 12px;
  color: var(--ink);
  font-weight: 500;
}
.auth-card input {
  height: 49px;
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}
.auth-password-wrap button {
  height: 49px;
}
.auth-submit {
  min-height: 49px;
  margin-top: 24px;
}
.auth-disclaimer {
  max-width: 350px;
  font-size: 11px;
  text-align: center;
  line-height: 1.5;
  margin-top: 22px;
}
.auth-error {
  font-size: 12px;
  line-height: 1.5;
}
@media (max-width: 760px) {
  .auth-page-brand {
    left: 24px;
    top: 24px;
    font-size: 25px;
  }
  .auth-form-panel {
    padding-top: 120px;
  }
  .auth-grid-detail {
    width: 260px;
    height: 230px;
    background-size: 56px 46px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .auth-card input,
  .auth-submit {
    transition: none;
  }
}
.auth-page-brand > span:last-child,
.sidebar .brand > span:last-child {
  display: inline;
}
.sidebar .school-meta {
  display: flex;
}
/* Identidade aprovada: g de dois traços com ponto laranja. */
.brand .brand-mark,
.auth-mobile-brand .brand-mark {
  padding: 0;
  background: transparent;
  overflow: visible;
}
.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.auth-watermark-mark {
  padding: 0;
  background: transparent;
  overflow: visible;
}
.auth-watermark-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
/* Ajuste óptico da assinatura: símbolo e palavra mais próximos. */
.brand {
  gap: 7px;
}
.brand > span:last-child,
.auth-mobile-brand > span:last-child {
  position: relative;
  top: -2px;
}
/* Palavra vetorizada da referência, com ponto final circular. */
.brand .brand-wordmark,
.auth-mobile-brand .brand-wordmark {
  display: block;
  width: 2.8em;
  height: 1em;
  flex: none;
}
.brand-wordmark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.brand-wordmark .wordmark-light {
  display: none;
}
body[data-theme='dark'] .brand-wordmark .wordmark-normal {
  display: none;
}
body[data-theme='dark'] .brand-wordmark .wordmark-light {
  display: block;
}
.auth-watermark .brand-wordmark {
  display: block;
  width: 2.9em;
  height: 1em;
}
#loginForm button[type='submit'][aria-busy='true'] {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 1;
  cursor: wait;
}
.login-loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 14px;
}
.login-loading-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  animation: grade-login-dot 1s ease-in-out infinite;
}
.login-loading-dots i:nth-child(2) {
  animation-delay: 0.16s;
}
.login-loading-dots i:nth-child(3) {
  animation-delay: 0.32s;
}
@keyframes grade-login-dot {
  0%,
  65%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .login-loading-dots i {
    animation: none;
    opacity: 1;
  }
}
/* Os spans do carregamento participam do flex; a seta normal continua absoluta. */
#loginForm .auth-submit[aria-busy='true'] > span {
  position: static;
  inset: auto;
  margin: 0;
  flex: none;
  line-height: 1.2;
}
#loginForm .auth-submit[aria-busy='true'] > .login-loading-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 14px;
}
/* Pontos na base da palavra, como reticências. */
#loginForm .auth-submit[aria-busy='true'] > .login-loading-dots {
  align-items: flex-end;
  height: 1em;
  padding-bottom: 1px;
}
@keyframes grade-login-dot {
  0%,
  65%,
  100% {
    opacity: 0.3;
    transform: none;
  }
  30% {
    opacity: 1;
    transform: none;
  }
}

/* Moldura compartilhada: campos de 350px dentro de uma superfície de vidro. */
.auth-screen .auth-card {
  box-sizing: border-box;
  width: min(100%, 432px);
  max-width: 432px;
  padding: 36px 40px 32px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow:
    0 16px 48px rgba(32, 64, 50, 0.08),
    0 0 0 1px rgba(40, 116, 95, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

/* === Compatibilidade do navegador === */
@supports ((backdrop-filter: blur(16px)) or (-webkit-backdrop-filter: blur(16px))) {
  .auth-screen .auth-card {
    background: rgba(255, 255, 255, 0.2);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
  }
}
.admin-auth #loginPanel h2 {
  margin-bottom: 28px;
}
@media (max-width: 480px) {
  .auth-screen .auth-card {
    padding: 30px 22px 26px;
    border-radius: 20px;
  }
}
