/* Self-hosted JetBrains Mono (variable, latin subset) - SIL OFL 1.1, see fonts/OFL.txt */
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 100 800;
    font-display: swap;
    src: url('fonts/jetbrains-mono-latin-wght.woff2') format('woff2-variations'), url('fonts/jetbrains-mono-latin-wght.woff2') format('woff2');
}

/* Inline SVG icons (sprite: icons.svg) */
.icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    fill: currentColor;
    vertical-align: -0.125em;
    flex-shrink: 0;
}

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

:root {
    --bg: #ffffff;
    --bg-alt: #f6f8fa;
    --border: #d0d7de;
    --text: #1f2328;
    --muted: #656d76;
    --green: #1a7f37;
    --cyan: #0969da;
    --amber: #9a6700;
    --red: #cf222e;
    --purple: #8250df;
    --shadow: rgba(31, 35, 40, 0.08);
    --glow: rgba(9, 105, 218, 0.15);
}

[data-theme="dark"] {
    --bg: #0d1117;
    --bg-alt: #161b22;
    --border: #30363d;
    --text: #c9d1d9;
    --muted: #8b949e;
    --green: #3fb950;
    --cyan: #58a6ff;
    --amber: #d29922;
    --red: #f85149;
    --purple: #bc8cff;
    --shadow: rgba(0, 0, 0, 0.4);
    --glow: rgba(63, 185, 80, 0.15);
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
    transition: background-color 0.4s ease, color 0.4s ease;
    min-height: 100vh;
    font-size: 15px;
}

/* ── Scroll Progress ── */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, var(--green), var(--cyan));
    z-index: 200;
    transition: width 0.1s linear;
}

/* ── Controls ── */
.controls {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 100;
}

.control-btn {
    width: 38px;
    height: 38px;
    border-radius: 6px;
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    background: var(--bg-alt);
    color: var(--muted);
}

.control-btn:hover {
    color: var(--cyan);
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px var(--glow);
}

/* ── Container ── */
.container {
    max-width: 880px;
    margin: 0 auto;
    padding: 4rem 1.5rem 3rem;
}

/* ── Terminal Window ── */
.terminal-window {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 12px 40px var(--shadow);
}

.terminal-titlebar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
}

