/* The retro font terminal (/tools/font-terminal). A beige monitor with a curved, glowing glass; the
   text is set in whichever catalog font is chosen (--ft-family). Colors come from the phosphor
   theme on #ftComputer, so a new look is one block of variables. */

.font-terminal .ft-stage {
    padding: clamp(0.75rem, 3vw, 2rem);
    border-radius: 1rem;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.7), transparent 70%),
        color-mix(in srgb, var(--primary, #5b3df5) 10%, var(--background, #fff));
    border: 1px solid color-mix(in srgb, var(--primary, #5b3df5) 18%, var(--background, #fff));
}
.ft-site-links {
    margin-bottom: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.font-terminal .ft-desk {
    display: grid;
    gap: 1rem;
    max-width: 58rem;
    margin-inline: 0;
}
.font-terminal .tool-intro,
.font-terminal .tool-docs {
    max-width: 42rem;
}
.font-terminal .tool-intro {
    margin-top: 1.5rem;
    color: var(--muted-foreground, #52525b);
    font-size: 1.0625rem;
    line-height: 1.7;
    text-wrap: pretty;
}
.font-terminal .sl-lede {
    max-width: 38rem;
    text-wrap: balance;
}

/* ---- phosphor themes ---- */
.ft-computer {
    --ft-fg: #39ff88;
    --ft-hi: #d8ffe6;
    --ft-dim: #1f9d52;
    --ft-bg: #020f07;
    --ft-glow: rgba(57, 255, 136, 0.55);
    --ft-warn: #ffe45c;
    --ft-err: #ff5d6c;
    --ft-scale: 1;
    --ft-line: 1.28;
    --ft-family: ui-monospace, 'Courier New', monospace;
}

/* ---- the monitor ---- */
.ft-computer {
    position: relative;
    padding: clamp(0.6rem, 2.2vw, 1.4rem);
    border-radius: 1.4rem 1.4rem 1rem 1rem;
    background: linear-gradient(160deg, #d9d2bf 0%, #c4bca6 48%, #b0a891 100%);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.55),
        inset 0 -6px 10px rgba(60, 50, 30, 0.35),
        0 18px 40px -14px rgba(20, 16, 8, 0.55),
        0 2px 0 #8d8571;
}
.ft-bezel {
    position: relative;
    padding: clamp(0.5rem, 1.6vw, 1rem);
    border-radius: 1.1rem;
    background: linear-gradient(180deg, #9d9582, #b5ad98);
    box-shadow:
        inset 0 6px 14px rgba(40, 32, 16, 0.55),
        inset 0 -2px 0 rgba(255, 255, 255, 0.4);
}
.ft-glass {
    position: relative;
    container-type: inline-size;
    aspect-ratio: 4 / 3;
    min-height: 17rem;
    overflow: hidden;
    border-radius: 2.2rem / 1.8rem;
    background: var(--ft-bg);
    box-shadow:
        inset 0 0 3.2rem rgba(0, 0, 0, 0.85),
        inset 0 0 0.6rem rgba(0, 0, 0, 0.9),
        0 0 0 3px #26231c;
    isolation: isolate;
}
.ft-screen {
    position: absolute;
    inset: 0;
    padding: 12% 6.5% 5%;
    color: var(--ft-fg);
    font-family: var(--ft-family);
    font-size: clamp(0.66rem, calc(var(--ft-scale) * 2.35cqi), 1.9rem);
    line-height: var(--ft-line);
    font-synthesis: none;
    font-kerning: none;
    cursor: text;
    text-shadow:
        0 0 0.18em var(--ft-glow),
        0 0 0.7em var(--ft-glow);
}
.ft-computer[data-crt='on'] .ft-screen {
    text-shadow:
        -0.05em 0 rgba(255, 40, 80, 0.32),
        0.05em 0 rgba(40, 200, 255, 0.3),
        0 0 0.2em var(--ft-glow),
        0 0 0.85em var(--ft-glow);
    animation: ft-flicker 5s infinite steps(1, end);
}
.ft-computer[data-crt='off'] .ft-screen {
    text-shadow: none;
}
.ft-status {
    position: absolute;
    top: 3.5%;
    left: 6.5%;
    right: 6.5%;
    display: flex;
    justify-content: space-between;
    gap: 1em;
    padding-bottom: 0.25em;
    border-bottom: 1px solid var(--ft-dim);
    white-space: nowrap;
    overflow: hidden;
    color: var(--ft-fg);
    font-size: 0.9em;
}
.ft-status b {
    color: var(--ft-hi, var(--ft-fg));
    font-weight: inherit;
}
.ft-interrupt {
    position: absolute;
    right: 6.5%;
    bottom: 4%;
    z-index: 2;
    padding: 0 0.6em;
    border: 1px solid var(--ft-warn);
    border-radius: 0.2em;
    background: rgba(255, 228, 92, 0.14);
    color: var(--ft-warn);
    font: inherit;
    font-size: 0.85em;
    text-shadow: 0 0 0.5em rgba(255, 228, 92, 0.55);
    cursor: pointer;
}
.ft-interrupt:hover,
.ft-interrupt:focus-visible {
    background: var(--ft-warn);
    color: var(--ft-bg, #000);
    text-shadow: none;
}
.ft-prompt-line[hidden] {
    display: none;
}
.ft-pick-row {
    cursor: pointer;
    white-space: pre;
}
.ft-pick-row.is-selected {
    background: var(--ft-fg);
    color: var(--ft-bg, #000);
    text-shadow: none;
}
.ft-output {
    height: 100%;
    overflow-y: auto;
    scrollbar-width: none;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    outline: none;
}
.ft-output::-webkit-scrollbar {
    display: none;
}
.ft-line {
    min-height: 1em;
}
.ft-line a {
    color: var(--ft-hi);
}
.c-dim {
    color: var(--ft-dim);
}
.c-hi {
    color: var(--ft-hi);
}
.c-warn {
    color: var(--ft-warn);
}
.c-err {
    color: var(--ft-err);
}
.c-inv {
    background: var(--ft-fg);
    color: var(--ft-bg);
    text-shadow: none;
}
.ft-prompt-line {
    display: block;
}
.ft-cursor {
    display: inline-block;
    min-width: 1ch;
    background: var(--ft-fg);
    color: var(--ft-bg);
    text-shadow: none;
    animation: ft-blink 1.06s steps(1, end) infinite;
}
.ft-screen:not(:focus-within) .ft-cursor {
    animation: none;
    background: transparent;
    outline: 1px solid var(--ft-fg);
    outline-offset: -1px;
    color: transparent;
}
.ft-input {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
    border: 0;
    padding: 0;
    font-size: 16px;
    pointer-events: none;
}
.ft-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: var(--ft-bg);
    cursor: pointer;
}

/* ---- glass effects ---- */
.ft-scanlines,
.ft-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}
.ft-scanlines {
    background: repeating-linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.3) 0,
        rgba(0, 0, 0, 0.3) 1px,
        transparent 1px,
        transparent 3px
    );
    mix-blend-mode: multiply;
}
.ft-scanlines::after {
    content: '';
    position: absolute;
    inset: -30% 0 auto;
    height: 30%;
    background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.07), transparent);
    animation: ft-roll 7s linear infinite;
}
.ft-vignette {
    background:
        radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.55) 100%),
        linear-gradient(115deg, rgba(255, 255, 255, 0.09) 0%, transparent 22%);
}
.ft-computer[data-crt='off'] .ft-scanlines,
.ft-computer[data-crt='off'] .ft-vignette {
    display: none;
}
.ft-computer[data-crt='off'] .ft-glass {
    border-radius: 0.8rem;
}
.ft-computer.is-powering .ft-glass {
    animation: ft-power-on 0.75s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.ft-computer.is-glitching .ft-screen,
.ft-computer.is-glitching .ft-canvas {
    animation: ft-glitch 0.9s steps(1, end);
}

.ft-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.4rem 0;
}
.ft-brand {
    font:
        700 0.7rem/1 system-ui,
        sans-serif;
    letter-spacing: 0.32em;
    color: #4b4638;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}
.ft-led {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: #43ff77;
    box-shadow:
        0 0 0.5rem #43ff77,
        inset 0 -1px 1px rgba(0, 0, 0, 0.35);
}
.ft-led.is-busy {
    background: #ffb629;
    box-shadow: 0 0 0.6rem #ffb629;
    animation: ft-blink 0.4s steps(1, end) infinite;
}
.ft-chin {
    height: 0.9rem;
    margin: 0.5rem 14% -0.4rem;
    border-radius: 0 0 0.9rem 0.9rem;
    background: linear-gradient(180deg, #a69e89, #8d8571);
    box-shadow: 0 8px 12px -6px rgba(20, 16, 8, 0.5);
}

/* ---- the panel under it ---- */
/* ---- motion ---- */
@keyframes ft-blink {
    50% {
        opacity: 0;
    }
}
@keyframes ft-flicker {
    0%,
    100% {
        opacity: 1;
    }
    93% {
        opacity: 0.96;
    }
    94% {
        opacity: 1;
    }
    97% {
        opacity: 0.93;
    }
    98% {
        opacity: 1;
    }
}
@keyframes ft-roll {
    to {
        transform: translateY(520%);
    }
}
@keyframes ft-power-on {
    0% {
        transform: scale(1, 0.005);
        filter: brightness(8) saturate(0);
    }
    35% {
        transform: scale(1, 0.01);
        filter: brightness(6);
    }
    70% {
        transform: scale(1, 1);
        filter: brightness(2.4);
    }
    100% {
        transform: scale(1, 1);
        filter: none;
    }
}
@keyframes ft-glitch {
    0% {
        transform: translate(0.4em, 0) skewX(-6deg);
        filter: hue-rotate(40deg);
    }
    15% {
        transform: translate(-0.6em, 0.1em);
        filter: hue-rotate(-60deg) saturate(2);
    }
    30% {
        transform: translate(0.2em, -0.15em) skewX(4deg);
        clip-path: inset(10% 0 55% 0);
    }
    45% {
        transform: translate(-0.3em, 0);
        clip-path: none;
        filter: invert(1);
    }
    60% {
        transform: translate(0.5em, 0.05em) skewX(-3deg);
        filter: hue-rotate(120deg);
    }
    80% {
        transform: translate(-0.1em, 0);
        filter: none;
    }
    100% {
        transform: none;
        filter: none;
    }
}
@media (prefers-reduced-motion: reduce) {
    .ft-computer[data-crt='on'] .ft-screen,
    .ft-scanlines::after,
    .ft-cursor,
    .ft-led.is-busy,
    .ft-computer.is-powering .ft-glass,
    .ft-computer.is-glitching .ft-screen,
    .ft-computer.is-glitching .ft-canvas {
        animation: none;
    }
}
@media (max-width: 575.98px) {
    .ft-glass {
        aspect-ratio: 3 / 4;
        border-radius: 1.6rem / 1.3rem;
    }
    .ft-chin {
        margin-inline: 8%;
    }
}

.ft-top h2 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}
.ft-top-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
.ft-top-list > li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.ft-top-list > li:has(.is-current) {
    grid-column: 1 / -1;
}
.ft-top-browse {
    margin: 0.75rem 0 0;
    font-size: 0.9rem;
}
.ft-style-tile.is-active {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}
.ft-top-download {
    flex-shrink: 0;
    margin-inline-end: 0.5rem;
}
.ft-top-download[hidden] {
    display: none;
}
.ft-top-button {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    gap: 0.125rem;
    align-items: flex-start;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border, #ddd);
    border-radius: 0.5rem;
    background: var(--background, #fff);
    color: inherit;
    text-align: start;
    cursor: pointer;
}
.ft-top-button:hover,
.ft-top-button:focus-visible {
    border-color: var(--primary, #5b3df5);
}
.ft-top-button.is-current {
    border-color: var(--primary, #5b3df5);
    background: color-mix(in srgb, var(--primary, #5b3df5) 10%, var(--background, #fff));
}
.ft-top-name {
    overflow: hidden;
    max-width: 100%;
    font-size: 1.05rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ft-top-kind {
    color: var(--muted-foreground, #666);
    font-size: 0.75rem;
}

/* Desktop: one row a font, the name set large in the font (as the single-line tool's list reads); the whole row, Download included, wears the current highlight */
@media (min-width: 992px) {
    .ft-top-list {
        grid-template-columns: 1fr;
        gap: 0;
        border: 1px solid var(--border, #ddd);
        border-radius: 0.75rem;
        background: var(--background, #fff);
        overflow: hidden;
    }
    .ft-top-list > li {
        padding-inline-end: 1rem;
    }
    .ft-top-list > li + li {
        border-top: 1px solid var(--border, #ddd);
    }
    .ft-top-list > li:has(.is-current) {
        background: color-mix(in srgb, var(--primary, #5b3df5) 10%, var(--background, #fff));
        box-shadow: inset 3px 0 0 var(--primary, #5b3df5);
    }
    .ft-top-button {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 1.5rem;
        padding: 0.75rem 1.5rem;
        border: 0;
        border-radius: 0;
        background: transparent;
    }
    .ft-top-button.is-current {
        background: transparent;
    }
    .ft-top-button:hover {
        background: color-mix(in srgb, var(--primary, #5b3df5) 6%, transparent);
    }
    .ft-top-name {
        font-size: clamp(1.75rem, 3.4vw, 2.75rem);
        line-height: 1.2;
    }
    .ft-top-kind {
        flex-shrink: 0;
        font-size: 0.8125rem;
    }
}

/* Wide screens: the monitor and the list side by side, the list scrolling beside it, so the font list is in the first screen */
@media (min-width: 1200px) {
    .font-terminal .ft-desk {
        max-width: none;
        grid-template-columns: minmax(0, 1.55fr) minmax(22rem, 1fr);
        align-items: start;
        column-gap: 1.5rem;
    }
    .font-terminal .ft-stage {
        grid-column: 1;
        grid-row: 1 / span 2;
        position: sticky;
        top: var(--site-header-clearance, 5rem);
    }
    .font-terminal .ft-top {
        grid-column: 2;
        grid-row: 1;
    }
    .font-terminal .ft-site-links {
        grid-column: 2;
        grid-row: 2;
    }
    .font-terminal .ft-top-list {
        max-height: min(36rem, calc(100vh - 12rem));
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    .font-terminal .ft-top-name {
        font-size: clamp(1.4rem, 2.2vw, 2rem);
    }
    .font-terminal .ft-top-button {
        padding: 0.6rem 1.1rem;
    }
}

.ft-styles h2 {
    margin: 1rem 0 0.5rem;
    font-size: 1rem;
}
.ft-style-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
.ft-style-tile {
    position: relative;
    --tint: #5b3df5;
    display: flex;
    height: 100%;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1rem;
    border: 1px solid color-mix(in srgb, var(--tint) 30%, var(--background, #fff));
    border-radius: 1rem;
    background: color-mix(in srgb, var(--tint) 10%, var(--background, #fff));
    color: inherit;
    text-decoration: none;
    transition: transform 0.15s ease;
}
.ft-style-tile:hover,
.ft-style-tile:focus-visible {
    transform: translateY(-3px) rotate(-1deg);
    border-color: var(--tint);
}
.ft-style-tile[data-tint='1'] {
    --tint: #0e9f6e;
}
.ft-style-tile[data-tint='2'] {
    --tint: #e0527a;
}
.ft-style-tile[data-tint='3'] {
    --tint: #d98a00;
}
.ft-style-tile[data-tint='4'] {
    --tint: #1e88e5;
}
.ft-style-tile[data-tint='5'] {
    --tint: #8e44ad;
}
.ft-style-sample {
    color: var(--tint);
    font-family: ui-monospace, 'Courier New', monospace;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
}
.ft-style-label {
    font-weight: 600;
}
.ft-style-preview + .ft-style-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
.ft-style-blurb {
    color: var(--muted-foreground, #666);
    font-size: 0.8125rem;
}
@media (prefers-reduced-motion: reduce) {
    .ft-style-tile {
        transition: none;
    }
    .ft-style-tile:hover,
    .ft-style-tile:focus-visible {
        transform: none;
    }
}

.ft-style-preview {
    display: block;
    width: auto;
    max-width: 100%;
    height: 2.5rem;
    object-fit: contain;
    object-position: left center;
}
