/* =============================================
   Git Cheatsheet Interactive — style.css
   Dark terminal aesthetic, expandable cards
   ============================================= */

:root {
    --bg: #1e1e2e;
    --surface: #24273a;
    --surface-2: #2a2d3e;
    --border: #363a52;
    --text: #cdd6f4;
    --muted: #6c7086;
    --blue: #89b4fa;
    --green: #a6e3a1;
    --red: #f38ba8;
    --yellow: #f9e2af;
    --purple: #cba6f7;
    --peach: #fab387;
    --primary: #89b4fa;
    --radius: 10px;
    --radius-sm: 5px;
    --top-bar-h: 48px;
    --cat-nav-h: 38px;
    --font-code: 'JetBrains Mono', monospace;
}

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

html,
body {
    height: 100vh;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 13px;
}

/* ── Top Bar ── */
.top-bar {
    height: var(--top-bar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 10px;
    flex-shrink: 0;
}

.top-left {
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--blue);
    white-space: nowrap;
}

.logo-icon {
    font-size: 1.2rem;
}

.search-wrap {
    flex: 1;
    max-width: 400px;
    position: relative;
    display: flex;
    align-items: center;
    margin: 0 auto;
}

.search-icon {
    position: absolute;
    left: 8px;
    font-size: 0.85rem;
    pointer-events: none;
}

.search-input {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.8rem;
    padding: 6px 32px 6px 28px;
    outline: none;
}

.search-input:focus {
    border-color: var(--blue);
}

.kbd {
    position: absolute;
    right: 6px;
    background: var(--border);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: var(--font-code);
    font-size: 0.65rem;
    color: var(--muted);
}

.top-right {
    display: flex;
    gap: 6px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.18s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--blue);
    color: var(--bg);
    font-weight: 600;
}

.btn-primary:hover {
    opacity: 0.88;
}

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--muted);
}

.btn-outline:hover {
    border-color: var(--blue);
    color: var(--text);
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: none;
}

.btn-ghost:hover {
    color: var(--text);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.76rem;
}

.btn-xs {
    padding: 2px 7px;
    font-size: 0.7rem;
}

/* ── Category Nav ── */
.cat-nav {
    height: var(--cat-nav-h);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 8px;
    overflow-x: auto;
    flex-shrink: 0;
}

.cat-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 6px 12px;
    font-family: inherit;
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.18s;
}

.cat-btn.active {
    color: var(--blue);
    border-bottom-color: var(--blue);
}

.cat-btn:hover {
    color: var(--text);
}

.cat-icon {
    font-size: 0.85rem;
}

.cat-count {
    font-size: 0.62rem;
    background: var(--surface);
    border-radius: 8px;
    padding: 1px 5px;
    height: 16px;
    line-height: 14px;
}

/* ── Main Layout ── */
.main-wrap {
    flex: 1;
    height: calc(100vh - var(--top-bar-h) - var(--cat-nav-h));
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cmd-grid-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 12px;
    gap: 10px;
}

/* ── Command Grid ── */
.cmd-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 8px;
    align-content: start;
}

.cmd-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.cmd-card:hover {
    border-color: var(--blue);
    background: var(--surface-2);
}

.cmd-card.expanded {
    border-color: var(--blue);
    background: var(--surface-2);
    grid-column: span 2;
}

.cmd-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.cmd-name {
    font-family: var(--font-code);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--blue);
    flex: 1;
    word-break: break-all;
}

.cmd-category-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}

.cmd-bookmark {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.75rem;
    color: var(--muted);
    cursor: pointer;
}

.cmd-bookmark.starred {
    color: #f9e2af;
}

.cmd-short {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 4px;
    line-height: 1.4;
}

/* ── Expanded Card ── */
.cmd-detail {
    margin-top: 10px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.detail-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.detail-desc {
    font-size: 0.78rem;
    line-height: 1.5;
}

.syntax-block {
    font-family: var(--font-code);
    font-size: 0.76rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    color: var(--green);
    position: relative;
}

.copy-dot {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 0.68rem;
    color: var(--muted);
    cursor: pointer;
}

.copy-dot:hover {
    color: var(--blue);
}

.params-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.param-row {
    font-size: 0.73rem;
}

.param-flag {
    font-family: var(--font-code);
    color: var(--peach);
}

.param-desc {
    color: var(--muted);
}

.detail-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.diagram-btn {
    font-size: 0.72rem;
}

/* ── Diagram ── */
.diagram-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}

.diagram-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.diagram-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--blue);
}

.branch-canvas {
    display: block;
    width: 100%;
    border-radius: var(--radius-sm);
    background: var(--bg);
}

.diagram-desc {
    font-size: 0.76rem;
    color: var(--muted);
    margin-top: 8px;
    line-height: 1.5;
}

/* ── Overlay Panels ── */
.overlay-panel {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 60px;
}

.overlay-panel[hidden] {
    display: none;
}

.quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.quiz-header h2 {
    font-size: 0.95rem;
    font-weight: 700;
}

.quiz-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.wizard-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 480px;
    overflow-y: auto;
}

.bookmarks-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

/* ── Shared Panel Box ── */
.quiz-header,
.quiz-body,
.wizard-body,
.bookmarks-list {
    background: var(--surface);
}

.overlay-panel>div {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 520px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.quiz-header+.quiz-body {
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
}

/* ── Quiz ── */
.quiz-q {
    font-size: 0.88rem;
    line-height: 1.5;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.quiz-answer {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-family: var(--font-code);
    font-size: 0.85rem;
    color: var(--green);
    outline: none;
    width: 100%;
}

.quiz-answer:focus {
    border-color: var(--blue);
}

.quiz-feedback {
    font-size: 0.78rem;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
}

.quiz-feedback.ok {
    background: rgba(166, 227, 161, 0.1);
    color: var(--green);
}

.quiz-feedback.fail {
    background: rgba(243, 139, 168, 0.1);
    color: var(--red);
}

.quiz-actions {
    display: flex;
    gap: 8px;
}

.quiz-score-row {
    display: flex;
    gap: 14px;
    font-size: 0.75rem;
    color: var(--muted);
}

/* ── Wizard ── */
.wizard-q {
    font-size: 0.88rem;
    font-weight: 600;
}

.wizard-opt {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.78rem;
    color: var(--text);
    text-align: left;
    transition: all 0.18s;
}

.wizard-opt:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.wizard-answer {
    background: rgba(166, 227, 161, 0.08);
    border: 1px solid rgba(166, 227, 161, 0.2);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.wizard-answer code {
    font-family: var(--font-code);
    color: var(--green);
    font-size: 0.82rem;
}

.wizard-answer p {
    font-size: 0.76rem;
    color: var(--muted);
    margin-top: 6px;
}

/* ── Bookmarks ── */
.bookmark-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    cursor: pointer;
}

.bookmark-card:hover {
    background: var(--surface-2);
}

.bookmark-card-name {
    font-family: var(--font-code);
    font-size: 0.8rem;
    color: var(--blue);
    flex: 1;
}

.bookmark-card-short {
    font-size: 0.72rem;
    color: var(--muted);
}

.bookmark-del {
    font-size: 0.7rem;
    color: var(--muted);
    cursor: pointer;
}

.bookmark-del:hover {
    color: var(--red);
}

/* ── Search no results ── */
.no-results {
    text-align: center;
    padding: 40px;
    color: var(--muted);
    font-size: 0.85rem;
}

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 16px;
    right: 16px;
    background: var(--text);
    color: var(--bg);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 0.78rem;
    z-index: 999;
    opacity: 0;
    transform: translateY(6px);
    transition: all 0.25s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}