/* =========================================================
   Biblioteca CIS — ecrãs de autenticação (login / cadastro)
   Linguagem visual partilhada com index.html: creme, preto,
   amarelo e vermelho, tipografia editorial (DM Serif Display)
   e linhas finas de 1px.
   ========================================================= */

:root {
    --primary-yellow: #ffcb01;
    --dark-yellow: #e6b800;
    --primary-red: #e31e25;
    --ink: #0b0b0b;
    --cream: #f7f3e9;
    --muted: rgba(0, 0, 0, 0.55);
    --line: rgba(0, 0, 0, 0.15);
    --sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --serif: 'DM Serif Display', Georgia, 'Times New Roman', serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--cream);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

::selection { background: var(--primary-yellow); color: #000; }

/* ---------- Página ---------- */
.page-auth {
    position: relative;
    isolation: isolate;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Grelha editorial discreta, como no hero do index */
.page-auth::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(to right, rgba(0, 0, 0, 0.045) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 0, 0, 0.035) 1px, transparent 1px);
    background-size: 76px 76px;
    -webkit-mask-image: radial-gradient(120% 90% at 15% 0%, #000 0%, transparent 72%);
    mask-image: radial-gradient(120% 90% at 15% 0%, #000 0%, transparent 72%);
}

/* ---------- Barra superior ---------- */
.auth-topbar {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 20px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand-home {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--ink);
    font-size: 19px;
    font-weight: 900;
    letter-spacing: -0.05em;
    white-space: nowrap;
}

.brand-home img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 3px;
    border-bottom: 1px solid transparent;
    color: rgba(0, 0, 0, 0.6);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-decoration: none;
    white-space: nowrap;
    transition: color 180ms ease, border-color 180ms ease;
}

.back-link:hover,
.back-link:focus-visible {
    color: #000;
    border-color: #000;
}

.back-link svg { width: 14px; height: 14px; }

/* Topbar compacta em ecrãs muito estreitos */
@media (max-width: 420px) {
    .auth-topbar { padding: 14px 16px; gap: 10px; }
    .brand-home { gap: 8px; font-size: 16px; }
    .brand-home img { width: 36px; height: 36px; }
    .back-link { font-size: 9px; letter-spacing: 0.08em; }
}

/* ---------- Estrutura ---------- */
.auth-main {
    flex: 1;
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 4px 20px 48px;
    display: flex;
    align-items: flex-start;
}

/* Só centra verticalmente quando há altura suficiente para o formulário não ser cortado */
@media (min-width: 1000px) and (min-height: 840px) {
    .auth-main { align-items: center; }
}

.auth-layout {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
    align-items: stretch;
}

@media (min-width: 1000px) {
    .auth-layout {
        grid-template-columns: 1.02fr 0.98fr;
        gap: 64px;
    }
}

/* ---------- Painel editorial ---------- */
.auth-pitch {
    position: relative;
    display: none;
    overflow: hidden;
    min-height: 540px;
    padding: 46px;
    background: var(--ink);
    color: #fff;
    border-radius: 2px;
}

@media (min-width: 1000px) {
    .auth-pitch { display: flex; }
}

.auth-pitch::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(to right, rgba(255, 255, 255, 0.07) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 64px 64px;
    -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 78%);
    mask-image: linear-gradient(to bottom, #000 0%, transparent 78%);
}

.auth-pitch::after {
    content: "";
    position: absolute;
    right: -84px;
    bottom: -84px;
    width: 236px;
    height: 236px;
    border-radius: 50%;
    background: var(--primary-yellow);
}

.pitch-bar {
    position: absolute;
    top: 46px;
    left: 0;
    width: 8px;
    height: 92px;
    background: var(--primary-red);
}

.pitch-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 40px;
    width: 100%;
}

.pitch-top {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.62);
}

.pitch-top .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-yellow);
}

.pitch-title {
    margin: 0 0 22px;
    max-width: 15ch;
    font-family: var(--serif);
    font-size: clamp(2.6rem, 4.2vw, 3.7rem);
    font-weight: 400;
    line-height: 0.98;
    letter-spacing: -0.045em;
}

.pitch-title em {
    position: relative;
    z-index: 0;
    font-style: normal;
}

.pitch-title .hl {
    position: absolute;
    left: 0;
    bottom: -3px;
    z-index: -1;
    width: 100%;
    height: 16%;
    background: var(--primary-yellow);
}

.pitch-text {
    margin: 0;
    max-width: 34ch;
    font-size: 14.5px;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.66);
}

.pitch-list {
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.78);
}

.pitch-list li {
    display: flex;
    align-items: baseline;
    gap: 14px;
    padding: 12px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.pitch-list li:last-child { border-bottom: 1px solid rgba(255, 255, 255, 0.14); }

.pitch-list .n {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.4);
}

