/* --- Základní nastavení a proměnné --- */
:root {
    --background: #1e1e1e;
    --foreground: #d4d4d4;
    --green: #00dd00;
    --link-color: #569cd6;
    --error-color: #ff5f56;
    --font: 'Source Code Pro', monospace;
    --header-height: 30px;
    --footer-height: 30px;
    --cursor-color: var(--foreground);
    --cursor-width: 3px;
}

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

html, body {
    height: 100%;
    line-height: 1.4;
}

body {
    font-family: var(--font);
    color: var(--foreground);
    display: flex; /* Klíč pro centrování */
    justify-content: center; /* Horizontální centrování */
    align-items: center;    /* Vertikální centrování */
    height: 100vh; /* Zajistí, že body zabírá celou výšku viewportu */
    padding: 10px; /* Malý okraj kolem na desktopu */
    margin: 0;
    overflow: hidden; /* Zabrání scrollbarům na body */
}

/* --- Styl pro Canvas --- */
#background-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    display: block;
    background-color: #28282e;
}

/* --- Struktura terminálu --- */
#terminal {
    position: relative; /* Zachovat pro z-index a stínování */
    z-index: 1;
    background-color: var(--background);
    border: 1px solid #555;
    border-radius: 8px;
    /* Výchozí velikost - bude přepsána v media queries nebo ovlivněna resize */
    width: 90%; /* Šířka relativní k rodiči (body s paddingem) */
    height: 90%; /* Výška relativní k rodiči */
    max-width: 800px; /* Maximální šířka */
    max-height: 700px; /* Maximální výška */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Výchozí overflow, změní se pro resize */
    /* resize: none; /* Výchozí stav - není potřeba, protože resize není dědičná */
}

#terminal-header {
    background-color: #3c3c3c;
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 10px;
    border-top-left-radius: inherit; /* Dědí z #terminal */
    border-top-right-radius: inherit; /* Dědí z #terminal */
    border-bottom: 1px solid #555;
    flex-shrink: 0;
    cursor: grab; /* Naznačuje možnost přesunu (i když ho neimplementujeme) */
}
#terminal-header:active {
    cursor: grabbing;
}


#terminal-header .button {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
}
#terminal-header .red { background-color: #ff5f56; }
#terminal-header .yellow { background-color: #ffbd2e; }
#terminal-header .green { background-color: #27c93f; }
#terminal-header .title {
    color: #bbb;
    font-size: 0.9em;
    margin: 0 auto;
    transform: translateX(-30px); /* Kompenzace tlačítek pro lepší centrování titlku */
    pointer-events: none; /* Aby titulek nepřekážel grab kurzoru */
    user-select: none; /* Aby se titulek neoznačoval při "grabování" */
}


#terminal-body {
    padding: 10px;
    overflow-y: auto; /* Povolit vertikální scroll JEN pro obsah */
    font-size: 1em;
    /* Výška se dynamicky dopočítá pomocí flexboxu */
    flex-grow: 1; /* Zajistí, že zabere všechen dostupný prostor mezi header a footer */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    background-color: var(--background); /* Zajistit, aby tělo mělo vždy pozadí */
}

/* --- Výstupní oblast --- */
#output {
    white-space: pre-wrap;
    word-wrap: break-word;
    margin-bottom: 5px;
}
/* ... (zbytek stylů pro #output, .command-line, .response atd. zůstává stejný) ... */
#output a { color: var(--link-color); text-decoration: underline; }
#output a:hover { text-decoration: none; }
#output .command-line { display: flex; align-items: baseline; margin-bottom: 2px; }
#output .command-line .prompt { color: var(--green); margin-right: 5px; flex-shrink: 0; }
#output .command-line .command { color: var(--foreground); word-break: break-all; }
#output .response { margin-bottom: 10px; }
#output .response.error { color: var(--error-color); }
#output .response strong { color: var(--green); font-weight: bold; }
#output .response ul { list-style: none; padding-left: 20px; }
#output .response li::before { content: "- "; color: var(--green); }
#output .command-button { background: none; border: none; color: var(--link-color); font-family: var(--font); font-size: inherit; font-weight: bold; text-decoration: underline; cursor: pointer; padding: 0; margin: 0 2px; display: inline; }
#output .command-button:hover { color: var(--green); text-decoration: none; }
.output-word { opacity: 0; transition: opacity 0.25s ease-in-out; display: inline-block; }
.output-word.visible { opacity: 1; }
#output > div > :not(.output-word) { transition: none; opacity: 1; }
#output > div .output-word a, #output > div .output-word button { opacity: 1; }


/* --- Vstupní řádek --- */
.input-line {
    display: flex;
    align-items: baseline;
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}
.input-line.hidden {
    opacity: 0;
    pointer-events: none;
}
.prompt {
    color: var(--green);
    margin-right: 5px;
    white-space: nowrap;
    flex-shrink: 0;
}
#input {
    background: none;
    border: none;
    color: var(--foreground);
    font-family: var(--font);
    font-size: 1em;
    flex-grow: 1;
    outline: none;
    padding: 0;
    margin: 0;
    caret-color: var(--cursor-color);
    box-shadow: none;
    
}

