/*
 * PostQuantum.Hybrid playground — minimal, tight typography, two accent
 * colors. Deep blue is the brand; teal is the "native backend" indicator.
 * Amber is the "fallback" indicator (informational, not error: both
 * backends are first-class).
 */

:root {
    --bg:            #f7f8fa;
    --surface:       #ffffff;
    --ink:           #0b1320;
    --ink-soft:      #4b5563;
    --rule:          #e5e7eb;
    --brand:         #1e3a8a;   /* deep blue */
    --accent:        #0d9488;   /* teal — native backend */
    --warn:          #b45309;   /* amber — fallback backend */
    --code-bg:       #0b1320;
    --code-ink:      #f3f4f6;
    --code-comment:  #9ca3af;
    --shadow:        0 1px 2px rgba(11, 19, 32, 0.04), 0 4px 12px rgba(11, 19, 32, 0.04);
    --radius:        10px;
    --max-width:     880px;
}

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

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 17px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--brand);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
}
a:hover { text-decoration-thickness: 2px; }

code, pre {
    font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
    font-size: 0.92em;
}

code {
    background: #eef0f4;
    padding: 0.08em 0.36em;
    border-radius: 4px;
}

pre.code {
    background: var(--code-bg);
    color: var(--code-ink);
    padding: 1.1rem 1.2rem;
    border-radius: var(--radius);
    overflow-x: auto;
    line-height: 1.5;
    font-size: 0.92rem;
}

pre.code code {
    background: transparent;
    color: inherit;
    padding: 0;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* ------------------------------ Header ----------------------------------- */

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--rule);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(8px);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.brand {
    text-decoration: none;
    color: var(--ink);
    display: inline-flex;
    align-items: baseline;
    gap: 0.6rem;
}

.brand-name {
    font-weight: 700;
    letter-spacing: -0.01em;
}

.brand-tag {
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.backend-badge {
    font-size: 0.82rem;
    padding: 0.32rem 0.7rem;
    border-radius: 999px;
    border: 1px solid;
    line-height: 1.2;
    white-space: nowrap;
}

.backend-badge strong { font-weight: 600; }

.badge-native {
    color: #064e3b;
    background: #ccfbf1;
    border-color: var(--accent);
}

.badge-fallback {
    color: #78350f;
    background: #fef3c7;
    border-color: var(--warn);
}

/* ------------------------------ Hero ------------------------------------- */

.hero {
    padding: 2.5rem 0 2.25rem;
    border-bottom: 1px solid var(--rule);
}

.hero h1 {
    font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.4rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin: 0 0 1rem;
}

.hero-sub {
    font-size: 1.08rem;
    color: var(--ink-soft);
    margin: 0 0 1.5rem;
    max-width: 60ch;
}

.hero-meta {
    margin: 1.25rem 0 0;
    font-size: 0.92rem;
    color: var(--ink-soft);
    max-width: 60ch;
}

.anchor-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.1rem;
    font-size: 0.95rem;
}

.anchor-nav a {
    color: var(--brand);
    text-decoration: none;
    border-bottom: 1px dotted var(--brand);
    padding-bottom: 1px;
}

.anchor-nav a:hover {
    border-bottom-style: solid;
}

/* ------------------------------ Bands ------------------------------------ */

.band {
    padding: 2.25rem 0;
    border-bottom: 1px solid var(--rule);
    scroll-margin-top: 4.5rem;
}

.band:last-of-type {
    border-bottom: none;
}

.band h2 {
    font-size: 1.45rem;
    letter-spacing: -0.01em;
    margin: 0 0 1rem;
}

.band p { margin: 0 0 1rem; max-width: 64ch; }

.placeholder {
    color: var(--ink-soft);
    border-left: 3px solid var(--rule);
    padding-left: 1rem;
}

/* ---------- Why-hybrid two-primitive grid ---------- */

.primitives {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin: 1.25rem 0 1.25rem;
}

@media (min-width: 640px) {
    .primitives { grid-template-columns: 1fr 1fr; gap: 1.25rem; }
}

