/* ==========================================================================
   mock.css - the OwletMock component (js/mock.js). A compact, honest mock
   of the app's UI: title bar, file tree, token-coloured editor, rendered
   preview and console. Everything reads the shared tokens so it follows
   both themes. Fixed aspect ratio: the mock never leaves an empty hole.
   ========================================================================== */

.dpm {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface-1);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-2);
    font-family: var(--font-sans);
    text-align: left;
}

/* ---------- title bar ---------- */

.dpm-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    flex: 0 0 auto;
}
.dpm-dots { display: inline-flex; gap: 5px; flex: 0 0 auto; }
.dpm-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--surface-3); }
.dpm-dots span:nth-child(1) { background: #ff6b5e; }
.dpm-dots span:nth-child(2) { background: #f5c04f; }
.dpm-dots span:nth-child(3) { background: #5ccb74; }
.dpm-tabs { display: flex; gap: 2px; min-width: 0; overflow: hidden; flex: 1; }
.dpm-tab {
    padding: 2px 9px;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-3);
    white-space: nowrap;
}
.dpm-tab.is-active { background: var(--surface-3); color: var(--text-1); }
.dpm-run {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: var(--on-accent);
    font-size: 0.62rem;
    font-weight: 600;
}

/* ---------- body ---------- */

.dpm-body {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(64px, 0.9fr) 2.2fr 1.8fr;
    grid-template-rows: 1fr auto;
    min-height: 0;
}
.dpm.layout-console .dpm-body { grid-template-columns: minmax(64px, 0.9fr) 2.6fr; }
.dpm.layout-console .dpm-preview { display: none; }
.dpm.layout-split .dpm-body { grid-template-columns: minmax(64px, 0.9fr) 1.7fr 1.7fr; grid-template-rows: 1fr; }
.dpm.layout-phone .dpm-body { grid-template-columns: minmax(64px, 0.9fr) 1.7fr 1.4fr; }
.dpm.no-tree .dpm-body { grid-template-columns: 2.2fr 1.8fr; }
.dpm.no-tree.layout-console .dpm-body { grid-template-columns: 1fr; }
.dpm.no-tree.layout-split .dpm-body { grid-template-columns: 1fr 1fr; }
.dpm.no-tree .dpm-tree { display: none; }

/* ---------- file tree ---------- */

.dpm-tree {
    padding: 8px 8px 8px 10px;
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    overflow: hidden;
}
.dpm-file {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-2);
    white-space: nowrap;
    padding: 3px 4px;
    border-radius: 5px;
}
.dpm-file::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 2px;
    background: var(--text-3);
    flex: 0 0 auto;
}
.dpm-file[data-kind="html"]::before { background: var(--syn-keyword); }
.dpm-file[data-kind="css"]::before { background: var(--syn-tag); }
.dpm-file[data-kind="js"]::before { background: var(--syn-string); }
.dpm-file.is-active { background: var(--surface-3); color: var(--text-1); }

/* ---------- editor ---------- */

