/* rembg.foundry.fyz.sh: same look as fyz.sh and the Foundry page (boxes, splash text,
   scanlines, hammer hero), with the tool's own pieces at the bottom. */

@import url("/assets/fonts/fonts.css");

:root {
    --gold: #DEAF2C;
    --yellow: #DEE142;
    --red: #c23c32;
    --line: rgba(255, 255, 255, 0.08);
    --muted: rgba(255, 255, 255, 0.65);
    --faint: rgba(255, 255, 255, 0.45);
}

html {
    background-color: #000;
}

/* CRT scanlines, same as the portfolio */
html::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 999990;
    background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .20) 0 1px, transparent 1px 4px);
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    background-color: #000;
    color: #fff;
    font-family: "Iosevka Charon Mono", monospace;
    font-weight: 400;
}

p {
    margin: 0;
}

a {
    color: inherit;
}

kbd {
    font: inherit;
    font-size: 0.9em;
    padding: 0 5px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-bottom-width: 2px;
    border-radius: 4px;
}

#wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    width: 60%;
}

@keyframes blink {
    from { opacity: 0.8; }
    to { opacity: 0; }
}

#page-content {
    margin-top: 110px;
    width: 100%;
}

footer {
    width: 100%;
    text-align: center;
    padding: 24px 0;
    margin-top: auto;
    opacity: 0.5;
    font-size: 14px;
}

footer a {
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ---------- hero (Foundry hammer, as scissors) ---------- */

@font-face {
    font-family: "Minecraft";
    src: url("/assets/fonts/Minecraft.ttf") format("truetype");
    font-display: swap;
}

.hero {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 50px;
}

/* yellow splash text, like "Sign my guestbook!" on fyz.sh */
.drop-wrap {
    position: relative;
}

.pin {
    position: absolute;
    top: 2px;
    right: -52px;
    z-index: 1;
    font-family: "Minecraft", sans-serif;
    font-size: 13px;
    color: #f0e001;
    text-decoration: none;
    white-space: nowrap;
    animation: bounceSize 0.7s infinite linear;
}

@keyframes bounceSize {
    0% { transform: scale(1) rotate(30deg); }
    50% { transform: scale(1.1) rotate(30deg); }
    100% { transform: scale(1) rotate(30deg); }
}

.hero-img-wrap {
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
    flex-shrink: 0;
    width: 150px;
    height: 150px;
    margin-right: 20px;
}

.hero-blade {
    -webkit-user-drag: none;
    position: absolute;
    inset: 0;
    width: 150px;
    height: 150px;
    image-rendering: pixelated;
    /* the pivot screw sits at (16, 14.5) on the 32px grid */
    transform-origin: 50% 45.3%;
}

.hero-blade--a {
    animation: snip-a 4s infinite;
}

.hero-blade--b {
    animation: snip-b 4s infinite;
}

/* open wide, then snap shut on the same beat as the Foundry hammer */
@keyframes snip-a {
    0% { transform: rotate(0deg); animation-timing-function: ease-in-out; }
    18% { transform: rotate(-9deg); animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45); }
    23% { transform: rotate(13deg); animation-timing-function: ease-out; }
    36%, 100% { transform: rotate(0deg); }
}

@keyframes snip-b {
    0% { transform: rotate(0deg); animation-timing-function: ease-in-out; }
    18% { transform: rotate(9deg); animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45); }
    23% { transform: rotate(-13deg); animation-timing-function: ease-out; }
    36%, 100% { transform: rotate(0deg); }
}

/* offcuts: little checkerboard squares, the "transparent" bits being cut away */
.hero-offcuts {
    position: absolute;
    left: 50%;
    top: 22%;
    width: 0;
    height: 0;
    pointer-events: none;
}