.primitive {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 1.1rem 1.2rem;
    box-shadow: var(--shadow);
}

.primitive h3 {
    margin: 0 0 0.35rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--brand);
}

.primitive-formula {
    margin: 0 0 0.45rem;
    font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
    font-size: 1.05rem;
    font-weight: 600;
}

.primitive-detail {
    margin: 0;
    font-size: 0.95rem;
    color: var(--ink-soft);
    line-height: 1.55;
}

/* ------------------------------ Caveat helper ---------------------------- */

.caveat {
    margin-top: 1.25rem;
    color: var(--ink-soft);
    font-size: 0.92rem;
    border-left: 3px solid var(--rule);
    padding-left: 1rem;
}

/* ------------------------------ Live demo shell -------------------------- */

.demo-shell {
    margin: 0.75rem 0 1.5rem;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    border-bottom: 1px solid var(--rule);
    background: #f1f5f9;
}

.tab {
    flex: 1 1 0;
    min-width: 120px;
    padding: 0.85rem 1rem 0.7rem;
    background: transparent;
    border: 0;
    border-right: 1px solid var(--rule);
    border-bottom: 3px solid transparent;
    cursor: pointer;
    text-align: left;
    color: var(--ink-soft);
    font: inherit;
    line-height: 1.2;
}
.tab:last-child { border-right: 0; }

.tab:hover {
    color: var(--ink);
    background: #e2e8f0;
}

.tab-active {
    background: var(--surface);
    color: var(--ink);
    border-bottom-color: var(--brand);
    font-weight: 600;
}

.tab-sub {
    display: block;
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--ink-soft);
    font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
    margin-top: 0.18rem;
}

.tab-active .tab-sub { color: var(--brand); }

.tab-panel { padding: 1.25rem 1.25rem 1.4rem; }

.tab-summary {
    margin: 0 0 1.1rem;
    color: var(--ink);
    font-size: 0.98rem;
    line-height: 1.55;
}

.field-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink-soft);
    margin: 0.6rem 0 0.35rem;
    letter-spacing: 0.01em;
}

.textarea {
    width: 100%;
    background: #f8fafc;
    color: var(--ink);
    border: 1px solid var(--rule);
    border-radius: 8px;
    padding: 0.7rem 0.85rem;
    font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
    font-size: 0.92rem;
    line-height: 1.5;
    resize: vertical;
}

.textarea:focus {
    outline: 2px solid var(--brand);
    outline-offset: 1px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 0.9rem 0 0;
}

.btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.55rem 1.05rem;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
}

