/* passwordpage.css — layout & structure, theme-independent */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: column;
}

/* ── Top bar ─────────────────────────────────────────────── */

#topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5em 0.75em;
    gap: 0.5em;
    z-index: 10;
}

#instruction {
    /* font-size: clamp(1rem, 3vw, 1.5rem); */
    font-weight: 600;
    opacity: 0.75;
    user-select: none;
    flex: 1 1 auto;
    margin: 0;
    line-height: 1.2;
    padding-left: clamp(1.5rem, 12vw, 7rem);
}

#topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5em;
    flex: 0 0 auto;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.3em;
    opacity: 0.45;
    line-height: 1;
    transition: opacity 0.15s;
    user-select: none;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn svg {
    width: 1.5rem;
    height: 1.5rem;
    display: block;
    flex-shrink: 0;
}

.icon-btn:hover {
    opacity: 0.9;
}

@media (max-width: 600px) {
    .icon-btn {
        padding: 0.4em;
        opacity: 0.6;
    }

    .icon-btn svg {
        width: 1.8rem;
        height: 1.8rem;
    }

    #topbar {
        padding: 0.6em 0.75em;
    }

    #topbar-actions {
        gap: 0.75em;
    }

    #instruction {
        font-size: 15px;
    }
}

/* ── Character grid ──────────────────────────────────────── */

#charfield-wrapper {
    flex: 1 1 auto;
    overflow: hidden;
    padding: 0 0.75em 0.75em;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

#matrix-rain {
    position: absolute;
    pointer-events: none;
    z-index: 1;
}

#charfield {
    flex: 1 1 auto;
    overflow: hidden;
    cursor: crosshair;
    user-select: none;
    -webkit-user-select: none;
    padding: 0.5em;
    line-height: 1.55;
    word-break: break-all;
    white-space: pre-wrap;
    font-family: 'JetBrains Mono', monospace;
}

/* Pulse applied to a span wrapping the selected chars */
.pwd-pulse {
    border-radius: 3px;
    animation: pulse-glow 1.8s ease-out forwards;
}

@keyframes pulse-glow {
    0%   { background-color: var(--pulse-color); }
    60%  { background-color: var(--pulse-color); }
    100% { background-color: transparent; }
}

/* Demo animation — gentle continuous pulse */
.demo-pulse {
    border-radius: 3px;
    animation: demo-glow 3s ease-in-out forwards;
}

@keyframes demo-glow {
    0%   { background-color: transparent; }
    20%  { background-color: var(--pulse-color); }
    65%  { background-color: var(--pulse-color); }
    100% { background-color: transparent; }
}

/* ── Toast ───────────────────────────────────────────────── */

#toast {
    position: fixed;
    bottom: 2em;
    left: 50%;
    transform: translateX(-50%) translateY(2em);
    padding: 0.6em 1.8em;
    border-radius: 6px;
    font-size: clamp(1rem, 3vw, 1.2rem);
    font-weight: 600;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    white-space: nowrap;
    z-index: 100;
}

#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Settings modal ──────────────────────────────────────── */

#modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    align-items: center;
    justify-content: center;
}

#modal-overlay.open {
    display: flex;
}

#modal {
    border-radius: 6px;
    padding: 1.5em;
    width: min(340px, 90vw);
    font-size: clamp(0.8rem, 2.5vw, 0.95rem);
}

#modal h2 {
    font-size: 1em;
    margin-bottom: 1em;
    letter-spacing: 0.05em;
}

.setting-group {
    margin-bottom: 1.25em;
}

.setting-group label.group-label {
    display: block;
    font-size: 0.8em;
    opacity: 0.6;
    margin-bottom: 0.5em;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Radio options */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.35em;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 0.5em;
    cursor: pointer;
}

.radio-group input[type="radio"] {
    accent-color: var(--accent-color);
}

.charset-preview { opacity: 0.7; }

/* Slider */
.slider-row {
    display: flex;
    align-items: center;
    gap: 0.75em;
}

#length-slider {
    flex: 1;
    accent-color: var(--accent-color);
}

#length-display {
    min-width: 2.5em;
    text-align: right;
    opacity: 0.8;
}

.slider-hint {
    font-size: 0.75em;
    opacity: 0.45;
    margin-top: 0.35em;
}

