/* === CSS Custom Properties === */
:root {
    --accent: #0077b6;
    --accent-glow: rgba(0, 80, 220, 0.3);
    --accent-readable: #0077b6;
    --bg: #0a0a0f;
    --surface: rgba(255, 255, 255, 0.04);
    --surface-hover: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --text-primary: #e4e4e7;
    --text-secondary: #8a8a94;
    --shadow: rgba(0, 0, 0, 0.3);
}

/* === Animations === */
@keyframes meshShift {
    0%, 100% {
        background-position: 0% 50%;
    }
    25% {
        background-position: 50% 0%;
    }
    50% {
        background-position: 100% 50%;
    }
    75% {
        background-position: 50% 100%;
    }
}

@keyframes meshGlow {
    0%, 100% {
        opacity: 0.4;
    }
    50% {
        opacity: 0.7;
    }
}

@keyframes reveal {
    from {
        opacity: 0.9;
        filter: blur(1px);
    }
    to {
        opacity: 1;
        filter: blur(0);
    }
}

/* === Base === */
body {
    background: var(--bg);
    color: var(--text-primary);
    text-align: center;
    font-family: monospace;
    transition: color .3s ease-out;
    padding-top: 1px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    margin: 0;
    position: relative;
    overflow-x: hidden;
}

/* Mesh gradient background */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(ellipse 80% 60% at 20% 40%, var(--accent-glow), transparent),
        radial-gradient(ellipse 60% 80% at 80% 20%, rgba(0, 102, 255, 0.12), transparent),
        radial-gradient(ellipse 70% 50% at 50% 80%, rgba(255, 51, 102, 0.08), transparent);
    animation: meshShift 60s ease-in-out infinite, meshGlow 30s ease-in-out infinite;
    background-size: 200% 200%;
    transition: opacity 2s ease-out;
}

/* Noise overlay */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
    pointer-events: none;
}

main { flex: 1; }

main, footer {
    width: calc(94% - 32px);
    margin-left: auto;
    margin-right: auto;
}

/* === Brand === */
.brand-logo {
    display: block;
    height: 24px;
    width: auto;
    margin: 0 auto 0.5rem;
    user-select: none;
    pointer-events: none;
    filter: invert(1);
    transition: filter .3s ease-out;
}

/* === Input Labels === */
.input-label {
    position: absolute;
    top: -1.4rem;
    left: 0.25rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    pointer-events: none;
    cursor: default;
    line-height: 1;
}

/* === Controls === */
.controls {
    display: flex;
    height: 5rem;
    width: 100%;
    margin: 2.5rem 0 2.5rem;
    gap: 1rem;
}

.input-wrapper {
    position: relative;
    height: 100%;
    display: flex;
}

input, button {
    background: var(--surface);
    height: 100%;
    text-align: center;
    transition: background .2s ease-out, border-color .2s ease-out, color .2s ease-out, box-shadow .2s ease-out;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

button {
    user-select: none;
    cursor: pointer;
}

button:active {
    transform: scale(0.97);
}

/* Reset Button Styles */
.reset-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    height: auto;
    width: auto;
    background: transparent;
    box-shadow: none;
    border: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding-left: 1rem;
    padding-right: 1rem;
    padding-top: 0.3rem;
    padding-bottom: 0.5rem;
    font-size: 1.8em;
    line-height: 1;
    color: var(--text-secondary);
    opacity: 0.5;
    border-radius: 8px;
    z-index: 5;
}

.reset-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    opacity: 1;
    color: var(--text-primary);
}

.reset-btn:active {
    transform: translateY(-50%) scale(0.93);
}

.chars-wrapper { width: 60%; }
.length-wrapper { width: 20%; }
#new { width: 20%; }

#chars, #length {
    width: 100%;
    padding: 0 1.5rem;
    padding-right: 3.5rem;
    text-overflow: ellipsis;
    font-size: 1.8em;
    box-sizing: border-box;
    font-family: monospace;
}

#new {
    font-size: 1.8em;
    text-transform: uppercase;
    text-decoration: none;
    font-weight: 700;
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(0, 255, 204, 0.05);
    transition: all .2s ease-out;
}

#new:hover {
    background: rgba(0, 255, 204, 0.12);
}

input:hover, button:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
}

input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* === Status / Complexity === */
#status {
    margin: 1rem 0;
}

#complexity {
    font-size: 5vmin;
    font-weight: 700;
    text-transform: uppercase;
    display: block;
    margin-top: 0.5rem;
    color: var(--accent);
    user-select: none;
    transition: color .3s ease-out;
}