.btn-primary {
    background: var(--brand);
    color: #fff;
}
.btn-primary:hover { background: #1d4ed8; }

.btn-ghost {
    background: transparent;
    color: var(--ink);
    border-color: var(--rule);
}
.btn-ghost:hover { border-color: var(--ink-soft); }

.btn-warn {
    background: #fff;
    color: var(--warn);
    border-color: var(--warn);
}
.btn-warn:hover { background: #fef3c7; }

/* ---------- Receipt panels ---------- */

.receipt {
    margin-top: 1.25rem;
    padding: 0.95rem 1.05rem 1rem;
    border: 1px solid var(--rule);
    border-radius: 8px;
    background: #f8fafc;
}

.receipt-ok    { border-left: 4px solid var(--accent); }
.receipt-warn  { border-left: 4px solid var(--warn);   }
.receipt-error { border-left: 4px solid #dc2626; background: #fef2f2; }
.receipt-tamper { border-left: 4px solid var(--brand); }

.receipt-headline {
    font-weight: 600;
    margin-bottom: 0.55rem;
}

.receipt-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 1.25rem;
    row-gap: 0.25rem;
    margin: 0;
    font-size: 0.92rem;
}

.receipt-grid dt {
    color: var(--ink-soft);
    font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
    font-size: 0.88rem;
    white-space: nowrap;
}

.receipt-grid dd {
    margin: 0;
    word-break: break-word;
}

.receipt details {
    margin-top: 0.85rem;
}

.receipt summary {
    cursor: pointer;
    color: var(--brand);
    font-weight: 500;
}

.envelope-pre {
    margin: 0.55rem 0 0;
    padding: 0.7rem 0.85rem;
    background: var(--code-bg);
    color: var(--code-ink);
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.45;
    max-height: 18rem;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ---------- Step list (Advanced tab) ---------- */

.step-list {
    margin: 0.7rem 0 0;
    padding: 0;
    list-style: none;
    counter-reset: step;
}

.step-list li {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-left: 3px solid var(--brand);
    border-radius: 6px;
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.55rem;
}

.step-title {
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 0.25rem;
}

.step-detail {
    color: var(--ink-soft);
    font-size: 0.92rem;
    margin-bottom: 0.3rem;
    line-height: 1.5;
}

.step-analyzer {
    font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
    font-size: 0.82rem;
    color: var(--accent);
    background: #ccfbf1;
    padding: 0.3rem 0.55rem;
    border-radius: 4px;
    display: inline-block;
    margin-top: 0.15rem;
}

/* ---------- Copyable code snippets ---------- */

.snippet-heading {
    margin: 1.4rem 0 0.5rem;
    font-size: 1rem;
    color: var(--ink);
}

.snippet {
    background: var(--code-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin: 0.4rem 0 0.6rem;
}

.snippet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.85rem;
    background: #111827;
    border-bottom: 1px solid #1f2937;
}

.snippet-label {
    color: var(--code-comment);
    font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.copy-btn {
    background: transparent;
    color: #e5e7eb;
    border: 1px solid #374151;
    border-radius: 6px;
    padding: 0.25rem 0.6rem;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.copy-btn:hover {
    background: #1f2937;
    border-color: #4b5563;
}

.copy-btn-done {
    background: #064e3b;
    color: #d1fae5;
    border-color: #047857;
}

.snippet .code {
    margin: 0;
    border-radius: 0;
    background: transparent;
}

/* ---------- Package matrix ---------- */

.package-matrix {
    margin: 0.6rem 0 0.4rem;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.package-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.3rem;
    padding: 0.85rem 1.05rem;
    border-bottom: 1px solid var(--rule);
}

.package-row:last-child { border-bottom: none; }

@media (min-width: 640px) {
    .package-row {
        grid-template-columns: 240px 1fr;
        gap: 1.25rem;
        align-items: baseline;
    }
}

.package-row-head {
    background: #f1f5f9;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-size: 0.75rem;
    color: var(--ink-soft);
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
}

.package-row-head + .package-row { border-top: 0; }

.package-row code {
    background: transparent;
    padding: 0;
    color: var(--brand);
    font-weight: 600;
}

/* ---------- Security hygiene (PQH001-PQH005) ---------- */

.hygiene-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.1rem;
    margin: 0.75rem 0 1.25rem;
}

.hygiene-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem 1.25rem 1.2rem;
    scroll-margin-top: 4.5rem;
}

.hygiene-card-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.7rem;
    margin-bottom: 0.65rem;
}

.hygiene-card-head h3 {
    margin: 0;
    font-size: 1.05rem;
    flex: 1 1 auto;
}

.rule-chip {
    display: inline-block;
    background: var(--brand);
    color: #fff;
    font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.25rem 0.55rem;
    border-radius: 6px;
}

.rule-severity {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--warn);
    padding: 0.18rem 0.5rem;
    border: 1px solid var(--warn);
    border-radius: 999px;
}

.rule-explanation {
    color: var(--ink-soft);
    margin: 0 0 0.85rem;
    font-size: 0.93rem;
    line-height: 1.55;
}

.rule-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.8rem;
    margin-bottom: 0.95rem;
}

@media (min-width: 720px) {
    .rule-grid { grid-template-columns: 1fr 1fr; gap: 1rem; }
}

.rule-pane {
    background: var(--code-bg);
    border-radius: 8px;
    padding: 0.65rem 0.85rem 0.7rem;
    border: 1px solid #1f2937;
    position: relative;
}

.rule-pane .code {
    margin: 0;
    background: transparent;
    padding: 0;
    font-size: 0.85rem;
}

