/* Interactive product demo (under the hero) and the architecture builder.
   Shared by interviewllm.dev and systemdesignllm.com; colours come from each
   site's own tokens in styles.css. Every class is prefixed dm- so nothing
   collides with the page styles. */

.dm-section { padding-top: 0.5rem; }

/* systemdesignllm.com's base styles set colour and centred text on every
   element (*), which breaks inheritance inside the demo. Restore it here;
   the specific rules below still win because they come later. */
.dm-stage, .dm-stage * { text-align: left; }
.dm-stage * { color: inherit; }

.dm-stage {
    background: var(--surface-muted, #fafafa);
    border: 1px solid var(--border, #e4e4e7);
    border-radius: var(--radius-lg, 14px);
    padding: 1.25rem;
    color: var(--text, #18181b);
    outline: none;
}
.dm-stage:focus-visible { box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.35); }

.dm-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.dm-eyebrow {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
    margin: 0 0 0.25rem;
}
.dm-title {
    font-size: clamp(1.25rem, 1.05rem + 0.8vw, 1.6rem);
    font-weight: 650;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 0;
}
.dm-sub { margin: 0.4rem 0 1rem; color: var(--text-muted, #52525b); font-size: 0.95rem; }

/* Step strip */
.dm-steps { display: flex; gap: 0.4rem; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.dm-steps li {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-muted, #52525b);
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e4e4e7);
    border-radius: 999px;
    padding: 0.25rem 0.65rem 0.25rem 0.3rem;
    transition: border-color 0.25s, color 0.25s;
}
.dm-steps .dm-n {
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--gray-100, #f4f4f5);
    color: var(--text-muted, #52525b);
}
.dm-steps li.is-current { border-color: var(--accent); color: var(--text, #18181b); }
.dm-steps li.is-current .dm-n { background: var(--accent); color: #fff; }
.dm-steps li.is-done .dm-n { background: var(--accent-subtle); color: var(--accent); }

/* Mock window */
.dm-win {
    position: relative;
    background: #fff;
    border: 1px solid var(--border, #e4e4e7);
    border-radius: 12px;
    overflow: hidden;
    height: 22rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 12px 32px -12px rgba(0, 0, 0, 0.14);
}
.dm-bar {
    height: 1.9rem;
    background: var(--gray-100, #f4f4f5);
    border-bottom: 1px solid var(--border, #e4e4e7);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.65rem;
    font-size: 0.72rem;
    color: var(--text-muted, #52525b);
}
.dm-bar > i { width: 9px; height: 9px; border-radius: 50%; background: var(--gray-300, #d4d4d8); }
.dm-bar-t { margin-left: 0.5rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-badge {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid var(--border, #e4e4e7);
    background: #fff;
    border-radius: 999px;
    padding: 0.05rem 0.45rem;
}
.dm-body { width: 46%; padding: 1rem 1.1rem; font-size: 0.875rem; line-height: 1.55; }
.dm-prob { position: relative; padding: 0.4rem; margin: -0.4rem; }
.dm-prob code { font-size: 0.8rem; background: var(--gray-100, #f4f4f5); padding: 0.05rem 0.25rem; border-radius: 4px; }
.dm-sel {
    position: absolute;
    inset: 0;
    border: 1.5px dashed var(--accent);
    background: rgba(var(--accent-rgb), 0.06);
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
}
.dm-sel.is-go { animation: dm-sel 0.45s ease-out forwards; }
@keyframes dm-sel {
    from { opacity: 1; clip-path: inset(0 100% 100% 0); }
    to { opacity: 1; clip-path: inset(0 0 0 0); }
}
.dm-ed { margin-top: 1rem; display: grid; gap: 0.45rem; font: 0.7rem/1 var(--font-mono, ui-monospace, monospace); color: var(--gray-400, #a1a1aa); }
.dm-ed i { display: block; height: 8px; border-radius: 4px; background: #eceef1; }
.dm-win.is-flash::after {
    content: "";
    position: absolute;
    inset: 0;
    background: #fff;
    animation: dm-flash 0.35s ease-out forwards;
    pointer-events: none;
}
@keyframes dm-flash { from { opacity: 0.85; } to { opacity: 0; } }

/* The app's overlay */
.dm-panel {
    position: absolute;
    right: 0.75rem;
    top: 2.6rem;
    bottom: 0.75rem;
    width: 48%;
    background: rgba(9, 9, 11, 0.95);
    color: #e4e4e7;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 18px 40px -10px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}
.dm-phead {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.65rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.72rem;
}
.dm-brand { display: flex; align-items: center; gap: 0.4rem; font-weight: 600; color: #fafafa; margin-right: auto; white-space: nowrap; }
.dm-brand i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-on-dark); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.35); }
.dm-chip {
    font: 0.66rem var(--font-mono, ui-monospace, monospace);
    color: #d4d4d8;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
    white-space: nowrap;
}
button.dm-chip { cursor: pointer; }
button.dm-chip:hover { border-color: var(--accent-on-dark); }
.dm-queue { display: flex; gap: 0.4rem; align-items: center; font-size: 0.7rem; color: #a1a1aa; padding: 0.5rem 0.65rem 0; }
.dm-thumb { width: 40px; height: 26px; border-radius: 4px; border: 1px dashed #3f3f46; background: #18181b; transition: 0.3s; }
.dm-thumb.is-on {
    border: 1px solid var(--accent-on-dark);
    background: #fff repeating-linear-gradient(#fff 0 4px, #e4e4e7 4px 6px) 4px 4px / 70% 18px no-repeat;
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.3);
}
.dm-status { font-size: 0.7rem; color: var(--accent-on-dark); padding: 0.4rem 0.65rem 0; min-height: 1rem; display: flex; align-items: center; gap: 0.4rem; }
.dm-spin { width: 9px; height: 9px; border: 1.5px solid rgba(255, 255, 255, 0.2); border-top-color: var(--accent-on-dark); border-radius: 50%; animation: dm-spin 0.7s linear infinite; }
@keyframes dm-spin { to { transform: rotate(360deg); } }
.dm-out { flex: 1; overflow: auto; padding: 0.25rem 0.65rem 0.65rem; font-size: 0.75rem; line-height: 1.5; }
.dm-oh { font-size: 0.62rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: #a1a1aa; margin: 0.6rem 0 0.2rem; }
.dm-out p { margin: 0; white-space: pre-wrap; }
.dm-code {
    margin: 0.1rem 0 0;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 6px;
    padding: 0.45rem 0.5rem;
    font: 0.7rem/1.55 var(--font-mono, ui-monospace, monospace);
    white-space: pre;
    overflow-x: auto;
}
.dm-kw { color: var(--accent-on-dark); }
.dm-nu { color: #fdba74; }
.dm-fn { color: #93c5fd; }
.dm-pills { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.dm-pill { font-size: 0.7rem; font-weight: 600; color: var(--accent-on-dark); background: rgba(var(--accent-rgb), 0.25); border-radius: 999px; padding: 0.1rem 0.5rem; }
.dm-bad { color: #fca5a5; }
.dm-ok { color: #86efac; }
.dm-div { border-top: 1px dashed rgba(255, 255, 255, 0.15); margin: 0.75rem 0 0.1rem; }
.dm-caret::after { content: "▍"; color: var(--accent-on-dark); animation: dm-blink 1s steps(1) infinite; }
@keyframes dm-blink { 50% { opacity: 0; } }

/* Shortcut buttons */
.dm-keys { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-top: 0.9rem; }
.dm-key {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font: inherit;
    font-size: 0.85rem;
    color: var(--text, #18181b);
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e4e4e7);
    border-radius: 8px;
    padding: 0.45rem 0.7rem;
    cursor: pointer;
    position: relative;
    transition: border-color 0.15s, transform 0.1s;
}
.dm-key:hover:not(:disabled) { border-color: var(--accent); }
.dm-key:disabled { opacity: 0.45; cursor: not-allowed; }
.dm-key.is-next { border-color: var(--accent); background: var(--accent); color: #fff; }
.dm-key.is-next::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 11px;
    border: 2px solid var(--accent);
    opacity: 0;
    animation: dm-pulse 1.6s ease-out infinite;
}
@keyframes dm-pulse { 0% { opacity: 0.6; transform: scale(0.97); } 100% { opacity: 0; transform: scale(1.06); } }
.dm-key.is-press { transform: translateY(1px) scale(0.98); }
.dm-key kbd {
    font: 0.7rem var(--font-mono, ui-monospace, monospace);
    border: 1px solid var(--gray-300, #d4d4d8);
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 0 0.25rem;
    background: #fff;
    color: var(--text, #18181b);
}
.dm-key.is-next kbd { border-color: rgba(255, 255, 255, 0.5); background: rgba(255, 255, 255, 0.15); color: #fff; }
.dm-spacer { flex: 1; }
.dm-key.dm-ghost { border-color: transparent; background: transparent; color: var(--text-muted, #52525b); }
.dm-hint { font-size: 0.8rem; color: var(--text-muted, #52525b); margin: 0.6rem 0 0; min-height: 1.2rem; }

/* Architecture builder (System Design LLM) */
.dm-layers { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.dm-layer {
    font: inherit;
    font-size: 0.85rem;
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e4e4e7);
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    cursor: pointer;
    color: var(--text, #18181b);
}
.dm-layer:hover { border-color: var(--accent); }
.dm-layer[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.dm-arch { width: 100%; height: auto; display: block; background: #fff; border: 1px solid var(--border, #e4e4e7); border-radius: 12px; }
.dm-arch .dm-node rect { fill: #fff; stroke: var(--gray-300, #d4d4d8); stroke-width: 1.2; }
.dm-arch .dm-node.is-new rect { fill: var(--accent-subtle); stroke: var(--accent); }
.dm-arch .dm-node text { font: 12px var(--font-sans, system-ui, sans-serif); fill: #18181b; text-anchor: middle; dominant-baseline: central; }
.dm-arch .dm-node, .dm-arch .dm-edge { transition: opacity 0.35s; }
.dm-arch .dm-edge { stroke: var(--gray-400, #a1a1aa); stroke-width: 1.3; fill: none; }
.dm-arch .dm-edge.is-new { stroke: var(--accent); }
.dm-arch .is-off { opacity: 0; }
.dm-fus { display: grid; gap: 0.4rem; margin-top: 0.75rem; }
.dm-fus details { background: var(--surface, #fff); border: 1px solid var(--border, #e4e4e7); border-radius: 8px; padding: 0.45rem 0.7rem; font-size: 0.875rem; }
.dm-fus summary { cursor: pointer; font-weight: 550; }
.dm-fus p { margin: 0.4rem 0 0; color: var(--text-muted, #52525b); line-height: 1.5; }

@media (max-width: 640px) {
    .dm-head { align-items: flex-start; }
    .dm-win { height: auto; }
    .dm-body { width: auto; }
    .dm-panel { position: static; width: auto; margin: 0 0.65rem 0.65rem; height: 19rem; }
    .dm-spacer { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .dm-key.is-next::after, .dm-sel.is-go, .dm-win.is-flash::after, .dm-caret::after, .dm-spin { animation: none; }
}