/* --- Blikající kurzor --- */
#input:focus {
    background-color: #444;
    box-shadow: none;
}
@keyframes blink-border {
  0%, 100% { border-right-color: var(--cursor-color); }
  50% { border-right-color: transparent; }
}

/* --- Patička s nápovědními tlačítky --- */
.commands-help-footer {
    height: var(--footer-height);
    background-color: #3c3c3c;
    border-top: 1px solid #555;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 0 10px;
    font-size: 0.85em;
    color: #aaa;
    border-bottom-left-radius: inherit; /* Dědí z #terminal */
    border-bottom-right-radius: inherit; /* Dědí z #terminal */
}
.commands-help-footer button {
    background: none;
    border: 1px solid var(--green);
    color: var(--green);
    font-family: var(--font);
    font-size: inherit;
    cursor: pointer;
    margin-left: 10px;
    padding: 1px 4px;
    border-radius: 3px;
}
.commands-help-footer button:hover {
    background-color: var(--green);
    color: var(--background);
}

/* --- Skrytí SEO obsahu --- */
.seo-content {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* --- Styl pro NoScript Fallback --- */
.noscript-warning {
    position: fixed; top: 10px; left: 10px; right: 10px; max-width: 600px;
    margin: 0 auto; background-color: #ffffe0; color: #333; padding: 15px;
    border: 1px solid #ccc; border-radius: 5px; z-index: 1000;
    font-family: sans-serif; text-align: center;
}
.noscript-warning a { color: #0000ee; font-weight: bold; }


/* --- Styly pro ASCII Art --- */
#output .ascii-header { display: flex; align-items: center; margin-bottom: 15px; }
#output .ascii-avatar { margin-top: -0.7rem; width: 4.0rem; height: 4.0rem; border-radius: 50%; margin-right: 15px; flex-shrink: 0; object-fit: cover; background-color: #555; }
#output .ascii-art { color: #a0a0a0; font-weight: bold; line-height: 1.0; padding: 0; text-align: left; margin: 0; }
#output pre { margin: 0; }

/* --- Responzivita --- */

/* ÚZKÉ OBRAZOVKY (Mobil): Terminál přes celou šířku/výšku, BEZ resize */
@media (max-width: 767px) { /* Zvýšil jsem breakpoint na 767px pro lepší pokrytí tabletů */
    body {
        padding: 0; /* Bez paddingu na body */
        /* align-items: stretch; Není nutné, výška terminálu je 100vh */
    }
    #terminal {
        width: 100%;      /* Plná šířka */
        height: 100vh;    /* Plná výška */
        max-width: none;  /* Ignorovat max-width */
        max-height: none; /* Ignorovat max-height */
        min-width: 0;     /* Bez min šířky */
        min-height: 0;    /* Bez min výšky */
        border-radius: 0; /* Bez zaoblení rohů */
        border: none;     /* Bez rámečku */
        resize: none;     /* Zakázat změnu velikosti */
        overflow: hidden; /* Skrýt overflow (pro jistotu) */
    }
    #terminal-body {
        font-size: 0.9em; /* Trochu menší písmo na mobilu */
    }
    #terminal-header, .commands-help-footer {
        border-radius: 0; /* Rovné rohy headeru/footeru */
    }
    .commands-help-footer {
        font-size: 0.8em;
        padding: 0 5px;
    }
    .commands-help-footer button {
        margin-left: 5px;
        padding: 1px 3px;
    }
    .noscript-warning {
        left: 5px; right: 5px; top: 5px; padding: 10px;
    }
    #terminal-header .title {
        transform: translateX(-15px); /* Menší kompenzace na mobilu */
    }
}

/* ŠIROKÉ OBRAZOVKY (Desktop): Terminál centrovaný, S možností resize */
@media (min-width: 768px) { /* Od 768px šířky výše */
    #terminal {
        resize: both;      /* Povolit změnu velikosti */
        overflow: auto;    /* Zobrazit scrollbary/úchyt POKUD je potřeba (nutné pro resize!) */

        /* Omezení velikosti při resize */
        min-width: 450px;  /* Minimální rozumná šířka */
        min-height: 350px; /* Minimální rozumná výška */

        /* Maximální velikost může být omezena viewportem nebo fixní hodnotou */
        /* Ponecháme původní max-width/max-height jako horní limit */
        max-width: 800px;
        max-height: 700px;
         /* Volitelně: Omezit na % viewportu, pokud chcete, aby se mohl zvětšit i za 800x700 */
        /* max-width: 95vw; */
        /* max-height: 95vh; */
    }
    /* Není potřeba přepisovat jiné styly, pokud výchozí desktopové vyhovují */
}