/* =========================================================
   strony logowania, rejestracji i resetu hasła (variables/auth-ui.php)
   web: tło erebus night / storm z animacją, karta 2 kolumny (ilustracja + formularz) w stylu landingu
   aplikacja (html.inapp): minimalizm, tło amoled black / białe wg motywu (inapp-dark / inapp-light)
   ========================================================= */
:root {
    --ap-blaze: #A61F2B;      /* ares blaze */
    --ap-dionysus: #732439;
    --ap-night: #1E2340;      /* erebus night */
    --ap-storm: #212B40;
    --ap-white: #F2F2F2;

    --auth-bg: var(--ap-night);
    --auth-fg: var(--ap-white);
    --auth-muted: rgba(242, 242, 242, 0.62);
    --auth-line: rgba(242, 242, 242, 0.12);
    --auth-field: rgba(242, 242, 242, 0.05);
    --auth-field-focus: rgba(242, 242, 242, 0.08);
    --auth-autofill: #262f47;
    --auth-radius: 14px;
    --auth-field-h: 54px;
    --auth-gap: 14px;
}

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

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

body.auth-body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background-color: var(--auth-bg);
    color: var(--auth-fg);
    font-family: "Urbanist", "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

.disable-selection {
    -webkit-user-select: none;
    user-select: none;
}

/* --- tło: poświaty + interaktywne cząsteczki (auth.js) --- */
.aura-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    overflow: hidden;
    background: radial-gradient(circle at 50% 50%, var(--ap-storm) 0%, var(--ap-night) 100%);
}
.aura-blob {
    position: absolute;
    width: 60vw;
    height: 60vw;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.3;
    animation: authAura 25s infinite alternate ease-in-out;
}
.aura-red {
    top: -10%;
    left: -10%;
    background: var(--ap-blaze);
}
.aura-blue {
    right: -10%;
    bottom: -10%;
    background: #4a54a4;
    animation-delay: -7s;
}
@keyframes authAura {
    0% { transform: translate(0, 0) scale(1) rotate(0deg); }
    50% { transform: translate(15%, 10%) scale(1.1) rotate(45deg); }
    100% { transform: translate(-5%, -15%) scale(1) rotate(-45deg); }
}
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* --- układ --- */
.auth {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(16px, 3vw, 48px);
}
.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: clamp(12px, 1.2vw, 20px);
    width: 100%;
    max-width: clamp(980px, 62vw, 1440px);
    min-height: min(740px, calc(100vh - 64px));
    padding: clamp(12px, 1.1vw, 20px);
    border: 1px solid var(--auth-line);
    border-radius: clamp(24px, 2vw, 36px);
    background: rgba(33, 43, 64, 0.82); /* storm */
    -webkit-backdrop-filter: blur(24px);
    backdrop-filter: blur(24px);
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.45);
    animation: authIn 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}
@keyframes authIn {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.985);
    }
}