.dpm-editor {
    position: relative;
    padding: 8px 10px;
    font-family: var(--font-mono);
    font-size: clamp(0.55rem, 0.5rem + 0.35vw, 0.72rem);
    line-height: 1.65;
    overflow: hidden;
    min-width: 0;
    background: var(--code-bg);
    color: var(--code-text);
}
.dpm-editor + .dpm-editor { border-left: 1px solid var(--line); }
.dpm-line { display: flex; gap: 8px; white-space: pre; }
.dpm-ln {
    flex: 0 0 auto;
    width: 1.2em;
    text-align: right;
    color: var(--text-3);
    opacity: 0.55;
    user-select: none;
}
.dpm-lc { min-width: 0; }
.dpm-line.is-err { background: rgba(255, 107, 94, 0.14); margin: 0 -10px; padding: 0 10px; border-left: 2px solid #ff6b5e; }
.dpm-line.is-hl { background: var(--accent-soft); margin: 0 -10px; padding: 0 10px; }
.dpm-caret {
    display: inline-block;
    width: 0.55em; height: 1em;
    background: var(--accent);
    vertical-align: text-bottom;
    animation: dpm-blink 1s steps(1) infinite;
}
@keyframes dpm-blink { 50% { opacity: 0; } }

/* syntax token colours (from the shared tokens) */
.tok-kw   { color: var(--syn-keyword); }
.tok-str  { color: var(--syn-string); }
.tok-tag  { color: var(--syn-tag); }
.tok-num  { color: var(--accent); }
.tok-cm   { color: var(--text-3); font-style: italic; }
.tok-fn   { color: var(--syn-tag); }
.tok-pl   { color: var(--code-text); }

/* ---------- preview ---------- */

.dpm-preview {
    position: relative;
    border-left: 1px solid var(--line);
    background: var(--surface-1);
    padding: 12px;
    overflow: hidden;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
}
.dpm-device {
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #ffffff;
    color: #1a1d26;
    padding: 10px;
    font-size: clamp(0.55rem, 0.5rem + 0.3vw, 0.7rem);
    line-height: 1.5;
    transition: max-width var(--dur-base) var(--ease-out);
}
.dpm[data-device="phone"] .dpm-device { max-width: 46%; margin: 0 auto; }
.dpm[data-device="tablet"] .dpm-device { max-width: 78%; margin: 0 auto; }
.dpm-device [data-node] h1, .dpm-device h1 { font-size: 1.25em; font-weight: 700; margin: 0 0 0.35em; letter-spacing: -0.01em; }
.dpm-device h2 { font-size: 1.05em; font-weight: 700; margin: 0 0 0.3em; }
.dpm-device p { margin: 0 0 0.5em; color: #4a5064; }
.dpm-device a { color: #b4530f; text-decoration: underline; }
.dpm-device .pv-btn {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    background: #ff8a4c;
    color: #fff;
    font-weight: 600;
}
.dpm-device .pv-card { border: 1px solid #e4e6ee; border-radius: 8px; padding: 8px; margin-bottom: 6px; }
.dpm-device .pv-row { display: flex; gap: 8px; align-items: center; }
.dpm-device .pv-box { border-radius: 6px; }

/* ---------- console ---------- */

.dpm-console {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    background: var(--surface-1);
    padding: 6px 10px;
    font-family: var(--font-mono);
    font-size: clamp(0.55rem, 0.5rem + 0.3vw, 0.68rem);
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 0;
    overflow: hidden;
    position: relative;
}
.dpm-crow { display: flex; gap: 7px; align-items: baseline; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dpm-crow::before { content: ">"; color: var(--text-3); flex: 0 0 auto; }
.dpm-crow.lvl-error { color: #ff6b5e; }
.dpm-crow.lvl-warn { color: #f5c04f; }
.dpm-crow.lvl-log { color: var(--text-2); }
.dpm-crow.is-new { animation: dpm-crow-in 300ms var(--ease-out); }
@keyframes dpm-crow-in { from { opacity: 0; transform: translateY(4px); } }

/* ---------- annotation callout ---------- */

.dpm-note {
    position: absolute;
    right: 8px; bottom: 8px;
    max-width: 72%;
    padding: 5px 9px;
    border-radius: var(--radius-xs);
    background: var(--accent);
    color: var(--on-accent);
    font-size: 0.66rem;
    font-weight: 600;
    line-height: 1.35;
    box-shadow: var(--shadow-1);
    z-index: 2;
}
.dpm-editor .dpm-note, .dpm-tree .dpm-note { bottom: auto; top: 8px; }
.dpm-tree .dpm-note { right: 6px; max-width: 86%; }

/* ---------- replay ---------- */

.dpm-replay {
    position: absolute;
    top: 6px; right: 8px;
    z-index: 3;
    border: 0;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    color: var(--text-1);
    font-family: var(--font-sans);
    font-size: 0.62rem;
    font-weight: 600;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--dur-fast) var(--ease-out);
}
.dpm:hover .dpm-replay, .dpm-replay:focus-visible, .dpm.is-done .dpm-replay { opacity: 1; }
.dpm-replay:hover { background: var(--accent); color: var(--on-accent); }

/* ---------- reduced motion / narrow ---------- */

@media (prefers-reduced-motion: reduce) {
    .dpm-caret { animation: none; }
    .dpm-crow.is-new { animation: none; }
    .dpm-device { transition: none; }
}

@media (max-width: 560px) {
    .dpm-body { grid-template-columns: 2fr 1.6fr; }
    .dpm.layout-console .dpm-body { grid-template-columns: 1fr; }
    .dpm.layout-split .dpm-body { grid-template-columns: 1fr 1fr; }
    .dpm.layout-phone .dpm-body { grid-template-columns: 1.6fr 1fr; }
    .dpm-tree { display: none; }
}
