/* Aegis Key System | Styles (mobile-first) */

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

:root {
    /* Overridden at runtime by THEME in js/config.js */
    --bg: #0a0a0a;
    --card: #141414;
    --border: #2a2a2a;
    --text: #ffffff;
    --muted: #888888;
    --error: #ff5555;

    --border-strong: #444444;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --mono: "Courier New", monospace;
    --ease: 0.2s ease;

    color-scheme: dark;
}

[hidden] {
    display: none !important;
}

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

body {
    min-height: 100vh;
    min-height: 100dvh;
    background-color: var(--bg);
    background-image: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(255, 255, 255, 0.06), transparent 70%);
    background-repeat: no-repeat;
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.clipboard-proxy {
    position: fixed;
    top: 0;
    left: 0;
    opacity: 0;
    pointer-events: none;
}

/* Layout */
.page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 24px 16px;
}

/* Card (subtle glass) */
.card {
    width: 100%;
    max-width: 520px;
    padding: 24px;
    border-radius: 12px;
    background: var(--card);
    background: color-mix(in srgb, var(--card) 82%, transparent);
    border: 1px solid var(--border);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        0 24px 60px rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    animation: card-in 0.5s ease both;
}

@media (min-width: 600px) {
    .card {
        padding: 40px;
    }
}

/* Hero */
.hero {
    text-align: center;
    margin-bottom: 28px;
}

.logo {
    display: block;
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    object-fit: contain;
}

.title {
    font-size: clamp(1.2rem, 5.6vw, 1.9rem);
    font-weight: 800;
    letter-spacing: 0.1em;
    text-indent: 0.1em;
    line-height: 1.15;
    text-wrap: balance;
}

.tagline {
    margin-top: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    text-wrap: balance;
}

.lead {
    max-width: 36ch;
    margin: 18px auto 0;
    color: var(--muted);
    text-wrap: balance;
}

/* Form */
.form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--mono);
    font-size: 16px; /* 16px prevents zoom on iOS */
    letter-spacing: 0.04em;
    transition: border-color var(--ease), box-shadow var(--ease);
}

.form input::placeholder {
    color: var(--muted);
    opacity: 0.8;
}

.form input:focus {
    outline: none;
    border-color: var(--border-strong);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.form input[aria-invalid="true"] {
    border-color: var(--error);
}

.hint {
    margin-top: -4px;
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 48px;
    background: var(--text);
    color: var(--bg);
    border: 0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--ease), transform var(--ease), box-shadow var(--ease);
}

.btn:hover {
    opacity: 0.85;
}

.btn:active {
    transform: scale(0.99);
}

.btn:focus-visible,
.key-box:focus-visible,
.link:focus-visible,
.manual-link:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 3px;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid #b5b5b5;
    border-top-color: #444444;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.btn.is-loading .btn-spinner {
    display: inline-block;
}

/* Status */
.status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 22px;
    margin-top: 16px;
    font-size: 0.875rem;
    text-align: center;
    color: var(--text);
}

.status.is-empty {
    visibility: hidden;
}

.status.is-busy {
    color: var(--muted);
}

.status.is-error {
    color: var(--error);
}

.spinner {
    display: none;
    flex: none;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--muted);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.status.is-busy .spinner {
    display: inline-block;
}

.manual-link {
    display: block;
    margin-top: 6px;
    font-size: 0.8rem;
    text-align: center;
    color: var(--muted);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color var(--ease);
}

.manual-link:hover {
    color: var(--text);
}

/* Section dividers and headings */
.key-section,
.info {
    margin-top: 28px;
    padding-top: 28px;
    border-top: 1px solid var(--border);
}

.section-title {
    margin-bottom: 14px;
    font-size: 1rem;
    font-weight: 700;
}

.key-section .section-title {
    text-align: center;
}

/* Key output */
.key-section {
    animation: reveal 0.35s ease both;
}

.key-box {
    display: block;
    width: 100%;
    padding: 20px 12px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--ease), background-color var(--ease), transform var(--ease);
}

.key-box:hover {
    border-color: #666666;
}

.key-box:active {
    transform: scale(0.99);
}

.key-box.is-copied {
    border-color: var(--text);
}

.key-value {
    font-family: var(--mono);
    font-size: clamp(1.15rem, 5.5vw, 1.75rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    word-break: break-all;
}

.copy-msg {
    min-height: 1.3em;
    margin-top: 10px;
    font-size: 0.8rem;
    text-align: center;
    color: var(--muted);
    transition: color var(--ease);
}

.copy-msg.is-copied {
    color: var(--text);
}

.copy-msg.is-error {
    color: var(--error);
}

.meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.meta-item {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.meta-item dt {
    font-size: 0.75rem;
    color: var(--muted);
}

.meta-item dd {
    margin-top: 2px;
    font-size: 0.875rem;
    font-weight: 600;
}

/* Info */
.steps {
    padding-left: 1.3rem;
    color: var(--muted);
}

.steps li {
    padding-left: 0.3rem;
    margin-bottom: 6px;
}

.steps li::marker {
    color: var(--text);
    font-weight: 600;
}

.link {
    display: inline-block;
    margin-top: 14px;
    color: var(--text);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: opacity var(--ease);
}

.link:hover {
    opacity: 0.7;
}

/* Footer */
.footer {
    font-size: 0.8rem;
    color: var(--muted);
    text-align: center;
}

/* Animations */
@keyframes card-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes reveal {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

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