.terminal-title {
    flex: 1;
    text-align: left;
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.win-controls {
    display: flex;
    gap: 0.3rem;
    flex-shrink: 0;
}

.win-btn {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font: inherit;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.win-btn:hover {
    background: var(--border);
    color: var(--text);
}

.win-btn:active {
    transform: scale(0.85);
}

.win-btn.win-close:hover {
    background: var(--red);
    color: #ffffff;
}

/* ── Window control animations ── */
.terminal-window.wm-pop {
    animation: wmPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes wmPop {
    0% { transform: scale(0.94); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

.terminal-window.wm-closing {
    animation: wmClose 0.35s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes wmClose {
    to { transform: scale(0.85); opacity: 0; }
}

.terminal-window.wm-maximized {
    position: fixed;
    inset: 1.25rem;
    width: auto;
    max-width: none;
    z-index: 300;
    display: flex;
    flex-direction: column;
}

.terminal-window.wm-maximized .terminal-titlebar,
.terminal-window.wm-maximized .status-bar {
    flex-shrink: 0;
}

.terminal-window.wm-maximized .terminal-body {
    flex: 1;
    overflow-y: auto;
}

.respawn-msg {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    color: var(--green);
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 250;
}

.respawn-msg.show { opacity: 1; }

.terminal-body {
    padding: 1.75rem 1.75rem 2rem;
    max-height: 20000px;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease, padding 0.35s ease;
}

.terminal-window.wm-minimized .terminal-body,
.terminal-window.wm-minimized .status-bar {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-color: transparent;
}

/* ── Command line ── */
.cmd-line {
    font-size: 0.88rem;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.cmd-line .prompt-user { color: var(--green); font-weight: 600; }
.cmd-line .prompt-path { color: var(--cyan); font-weight: 600; }
.cmd-line .prompt-dollar { color: var(--muted); }
.cmd-line .prompt-cmd {
    color: var(--text);
    font-weight: 500;
    overflow: hidden;
    white-space: nowrap;
    width: 15.5ch;
}

/* The typing effect only runs on a first visit (html.anim is set by theme.js) */
html.anim .cmd-line .prompt-cmd {
    border-right: 2px solid var(--green);
    animation: typing 1s steps(14) 0.2s forwards, caretBlink 0.8s step-end 1.2s 3 forwards;
}

@keyframes typing {
    from { width: 0; }
    to { width: 15.5ch; }
}

@keyframes caretBlink {
    0%, 100% { border-color: var(--green); }
    50% { border-color: transparent; }
}

/* ── Markdown output ── */
.md-mark { color: var(--muted); font-weight: 400; opacity: 0.6; }


h1 {
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 0.4rem;
}

.md-quote {
    border-left: 3px solid var(--border);
    padding-left: 0.9rem;
    color: var(--muted);
    font-style: italic;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.badges-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.1rem;
}

.badge-pill {
    display: inline-flex;
    border-radius: 4px;
    overflow: hidden;
    font-size: 0.68rem;
    font-weight: 600;
    border: 1px solid var(--border);
}

.badge-label {
    background: var(--bg);
    color: var(--muted);
    padding: 0.22rem 0.55rem;
}

.badge-value {
    padding: 0.22rem 0.55rem;
    color: var(--bg);
}

.badge-value.green { background: var(--green); }
.badge-value.blue { background: var(--cyan); }

.meta-line {
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: 1.75rem;
}

.role-typed {
    color: var(--cyan);
    font-weight: 600;
}

.md-quote .cursor-blink {
    background: var(--cyan);
    margin-left: 1px;
}

h2.md-h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 2.25rem 0 1rem;
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
}

.about-text p {
    color: var(--text);
    margin-bottom: 0.85rem;
    font-size: 0.92rem;
}

.about-text strong { color: var(--cyan); font-weight: 600; }

/* ── Tools grid ── */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.tool-entry {
    position: relative;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.1rem 1.2rem;
    text-decoration: none;
    color: var(--text);
    display: block;
    overflow: hidden;
    transition: border-color 0.25s ease, transform 0.25s ease;
}

.tool-entry::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), var(--glow), transparent 60%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.tool-entry:hover {
    border-color: var(--cyan);
    transform: translateY(-2px);
}

.tool-entry:hover::before { opacity: 1; }

.tool-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.tool-name {
    font-weight: 700;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tool-name .icon { color: var(--cyan); font-size: 0.85rem; }

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    flex-shrink: 0;
    position: relative;
}

.status-dot::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 1px solid var(--green);
    opacity: 0.6;
    animation: pulseRing 1.8s ease-out infinite;
}

@keyframes pulseRing {
    0% { transform: scale(0.6); opacity: 0.6; }
    100% { transform: scale(1.8); opacity: 0; }
}

.status-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.68rem;
    color: var(--green);
    font-weight: 600;
    text-transform: lowercase;
}

.pwa-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--cyan);
    background: var(--glow);
    padding: 0.1rem 0.4rem;
    border-radius: 2em;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.tool-desc {
    color: var(--muted);
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
    line-height: 1.55;
}

.topic-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.topic-tag {
    background: var(--glow);
    color: var(--cyan);
    font-size: 0.68rem;
    font-weight: 500;
    padding: 0.1rem 0.55rem;
    border-radius: 2em;
}

/* ── Tools: lead section ── */
.lead {
    color: var(--muted);
    font-size: 0.88rem;
    margin: -0.35rem 0 1rem;
}

.lead a { color: var(--cyan); text-decoration: none; }
.lead a:hover { text-decoration: underline; }

.tool-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    padding: 0.55rem 0.85rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tool-filter:focus-within {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px var(--glow);
}

.tool-filter .prompt-user { color: var(--green); font-weight: 600; }
.tool-filter .prompt-path { color: var(--cyan); font-weight: 600; }
.tool-filter .prompt-dollar { color: var(--muted); }
.tool-filter label { color: var(--text); font-weight: 500; }

.tool-filter input {
    flex: 1 1 8rem;
    min-width: 0;
    font: inherit;
    color: var(--text);
    background: transparent;
    border: 0;
    outline: 0;
    caret-color: var(--green);
}

.tool-filter input::placeholder { color: var(--muted); opacity: 0.8; }

.tool-filter kbd {
    font: inherit;
    font-size: 0.7rem;
    color: var(--muted);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 0 0.4rem;
}

.tool-count {
    color: var(--muted);
    font-size: 0.72rem;
    white-space: nowrap;
}

.tool-group { margin-bottom: 1.5rem; }
.tool-group[hidden], .tool-entry[hidden], .tool-empty[hidden] { display: none; }

.tool-group h3 {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.7rem;
    text-transform: lowercase;
    letter-spacing: 0.02em;
}

.tool-checks {
    color: var(--text);
    font-size: 0.74rem;
    line-height: 1.5;
    margin: -0.35rem 0 0.75rem;
}

.tool-checks b { color: var(--green); font-weight: 600; }

.tool-empty {
    color: var(--muted);
    font-size: 0.85rem;
    padding: 0.5rem 0;
}

.launch-block .cmd-line { margin-bottom: 0.9rem; }
.title-icon { font-size: 0.72rem; margin-right: 0.4rem; }
.meta-line .icon { margin-right: 0.15rem; }
.site-btn .icon { font-size: 0.9em; }

:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.tool-filter input:focus-visible { outline: 0; }

/* ── Code block (tech stack) ── */
.code-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    font-size: 0.82rem;
    overflow-x: auto;
    white-space: pre;
}

.yaml-key { color: var(--purple); }
.yaml-punc { color: var(--muted); }
.yaml-val { color: var(--green); }

/* ── Contact list ── */
.md-list { list-style: none; }

.md-list li {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.55rem;
    font-size: 0.9rem;
}

.md-list a {
    color: var(--cyan);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.md-list a:hover { text-decoration: underline; }
.md-list .icon { width: 16px; color: var(--muted); }

.copy-hint {
    color: var(--muted);
    font-size: 0.72rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.copy-hint.show { opacity: 1; }

/* ── Launch script block ── */
.launch-block {
    margin-top: 2.25rem;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--border);
}

.site-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    background: var(--green);
    color: var(--bg);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.site-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--glow);
}