/* Theme swatches — 2-column scrollable grid */
.theme-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4em;
    max-height: 13em;
    overflow-y: auto;
}

.theme-btn {
    padding: 0.45em 0.6em;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    border: 2px solid transparent;
    transition: opacity 0.15s;
    text-align: left;
    opacity: 0.85;
}

.theme-btn:hover { opacity: 1; }

.theme-btn.active {
    outline: 2px solid currentColor;
    outline-offset: 2px;
    opacity: 1;
}

/* Swatch colours — previews of each theme regardless of current theme */
.theme-btn[data-theme="parchment"] { background: #f5efe0; color: #3d2f1e; }
.theme-btn[data-theme="mist"]      { background: #e8edf3; color: #1e2d3d; }
.theme-btn[data-theme="lavender"]  { background: #f0ecf8; color: #2d1b5e; }
.theme-btn[data-theme="sand"]      { background: #f2e8d0; color: #4a3520; }
.theme-btn[data-theme="rose"]      { background: #fdf0f0; color: #5c2a2a; }
.theme-btn[data-theme="sage"]      { background: #eaf2ea; color: #1e3a1e; }
.theme-btn[data-theme="midnight"]  { background: #0d1117; color: #c9d1d9; }
.theme-btn[data-theme="ember"]     { background: #1c1008; color: #e8c97a; }
.theme-btn[data-theme="neon"]      { background: #03080f; color: #00e5ff; }
.theme-btn[data-theme="matrix"]    { background: #0d0d0d; color: #00ff41; }

/* ── How-it-works & FAQ modals ───────────────────────────── */

#howto-overlay,
#faq-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    align-items: center;
    justify-content: center;
}

#howto-overlay.open,
#faq-overlay.open {
    display: flex;
}

#howto-modal,
#faq-modal {
    border-radius: 6px;
    padding: 1.5em;
    font-size: clamp(0.8rem, 2.5vw, 0.95rem);
    max-height: 85vh;
    overflow-y: auto;
}

#howto-modal { width: min(380px, 92vw); }
#faq-modal   { width: min(520px, 92vw); }

#howto-modal h2,
#faq-modal h2 {
    font-size: 1em;
    margin-bottom: 1em;
    letter-spacing: 0.05em;
}

.info-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65em;
}

.info-list li {
    display: flex;
    gap: 0.6em;
    line-height: 1.45;
}

.info-list .info-icon {
    flex: 0 0 auto;
    opacity: 0.6;
}

.faq-list {
    margin: 0;
    padding: 0;
}

.faq-list dt {
    font-weight: 600;
    margin-top: 0.9em;
    line-height: 1.3;
}

.faq-list dt:first-child {
    margin-top: 0;
}

.faq-list dd {
    margin: 0.25em 0 0 0;
    opacity: 0.8;
    line-height: 1.5;
}

.faq-privacy {
    margin-top: 1.1em;
    padding-top: 1em;
    border-top: 1px solid currentColor;
    opacity: 0.6;
}

.faq-privacy h3 {
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.4em;
}

.faq-privacy p {
    font-size: 0.85em;
    line-height: 1.5;
}

.settings-privacy-note {
    font-size: 0.75em;
    opacity: 0.45;
    margin-top: 1em;
    line-height: 1.4;
    text-align: center;
}

/* ── PWA install banner ──────────────────────────────────── */

#install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 0.75em;
    padding: 0.75em 1em;
    z-index: 200;
    font-size: clamp(0.8rem, 3vw, 0.9rem);
    background: var(--modal-bg);
    color: var(--text);
    border-top: 1px solid var(--topbar-border);
    box-shadow: 0 -2px 10px var(--modal-shadow);
}

#install-banner span {
    flex: 1;
    line-height: 1.4;
}

#install-btn {
    padding: 0.4em 1em;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    white-space: nowrap;
    background: var(--accent-color);
    color: var(--modal-bg);
    flex: 0 0 auto;
}

#install-btn:hover { opacity: 0.85; }

#install-dismiss {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.2em 0.3em;
    opacity: 0.5;
    flex: 0 0 auto;
    color: var(--text);
    line-height: 1;
}

#install-dismiss:hover { opacity: 1; }

/* ── Close buttons ───────────────────────────────────────── */

#howto-close,
#faq-close,
#modal-close {
    margin-top: 1.25em;
    width: 100%;
    padding: 0.5em;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    border: none;
}
