/* Strona logowania: terminal VS Code ze stonowanymi efektami (zmienne --vsc-* z main.css) */

body.login {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 16px 38px;
    overflow: hidden;
    background: var(--vsc-chrome);
}

/* ---------- Tło: poświaty, siatka punktów, przewijany kod ---------- */

.login-backdrop {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.login-glow {
    position: absolute;
    width: 60vmax;
    height: 60vmax;
    border-radius: 50%;
    filter: blur(90px);
    animation: glow-drift 26s ease-in-out infinite alternate;
}

.login-glow-blue {
    top: -22vmax;
    left: -18vmax;
    background: var(--vsc-accent);
    opacity: 0.16;
}

.login-glow-orange {
    right: -22vmax;
    bottom: -26vmax;
    background: #f48771;
    opacity: 0.09;
    animation-delay: -13s;
}

@keyframes glow-drift {
    to { transform: translate(9vmax, 7vmax) scale(1.12); }
}

.login-grid {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
    background-size: 24px 24px;
    -webkit-mask-image: radial-gradient(ellipse at center, #000 25%, transparent 75%);
    mask-image: radial-gradient(ellipse at center, #000 25%, transparent 75%);
}

.login-code-wrap {
    position: absolute;
    inset: 0;
    -webkit-mask-image: linear-gradient(transparent, #000 25%, #000 75%, transparent);
    mask-image: linear-gradient(transparent, #000 25%, #000 75%, transparent);
}

/* Treść to dwie identyczne połowy, więc przesunięcie o -50% zapętla się bez skoku */
.login-code {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    margin: 0;
    padding: 0 6vw;
    color: rgba(204, 204, 204, 0.06);
    font: 13px/1.9 var(--vsc-font-mono);
    white-space: pre;
    animation: code-scroll 90s linear infinite;
}

@keyframes code-scroll {
    to { transform: translateY(-50%); }
}

/* ---------- Okno terminala ---------- */

@property --edge-angle {
    syntax: '<angle>';
    inherits: false;
    initial-value: 0deg;
}

.terminal {
    position: relative;
    width: min(640px, 100%);
    background: var(--vsc-editor);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
    animation: terminal-in 0.6s ease-out both;
}

/* Krawędź z wolno obiegającym blaskiem */
.terminal::before {
    content: '';
    position: absolute;
    inset: -1px;
    padding: 1px;
    border-radius: 9px;
    background: conic-gradient(from var(--edge-angle), var(--vsc-border) 0 62%, var(--vsc-accent) 76%, #f48771 86%, var(--vsc-border) 100%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: edge-spin 9s linear infinite;
    pointer-events: none;
}

@keyframes edge-spin {
    to { --edge-angle: 360deg; }
}

@keyframes terminal-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
}

.terminal-header {
    display: flex;
    align-items: center;
    gap: 20px;
    height: 35px;
    padding: 0 16px;
    border-bottom: 1px solid var(--vsc-border);
    color: var(--vsc-fg-muted);
    font-size: 11px;
    text-transform: uppercase;
    user-select: none;
}

.terminal-header .active {
    display: flex;
    align-items: center;
    height: 100%;
    color: #e7e7e7;
    box-shadow: inset 0 -1px 0 var(--vsc-accent);
}

.terminal-shell {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    text-transform: none;
}

.terminal-shell .codicon {
    font-size: 14px;
}

.terminal-body {
    min-height: 150px;
    max-height: 260px;
    overflow-y: auto;
    padding: 16px 18px 22px;
    color: var(--vsc-fg);
    font: 14px/1.8 var(--vsc-font-mono);
}

#terminal-log {
    white-space: pre-wrap;
}

.prompt-user { color: #89d185; }
.prompt-path { color: var(--vsc-link); }

.typed-cursor {
    display: inline-block;
    width: 8px;
    height: 1.1em;
    margin-left: 1px;
    vertical-align: text-bottom;
    background: #aeafad;
    animation: cursor-blink 1s steps(1) infinite;
}

.terminal.ready .typed-cursor {
    display: none;
}

/* Złe hasło: komunikaty jak w ssh, nowe linie dopisują się kolejno, okno krótko drży */
.terminal-error {
    color: #f48771;
}

.terminal-warning {
    color: #cca700;
}

.terminal-timer {
    color: var(--vsc-fg-strong);
}

.line-new {
    animation: line-in 0.35s ease-out both;
}

@keyframes line-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
}

.terminal.denied {
    animation: terminal-shake 0.45s ease-in-out;
}

@keyframes terminal-shake {
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* Blokada po 3 próbach: czerwona krawędź, bez monitu o hasło */
.terminal.locked {
    animation: terminal-shake 0.45s ease-in-out 1.2s;
}

.terminal.locked::before {
    background: conic-gradient(from var(--edge-angle), #5a1d1d 0 55%, #f48771 75%, #be1100 88%, #5a1d1d 100%);
}

.terminal.locked .password-line {
    display: none;
}

/* Poprawne hasło: powitanie, zielona krawędź po połączeniu, terminal "otwiera" VS Code */
.terminal-success {
    color: #89d185;
}

.terminal-muted {
    color: var(--vsc-fg-muted);
}

.terminal.welcome .password-line {
    display: none;
}

.terminal.connected::before {
    background: conic-gradient(from var(--edge-angle), #1e3a26 0 50%, #89d185 70%, var(--vsc-accent) 85%, #1e3a26 100%);
}

body.launching .terminal {
    opacity: 0;
    transform: scale(1.06);
    filter: blur(2px);
    transition: opacity 0.6s ease-in, transform 0.6s ease-in, filter 0.6s ease-in;
}

body.launching .login-backdrop,
body.launching .login-statusbar {
    opacity: 0;
    transition: opacity 0.6s ease-in;
}

.login-statusbar #error-count {
    font-weight: 400;
}

.login-statusbar #error-count.has-errors {
    color: #f48771;
}

.login-statusbar .statusbar-remote.locked {
    background: #be1100;
}

@keyframes cursor-blink {
    50% { opacity: 0; }
}

.password-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.3s, transform 0.3s;
}

.terminal.ready .password-line {
    opacity: 1;
    transform: none;
}

.terminal input[type="password"] {
    flex: 1;
    min-width: 120px;
    padding: 0;
    background: transparent;
    border: 0;
    color: var(--vsc-fg-strong);
    font: inherit;
    letter-spacing: 3px;
    caret-color: #f48771;
}

.terminal input[type="password"]:focus {
    outline: none;
    border: 0;
}

/* Hasło z menedżera haseł: przeglądarka daje polu jasne tło i ciemny tekst (:autofill).
   Tła nie da się nadpisać wprost, więc jego zmiana trwa „wieczność”, a kolor tekstu wymuszamy. */
.terminal input[type="password"]:-webkit-autofill,
.terminal input[type="password"]:-webkit-autofill:hover,
.terminal input[type="password"]:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--vsc-fg-strong);
    caret-color: #f48771;
    transition: background-color 600000s 0s, color 600000s 0s;
}

.terminal input[type="password"]:autofill {
    filter: none;
}

.terminal-enter {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    background: transparent;
    border: 1px solid var(--vsc-input-border);
    border-radius: 3px;
    color: var(--vsc-fg-muted);
    font: 11px/20px var(--vsc-font-ui);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.terminal-enter .codicon {
    font-size: 12px;
}

.terminal-enter:hover,
.terminal-enter:focus-visible {
    color: #f48771;
    border-color: #f48771;
    outline: none;
}

/* ---------- Pasek statusu ---------- */

.login-statusbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    height: 22px;
    background: var(--vsc-chrome);
    border-top: 1px solid var(--vsc-border);
    color: var(--vsc-fg);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    user-select: none;
}

.login-statusbar > div {
    display: flex;
}

.login-statusbar > div > span,
.login-statusbar .statusbar-link {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
}

.login-statusbar .statusbar-link {
    color: inherit;
    text-decoration: none;
    user-select: auto;
}

.login-statusbar .statusbar-link:hover {
    background: rgba(241, 241, 241, 0.2);
}

.login-statusbar .codicon {
    font-size: 14px;
}

.login-statusbar .statusbar-remote {
    padding: 0 10px;
    background: var(--vsc-accent);
    color: var(--vsc-fg-strong);
}

@media (max-width: 600px) {
    .terminal-header .optional,
    .login-statusbar .optional {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .login-glow,
    .login-code,
    .terminal,
    .terminal.denied,
    .terminal.locked,
    .terminal::before,
    .typed-cursor,
    .line-new {
        animation: none;
    }
}