/* ── Final prompt ── */
.final-prompt {
    margin-top: 1.75rem;
    font-size: 0.88rem;
    display: flex;
    gap: 0.5rem;
}

.cursor-blink {
    display: inline-block;
    width: 8px;
    height: 1.1em;
    background: var(--green);
    animation: caretBlink 0.9s step-end infinite;
    vertical-align: text-bottom;
}

/* ── Status bar footer ── */
.status-bar {
    display: flex;
    align-items: stretch;
    font-size: 0.72rem;
    border-top: 1px solid var(--border);
    max-height: 60px;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease, border-color 0.25s ease;
}

.status-bar .sb-mode {
    background: var(--green);
    color: #0d1117;
    font-weight: 700;
    padding: 0.4rem 0.75rem;
}

.status-bar .sb-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.4rem 0.9rem;
    color: var(--muted);
    background: var(--bg-alt);
    overflow-x: auto;
    white-space: nowrap;
}

.status-bar .sb-info a { color: var(--muted); text-decoration: none; }
.status-bar .sb-info a:hover { color: var(--cyan); }

/* ── Animations ── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .container { padding: 2rem 1rem 2.5rem; }
    .terminal-body { padding: 1.25rem 1.1rem 1.5rem; }
    h1 { font-size: 1.5rem; }
    .tools-grid { grid-template-columns: 1fr; }
    .controls { top: 0.9rem; right: 0.9rem; }
    .status-bar .sb-info { gap: 0.75rem; }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html.anim .cmd-line .prompt-cmd {
        width: 15.5ch;
        border-right-color: transparent;
    }
}
