/* ============================================================
   n-Qubit States Classifier — modern UI stylesheet
   ============================================================ */

:root {
    --bg-0: #eef1fb;
    --bg-1: #e6e9f7;
    --surface: rgba(255, 255, 255, 0.72);
    --surface-solid: #ffffff;
    --border: rgba(99, 102, 241, 0.16);
    --border-strong: rgba(99, 102, 241, 0.34);
    --text: #1a1c2e;
    --text-soft: #4b4f6b;
    --text-muted: #7c8099;
    --accent: #6366f1;
    --accent-2: #8b5cf6;
    --accent-3: #06b6d4;
    --accent-ink: #4338ca;
    --success: #0f9d76;
    --danger: #e5484d;
    --shadow: 0 20px 50px -24px rgba(49, 46, 129, 0.45);
    --shadow-sm: 0 4px 14px -6px rgba(49, 46, 129, 0.35);
    --radius: 20px;
    --radius-sm: 12px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-0: #0b0d1a;
        --bg-1: #11132a;
        --surface: rgba(23, 26, 48, 0.66);
        --surface-solid: #171a30;
        --border: rgba(139, 138, 255, 0.16);
        --border-strong: rgba(139, 138, 255, 0.38);
        --text: #edeefc;
        --text-soft: #b8bbdc;
        --text-muted: #8286ab;
        --accent: #818cf8;
        --accent-2: #a78bfa;
        --accent-3: #22d3ee;
        --accent-ink: #c7d2fe;
        --success: #34d399;
        --danger: #ff6b6f;
        --shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.8);
        --shadow-sm: 0 6px 18px -8px rgba(0, 0, 0, 0.6);
    }
}

* {
    box-sizing: border-box;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 1rem;
    line-height: 1.55;
    color: var(--text);
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(1200px 700px at 78% -8%, rgba(139, 92, 246, 0.16), transparent 60%),
        radial-gradient(900px 600px at 5% 8%, rgba(6, 182, 212, 0.12), transparent 55%),
        linear-gradient(160deg, var(--bg-0), var(--bg-1));
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* -------- Decorative animated background -------- */
.bg-decoration {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.55;
    animation: drift 22s ease-in-out infinite;
}

.orb-1 {
    width: 460px; height: 460px;
    top: -140px; right: -80px;
    background: radial-gradient(circle at 30% 30%, #8b5cf6, transparent 70%);
}

.orb-2 {
    width: 380px; height: 380px;
    bottom: -120px; left: -60px;
    background: radial-gradient(circle at 30% 30%, #06b6d4, transparent 70%);
    animation-delay: -7s;
}

.orb-3 {
    width: 300px; height: 300px;
    top: 40%; left: 55%;
    background: radial-gradient(circle at 30% 30%, #6366f1, transparent 70%);
    opacity: 0.35;
    animation-delay: -14s;
}

.grid-overlay {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(99, 102, 241, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 102, 241, 0.05) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(ellipse 90% 70% at 50% 30%, #000 40%, transparent 100%);
    -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 30%, #000 40%, transparent 100%);
}

@keyframes drift {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50%      { transform: translate(30px, -24px) scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
    .orb { animation: none; }
}

/* -------- Layout shell -------- */
.page-shell {
    max-width: 860px;
    margin: 0 auto;
    padding: 56px 24px 96px;
    padding-left: max(24px, calc(50% - 430px));
}

.content {
    display: none; /* Hide nQubitPage by default */
}

/* -------- Card -------- */
.card {
    position: relative;
    background: var(--surface);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px 44px 44px;
    overflow: hidden;
}

.card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-3), var(--accent), var(--accent-2));
}

/* -------- Typography -------- */
.eyebrow {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-ink);
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid var(--border);
    padding: 5px 12px;
    border-radius: 999px;
    margin-bottom: 18px;
}

h1 {
    color: var(--text);
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin: 0 0 14px;
    background: linear-gradient(120deg, var(--text), var(--accent-ink));
    -webkit-background-clip: text;
    background-clip: text;
}

h2 {
    font-size: 1.02rem;
    font-weight: 500;
    line-height: 1.5;
    color: var(--text-soft);
    margin: 0 0 10px;
}

p {
    margin: 0;
    font-size: 0.92rem;
    color: var(--text-soft);
}

p.ref {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-style: italic;
    margin: 14px 0 6px;
}

p.note {
    font-size: 0.88rem;
    color: var(--text-soft);
    margin-top: 12px;
    padding: 16px 18px;
    background: rgba(99, 102, 241, 0.055);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
}

sub, sup {
    font-size: 0.72em;
}

span {
    color: var(--accent);
}

/* -------- 3-qubit input groups -------- */
form {
    margin-top: 26px;
}

.input_group {
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 14px;
}

.input_group label {
    text-align: left;
    font-weight: 600;
    color: var(--text-soft);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.86rem;
}

/* -------- Shared input styling -------- */
input {
    font-family: 'JetBrains Mono', ui-monospace, 'Cascadia Code', monospace;
    font-size: 0.92rem;
    color: var(--text);
    background: var(--surface-solid);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    width: 100%;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    outline: none;
}

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

input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18);
}