.hero-offcut {
    position: absolute;
    width: 8px;
    height: 8px;
    margin: -4px 0 0 -4px;
    opacity: 0;
    background:
        linear-gradient(45deg, #9a9a9a 25%, transparent 25%, transparent 75%, #9a9a9a 75%),
        linear-gradient(45deg, #9a9a9a 25%, #fff 25%, #fff 75%, #9a9a9a 75%);
    background-size: 4px 4px;
    background-position: 0 0, 2px 2px;
    image-rendering: pixelated;
    animation: offcut-fall 4s infinite;
}

.hero-offcut:nth-child(1) { --dx: -34px; --dy: -22px; --r: -70deg; }
.hero-offcut:nth-child(2) { --dx: -18px; --dy: -34px; --r: 40deg; width: 6px; height: 6px; }
.hero-offcut:nth-child(3) { --dx: 20px; --dy: -30px; --r: -35deg; }
.hero-offcut:nth-child(4) { --dx: 36px; --dy: -16px; --r: 80deg; width: 6px; height: 6px; }
.hero-offcut:nth-child(5) { --dx: -8px; --dy: -42px; --r: 20deg; width: 4px; height: 4px; background: var(--gold); box-shadow: 0 0 6px rgba(222, 175, 44, 0.8); }
.hero-offcut:nth-child(6) { --dx: 10px; --dy: -44px; --r: -20deg; width: 4px; height: 4px; background: #fff; box-shadow: 0 0 5px rgba(255, 255, 255, 0.7); }
.hero-offcut:nth-child(7) { --dx: -44px; --dy: -6px; --r: 55deg; width: 4px; height: 4px; background: var(--yellow); box-shadow: 0 0 6px rgba(222, 225, 66, 0.8); }
.hero-offcut:nth-child(8) { --dx: 46px; --dy: -4px; --r: -55deg; width: 4px; height: 4px; background: var(--gold); box-shadow: 0 0 6px rgba(222, 175, 44, 0.8); }

@keyframes offcut-fall {
    0%, 22% { opacity: 0; transform: translate(0, 0) rotate(0deg) scale(1); animation-timing-function: linear; }
    23% { opacity: 1; animation-timing-function: ease-out; }
    38% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--r)) scale(0.6); }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--r)) scale(0.6); }
}

.hero-text {
    animation: hero-text-impact 4s infinite;
}

.hero-text h1 {
    margin: 0 0 12px;
    font-size: 40px;
    font-weight: 900;
}

.hero-text p {
    max-width: 34rem;
    line-height: 1.5;
}

@keyframes hero-text-impact {
    0%, 22% { transform: translate(0, 0); }
    23% { transform: translate(-2px, 1px) rotate(-0.35deg); }
    24% { transform: translate(3px, -1px) rotate(0.3deg); }
    25% { transform: translate(-2px, 2px) rotate(0.2deg); }
    26% { transform: translate(2px, -1px) rotate(-0.15deg); }
    27%, 100% { transform: translate(0, 0); }
}

.text-link {
    display: inline-block;
    margin-top: 16px;
    padding: 0;
    font-size: 16px;
    font-weight: 500;
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid #fff;
}

.text-link:hover {
    color: var(--gold);
    border-bottom-color: var(--gold);
}

@media (prefers-reduced-motion: reduce) {
    .hero-blade,
    .hero-text {
        animation: none;
    }

    .pin {
        animation: none;
        transform: rotate(30deg);
    }

    .hero-offcut {
        animation: none;
        opacity: 0;
    }
}

/* ---------- tool ---------- */

.box {
    border: 1px solid #fff;
    border-radius: 10px;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 20px;
    margin-bottom: 16px;
}

.modes {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
}

.modes-label {
    color: var(--yellow);
    font-weight: 700;
}

.mode {
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    padding: 6px 12px;
    color: #fff;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 6px;
    cursor: pointer;
}

.mode:hover:not(:disabled):not([aria-pressed="true"]) {
    background: rgba(255, 255, 255, 0.06);
}

.mode[aria-pressed="true"]:hover {
    filter: brightness(1.08);
}

.mode[aria-pressed="true"] {
    color: #000;
    background: var(--gold);
    border-color: var(--gold);
    font-weight: 700;
}

.mode:disabled {
    color: var(--faint);
    border-style: dashed;
    cursor: not-allowed;
}

.mode-hint {
    font-size: 14px;
    color: var(--muted);
}

.drop {
    display: grid;
    place-items: center;
    min-height: 220px;
    padding: 32px 16px;
    box-sizing: border-box;
    text-align: center;
    cursor: pointer;
    border-style: dashed;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.drop:hover,
.drop.over {
    border-color: var(--gold);
    background: rgba(222, 175, 44, 0.04);
}

.drop:focus-within {
    outline: 1px solid var(--gold);
    outline-offset: 3px;
}

.drop-title {
    display: block;
    margin-bottom: 8px;
    font-size: 24px;
    font-weight: 700;
}

.drop-title::after {
    content: "_";
    margin-left: 2px;
    animation: blink 1.2s steps(1) infinite;
}

.drop-sub {
    font-size: 14px;
    color: var(--muted);
}

/* keep the input focusable for keyboard users, just invisible */
.drop input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.jobs {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

.job {
    overflow: hidden;
}

.job-head,
.job-foot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    font-size: 14px;
}

.job-head {
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.35);
}