/* === Password Result === */
#result {
    margin: 1.5rem 0 3rem;
    word-wrap: break-word;
    text-rendering: optimizeLegibility;
    outline: 0;
    display: block;
    width: 100%;
    font-size: 76px;
    font-size: 8.5vmin;
    font-weight: 700;
    box-sizing: border-box;
    transition: color .3s ease-out, background .2s ease-out;
    cursor: text;
    border-radius: 12px;
    padding: 0.5rem;
}

#result:hover {
    background: var(--surface);
}

#result:focus {
    background: var(--surface);
}

#result.fresh {
    animation: reveal 0.11s ease-out;
}

/* === Copy Button === */
#copyBtn {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1.3em;
    margin-top: 1rem;
    position: relative;
    z-index: 10;
    margin-bottom: 1.5rem;
    border-color: var(--border);
}

#copyBtn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

#copyBtn.copied {
    border-color: var(--accent);
    color: var(--accent);
}

/* === Trust Line === */
.trust-line {
    color: var(--text-secondary);
    font-size: 1em;
    letter-spacing: 0.03em;
    margin-bottom: 3rem;
    user-select: none;
}

/* === Links === */
a { color: var(--text-secondary); text-decoration: none; border-bottom: 1px dashed var(--text-secondary); }
a:hover { border-bottom-style: solid; color: var(--text-primary); }

/* === Misc === */
.input-label,
label {
    font-size: 0.7rem;
    line-height: 1;
}

::placeholder { opacity: 1; color: var(--text-secondary); text-overflow: ellipsis; }
input[type="number"] { appearance: textfield; }

::selection { background: rgba(255, 255, 255, .15); }

/* === Footer === */
footer {
    padding: 2rem 0;
    margin-top: auto;
    font-size: 1em;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
}

footer nav {
    margin-top: 0.5rem;
}

footer nav a {
    margin: 0 0.5rem;
}

/* === Theme Toggle === */
#themeToggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border-hover);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 200;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

#themeToggle:hover {
    transform: scale(1.08);
    border-color: var(--text-secondary);
}

/* === Light Mode === */
html.light {
    --bg: #f5f5f7;
    --surface: rgba(0, 0, 0, 0.03);
    --surface-hover: rgba(0, 0, 0, 0.06);
    --border: rgba(0, 0, 0, 0.1);
    --border-hover: rgba(0, 0, 0, 0.18);
    --text-primary: #1a1a2e;
    --text-secondary: #6b6b80;
    --shadow: rgba(0, 0, 0, 0.08);
}

html.light body::before {
    opacity: 0.5;
}

html.light ::selection { background: rgba(0, 0, 0, .1); }

html.light .reset-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

html.light #complexity {
    color: var(--accent-readable);
}

html.light .brand-logo {
    filter: none;
}

html.light #new {
    border-color: var(--accent-readable);
    color: var(--accent-readable);
    background: var(--surface);
}

html.light #new:hover {
    background: var(--surface-hover);
}

html.light input:focus {
    border-color: var(--accent-readable);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

html.light #copyBtn:hover,
html.light #copyBtn.copied {
    border-color: var(--accent-readable);
    color: var(--accent-readable);
}

/* === Desktop === */
@media (min-width: 701px) {
    .brand-logo {
        margin-bottom: 1rem;
    }
}

/* === Mobile === */
@media (max-width: 700px) {
    .controls {
        flex-wrap: wrap;
        height: auto;
        gap: 0.8rem;
        padding: 0;
        box-shadow: none;
    }

    .chars-wrapper { width: 100%; height: 4rem; order: 1; }
    .length-wrapper { width: 100%; height: 4rem; order: 2; }

    .input-label {
        top: -1.2rem;
    }

    #result {
        margin: 1.5rem 0 2.5rem;
    }

    #copyBtn {
        font-size: 1.2rem;
        margin-top: 0;
    }

    #new {
        position: fixed;
        bottom: 2rem;
        right: 2rem;
        width: auto;
        height: auto;
        padding: 12px 24px;
        font-size: 1.2rem;
        z-index: 100;
        background: var(--accent);
        color: var(--bg);
        box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
        border-radius: 50px;
        border-color: transparent;
        font-weight: 700;
    }

    html.light #new {
        background: var(--accent-readable);
        color: #fff;
        border-color: transparent;
    }

    html.light #new:hover {
        background: var(--accent-readable);
    }

    #new:hover {
        background: var(--accent);
    }

    #themeToggle {
        right: auto;
        left: 2rem;
    }

    footer {
        padding-bottom: 7rem;
    }

    footer nav {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
        margin-top: 1rem;
    }

    footer nav .nav-divider {
        display: none;
    }

    .trust-line {
        margin-bottom: 2rem;
    }
}

/* === Reduced Motion === */
/*@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}*/
