/* Sign in and create an account (index.php). Colour tokens come from tresi-brand.css. */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Layout: two halves, fixed to the viewport ---------- */
.auth {
    --pad: clamp(10px, 1.4vw, 18px);
    --swap: 0.95s cubic-bezier(0.77, 0, 0.18, 1);
    position: fixed;
    inset: 0;
    height: 100dvh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: var(--pad);
    background:
        radial-gradient(60rem 40rem at 0% 0%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 60%),
        var(--bg);
}

.auth-pane {
    position: relative;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(18px, 3.2vw, 56px) clamp(16px, 4vw, 64px);
    overflow-y: auto;
    scrollbar-width: none;
}
.auth-pane::-webkit-scrollbar { display: none; }

.auth-form-wrap {
    width: 100%;
    max-width: 25.5rem;
    transition: opacity 0.55s ease 0.32s, transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) 0.28s, filter 0.55s ease 0.32s;
}
/* the form being covered steps back and blurs; the revealed one arrives once the panel has passed */
.auth[data-mode="signup"] .auth-pane--signin .auth-form-wrap,
.auth[data-mode="signin"] .auth-pane--signup .auth-form-wrap {
    opacity: 0;
    filter: blur(6px);
    transition-delay: 0s;
    transition-duration: 0.35s, 0.6s, 0.35s;
}
.auth[data-mode="signup"] .auth-pane--signin .auth-form-wrap { transform: translateX(-28px) scale(0.98); }
.auth[data-mode="signin"] .auth-pane--signup .auth-form-wrap { transform: translateX(28px) scale(0.98); }

/* ---------- Form ---------- */
.auth-title {
    margin: 1.25rem 0 0.45rem;
    font-size: clamp(1.7rem, 2.5vw, 2.25rem);
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.15;
    text-wrap: balance;
}
.auth-lead {
    margin: 0 0 1.5rem;
    color: var(--muted);
    line-height: 1.6;
    max-width: 36ch;
}
.auth-form { display: flex; flex-direction: column; gap: 1.05rem; }
.field { display: flex; flex-direction: column; gap: 0.45rem; min-width: 0; }
.field label { font-size: 0.84rem; font-weight: 500; color: var(--text); }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }

.field input {
    width: 100%;
    height: 2.85rem;
    padding: 0 0.95rem;
    border: 0;
    border-radius: 0.7rem;
    background: var(--input-bg);
    box-shadow: var(--input-ring);
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
    transition: box-shadow 0.2s ease, background-color 0.2s ease;
}
.field input::placeholder { color: var(--faint); }
.field input:focus {
    outline: none;
    box-shadow: var(--input-ring), 0 0 0 3px color-mix(in srgb, var(--accent) 38%, transparent);
}
.field input[aria-invalid="true"] {
    box-shadow: 0 0 0 1px var(--danger), 0 0 0 4px var(--danger-bg);
}

.field-pw { position: relative; }
.field-pw input { padding-right: 2.9rem; }
.pw-toggle {
    position: absolute;
    top: 50%;
    right: 0.35rem;
    translate: 0 -50%;
    width: 2.2rem;
    height: 2.2rem;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 0.55rem;
    background: none;
    color: var(--faint);
    cursor: pointer;
}
.pw-toggle:hover { color: var(--text); }
.pw-toggle:focus-visible { outline: 2px solid var(--accent); }
.pw-toggle svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.pw-toggle .slash { stroke-dasharray: 23; stroke-dashoffset: 23; transition: stroke-dashoffset 0.3s ease; }
.pw-toggle[aria-pressed="true"] .slash { stroke-dashoffset: 0; }

.pw-meter { height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.pw-meter span {
    display: block;
    height: 100%;
    width: var(--pw, 0%);
    border-radius: inherit;
    background: linear-gradient(90deg, var(--warm), var(--accent) 60%, var(--accent-2));
    transition: width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.field-hint { margin: 0; font-size: 0.78rem; color: var(--faint); }

.field-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-size: 0.86rem; }
.check { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--muted); cursor: pointer; }
.check input { width: 1rem; height: 1rem; margin: 0; accent-color: var(--accent); }