/* --- lewa część: czerwona karta z ilustracją --- */
.auth-visual {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: clamp(28px, 2.8vw, 56px);
    border-radius: clamp(18px, 1.5vw, 28px);
    background: linear-gradient(155deg, #b0232f 0%, var(--ap-blaze) 30%, #8a1f35 65%, var(--ap-dionysus) 100%);
}
/* ukośne linie jak na kartach landingu, wygaszane w stronę dołu */
.auth-visual-pattern {
    position: absolute;
    top: -40px;
    right: -40px;
    bottom: -40px;
    left: -40px;
    z-index: -1;
    pointer-events: none;
    background: repeating-linear-gradient(135deg, rgba(242, 242, 242, 0.1) 0 1px, transparent 1px 14px);
    -webkit-mask-image: linear-gradient(200deg, #000 10%, rgba(0, 0, 0, 0.3) 50%, transparent 80%);
    mask-image: linear-gradient(200deg, #000 10%, rgba(0, 0, 0, 0.3) 50%, transparent 80%);
}
.auth-visual-title {
    max-width: 13em;
    margin: 0 0 clamp(14px, 1.2vw, 22px);
    color: var(--ap-white);
    font-size: clamp(30px, 2.5vw, 50px);
    font-weight: 800;
    line-height: 1.12;
    letter-spacing: -0.01em;
}
/* odręczne podkreślenie słowa */
.auth-swash {
    position: relative;
    white-space: nowrap;
}
.auth-swash::after {
    content: "";
    position: absolute;
    left: -2%;
    right: -4%;
    bottom: -0.2em;
    height: 0.32em;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 16' preserveAspectRatio='none'%3E%3Cpath d='M3 11c40-6 98-9 194-4' fill='none' stroke='%23F2F2F2' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.auth-visual-text {
    max-width: 30em;
    margin: 0;
    color: rgba(242, 242, 242, 0.85);
    font-size: clamp(15px, 0.95vw, 19px);
    line-height: 1.55;
}
.auth-visual-img {
    display: block;
    width: 100%;
    max-width: 440px;
    min-height: 0;
    flex: 1 1 auto;
    max-height: 340px;
    margin: clamp(20px, 2vw, 40px) auto 0;
    object-fit: contain;
    object-position: center bottom;
    -webkit-user-drag: none;
    pointer-events: none;
}

/* --- prawa część: formularz --- */
.auth-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
    padding: clamp(20px, 2.6vw, 48px) clamp(8px, 2vw, 32px);
}
.auth-head {
    margin-bottom: clamp(18px, 2vw, 28px);
    text-align: center;
}
.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: clamp(16px, 1.8vw, 26px);
    color: var(--auth-fg);
    font-size: 19px;
    font-weight: 700;
    text-decoration: none;
}
.auth-brand img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    -webkit-user-drag: none;
}
.auth-title {
    margin: 0 0 6px;
    color: var(--auth-fg);
    font-size: clamp(30px, 2.3vw, 44px);
    font-weight: 800;
    line-height: 1.15;
}
.auth-title em {
    font-style: normal;
}
.auth-sub {
    margin: 0;
    color: var(--auth-muted);
    font-size: 15px;
    line-height: 1.5;
}

/* komunikaty */
.auth-msg {
    margin-bottom: var(--auth-gap);
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid;
    font-size: 14px;
    line-height: 1.45;
    text-align: center;
}
.auth-msg--error {
    border-color: rgba(166, 31, 43, 0.7);
    background: rgba(166, 31, 43, 0.18);
    color: #ffc4c9;
}
.auth-msg--info,
.auth-msg--success {
    border-color: rgba(43, 166, 125, 0.55);
    background: rgba(43, 166, 125, 0.13);
    color: #a6f0d2;
}
.auth-msg ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* formularz */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--auth-gap);
    margin: 0;
}
.auth-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--auth-gap);
}
.auth-field {
    position: relative;
}
.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="text"] {
    display: block;
    width: 100%;
    height: var(--auth-field-h);
    margin: 0;
    padding: 0 18px;
    border: 1px solid var(--auth-line);
    border-radius: var(--auth-radius);
    background: var(--auth-field);
    color: var(--auth-fg);
    font: inherit;
    font-size: 16px; /* 16px – iOS nie przybliża strony przy fokusie */
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    box-shadow: none;
    transition: border-color 0.25s ease, background-color 0.25s ease, box-shadow 0.25s ease;
}
.auth-form input::placeholder {
    color: var(--auth-muted);
    opacity: 1;
}
.auth-form input[type="email"]:focus,
.auth-form input[type="password"]:focus,
.auth-form input[type="text"]:focus {
    border-color: var(--ap-blaze);
    background: var(--auth-field-focus);
    box-shadow: 0 0 0 4px rgba(166, 31, 43, 0.22);
}
/* autouzupełnianie (chromium, safari) – bez białego/żółtego tła */
.auth-form input:-webkit-autofill,
.auth-form input:-webkit-autofill:hover,
.auth-form input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--auth-fg);
    -webkit-box-shadow: 0 0 0 1000px var(--auth-autofill) inset;
    caret-color: var(--auth-fg);
    transition: background-color 9999s ease 0s;
}
.auth-field--password input[type="password"],
.auth-field--password input[type="text"] {
    padding-right: 52px;
}
.auth-eye {
    position: absolute;
    top: 50%;
    right: 6px;
    width: 42px;
    height: 42px;
    margin-top: -21px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--auth-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, background-color 0.2s ease;
}
.auth-eye:hover {
    color: var(--auth-fg);
}
.auth-eye:focus-visible {
    outline: 2px solid var(--ap-blaze);
    outline-offset: -2px;
}
.auth-eye svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.auth-eye-off,
.auth-eye[aria-pressed="true"] .auth-eye-on {
    display: none;
}
.auth-eye[aria-pressed="true"] .auth-eye-off {
    display: block;
}

