:root {
    color-scheme: dark;
    --page: #0b0d10;
    --grid: rgba(255, 255, 255, .035);
    --bg: #12151b;
    --chrome: #1a1e26;
    --border: #262b35;
    --fg: #d7dce2;
    --dim: #6f7885;
    --green: #7ee787;
    --yellow: #e3b341;
    --red: #ff5f56;
    --blue: #79c0ff;
    --cyan: #56d4dd;
    --accent: #ff2d20;
    --shadow: 0 30px 80px rgba(0, 0, 0, .55);
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        color-scheme: light;
        --page: #ebe7df;
        --grid: rgba(0, 0, 0, .045);
        --bg: #fbfaf6;
        --chrome: #f0ede6;
        --border: #d9d4c9;
        --fg: #24292f;
        --dim: #7d848e;
        --green: #1a7f37;
        --yellow: #9a6700;
        --red: #cf222e;
        --blue: #0969da;
        --cyan: #1b7c83;
        --accent: #e3241a;
        --shadow: 0 30px 80px rgba(60, 50, 30, .22);
    }
}

:root[data-theme="light"] {
    color-scheme: light;
    --page: #ebe7df;
    --grid: rgba(0, 0, 0, .045);
    --bg: #fbfaf6;
    --chrome: #f0ede6;
    --border: #d9d4c9;
    --fg: #24292f;
    --dim: #7d848e;
    --green: #1a7f37;
    --yellow: #9a6700;
    --red: #cf222e;
    --blue: #0969da;
    --cyan: #1b7c83;
    --accent: #e3241a;
    --shadow: 0 30px 80px rgba(60, 50, 30, .22);
}

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

html,
body {
    height: 100%;
    margin: 0;
}

body {
    display: grid;
    place-items: center;
    background-color: var(--page);
    background-image: linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
    background-size: 32px 32px;
    color: var(--fg);
    font: 15px/1.6 ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, "Liberation Mono", monospace;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Fenêtre */

.window {
    display: flex;
    flex-direction: column;
    width: min(920px, 100% - 48px);
    height: min(660px, 100dvh - 96px);
    overflow: hidden;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.titlebar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    flex: none;
    height: 40px;
    padding: 0 12px;
    background: var(--chrome);
    border-bottom: 1px solid var(--border);
    user-select: none;
}

.lights {
    display: flex;
    gap: 8px;
}

.lights i {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ff5f56;
}

.lights i:nth-child(2) {
    background: #ffbd2e;
}

.lights i:nth-child(3) {
    background: #27c93f;
}

.title {
    color: var(--dim);
    font-size: 13px;
    white-space: nowrap;
}

.theme-toggle {
    justify-self: end;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    color: var(--dim);
    background: none;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}

.theme-toggle:hover {
    color: var(--fg);
}

/* Écran */

.screen {
    position: relative;
    flex: 1;
    min-height: 0;
    padding: 16px 20px 20px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    cursor: text;
}

.block {
    margin: 0 0 1.1em;
}

.line {
    margin: 0;
    min-height: 1.6em;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.section {
    margin: 1em 0 0;
    color: var(--green);
    font-weight: 700;
}

.block > .section:first-child {
    margin-top: 0;
}

.dim {
    color: var(--dim);
}

.green {
    color: var(--green);
}

.yellow {
    color: var(--yellow);
}

.red {
    color: var(--red);
}

.blue {
    color: var(--blue);
}

.bold {
    font-weight: 700;
}

/* Ligne « libellé ......... valeur », façon artisan about */

.row {
    display: flex;
    align-items: baseline;
    gap: 1ch;
    max-width: 78ch;
    margin: 0;
}

.row .dots {
    flex: 1;
    min-width: 3ch;
    overflow: hidden;
    color: var(--dim);
    white-space: nowrap;
    opacity: .6;
}

.row .dots::before {
    content: "........................................................................................................................";
}

.row .value {
    min-width: 0;
    text-align: right;
    overflow-wrap: anywhere;
}

.row.section {
    margin-top: 1em;
}

.block > .row.section:first-child {
    margin-top: 0;
}

/* Historique façon git log */

.commit {
    display: flex;
    gap: 1ch;
    margin: 0;
}

.commit .graph {
    flex: none;
    color: var(--red);
}

.commit .hash {
    flex: none;
    color: var(--yellow);
}

.commit .msg {
    min-width: 0;
}

.commit .employer {
    white-space: nowrap;
}

/* Erreur façon Laravel */

.badge {
    padding: 0 1ch;
    color: #fff;
    background: var(--accent);
    font-weight: 700;
}

.badge.info {
    color: var(--bg);
    background: var(--blue);
}

.cmd-link {
    padding: 0;
    color: var(--blue);
    background: none;
    border: 0;
    font: inherit;
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--blue) 40%, transparent);
    text-underline-offset: 3px;
    cursor: pointer;
}

.cmd-link:hover {
    text-decoration-color: currentColor;
}

/* Invite de commande */

.prompt {
    display: flex;
    align-items: baseline;
    gap: 1ch;
}

.prompt[hidden],
.chips[hidden] {
    display: none;
}

.ps1 {
    flex: none;
    white-space: nowrap;
}

.p-arrow {
    color: var(--green);
    font-weight: 700;
}

.p-path {
    color: var(--cyan);
    font-weight: 700;
}

.p-git {
    color: var(--blue);
    font-weight: 700;
}

.p-branch {
    color: var(--red);
}

.prompt input {
    flex: 1;
    min-width: 0;
    padding: 0;
    color: inherit;
    background: none;
    border: 0;
    outline: 0;
    font: inherit;
    caret-color: var(--accent);
    caret-shape: block;
}

/* Raccourcis cliquables */

.chips {
    display: flex;
    flex: none;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    overflow-x: auto;
    background: var(--chrome);
    border-top: 1px solid var(--border);
    scrollbar-width: none;
}

.chips button {
    flex: none;
    padding: 6px 14px;
    color: var(--fg);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: border-color .15s, color .15s;
}

.chips button::before {
    content: "$ ";
    color: var(--dim);
}

.chips button:hover {
    color: var(--green);
    border-color: var(--green);
}

:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

.prompt input:focus-visible {
    outline: 0;
}

/* Mobile : le terminal prend tout l'écran */

@media (max-width: 640px) {
    body {
        font-size: 13px;
        background-image: none;
        background-color: var(--bg);
    }

    .window {
        width: 100%;
        height: 100dvh;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .titlebar {
        padding-top: env(safe-area-inset-top);
        height: calc(40px + env(safe-area-inset-top));
    }

    .screen {
        padding: 12px 14px 16px;
    }

    .p-git {
        display: none;
    }

    /* Évite le zoom automatique d'iOS sur les champs < 16px. */
    .prompt input {
        font-size: 16px;
        line-height: 1.3;
    }

    /* Les cinq raccourcis tiennent sur une ligne, sans défilement. */
    .chips {
        gap: 6px;
        padding-inline: 10px;
    }

    .chips button {
        flex: 1 0 auto;
        padding: 9px 8px;
        font-size: 12px;
    }

    .chips button::before {
        content: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}
