/* ─────────────────────────────────────────
   AMW Simple Login — v1.2.0
   alvaromarquezweb.com

   FONTS: system-ui, no external load.
   The browser uses the operating system font
   (San Francisco on macOS/iOS, Segoe UI on Windows,
   Roboto on Android/Chrome OS).

   COLORS: every variable is injected from PHP
   (amw_login_dynamic_styles). The :root values are
   only a safety fallback.

   Derived tones (focus, errors, background tint) are
   computed with color-mix from --amw-text, so the
   screen works the same with a light or dark palette.
   Each rule ships a plain declaration first as a fallback
   for browsers without color-mix support.
───────────────────────────────────────── */

/* ── Variables (fallback: overridden from PHP) ── */
:root {
    --amw-bg:           #0a0a0a;
    --amw-surface:      #141414;
    --amw-surface-alt:  #1c1c1c;
    --amw-input-bg:     #1c1c1c;
    --amw-border:       #2a2a2a;
    --amw-text:         #fafafa;
    --amw-text-muted:   #888888;
    --amw-accent:       #fafafa;
    --amw-accent-fg:    #0a0a0a;
    --amw-error:        #c0392b;
    --amw-radius:       8px;
    /* Field and button radius: derived from the main one and capped at 10px,
       so large radii do not turn the whole box into pills. */
    --amw-radius-field: min(var(--amw-radius), 10px);
    --amw-logo-width:   160px;
    --amw-logo-height:  60px;
    /* Form-column width used by the left/right two-column layout. */
    --amw-col:          480px;
    --amw-font:         system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ── Base reset ── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* ── Page ── */
html {
    height: 100%;
}

body.login {
    height: 100%;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    /* Base background: solid colour, gradient, or (for an image) the panel
       colour, all fed from PHP. Falls back to the palette page colour.
       !important so it beats the core wp-login background. */
    background: var(--amw-page-bg, var(--amw-bg)) !important;
    font-family: var(--amw-font);
    position: relative;
}

/* ── Main container, centered with transform ── */
body.login #login {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 340px;
    max-width: calc(100vw - 32px);
    padding: 0;
}

body.login #login > * {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* ── Logo ──
   Image replacement using the "Phark" method: the text stays
   in the accessibility tree (screen readers read the site name)
   but is not visible. */
.login h1 {
    text-align: center;
    margin: 0 0 8px;
    padding: 0;
    line-height: 0;
}

.login h1 a {
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    width: var(--amw-logo-width);
    height: var(--amw-logo-height);
    display: block;
    margin: 0 auto;
    outline-offset: 4px;
    text-indent: 100%;
    white-space: nowrap;
    overflow: hidden;
}

/* Hide the "Log In" / page title WP prints outside #login */
.login #login_header,
.login .login-header,
body.login > h1:first-of-type {
    display: none !important;
}

/* ── Form box ── */
#loginform,
#lostpasswordform,
#registerform {
    background: var(--amw-surface);
    border: 1px solid var(--amw-border);
    border-radius: var(--amw-radius);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
    box-shadow: var(--amw-shadow, 0 24px 64px rgba(0, 0, 0, 0.35));
    padding: 32px 36px;
    margin-top: 16px;
    box-sizing: border-box;
    width: 100%;
}

/* ── Labels ── */
.login label {
    color: var(--amw-text-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    display: block;
    margin-bottom: 4px;
}

/* ── Inputs ── */
.login input[type="text"],
.login input[type="password"],
.login input[type="email"] {
    background-color: var(--amw-input-bg) !important;
    border: 1px solid var(--amw-border) !important;
    border-radius: var(--amw-radius-field) !important;
    color: var(--amw-text) !important;
    font-family: var(--amw-font);
    font-size: 14px;
    padding: 10px 14px;
    box-shadow: none !important;
    transition: border-color 0.2s ease;
    width: 100%;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.login input[type="text"]:focus,
.login input[type="password"]:focus,
.login input[type="email"]:focus {
    border-color: color-mix(in srgb, var(--amw-text) 40%, var(--amw-border)) !important;
    border-color: var(--amw-focus, color-mix(in srgb, var(--amw-text) 40%, var(--amw-border))) !important;
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--amw-text) 8%, transparent) !important;
    box-shadow: 0 0 0 3px var(--amw-focus-ring, color-mix(in srgb, var(--amw-text) 8%, transparent)) !important;
}

/* ── "Remember me" checkbox ── */
.login .forgetmenot {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 10px;
}

.login .forgetmenot label {
    color: var(--amw-text-muted);
    font-size: 12px;
    letter-spacing: normal;
    text-transform: none;
    font-weight: 400;
    margin-bottom: 0;
}

.login input[type="checkbox"] {
    -webkit-appearance: checkbox;
    appearance: checkbox;
    accent-color: var(--amw-accent);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ── Primary button ── */
.login .button-primary,
.login #wp-submit {
    background: var(--amw-accent) !important;
    border: none !important;
    border-radius: var(--amw-radius-field) !important;
    color: var(--amw-accent-fg) !important;
    font-family: var(--amw-font);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 11px 0;
    width: 100%;
    cursor: pointer;
    box-shadow: none !important;
    transition: opacity 0.2s ease, transform 0.1s ease;
    display: block;
}

.login .button-primary:hover,
.login #wp-submit:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

.login .button-primary:active,
.login #wp-submit:active {
    transform: translateY(0);
}