.link { color: var(--accent); font-weight: 500; text-decoration: none; border-radius: 4px; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.btn-primary {
    position: relative;
    height: 2.95rem;
    margin-top: 0.35rem;
    border: 0;
    border-radius: 0.8rem;
    background: var(--btn-bg);
    color: var(--btn-text);
    font: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.2s ease, box-shadow 0.25s ease;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 8px 22px -12px color-mix(in srgb, var(--btn-bg) 70%, transparent);
}
.btn-primary:hover { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 12px 28px -12px color-mix(in srgb, var(--accent) 60%, transparent); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn-primary[aria-busy="true"] { color: transparent; pointer-events: none; }
.btn-primary[aria-busy="true"]::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 50%;
    border: 2px solid color-mix(in srgb, var(--btn-text) 30%, transparent);
    border-top-color: var(--btn-text);
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth-switch { margin: 1.5rem 0 0; text-align: center; color: var(--muted); font-size: 0.9rem; }

.auth-msg {
    margin: 0 0 1.1rem;
    padding: 0.7rem 0.95rem;
    border-radius: 0.7rem;
    font-size: 0.87rem;
    line-height: 1.45;
    animation: msg-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.auth-msg--error { background: var(--danger-bg); color: var(--danger); }
.auth-msg--ok { background: var(--success-bg); color: var(--success); }
@keyframes msg-in { from { opacity: 0; transform: translateY(-4px); } }
.shake { animation: shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ---------- Visual panel ---------- */
.auth-visual {
    position: absolute;
    z-index: 2;
    top: var(--pad);
    bottom: var(--pad);
    left: 50%;
    width: calc(50% - var(--pad));
    overflow: hidden;
    border-radius: 1.6rem;
    background: #05070b;
    box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.55);
    transition: transform var(--swap);
    will-change: transform;
}
.auth[data-mode="signup"] .auth-visual { transform: translateX(-100%); }

.av-gradient {
    position: absolute;
    inset: -12%;
    width: 124%;
    height: 124%;
    filter: blur(46px) saturate(1.1);
    opacity: 0.95;
    -webkit-mask-image: linear-gradient(to top, #000 42%, transparent 92%);
    mask-image: linear-gradient(to top, #000 42%, transparent 92%);
}

.av-tiles {
    position: absolute;
    display: grid;
    grid-template-columns: repeat(4, 10rem);
    gap: 8rem;
    transform: rotate(45deg);
}
.av-tiles i {
    width: 10rem;
    height: 10rem;
    border-radius: 1.6rem;
    background: #131313;
    box-shadow: 0 2px 0 0 #4a4a4a inset;
}
.av-tiles--a { top: -12rem; right: -10rem; }
.av-tiles--b { top: 0; right: -2.5rem; opacity: 0.5; }

.av-grain {
    position: absolute;
    inset: 0;
    opacity: 0.09;
    mix-blend-mode: overlay;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.av-content {
    position: absolute;
    z-index: 3;
    left: clamp(1rem, 2.6vw, 2rem);
    right: clamp(1rem, 2.6vw, 2rem);
    bottom: clamp(1rem, 2.6vw, 2rem);
    transition: opacity 0.5s ease 0.5s, transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) 0.45s;
}
.auth[data-mode="signin"] .av-content--signup,
.auth[data-mode="signup"] .av-content--signin {
    opacity: 0;
    transform: translateY(14px);
    transition-delay: 0s;
    transition-duration: 0.3s;
}
.av-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.6rem; }
.av-tags span {
    padding: 0.25rem 0.55rem;
    border-radius: 0.4rem;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 0.74rem;
}
.av-card {
    max-width: 24rem;
    padding: 1rem 1.1rem;
    border-radius: 0.9rem;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: #fff;
}
.av-card p { margin: 0 0 0.9rem; font-size: 0.98rem; line-height: 1.55; }
.av-meta { display: block; font-size: 0.82rem; color: rgba(255, 255, 255, 0.55); line-height: 1.6; }
.av-meta b { font-weight: 600; color: rgba(255, 255, 255, 0.75); }

/* ---------- Small screens: one column, the forms cross-fade ---------- */
@media (max-width: 880px) {
    .auth { grid-template-columns: 1fr; }
    .auth-pane { grid-area: 1 / 1; }
    .auth-visual { display: none; }
    .auth[data-mode="signin"] .auth-pane--signup,
    .auth[data-mode="signup"] .auth-pane--signin { pointer-events: none; }
    .auth[data-mode="signup"] .auth-pane--signin .auth-form-wrap,
    .auth[data-mode="signin"] .auth-pane--signup .auth-form-wrap { transform: translateY(10px) scale(0.98); }
}
@media (max-width: 420px) {
    .field-pair { grid-template-columns: 1fr; }
}
@media (max-height: 700px) {
    .auth-title { margin-top: 0.8rem; }
    .auth-lead { margin-bottom: 1rem; }
    .auth-form { gap: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
    .auth *, .auth *::before, .auth *::after { transition-duration: 0.01s !important; transition-delay: 0s !important; animation-duration: 0.01s !important; }
}

.auth.is-leaving { opacity: 0.6; transition: opacity 0.3s ease; }