.rule-pane-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.4rem;
    color: var(--code-comment);
}

.rule-bad .rule-pane-label { color: #fca5a5; }
.rule-good .rule-pane-label { color: #6ee7b7; }
.rule-bad   { border-color: #7f1d1d; }
.rule-good  { border-color: #065f46; }

.rule-diagnostic {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-left: 4px solid var(--warn);
    border-radius: 6px;
    padding: 0.55rem 0.8rem;
    margin-bottom: 0.7rem;
    font-size: 0.88rem;
}

.rule-diagnostic-label {
    color: var(--warn);
    font-weight: 600;
    margin-right: 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.72rem;
}

.rule-diagnostic-text {
    color: #92400e;
    background: transparent;
    padding: 0;
}

.rule-link {
    margin: 0;
    font-size: 0.88rem;
}

/* ---------- Rotation visualization ---------- */

.rotation-shell {
    margin: 0.5rem 0 1.25rem;
}

.rotation-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .rotation-cards { grid-template-columns: 1fr 1fr; gap: 1.25rem; }
}

.rotation-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 1.1rem 1.2rem;
    box-shadow: var(--shadow);
}

.rotation-card-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-soft);
    margin-bottom: 0.55rem;
}

.version-badge {
    display: inline-block;
    background: var(--brand);
    color: #fff;
    font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 0.45rem 1.05rem;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(30, 58, 138, 0.18);
    transition: transform 200ms ease, box-shadow 200ms ease;
}

.version-badge-flash {
    transform: scale(1.06);
    box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.32);
    animation: badgePulse 700ms ease;
}

@keyframes badgePulse {
    0%   { transform: scale(1);    box-shadow: 0 1px 2px rgba(30, 58, 138, 0.18); }
    35%  { transform: scale(1.10); box-shadow: 0 0 0 6px rgba(13, 148, 136, 0.34); }
    100% { transform: scale(1.06); box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.32); }
}

.rotation-explanation {
    margin: 0.6rem 0 0.85rem;
    color: var(--ink-soft);
    font-size: 0.93rem;
    line-height: 1.55;
}

.rotation-log {
    margin-top: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    box-shadow: var(--shadow);
}

.rotation-log-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-soft);
    margin-bottom: 0.55rem;
}

.rotation-log-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.rotation-log-list li {
    display: grid;
    grid-template-columns: 4.2rem 4.8rem 1fr;
    gap: 0.85rem;
    align-items: baseline;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--rule);
    font-size: 0.9rem;
}

.rotation-log-list li:last-child { border-bottom: 0; }

.log-version {
    font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
    font-weight: 600;
    color: var(--brand);
}

.log-time {
    font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
    color: var(--ink-soft);
    font-size: 0.85rem;
}

.log-detail {
    color: var(--ink);
}

/* ---------- Tamper panel ---------- */

.tamper-panel {
    border-top: 1px solid var(--rule);
    padding: 1.25rem 1.25rem 1.4rem;
    background: #fffbeb;
}

.tamper-panel h3 {
    margin: 0 0 0.45rem;
    font-size: 1.05rem;
    color: var(--warn);
}

.tamper-panel p {
    margin: 0;
    color: var(--ink);
    font-size: 0.95rem;
    max-width: 64ch;
}

/* ------------------------------ Footer ----------------------------------- */

.site-footer {
    padding: 2.25rem 0;
    background: var(--surface);
    border-top: 1px solid var(--rule);
    color: var(--ink-soft);
}

.footer-inner p { margin: 0 0 0.5rem; font-size: 0.9rem; }

.cold-start { font-style: italic; }
.doxology   { color: var(--ink-soft); opacity: 0.8; }

/* ------------------------------ Blazor error UI -------------------------- */

#blazor-error-ui {
    background: #fee2e2;
    color: #7f1d1d;
    border-top: 1px solid #fecaca;
    bottom: 0;
    box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.1);
    display: none;
    left: 0;
    padding: 0.75rem 1.5rem 0.7rem 1.5rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}