/* ── Nav links ── */
.login #nav a,
.login #backtoblog a {
    color: var(--amw-text-muted);
    font-size: 12px;
    text-decoration: none;
    transition: color 0.2s;
}

.login #nav a:hover,
.login #backtoblog a:hover {
    color: var(--amw-text);
}

.login #nav,
.login #backtoblog {
    text-align: center;
    margin-top: 16px;
}

/* ── Keyboard focus visible ── */
.login h1 a:focus-visible,
.login #nav a:focus-visible,
.login #backtoblog a:focus-visible,
.login #wp-submit:focus-visible {
    outline: 2px solid var(--amw-accent);
    outline-offset: 3px;
    border-radius: 2px;
}

/* ── Error messages ── */
.login #login_error {
    background: var(--amw-surface-alt);
    background: color-mix(in srgb, var(--amw-error) 12%, var(--amw-surface));
    border-left: 3px solid var(--amw-error);
    border-radius: var(--amw-radius-field);
    color: var(--amw-error);
    color: color-mix(in srgb, var(--amw-error) 55%, var(--amw-text));
    font-size: 13px;
    padding: 12px 16px;
    margin-bottom: 16px;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* ── Success / notice messages ── */
.login .message,
.login .success {
    background: var(--amw-surface-alt);
    border-left: 3px solid var(--amw-text-muted);
    border-left-color: color-mix(in srgb, var(--amw-text) 40%, var(--amw-border));
    border-radius: var(--amw-radius-field);
    color: var(--amw-text-muted);
    font-size: 13px;
    padding: 12px 16px;
    margin-bottom: 16px;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* ── Password toggle (WP 5.8+) ── */
.login .wp-pwd {
    position: relative;
}

.login .wp-pwd button.button {
    background: transparent;
    border: none;
    color: var(--amw-text-muted);
    box-shadow: none;
    padding: 0 4px;
}

.login .wp-pwd button.button:hover {
    color: var(--amw-text);
    background: transparent;
    box-shadow: none;
}

.login .wp-pwd button .dashicons {
    color: inherit;
    fill: currentColor;
}

/* ── Optional heading above the form ── */
.login .amw-heading {
    text-align: center;
    color: var(--amw-text);
    font-family: var(--amw-font);
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 16px;
    padding: 0;
}

/* ── Legal links ──
   login_footer prints the <p> OUTSIDE #login, so it is positioned absolutely. */
.amw-legal-links {
    position: absolute;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    width: 340px;
    max-width: calc(100vw - 32px);
    margin: 0;
    text-align: center;
    font-family: var(--amw-font);
    font-size: 11px;
    color: var(--amw-text-muted);
}
.amw-legal-links a {
    color: var(--amw-text-muted);
    text-decoration: none;
    transition: color 0.2s;
}
.amw-legal-links a:hover { color: var(--amw-text); }
.amw-legal-links a:focus-visible {
    outline: 2px solid var(--amw-accent);
    outline-offset: 3px;
    border-radius: 2px;
}

/* ── Hidden nav links (toggled by body classes set in PHP) ── */
body.login.amw-hide-backtoblog #backtoblog { display: none !important; }
body.login.amw-hide-forgotpw #nav { display: none !important; }

/* ── Background layers: position, side panel and image ──
   Structure is static and lives here; PHP only feeds the CSS variables and the
   body classes (amw-pos-*, amw-has-panel, amw-has-image). */

/* Side panel (left/right): opaque strip behind the form. */
body.login.amw-has-panel::after {
    content: "";
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: -1;
    background: var(--amw-panel);
}
body.login.amw-pos-left.amw-has-panel::after  { left: 0; width: var(--amw-col); }
body.login.amw-pos-right.amw-has-panel::after { right: 0; left: auto; width: var(--amw-col); }

/* Form and legal links horizontal position. */
body.login.amw-pos-left #login,
body.login.amw-pos-left .amw-legal-links  { left: calc(var(--amw-col) / 2); }
body.login.amw-pos-right #login,
body.login.amw-pos-right .amw-legal-links { left: calc(100% - var(--amw-col) / 2); }

/* Image background: opposite side in left/right, full in center. */
body.login.amw-has-image::before {
    content: "";
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: -2;
    background: var(--amw-overlay), var(--amw-bg-image);
    background-size: cover;
    background-position: center;
    filter: blur(var(--amw-blur, 0px));
    /* Slight oversize so the blur does not leave a halo at the edges. */
    transform: scale(1.06);
}
body.login.amw-pos-left.amw-has-image::before   { left: var(--amw-col); right: 0; }
body.login.amw-pos-right.amw-has-image::before  { left: 0; right: var(--amw-col); }
body.login.amw-pos-center.amw-has-image::before { left: 0; right: 0; }

/* Mobile: single column, no panel; image (if any) full width. */
@media (max-width: 782px) {
    body.login.amw-has-image::before { left: 0 !important; right: 0 !important; }
    body.login.amw-has-panel::after  { display: none !important; }
    body.login #login,
    body.login .amw-legal-links { left: 50% !important; }
}

/* ── Responsive ── */
@media (max-width: 360px) {
    #loginform,
    #lostpasswordform,
    #registerform {
        padding: 24px 20px;
    }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    .login .button-primary,
    .login #wp-submit,
    .login #nav a,
    .login #backtoblog a,
    .login input[type="text"],
    .login input[type="password"],
    .login input[type="email"] {
        transition: none;
    }

    .login .button-primary:hover,
    .login #wp-submit:hover {
        transform: none;
    }
}