/* ---------- Cartão do formulário ---------- */
.auth-card {
    width: 100%;
    max-width: 470px;
    margin: 0 auto;
    align-self: center;
    padding: 36px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 2px;
    box-shadow: 10px 10px 0 var(--primary-yellow);
}

@media (max-width: 520px) {
    .auth-main { padding: 16px 16px 32px; }
    .auth-topbar { padding: 16px; }
    .auth-card { padding: 26px 22px; box-shadow: 6px 6px 0 var(--primary-yellow); }
}

.auth-eyebrow {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 12px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
}

.auth-eyebrow::before {
    content: "";
    width: 22px;
    height: 1px;
    background: #000;
}

.auth-title {
    margin: 0 0 10px;
    font-family: var(--serif);
    font-size: clamp(2rem, 3vw, 2.45rem);
    font-weight: 400;
    line-height: 1.04;
    letter-spacing: -0.04em;
}

.auth-sub {
    margin: 0 0 26px;
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--muted);
}

/* ---------- Alerta ---------- */
.form-alert {
    display: none;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 18px;
    padding: 12px 14px;
    border: 1px solid rgba(227, 30, 37, 0.35);
    border-left: 3px solid var(--primary-red);
    background: rgba(227, 30, 37, 0.07);
    color: #a3151b;
    font-size: 13px;
    line-height: 1.45;
}

.form-alert.show { display: flex; }

.form-alert.is-success {
    border-color: rgba(22, 163, 74, 0.35);
    border-left-color: #16a34a;
    background: rgba(22, 163, 74, 0.08);
    color: #15803d;
}

.form-alert svg {
    flex: 0 0 auto;
    width: 17px;
    height: 17px;
    margin-top: 1px;
}

/* ---------- Campos ---------- */
.field { margin-bottom: 16px; }

.field label {
    display: block;
    margin-bottom: 7px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(0, 0, 0, 0.55);
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrap input {
    width: 100%;
    min-height: 50px;
    padding: 0 14px;
    font: inherit;
    font-size: 14px;
    color: var(--ink);
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.22);
    border-radius: 2px;
    transition: border-color 180ms ease, box-shadow 180ms ease;
}

.input-wrap input::placeholder { color: rgba(0, 0, 0, 0.34); }

.input-wrap input:hover { border-color: rgba(0, 0, 0, 0.4); }

.input-wrap input:focus {
    outline: none;
    border-color: #000;
    box-shadow: 0 0 0 3px rgba(255, 203, 1, 0.4);
}

.input-wrap input[type="password"],
.input-wrap input.has-toggle { padding-right: 50px; }

.input-wrap input:disabled {
    background: #f4f4f4;
    color: rgba(0, 0, 0, 0.5);
    cursor: not-allowed;
}

.field-hint {
    margin: 6px 0 0;
    font-size: 11.5px;
    line-height: 1.5;
    color: rgba(0, 0, 0, 0.45);
}

/* Botão mostrar/ocultar senha */
.password-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: rgba(0, 0, 0, 0.5);
    cursor: pointer;
    transition: background 180ms ease, color 180ms ease;
}

.password-toggle:hover { background: rgba(0, 0, 0, 0.06); color: #000; }

.password-toggle:focus-visible {
    outline: 2px solid #000;
    outline-offset: 2px;
}

.password-toggle svg { width: 18px; height: 18px; }

.password-toggle .eye-off { display: none; }
.password-toggle.is-visible .eye { display: none; }
.password-toggle.is-visible .eye-off { display: block; }

/* ---------- Botão principal ---------- */
.btn-auth {
    width: 100%;
    min-height: 52px;
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 22px;
    border: 1px solid #000;
    border-radius: 2px;
    background: var(--primary-yellow);
    color: #000;
    font-family: inherit;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 180ms ease, transform 180ms ease;
}

.btn-auth:hover { background: var(--dark-yellow); transform: translateY(-1px); }
.btn-auth:active { transform: translateY(0); }

.btn-auth:focus-visible {
    outline: 2px solid #000;
    outline-offset: 3px;
}

.btn-auth:disabled {
    opacity: 0.65;
    cursor: progress;
    transform: none;
}

.btn-auth svg { width: 16px; height: 16px; }

/* ---------- Ligações auxiliares ---------- */
.auth-alt {
    margin: 22px 0 0;
    text-align: center;
    font-size: 13px;
    color: var(--muted);
}

.auth-alt a {
    color: #000;
    font-weight: 800;
    text-decoration: none;
    border-bottom: 1px solid var(--primary-yellow);
    padding-bottom: 1px;
}

.auth-alt a:hover { background: var(--primary-yellow); }

.auth-foot {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 16px 20px 26px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 20px;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(0, 0, 0, 0.42);
}

.auth-foot a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.auth-foot a:hover { color: #000; border-color: #000; }

/* ---------- Acessibilidade ---------- */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }
}