.job-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.job-status {
    flex-shrink: 0;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.job-status.is-done {
    color: var(--yellow);
}

.job-status.is-error {
    color: #ff6b5e;
}

.stage {
    position: relative;
    /* sit above the scanline overlay (html::after, z 999990) so the
       input and the cutout are shown exactly as they are */
    z-index: 999991;
    display: grid;
    place-items: center;
    height: min(480px, 70vh);
    overflow: hidden;
    user-select: none;
    touch-action: none;
    /* chunky pixel checkerboard, the classic "transparent" pattern */
    background-color: #1c1c21;
    background-image:
        linear-gradient(45deg, #2a2a31 25%, transparent 25%, transparent 75%, #2a2a31 75%),
        linear-gradient(45deg, #2a2a31 25%, transparent 25%, transparent 75%, #2a2a31 75%);
    background-size: 24px 24px;
    background-position: 0 0, 12px 12px;
}

/* sized by fitStage() in rembg.js: scaled up or down to fill the box */
.stage img {
    grid-area: 1 / 1;
    display: block;
    -webkit-user-drag: none;
}

.stage .before {
    clip-path: inset(0 calc(100% - var(--pos, 50%)) 0 0);
}

.stage.loading .before {
    clip-path: none;
    filter: grayscale(0.7) brightness(0.55);
}

/* scanning bar while the model runs */
.stage.loading::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 3px;
    background: var(--gold);
    box-shadow: 0 0 12px rgba(222, 175, 44, 0.9);
    animation: scan 1.6s steps(24) infinite;
}

@keyframes scan {
    from { top: 0; }
    to { top: calc(100% - 3px); }
}

@media (prefers-reduced-motion: reduce) {
    .stage.loading::after {
        animation: none;
        top: auto;
        bottom: 0;
    }

    .drop-title::after {
        animation: none;
    }
}

.handle {
    display: none;
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    margin-left: -1px;
    background: #fff;
    cursor: ew-resize;
}

.handle::after {
    content: "<>";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 4px 6px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    background: #000;
    border: 1px solid #fff;
    border-radius: 4px;
}

.handle[data-edge="left"]::after {
    transform: translate(0, -50%);
}

.handle[data-edge="right"]::after {
    transform: translate(-100%, -50%);
}

.stage.done .handle {
    display: block;
}

.job-foot {
    flex-wrap: wrap;
    border-top: 1px solid rgba(255, 255, 255, 0.35);
}

.swatches {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: auto;
    color: var(--muted);
}

.swatch {
    position: relative;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    cursor: pointer;
}

.swatch[aria-pressed="true"] {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

.swatch--none {
    background-color: #fff;
    background-image:
        linear-gradient(45deg, #9a9a9a 25%, transparent 25%, transparent 75%, #9a9a9a 75%),
        linear-gradient(45deg, #9a9a9a 25%, transparent 25%, transparent 75%, #9a9a9a 75%);
    background-size: 10px 10px;
    background-position: 0 0, 5px 5px;
}

.swatch--custom {
    background: conic-gradient(#ff5555, #ffff55, #55ff55, #55ffff, #5555ff, #ff55ff, #ff5555);
}

.swatch--custom input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.btn {
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    padding: 7px 14px;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 6px;
    cursor: pointer;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

.btn--primary {
    font-weight: 600;
    color: #000;
    background: var(--gold);
    border-color: var(--gold);
}

.btn--primary:hover {
    background: var(--gold);
    filter: brightness(1.05);
}

/* ---------- details (Foundry style) ---------- */

.details {
    margin-top: 36px;
    padding-top: 22px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 14px;
    line-height: 1.5;
    color: var(--muted);
}

.details h2 {
    margin: 0 0 12px;
    font-size: 17px;
    color: var(--yellow);
}

.details ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.details li {
    display: flex;
    gap: 8px;
    max-width: 46rem;
    margin-bottom: 8px;
}

.details li::before {
    content: "[>]";
    flex-shrink: 0;
    color: var(--faint);
}

.details strong {
    color: #fff;
    font-weight: 500;
}

/* ---------- small screens (same breakpoints as global.css) ---------- */

@media (max-width: 1000px) {
    #wrapper {
        width: 92%;
    }

    /* same as fyz.sh: the splash only shows on wide screens */
    .pin {
        display: none;
    }

    #page-content {
        margin-top: 48px;
    }

    .hero {
        margin-bottom: 30px;
    }

    .hero-img-wrap,
    .hero-blade {
        width: 96px;
        height: 96px;
    }

    .hero-text h1 {
        font-size: 30px;
    }

    .stage {
        height: min(360px, 60vh);
    }

    footer {
        margin-top: 24px;
    }
}

@media (max-width: 560px) {
    .hero {
        flex-direction: column;
        text-align: center;
    }

    .hero-img-wrap {
        margin: 0 0 16px;
    }
}

@media (max-width: 420px) {
    #wrapper {
        width: 96%;
    }

    #page-content {
        margin-top: 32px;
    }
}