.auth-hint {
    margin: -6px 2px 0;
    color: var(--auth-muted);
    font-size: 13px;
    line-height: 1.4;
}
.auth-forgot {
    align-self: flex-end;
    margin: -4px 2px 2px;
    color: var(--auth-muted);
    font-size: 14px;
    text-decoration: none;
    transition: color 0.2s ease;
}
.auth-forgot:hover,
.auth-forgot:focus-visible {
    color: var(--auth-fg);
}

/* checkbox: natywny input (działa "required"), wygląd własny */
.auth-check {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 2px 0;
    color: var(--auth-muted);
    font-size: 14px;
    line-height: 1.45;
    cursor: pointer;
}
.auth-check input[type="checkbox"] {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin: 0;
    border: 1px solid rgba(242, 242, 242, 0.3);
    border-radius: 6px;
    background: var(--auth-field) center / 14px 14px no-repeat;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}
.auth-check input[type="checkbox"]:checked {
    border-color: var(--ap-blaze);
    background-color: var(--ap-blaze);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='%23F2F2F2' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.auth-check input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--ap-blaze);
    outline-offset: 2px;
}
.auth-check a,
.auth-alt a {
    color: var(--auth-fg);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: rgba(166, 31, 43, 0.9);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    transition: color 0.2s ease;
}
.auth-check a:hover,
.auth-alt a:hover {
    color: #ff8f99;
}

/* przyciski */
.auth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: var(--auth-field-h);
    margin: 4px 0 0;
    padding: 0 20px;
    border: 1px solid var(--ap-blaze);
    border-radius: var(--auth-radius);
    background: var(--ap-blaze);
    color: var(--ap-white);
    font-family: "Poppins", "Urbanist", sans-serif;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: background-color 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}
.auth-btn:hover {
    border-color: var(--ap-dionysus);
    background: var(--ap-dionysus);
    transform: translateY(-1px);
}
.auth-btn:focus-visible {
    outline: 2px solid var(--ap-white);
    outline-offset: 3px;
}
.auth-alt {
    margin: clamp(14px, 1.6vw, 22px) 0 0;
    color: var(--auth-muted);
    font-size: 15px;
    text-align: center;
}

.auth-copy {
    position: fixed;
    left: 14px;
    bottom: 10px;
    margin: 0;
    color: rgba(242, 242, 242, 0.35);
    font-size: 12px;
    pointer-events: none;
}
.auth-copy--version {
    left: auto;
    right: 14px;
}

/* --- duże ekrany 21:9 / 4K --- */
@media (min-width: 2200px) {
    .auth-panel {
        max-width: 560px;
    }
    :root {
        --auth-field-h: 62px;
        --auth-gap: 16px;
    }
    .auth-brand {
        font-size: 22px;
    }
    .auth-sub,
    .auth-alt {
        font-size: 17px;
    }
    .auth-form input[type="email"],
    .auth-form input[type="password"],
    .auth-form input[type="text"] {
        font-size: 18px;
    }
    .auth-btn {
        font-size: 16px;
    }
    .auth-forgot,
    .auth-check,
    .auth-hint {
        font-size: 15px;
    }
}