.input_group input { /* Input fields */
    display: block;
    width: 100%;
}

input::placeholder,
.input_group input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
    font-size: 1em;
}

/* -------- Buttons -------- */
.button-row {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

button { /* Calculate and reset buttons */
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 24px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
    box-shadow: var(--shadow-sm);
}

button:hover {
    transform: translateY(-2px);
    filter: brightness(1.06);
    box-shadow: 0 12px 26px -10px rgba(99, 102, 241, 0.7);
}

button:active {
    transform: translateY(0);
}

button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

button.secondary {
    color: var(--text-soft);
    background: transparent;
    border: 1px solid var(--border-strong);
    box-shadow: none;
}

button.secondary:hover {
    color: var(--text);
    background: rgba(99, 102, 241, 0.08);
    border-color: var(--accent);
}

/* -------- Results -------- */
.result-line {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-top: 14px;
    word-break: break-word;
}

.result-line:not(:empty) {
    padding: 14px 18px;
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.1), rgba(99, 102, 241, 0.1));
    border: 1px solid var(--border);
    border-left: 3px solid var(--success);
    border-radius: var(--radius-sm);
    animation: pop 0.28s ease;
}

#result:not(:empty) {
    margin-top: 26px;
}

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

/* -------- n-qubit specific -------- */
#nQubitsField {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-soft);
    padding-bottom: 4px;
}

.n-input {
    font-size: 0.9rem;
    max-width: 180px;
}

.input-labels, .input-fields {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    margin-bottom: 10px;
}

.input-labels > label {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-muted);
    flex: 1;
    max-width: 240px;
}

.input-fields > input {
    flex: 1;
    max-width: 240px;
}

.number-input {
    max-width: 240px;
}

.value-input {
    max-width: 240px;
}

/* -------- Sidebar page-switcher -------- */
.switching-buttons {
    position: fixed;
    left: 20px;
    top: 26px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    background: var(--surface);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    max-width: 210px;
}

.switching-buttons p {
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 2px;
}

.switching-buttons button {
    font-size: 0.8rem;
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    color: var(--text);
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid var(--border);
    box-shadow: none;
}

.switching-buttons button:hover {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    border-color: transparent;
}

/* -------- Footer -------- */
.site-footer {
    margin-top: 36px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.site-footer p {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 12px;
}

.footer-links a {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--accent-ink);
    text-decoration: none;
    padding: 4px 2px;
    border-bottom: 1px solid transparent;
    transition: color 0.18s ease, border-color 0.18s ease;
}

.footer-links a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.footer-sep {
    color: var(--text-muted);
}

/* -------- Responsive -------- */
@media (max-width: 720px) {
    html { font-size: 15.5px; }

    .page-shell {
        padding: 96px 16px 72px;
        padding-left: 16px;
    }

    .card {
        padding: 28px 22px 32px;
    }

    h1 { font-size: 1.55rem; }

    .input_group {
        gap: 6px;
    }

    .switching-buttons {
        position: static;
        max-width: none;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        margin: 0 auto 20px;
        max-width: 640px;
    }

    .switching-buttons p {
        width: 100%;
    }

    .switching-buttons button {
        width: auto;
        flex: 1;
        text-align: center;
        min-width: 140px;
    }

    .input-labels > label,
    .input-fields > input,
    .number-input,
    .value-input {
        max-width: none;
    }
}
