/* Jessica Syafaq Muthmaina, terminal portfolio
   Design after github.com/jackb1434/Terminal-Portfolio (recoloured in blue) */

:root {
    --bg: #0b1a2e;
    --bg-soft: #12263f;
    --fg: #dce9f8;
    --gray: #7489a6;
    --red: #ff6b81;
    --green: #6fe0d0;
    --lime: #4fc3f7;
    --yellow: #a8d4ff;
    --blue: #82aaff;
    --pink: #b3a6ff;
}

* {
    box-sizing: border-box;
}

html,
body {
    padding: 0;
    margin: 0;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg);
    color: var(--fg);
}

p,
pre,
h1 {
    margin: 0;
}

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

/* The shell tracks the visible viewport. Output scrolls in the top part and the
   prompt is pinned to the bottom, so it sits right above a phone keyboard. */
.content {
    position: fixed;
    top: var(--vv-top, 0px);
    left: 0;
    right: 0;
    height: var(--vv-height, 100dvh);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation-name: fadeIn;
    animation-duration: 1s;
}

.terminal {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 20px 20px 0;
    display: flex;
    flex-direction: column;
}

.terminal > * {
    flex-shrink: 0;
}

#iterm {
    margin-bottom: 8px;
}

.terminal,
.inputArea {
    width: 100%;
    max-width: 1000px;
    font-size: 18px;
    line-height: 25px;
    text-align: left;
    font-weight: 700;
    font-family: monospace;
    overflow-wrap: anywhere;
}

.banner {
    font-family: monospace;
    color: var(--fg);
    overflow: hidden;
}

.version {
    color: var(--gray);
}

/* ---------- output ---------- */

#iterm p {
    min-height: 25px;
}

.event {
    color: var(--pink);
}

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

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

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

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

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

.echo {
    color: var(--fg);
}

/* "command - description" rows */
.row {
    display: grid;
    grid-template-columns: 13ch 1fr;
    column-gap: 1ch;
}

.row.wide {
    grid-template-columns: 19ch 1fr;
}

.indent {
    padding-left: 2ch;
}

.sub {
    padding-left: 5ch;
}

.hang {
    padding-left: 5ch;
    text-indent: -5ch;
}

.terminal a {
    color: var(--blue);
    text-decoration: underline;
}

.terminal a:hover,
.terminal a:focus-visible {
    color: var(--green);
}

/* clickable command names */
.cmd {
    font: inherit;
    color: var(--lime);
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    text-align: left;
}

.cmd:hover,
.cmd:focus-visible {
    text-decoration: underline;
    outline: none;
}

.portrait img {
    display: block;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    border: 2px solid var(--blue);
    margin: 4px 0 10px;
}

.bannerArt img {
    display: block;
    width: 100%;
    max-width: 760px;
    height: auto;
    border-radius: 6px;
    margin: 6px 0;
}

.figures {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 6px 0;
    max-width: 760px;
}

.figures figure {
    margin: 0;
}

.figures img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--gray);
    background: #fff;
}

.figures figcaption {
    color: var(--gray);
    font-size: 14px;
}

/* ---------- input ---------- */

.inputArea {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0 10px;
    border: none;
    border-top: 1px solid var(--bg-soft);
    outline: none;
    margin: 0;
    /* pinned to the bottom of the terminal, like a prompt waiting for input */
    position: sticky;
    bottom: 0;
    margin-top: auto;
    background-color: var(--bg);
    padding: 8px 0 calc(12px + env(safe-area-inset-bottom));
}

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

.inputLine {
    color: var(--lime);
    white-space: nowrap;
}

.inputArea input {
    flex: 1 1 12ch;
    min-width: 0;
    font: inherit;
    color: var(--fg);
    caret-color: var(--fg);
    background-color: transparent;
    border: none;
    outline: none;
    padding: 0;
}

.inputArea input::placeholder {
    color: var(--gray);
    opacity: 1;
}

/* keyboard-overlay layout: the prompt flows after the output, with room below
   it so it can rest in the upper half of the screen, clear of the keyboard */
.kb-overlay .inputArea {
    position: static;
    margin-top: 0;
    border-top: none;
    padding: 0 0 70vh;
}

/* ---------- AstroNotes viewer ---------- */

.viewer {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    font-family: monospace;
    font-weight: 700;
    font-size: 16px;
    animation: fadeIn 0.3s;
}

.viewer[hidden] {
    display: none;
}

.viewerBar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 4px 16px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--gray);
}

.viewerPath {
    color: var(--lime);
    overflow-wrap: anywhere;
}

.viewerActions {
    display: flex;
    gap: 16px;
}

.viewerActions a,
.viewerActions button {
    font: inherit;
    color: var(--blue);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-decoration: none;
}

.viewerActions a:hover,
.viewerActions button:hover,
.viewerActions a:focus-visible,
.viewerActions button:focus-visible {
    color: var(--green);
    text-decoration: underline;
    outline: none;
}

.viewer iframe {
    flex: 1;
    width: 100%;
    border: none;
    background: #fff;
}

/* ---------- motion & small screens ---------- */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .content,
    .viewer {
        animation: none;
    }
}

@media (max-width: 600px) {
    .terminal,
    .inputArea {
        font-size: 14px;
        line-height: 21px;
    }

    .terminal {
        padding: 16px 16px 0;
    }

    .inputArea {
        padding: 8px 0 calc(10px + env(safe-area-inset-bottom));
    }

    .kb-overlay .inputArea {
        padding: 0 0 70vh;
    }

    #iterm p {
        min-height: 21px;
    }

    /* keep the input at 16px so iOS doesn't zoom on focus */
    .inputArea input {
        font-size: 16px;
    }

    .row,
    .row.wide {
        grid-template-columns: 11ch 1fr;
    }

    .viewer {
        font-size: 14px;
    }

    .viewerBar {
        padding: 10px 16px;
    }
}
