/* ============================================================
   WebCoder — terminal/matrix aesthetic.
   Reference: maaslalu/slides + Debian TTY + Alacritty window.
   Self-contained. No frameworks. Dark-only by design.
   ============================================================ */

@font-face {
    font-family: 'Fira Code';
    src: url('../fonts/FiraCode-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Fira Code';
    src: url('../fonts/FiraCode-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'JetBrains Mono';
    src: url('../fonts/JetBrainsMono-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'JetBrains Mono';
    src: url('../fonts/JetBrainsMono-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'JetBrains Mono';
    src: url('../fonts/JetBrainsMono-Italic.woff2') format('woff2');
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}

:root {
    --bg:        #0a0e0a;
    --bg-soft:   #0f1410;
    --bg-window: #0d120e;
    --fg:        #c8facc;
    --fg-bright: #e7ffe9;
    --green:     #4ade80;
    --green-dim: #22c55e;
    --green-deep:#166534;
    --yellow:    #fbbf24;
    --red:       #ef4444;
    --cyan:      #67e8f9;
    --magenta:   #f0abfc;
    --dim:       #5a7a5e;
    --rule:      #1c3a23;
    --rule-bright:#2d5c3a;

    --mono: 'JetBrains Mono', 'Fira Code', 'IBM Plex Mono', 'Cascadia Code',
            'Consolas', 'Menlo', ui-monospace, monospace;

    --line: 1.55;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html {
    background: var(--bg);
    color-scheme: dark;
}

body {
    font-family: var(--mono);
    font-size: clamp(13px, 1.4vw, 15px);
    line-height: var(--line);
    color: var(--fg);
    background: var(--bg);
    min-height: 100vh;
    overflow-x: hidden;
    font-feature-settings: 'liga' 1, 'calt' 1, 'zero' 1, 'ss02' 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* subtle scanlines */
    background-image:
        repeating-linear-gradient(
            to bottom,
            rgba(0, 0, 0, 0) 0,
            rgba(0, 0, 0, 0) 2px,
            rgba(0, 255, 65, 0.012) 2px,
            rgba(0, 255, 65, 0.012) 3px
        );
}

/* CRT scanlines — fullscreen overlay above everything else.
   Subtle 1px line every 3px + a slow scan beam + faint flicker.
   Toggle via `crt` REPL command (sets html.crt-off). */
.crt-scanlines {
    position: fixed;
    inset: 0;
    z-index: 10000;
    pointer-events: none;
    background-image: repeating-linear-gradient(
        180deg,
        rgba(0, 0, 0, 0)        0px,
        rgba(0, 0, 0, 0)        3px,
        rgba(0, 25, 0, 0.035)   3px,
        rgba(0, 25, 0, 0.035)   4px
    );
    animation: crt-flicker 7s infinite;
    transition: opacity 0.3s ease-out;
}
.crt-scanlines::before {
    content: '';
    position: absolute;
    left: 0; right: 0;
    height: 14vh;
    background: linear-gradient(180deg,
        transparent 0%,
        rgba(74, 222, 128, 0.018) 50%,
        transparent 100%);
    animation: crt-scan 12s linear infinite;
}
html.crt-off .crt-scanlines { opacity: 0; animation: none; }
html.crt-off .crt-scanlines::before { display: none; }

@keyframes crt-flicker {
    0%, 100%  { opacity: 1; }
    96%       { opacity: 0.97; }
    97%       { opacity: 0.99; }
    98%       { opacity: 0.96; }
    99%       { opacity: 0.98; }
}
@keyframes crt-scan {
    from { transform: translateY(-14vh); }
    to   { transform: translateY(100vh); }
}

@media (prefers-reduced-motion: reduce) {
    .crt-scanlines           { animation: none; }
    .crt-scanlines::before   { animation: none; display: none; }
}

/* Matrix rain canvas */
#matrix {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    opacity: 0.38;
    pointer-events: none;
    mix-blend-mode: screen;
    transition: opacity 1.6s ease-in-out;
}

/* `cmatrix` easter egg — canvas leaps to the top of the z-stack and
   slowly fades to full opacity. Keeps mix-blend-mode: screen so the
   dark canvas background stays transparent — only bright katakana
   glyphs glow over the terminal. */
html.cmatrix-active #matrix {
    z-index: 9999;
    opacity: 1;
}
html.cmatrix-active .window {
    box-shadow: 0 0 30px rgba(74, 222, 128, 0.55);
}

::selection { background: var(--green); color: var(--bg); }

/* ============================================================
   APP — centered window layout (only visible when JS-ready)
   ============================================================ */

.app {
    display: none;
}

html.js-ready .app {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 5vh clamp(16px, 3vw, 28px);
    gap: clamp(14px, 2.2vw, 22px);
    position: relative;
    z-index: 1;
    box-sizing: border-box;
}

/* Hero — big "$ webcoder" logo + tagline */
.hero {
    text-align: center;
    margin: 0;
}

.logo {
    margin: 0;
    font-family: var(--mono);
    font-weight: 700;
    font-size: clamp(32px, 6vw, 64px);
    letter-spacing: 0.04em;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 0.18em;
    color: var(--green);
    text-shadow: 0 0 18px rgba(74, 222, 128, 0.35);
}

.logo-prompt { color: var(--dim); }
.logo-text { color: var(--green); }

/* Logo link — inherits all styles, just adds cursor + subtle hover */
.logo-link {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.18em;
    cursor: pointer;
    transition: filter 0.15s ease-out;
}
.logo-link:hover .logo-text,
.logo-link:focus .logo-text {
    filter: brightness(1.15);
}
.logo-link:focus { outline: none; }

/* When JS is enabled, hide logo-text until typing animation kicks in.
   Without JS, logo stays visible immediately (SEO + no-JS UX). */
html.js-ready .logo-text:not(.is-typed) {
    visibility: hidden;
}

/* Intro PHASE 1: only the logo exists in layout — everything else is
   completely removed (display: none) so the logo is perfectly centered. */
html.js-ready:not(.intro-done) .tagline,
html.js-ready:not(.intro-done) .appnav,
html.js-ready:not(.intro-done) .window,
html.js-ready:not(.intro-done) .app > .footline {
    display: none;
}

/* Intro PHASE 2: html.intro-done — elements re-enter the layout, then fade in */
html.intro-done .tagline:not(.intro-shown),
html.intro-done .appnav:not(.intro-shown),
html.intro-done .window:not(.intro-shown),
html.intro-done .app > .footline:not(.intro-shown) {
    opacity: 0;
    pointer-events: none;
}

/* Tagline + menu slide DOWN from just above (under the logo) */
html.intro-done .tagline:not(.intro-shown),
html.intro-done .appnav:not(.intro-shown) {
    transform: translateY(-14px);
}

/* Footer slides UP slightly */
html.intro-done .app > .footline:not(.intro-shown) {
    transform: translateY(8px);
}

/* Window also "opens" from the top — clip-path animates from 0 to full */
html.intro-done .window:not(.intro-shown) {
    transform: translateY(6px);
    clip-path: inset(0 0 100% 0);
}

html.intro-done .tagline,
html.intro-done .appnav,
html.intro-done .app > .footline {
    transition: opacity 0.55s ease-out, transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
html.intro-done .window {
    transition:
        opacity   0.5s  ease-out 0.05s,
        transform 0.55s ease-out 0.05s,
        clip-path 0.7s  cubic-bezier(0.65, 0, 0.35, 1) 0.1s;
}

/* Boot lines inside the window — dim system text.
   Ligatures off: JetBrains Mono reshapes `**` / `***` into a centered glyph,
   which makes asterisks bounce vertically as they're typed in. */
.boot-line {
    margin: 0;
    color: var(--dim);
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
    font-variant-ligatures: none;
    font-feature-settings: "liga" 0, "calt" 0;
}
.boot-line.boot-bright { color: var(--fg-bright); }
.boot-line.boot-ok     { color: var(--green); }
.boot-mask             { color: var(--green); letter-spacing: 0.1em; font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }

/* Logo cursor — underscore matching the favicon ('>_' look). */
.logo .cursor-block {
    display: inline-block;
    color: var(--green);
    background: transparent;
    width: auto;
    height: auto;
    margin-left: 0.05em;
    line-height: 1;
    align-self: baseline;
    animation: blink 1.05s steps(1) infinite;
}
.logo .cursor-block::after {
    content: '_';
}

.tagline {
    margin: 8px 0 0;
    color: var(--dim);
    letter-spacing: 0.18em;
    font-size: clamp(11px, 1.2vw, 13px);
    text-transform: lowercase;
}

/* Nav above the window */
.appnav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    justify-content: center;
    align-items: center;
    color: var(--green);
    font-size: clamp(12px, 1.3vw, 14px);
}

.appnav a {
    color: var(--green);
    text-decoration: none;
    padding: 2px 4px;
    transition: color 0.12s, background 0.12s;
}

.appnav a:hover,
.appnav a:focus {
    color: var(--bg);
    background: var(--green);
    outline: none;
}

/* Active page — subtle, more delicate than hover */
.appnav a.is-active {
    color: var(--green);
    background: rgba(74, 222, 128, 0.10);
}
.appnav a.is-active:hover,
.appnav a.is-active:focus {
    color: var(--bg);
    background: var(--green);
}

.appnav-sep { color: var(--rule-bright); }

.appnav .langswitch {
    color: var(--cyan);
    border: 1px solid var(--rule);
    padding: 1px 8px;
    margin-left: 4px;
}
.appnav .langswitch:hover,
.appnav .langswitch:focus {
    color: var(--bg);
    background: var(--cyan);
    border-color: var(--cyan);
}

/* ============================================================
   WINDOW — the terminal-app frame
   ============================================================ */

.window {
    width: 100%;
    max-width: 760px;
    height: 540px;            /* fixed — predictable terminal size */
    background: var(--bg-window);
    border: 1px solid var(--rule-bright);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.6),
        0 12px 48px rgba(0, 0, 0, 0.6),
        0 0 80px rgba(74, 222, 128, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 4px;
}

/* tmux-style status bar — green tag on dark, status pushed right */
.window-chrome {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 10px;
    background: #0f1611;
    border-bottom: 1px solid var(--rule);
    user-select: none;
    font-size: 0.82em;
}

.window-tag {
    display: inline-block;
    background: var(--green);
    color: var(--bg);
    padding: 0 8px;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: 0.05em;
}

.window-name {
    color: var(--fg);
    letter-spacing: 0.02em;
    flex: 0 1 auto;
}

.window-status {
    margin-left: auto;
    color: var(--dim);
    font-size: 0.96em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.window-screen {
    padding: 16px clamp(14px, 2.4vw, 22px) 14px;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;            /* internal scroll is on .window-history */
}

/* History area scrolls internally — REPL stays pinned to bottom of window. */
.window-history {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--rule-bright) transparent;
}

.window-history::-webkit-scrollbar { width: 10px; }
.window-history::-webkit-scrollbar-track { background: transparent; }
.window-history::-webkit-scrollbar-thumb {
    background: var(--rule-bright);
    border-radius: 0;
}

.window-history {
    /* history entries stack here */
}

/* ============================================================
   BLOCK (re-used in both window and static-source)
   ============================================================ */

.block { margin: 0 0 18px; }

.prompt {
    margin: 0 0 6px;
    color: var(--green);
    font-weight: 500;
    white-space: pre-wrap;
    word-break: break-word;
}

.ps1     { color: var(--green); }
.prompt .path { color: var(--cyan); }
.cmd     { color: var(--yellow); }

.output { margin: 0 0 4px; }

.output p {
    margin: 0;
    color: var(--fg-bright);
    white-space: pre-wrap;
}

.output-boxed { color: var(--green-dim); font-variant-ligatures: none; line-height: 1.3; }
.output-boxed p { color: var(--fg-bright); line-height: 1.3; }

.output-boxed .box-title,
.output-boxed .box-bottom {
    color: var(--green);
    white-space: pre;
    display: flex;
    align-items: center;
    gap: 4px;
}

.box-fill {
    flex: 1;
    height: 1px;
    border-top: 1px solid var(--green);
    margin: 0 4px;
    align-self: center;
    opacity: 0.85;
    transform: scaleX(1);
    transform-origin: left center;
    transition: transform 0.55s ease-out;
}
.box-bottom .box-fill { margin: 0; }

.hl-num  { color: var(--magenta); }
.hl-file { color: var(--cyan); }
a.hl-file.service-link {
    color: var(--cyan);
    text-decoration: none;
    border-bottom: 1px dotted transparent;
    transition: border-color 0.15s ease-out, color 0.15s ease-out;
}
a.hl-file.service-link:hover,
a.hl-file.service-link:focus {
    color: var(--fg-bright);
    border-bottom-color: var(--cyan);
}

/* Inline see-also link inside a card body. */
.service-card a.service-link {
    color: var(--cyan);
    text-decoration: none;
    border-bottom: 1px dotted var(--rule);
}
.service-card a.service-link:hover { color: var(--fg-bright); border-bottom-color: var(--cyan); }

.output.service-card a.service-cta,
.output.service-card a.service-cta:hover,
.output.service-card a.service-cta:focus {
    color: var(--bg);
    background: var(--green);
    padding: 1px 6px;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.15s ease-out, box-shadow 0.15s ease-out;
}
.output.service-card a.service-cta:hover,
.output.service-card a.service-cta:focus {
    background: var(--green-dim);
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.45);
}
.hl-key  { color: var(--yellow); }
.dim     { color: var(--dim); }

.output a {
    color: var(--cyan);
    text-decoration: underline;
    text-decoration-color: var(--green-deep);
    text-underline-offset: 2px;
}
.output a:hover, .output a:focus {
    color: var(--green);
    text-decoration-color: var(--green);
    outline: none;
}

/* Reveal animation when a block lands in the window */
.output.is-pending,
.output.is-pending .box-title,
.output.is-pending .box-bottom,
.output.is-pending > p { opacity: 0; }

.output.is-pending .box-fill { transform: scaleX(0); }

.output.is-revealed { transition: none; }
.output.is-revealed .box-fill { transform: scaleX(1); }

.output.is-revealed .box-title,
.output.is-revealed .box-bottom,
.output.is-revealed > p {
    animation: fadein 0.28s ease-out forwards;
}

.output.is-revealed > p:nth-child(2)  { animation-delay: 0.06s; }
.output.is-revealed > p:nth-child(3)  { animation-delay: 0.12s; }
.output.is-revealed > p:nth-child(4)  { animation-delay: 0.18s; }
.output.is-revealed > p:nth-child(5)  { animation-delay: 0.24s; }
.output.is-revealed > p:nth-child(6)  { animation-delay: 0.30s; }
.output.is-revealed > p:nth-child(7)  { animation-delay: 0.36s; }
.output.is-revealed > p:nth-child(8)  { animation-delay: 0.42s; }
.output.is-revealed > p:nth-child(9)  { animation-delay: 0.48s; }
.output.is-revealed > p:nth-child(10) { animation-delay: 0.54s; }
.output.is-revealed > p:nth-child(11) { animation-delay: 0.60s; }
.output.is-revealed > p:nth-child(12) { animation-delay: 0.66s; }
.output.is-revealed > p:nth-child(13) { animation-delay: 0.72s; }
.output.is-revealed > p:nth-child(14) { animation-delay: 0.78s; }
.output.is-revealed > p:nth-child(15) { animation-delay: 0.84s; }
.output.is-revealed > p:nth-child(16) { animation-delay: 0.90s; }
.output.is-revealed > p:nth-child(17) { animation-delay: 0.96s; }
.output.is-revealed > p:nth-child(18) { animation-delay: 1.02s; }
.output.is-revealed > p:nth-child(19) { animation-delay: 1.08s; }
.output.is-revealed > p:nth-child(20) { animation-delay: 1.14s; }
.output.is-revealed .box-bottom { animation-delay: 1.2s; }

@keyframes fadein {
    from { opacity: 0; transform: translateY(2px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   REPL — interactive prompt at the bottom of the window
   ============================================================ */

.repl {
    display: flex;
    align-items: center;
    margin: 4px 0 0;
    flex-wrap: wrap;
}

/* REPL is hidden until the current section finishes loading.
   .window-screen.is-ready unhides it. No-JS users see it from the start. */
html.js-ready .window-screen:not(.is-ready) .repl {
    opacity: 0;
    pointer-events: none;
}
html.js-ready .window-screen .repl {
    transition: opacity 0.32s ease-out;
}

.repl-label {
    color: var(--green);
    user-select: none;
    white-space: nowrap;
}

.repl-input {
    flex: 1;
    min-width: 12ch;
    appearance: none;
    background: transparent;
    border: 0;
    outline: 0;
    color: var(--yellow);
    font: inherit;
    padding: 0;
    margin: 0;
    caret-color: var(--green);
}

.repl-input::placeholder {
    color: var(--dim);
    opacity: 1;
}

.repl-input:focus { outline: none; }

/* Ctrl+R reverse-i-search — bash-style prompt and match display.
   `.repl-label` is rewritten in JS to `(reverse-i-search)\``, the user types
   into the normal input (its value is the query), and `.repl-search-after`
   shows the closing `':` plus the matched command. */
.search-prompt  { color: var(--cyan); }
.search-failed  { color: var(--red); }
.repl-search-after {
    color: var(--dim);
    white-space: nowrap;
    user-select: none;
}
.repl-search-after .search-match {
    color: var(--yellow);
}

/* Contact form — one continuous CSS line on the left, drawn as a background
   gradient stripe so it can't break across rows or next to the textarea.
   Text │ chars in markup are hidden but kept for layout space. */
.contact-form {
    margin: 8px 0 12px;
    color: var(--green-dim);
    font-variant-ligatures: none;
    line-height: 1.3;
    background-image: linear-gradient(
        to right,
        transparent calc(0.5ch - 0.5px),
        var(--green)  calc(0.5ch - 0.5px),
        var(--green)  calc(0.5ch + 0.5px),
        transparent  calc(0.5ch + 0.5px)
    );
    background-position: 0 1.4em;
    background-size: 100% calc(100% - 2.8em);
    background-repeat: no-repeat;
}

/* The text │ chars are hidden (their pixels would overlap the gradient line
   and cause subtle anti-aliasing artefacts), but they stay in markup so the
   layout — label indents, flex columns — remains identical. */
.contact-form .ff-pipe {
    visibility: hidden;
    user-select: none;
}
.contact-form .ff-title,
.contact-form .ff-bottom {
    color: var(--green);
    white-space: pre;
    display: flex;
    align-items: center;
    gap: 4px;
}

.contact-form .ff-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 0;
    /* Match the left-side offset (pipe at 0.5ch + visual breathing room)
       so inputs/textarea don't kiss the right corner glyph. */
    padding: 1px 1ch 1px 0;
}

.contact-form .ff-pipe {
    color: var(--green);
    flex: 0 0 auto;
    user-select: none;
}

.contact-form .ff-label {
    color: var(--yellow);
    flex: 0 0 12ch;
}

.contact-form .ff-input,
.contact-form .ff-textarea {
    flex: 1 1 auto;
    appearance: none;
    background: rgba(0, 0, 0, 0.3);     /* visible field box — clearly clickable */
    border: 0;
    outline: 0;
    color: var(--fg-bright);
    font: inherit;
    padding: 2px 6px;
    margin: 0;
    caret-color: var(--green);
    resize: none;
    min-width: 0;
    border-radius: 2px;
}
.contact-form .ff-input:focus {
    background: rgba(74, 222, 128, 0.08);
    box-shadow: inset 0 0 0 1px var(--green-deep);
}

/* Message label sits alone on a row; textarea on the next row */
.contact-form .ff-msgrow .ff-label {
    flex: 0 0 auto;
}

/* Textarea row — same visible field bg as inputs */
.contact-form .ff-textarea-row {
    align-items: flex-start;
}
.contact-form .ff-textarea-row .ff-textarea {
    width: 100%;
    min-height: 4.5em;
    padding: 6px 8px;
}
.contact-form .ff-textarea-row .ff-textarea:focus {
    background: rgba(74, 222, 128, 0.08);
    box-shadow: inset 0 0 0 1px var(--green-deep);
}
.contact-form .ff-spacer {
    height: 1.4em;
}

/* honeypot — visually hidden */
.contact-form .ff-honey {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.contact-form .ff-actions {
    gap: 14px;
    align-items: center;
}
.contact-form .ff-btn {
    appearance: none;
    border: 0;
    font: inherit;
    cursor: pointer;
    padding: 2px 6px;
    text-transform: lowercase;
    transition: color 0.12s, background 0.12s, box-shadow 0.12s;
}

/* Primary action — solid green CTA, stands out from the [ napisz wiadomość ]
   link and other secondary actions on the site. */
.contact-form .ff-btn-send {
    background: var(--green);
    color: var(--bg);
    font-weight: 700;
    box-shadow: 0 0 0 1px var(--green);
}
.contact-form .ff-btn-send:hover,
.contact-form .ff-btn-send:focus {
    background: var(--fg-bright);
    box-shadow: 0 0 0 1px var(--fg-bright), 0 0 12px rgba(74, 222, 128, 0.4);
    outline: none;
}
.contact-form .ff-btn-send:disabled {
    background: var(--green-deep);
    color: var(--dim);
    box-shadow: none;
    cursor: wait;
}

/* Secondary — quiet text link */
.contact-form .ff-btn-cancel {
    background: transparent;
    color: var(--dim);
}
.contact-form .ff-btn-cancel:hover,
.contact-form .ff-btn-cancel:focus {
    color: var(--fg-bright);
    background: transparent;
    outline: none;
}

.contact-form .ff-status-row .ff-status {
    color: var(--dim);
    font-size: 0.95em;
    min-height: 1em;
}
.contact-form .ff-status.is-ok  { color: var(--green); }
.contact-form .ff-status.is-err { color: var(--red); }

/* Make the "[ napisz wiadomość ]" link in the contact box look clickable */
.output a.form-open {
    color: var(--cyan);
    cursor: pointer;
}
.output a.form-open:hover,
.output a.form-open:focus {
    color: var(--green);
    background: rgba(74, 222, 128, 0.10);
}

/* Inline cursor — for the logo */
.cursor-block {
    display: inline-block;
    width: 0.6em;
    height: 1.05em;
    margin-left: 1px;
    background: var(--green);
    vertical-align: middle;
    animation: blink 1.05s steps(1) infinite;
}

@keyframes blink {
    0%, 49%   { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* Footer line under the window */
.footline {
    color: var(--dim);
    font-size: 0.82em;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 14px;
    text-align: center;
    margin: 0;
}

/* ============================================================
   STATIC-SOURCE — visible only when JS is disabled.
   When JS is active, kept in DOM (off-screen) for SEO/AI crawlers.
   ============================================================ */

.static-source {
    max-width: 920px;
    margin: 0 auto;
    padding: clamp(16px, 3vw, 28px);
    position: relative;
    z-index: 1;
}

html.js-ready .static-source {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    left: -10000px;
    top: auto;
}

.static-source .topbar {
    padding-bottom: 14px;
    border-bottom: 1px dashed var(--rule);
    margin-bottom: 22px;
    font-size: 0.92em;
}

.static-source .tab {
    padding: 2px 10px;
    border: 1px solid var(--rule);
    color: var(--bg);
    background: var(--green);
    font-weight: 600;
}

.static-source .boot { margin-bottom: 24px; color: var(--dim); }

.static-source .boot-pre {
    margin: 0;
    font-family: var(--mono);
    font-size: 0.94em;
    color: var(--dim);
    white-space: pre-wrap;
    word-break: break-word;
}

.static-source .footline {
    margin-top: 36px;
    padding-top: 14px;
    border-top: 1px dashed var(--rule);
    font-size: 0.88em;
    justify-content: space-between;
}

/* `vim` easter egg — fullscreen fake editor inside the terminal.
   Read-only viewer with NORMAL + COMMAND modes. :q actually exits. */
.window-screen { position: relative; }
.vim-editor {
    position: absolute;
    inset: 0;
    background: var(--bg-window);
    color: var(--fg);
    font: inherit;
    display: flex;
    flex-direction: column;
    z-index: 5;
}
.vim-buffer {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px 2px;
}
.vim-line {
    line-height: 1.4;
    white-space: pre-wrap;
    min-height: 1.4em;
}
.vim-tilde { color: var(--green-deep); }
.vim-status {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 2px 8px;
    background: rgba(74, 222, 128, 0.22);
    color: var(--fg-bright);
    border-top: 1px solid var(--rule);
    min-height: 1.4em;
    font-variant-ligatures: none;
}
.vim-file { font-weight: 600; }
.vim-pos  { color: var(--dim); }
.vim-cmd  { color: var(--fg-bright); }
.vim-msg  { color: var(--yellow); }
.vim-block-cursor {
    display: inline-block;
    min-width: 0.6em;
    background: var(--fg-bright);
    color: var(--bg-window);
    animation: blink 1.1s steps(1) infinite;
}

/* `sl` easter egg — steam locomotive that chugs across the window.
   The pre is wider than the container; we translate it from right
   off-screen to far-left off-screen over ~5s. */
.sl-frame {
    width: 100%;
    height: 9em;
    overflow: hidden;
    position: relative;
    margin: 4px 0;
}
.sl-train {
    position: absolute;
    top: 0;
    left: 100%;
    margin: 0;
    font: inherit;
    color: var(--yellow);
    white-space: pre;
    animation: sl-chug 5s linear forwards;
}
@keyframes sl-chug {
    from { transform: translateX(0); }
    to   { transform: translateX(calc(-100vw - 100%)); }
}

/* Manual pages — rendered inside the terminal by `man <service>`,
   and mirrored into .static-source for SEO/AI crawlers. */
.manpage-output {
    margin: 0 0 8px;
    color: var(--fg-bright);
    font: inherit;
    white-space: pre;
    line-height: 1.35;
    overflow-x: auto;
}
.static-source .manpages { margin-top: 28px; }
.static-source .manpage-pre {
    margin: 0 0 22px;
    font-family: var(--mono);
    font-size: 0.94em;
    color: var(--fg);
    white-space: pre-wrap;
}
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================================
   Mobile tweaks
   ============================================================ */

@media (max-width: 520px) {
    .logo { font-size: 38px; letter-spacing: 0.03em; }
    .tagline { font-size: 10px; letter-spacing: 0.14em; }
    .appnav { gap: 2px 10px; }
    .window-screen { padding: 12px 14px; }
    .window { height: clamp(360px, 70vh, 540px); }
    .window-name { font-size: 0.78em; }
    .footline { font-size: 0.78em; }
}

@media (prefers-reduced-motion: reduce) {
    .cursor-block { animation: none; opacity: 1; }
    .output.is-pending,
    .output.is-pending > p,
    .output.is-pending .box-title,
    .output.is-pending .box-bottom { opacity: 1 !important; }
    .output.is-pending .box-fill { transform: scaleX(1) !important; }
}