/* --- tablet / Fold / telefon w poziomie: bez ilustracji, sam formularz --- */
@media (max-width: 900px), (max-height: 560px) {
    .auth-shell {
        grid-template-columns: minmax(0, 1fr);
        max-width: 520px;
        min-height: 0;
        padding: clamp(8px, 3vw, 16px);
    }
    .auth-visual {
        display: none;
    }
}

/* --- telefon: bez karty, formularz na tle --- */
@media (max-width: 560px) {
    .auth {
        align-items: stretch;
        padding: 0;
    }
    .auth-shell {
        border: 0;
        border-radius: 0;
        background: rgba(30, 35, 64, 0.55);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        box-shadow: none;
        padding: 0;
        animation: none;
    }
    .auth-panel {
        padding: max(20px, env(safe-area-inset-top)) 20px max(36px, env(safe-area-inset-bottom));
    }
    .auth-copy {
        left: 20px;
        bottom: max(10px, env(safe-area-inset-bottom));
    }
    .auth-copy--version {
        left: auto;
        right: 20px;
    }
}
@media (max-width: 340px) {
    .auth-row--names {
        grid-template-columns: minmax(0, 1fr);
    }
}
@media (max-width: 480px) {
    .auth-row--passwords {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* --- niskie ekrany: ciaśniej, żeby logowanie i reset mieściły się bez przewijania --- */
@media (max-height: 820px) {
    .auth {
        padding-top: 16px;
        padding-bottom: 16px;
    }
    .auth-shell {
        min-height: 0;
    }
}
@media (max-height: 760px) {
    :root {
        --auth-field-h: 48px;
        --auth-gap: 11px;
    }
    .auth-brand {
        margin-bottom: 12px;
    }
    .auth-brand img {
        width: 36px;
        height: 36px;
    }
    .auth-head {
        margin-bottom: 16px;
    }
    .auth-title {
        font-size: clamp(26px, 2vw, 36px);
    }
}
@media (max-height: 560px) {
    .auth-brand,
    .auth-copy {
        display: none;
    }
    .auth-sub {
        font-size: 14px;
    }
}
/* telefon w poziomie */
@media (max-height: 460px) {
    :root {
        --auth-field-h: 44px;
        --auth-gap: 9px;
    }
    .auth {
        padding-top: 8px;
        padding-bottom: 8px;
    }
    .auth-panel {
        padding-top: 10px;
        padding-bottom: 10px;
    }
    .auth-head {
        margin-bottom: 12px;
    }
    .auth-title {
        font-size: 24px;
    }
    .auth-alt {
        margin-top: 10px;
    }
}
@media (max-height: 380px) {
    .auth-sub {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .aura-blob,
    .auth-shell {
        animation: none;
    }
}

/* =========================================================
   aplikacja mobilna (html.inapp): minimalizm, bez grafik i kart
   ========================================================= */
html.inapp {
    --auth-radius: 14px;
    --auth-field-h: 52px;
}
html.inapp-dark {
    --auth-bg: #000000;
    --auth-fg: #F2F2F2;
    --auth-muted: rgba(242, 242, 242, 0.55);
    --auth-line: rgba(242, 242, 242, 0.22);
    --auth-autofill: #000000;
}
html.inapp-light {
    --auth-bg: #FFFFFF;
    --auth-fg: #1E2340;
    --auth-muted: rgba(30, 35, 64, 0.58);
    --auth-line: rgba(30, 35, 64, 0.2);
    --auth-autofill: #FFFFFF;
}
html.inapp body.auth-body {
    font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
}
html.inapp .auth {
    align-items: center;
    padding: 0;
}
html.inapp .auth-shell {
    display: block;
    max-width: 440px;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: none;
    animation: none;
}
html.inapp .auth-panel {
    max-width: none;
    padding: max(28px, env(safe-area-inset-top)) 24px max(28px, env(safe-area-inset-bottom));
}
html.inapp .auth-head {
    margin-bottom: 32px;
    text-align: left;
}
html.inapp .auth-brand-text {
    margin: 0 0 28px;
    color: var(--auth-muted);
    font-family: "Instrument Serif", Georgia, serif;
    font-size: 20px;
    line-height: 1.2;
}
html.inapp .auth-brand-text em,
html.inapp .auth-title em {
    font-family: "Instrument Serif", Georgia, serif;
    font-style: italic;
    font-weight: 400;
}
html.inapp .auth-title em {
    color: var(--ap-blaze);
    font-size: 1.12em;
}
html.inapp-dark .auth-title em {
    color: #d8434f; /* jaśniejszy blaze – czytelny na czarnym */
}
html.inapp .auth-title {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.02em;
}
html.inapp .auth-sub {
    margin-top: 8px;
}
/* pola: tylko dolna linia */
html.inapp .auth-form input[type="email"],
html.inapp .auth-form input[type="password"],
html.inapp .auth-form input[type="text"] {
    padding: 0 2px;
    border: 0;
    border-bottom: 1px solid var(--auth-line);
    border-radius: 0;
    background: transparent;
}
html.inapp .auth-field--password input[type="password"],
html.inapp .auth-field--password input[type="text"] {
    padding-right: 46px;
}
html.inapp .auth-form input[type="email"]:focus,
html.inapp .auth-form input[type="password"]:focus,
html.inapp .auth-form input[type="text"]:focus {
    border-bottom-color: var(--ap-blaze);
    background: transparent;
    box-shadow: 0 1px 0 0 var(--ap-blaze);
}
html.inapp .auth-eye {
    right: 0;
}
html.inapp .auth-check input[type="checkbox"] {
    border-color: var(--auth-line);
    background-color: transparent;
}
html.inapp .auth-check input[type="checkbox"]:checked {
    border-color: var(--ap-blaze);
    background-color: var(--ap-blaze);
}
html.inapp .auth-check a,
html.inapp .auth-alt a {
    color: var(--auth-fg);
}
html.inapp .auth-btn {
    margin-top: 12px;
    border-radius: 999px;
    font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    letter-spacing: 0.01em;
    text-transform: none;
    box-shadow: none;
}
html.inapp .auth-btn:hover {
    transform: none;
}
html.inapp .auth-btn:active {
    background: var(--ap-dionysus);
    border-color: var(--ap-dionysus);
}
html.inapp .auth-msg {
    text-align: left;
}
html.inapp-light .auth-msg--error {
    color: #8c1a24;
    background: rgba(166, 31, 43, 0.08);
}
html.inapp-light .auth-msg--info,
html.inapp-light .auth-msg--success {
    color: #17694f;
    background: rgba(43, 166, 125, 0.1);
}
html.inapp .auth-copy {
    display: none;
}
@media (max-height: 700px) {
    html.inapp .auth-panel {
        padding-top: max(16px, env(safe-area-inset-top));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
    html.inapp .auth-head {
        margin-bottom: 20px;
    }
    html.inapp .auth-brand-text {
        margin-bottom: 14px;
    }
}
/* telefon w poziomie */
@media (max-height: 460px) {
    html.inapp .auth-panel {
        padding-top: max(10px, env(safe-area-inset-top));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
    html.inapp .auth-brand-text {
        display: none;
    }
    html.inapp .auth-head {
        margin-bottom: 12px;
    }
    html.inapp .auth-title {
        font-size: 26px;
    }
    html.inapp .auth-btn {
        margin-top: 4px;
    }
}
