:root {
    --mouseX: 0;
    --mouseY: 0;
    --mask: none;
    --holoTexture: none;
    --holoTexSize: 50%;           /* Feature 4: controlled via JS */
    --linear-gradient: linear-gradient(90deg,
            rgba(255, 0, 0, 1) 0%,
            rgba(255, 154, 0, 1) 10%,
            rgba(208, 222, 33, 1) 20%,
            rgba(79, 220, 74, 1) 30%,
            rgba(63, 218, 216, 1) 40%,
            rgba(47, 201, 226, 1) 50%,
            rgba(28, 127, 238, 1) 60%,
            rgba(95, 21, 242, 1) 70%,
            rgba(186, 12, 248, 1) 80%,
            rgba(251, 7, 217, 1) 90%,
            rgba(255, 0, 0, 1) 100%);
    --gradientColor: var(--linear-gradient);
    --radial-gradient: radial-gradient(circle,
            rgba(255, 0, 0, 1) 0%,
            rgba(255, 154, 0, 1) 10%,
            rgba(208, 222, 33, 1) 20%,
            rgba(79, 220, 74, 1) 30%,
            rgba(63, 218, 216, 1) 40%,
            rgba(47, 201, 226, 1) 50%,
            rgba(28, 127, 238, 1) 60%,
            rgba(95, 21, 242, 1) 70%,
            rgba(186, 12, 248, 1) 80%,
            rgba(251, 7, 217, 1) 90%,
            rgba(255, 0, 0, 1) 100%);
    --silver-gradient: linear-gradient(-80deg,
            #555, #555, silver, white,
            #555, #555, silver, white,
            #555, #555, silver, white,
            #555, #555, silver, white,
            #555, #555, silver, white);
    --textureBlendMode: color-dodge;
    --holoBlendMode: soft-light;
    --gradientBlendMode: color-burn;
}

body {
    background: #222;
    color: #eee;
    font-family: 'Courier New', Courier, monospace;
    padding: 20px;
    margin: 0;
    min-height: 100vh;
}

#image_upload,
#holo_upload {
    padding: 5px;
    margin-top: 15px;
    text-align: center;
    background: transparent;
    display: none;
}

.label_upload {
    display: inline-block;
    padding: 5px;
    text-align: center;
    background: #333;
    cursor: pointer;
    border: 1px solid #eee;
    width: 244px;
}

#image_container {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 20px;
}

/* Natural aspect ratio for all loaded-image previews (cards 1-4) */
.preview_img {
    width: 100%;
    height: auto;
    display: block;
    box-sizing: border-box;
}

/* Placeholder box shown before an image is uploaded/set */
.preview_img.is_empty {
    border: 1px solid #eee;
    aspect-ratio: 1;
}

#image_preview_holo {
    object-fit: contain;
}

/* Checkerboard background for images with transparency */
.checkerboard {
    background: repeating-conic-gradient(#444 0% 25%, #555 0% 50%) 0 0 / 16px 16px;
    object-fit: contain;
}

.card {
    display: flex;
    height: fit-content;
    gap: 20px;
    flex-direction: column;
    padding: 20px;
    border-radius: 5px;
    background-color: #333;
    width: 256px;
    min-width: 256px;   /* keeps cards stable even when pinSize < 256 */
}

/* Pixel dimensions shown below base image and holo texture previews */
.image_dims {
    text-align: center;
    font-size: 11px;
    color: #888;
    min-height: 1em;   /* reserves space so card doesn't shift when empty */
    margin-top: -10px; /* tighten gap between image and dims text */
}

.columns {
    width: 572px;
    flex-direction: row;
    gap: 60px;
}

.card_column {
    width: 256px;
    gap: 20px;
    display: flex;
    flex-direction: column;
}

.node_title,
.node_info {
    text-align: center;
    padding: 5px;
    background: transparent;
}

.node_info::before {
    content: "\24D8";
    margin-right: 5px;
}

.select_dropdown {
    border: 1px solid #eee;
    background: #333;
    padding: 5px;
    text-align: center;
    color: #eee;
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
}

input[type="number"].select_dropdown {
    cursor: text;
    -moz-appearance: textfield;
}

input[type="number"].select_dropdown::-webkit-inner-spin-button,
input[type="number"].select_dropdown::-webkit-outer-spin-button {
    opacity: 1;
}

.button_action,
#button_copy_pin_clipboard,
#link_svg_download {
    border: 1px solid #eee;
    background: transparent;
    padding: 5px;
    text-align: center;
    color: #eee;
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
}

.button_action:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.copied {
    display: none;
}

.copied::after {
    content: "\2713";
    margin-left: 5px;
}

input[type="range"] {
    flex-grow: 1;
}

.css_value {
    width: 30px;
    margin-top: 3px;
    text-align: right;
}

/* Feature 4/9: wider value display for %-suffixed and s-suffixed values */
.css_value.wide {
    width: 44px;
}

.css_prop {
    display: flex;
    gap: 8px;
}

.color_gradient {
    background-image: var(--gradientColor);
}

.moveable {
    background-size: 200% 200%;
    background-position-x: var(--mouseX);
    background-position-y: var(--mouseY);
}

.rotate {
    transform: rotateY(calc(var(--rotDirY) * var(--rotateY))) rotateX(calc(var(--rotDirX) * var(--rotateX)));
}

textarea[name="textarea_download"],
textarea[name="textarea_gradient"] {
    resize: none;
    background: transparent;
    border: 1px solid #eee;
    height: 100%;
    padding: 5px;
    color: #eee;
    font-family: inherit;
    font-size: 10px;
}

#svg_result {
    border: 1px solid #eee;
}

.result {
    display: grid;
    grid-area: 1/1;
    width: 256px;
    will-change: transform;
}

#result_image {
    grid-area: 1/1;
}

.result_shine,
.result_shine::after {
    mask-image: var(--mask);
    mask-size: cover;
}

.result_shine {
    /* Feature 4: --holoTexSize is now a root CSS variable controlled by JS */
    height: 256px;
    display: grid;
    grid-area: 1/1;
    mix-blend-mode: var(--textureBlendMode);
    background-image: var(--holoTexture), var(--holoTexture), radial-gradient(circle at var(--mouseX) var(--mouseY), hsla(0, 0%, 100%, 0.6) 10%, hsla(0, 0%, 100%, 0.4) 40%, rgba(92, 92, 92, 0.1) 90%);
    background-size: var(--holoTexSize) var(--holoTexSize), var(--holoTexSize) var(--holoTexSize), cover;
    background-position: 40% 45%, 55% 55%, center center;
    background-blend-mode: var(--holoBlendMode);
    filter: brightness(1) contrast(1) saturate(2);
}

.result_shine::after {
    content: "";
    mask-image: none !important;
    background-image: var(--gradientColor);
    background-size: 200% 200%;
    background-position-x: var(--mouseX);
    background-position-y: var(--mouseY);
    filter: brightness(1) contrast(1) saturate(1.2);
    mix-blend-mode: var(--gradientBlendMode);
}

/* ─── Mask editor modal ───────────────────────────────────────────────────── */

.modal_overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.modal_box {
    background: #333;
    border-radius: 5px;
    border: 1px solid #555;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    max-width: 90vw;
    max-height: 95vh;
}

.modal_header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.modal_canvas_area {
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
}

#mask_canvas_modal {
    border: 1px solid #555;
    image-rendering: pixelated;
    display: block;
}

.modal_footer {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal_tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Active tool button highlight */
.mask_tool_btn.active {
    background: #555;
    border-color: #aef;
    color: #aef;
}

.threshold_control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.threshold_control label {
    white-space: nowrap;
}

.threshold_control input[type="range"] {
    flex-grow: 1;
    min-width: 120px;
}

#threshold_value {
    width: 28px;
    text-align: right;
}

/* ─── Feature 7: Color swatch ────────────────────────────────────────────── */

#color_swatch {
    background: #2a2a2a;
    border: 1px solid #555;
    border-radius: 3px;
    padding: 4px 8px;
    font-size: 12px;
    font-family: 'Courier New', Courier, monospace;
    align-items: center;
    gap: 6px;
}

#color_swatch_box {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 1px solid #888;
    flex-shrink: 0;
    vertical-align: middle;
}

#color_swatch_hex {
    vertical-align: middle;
    letter-spacing: 0.05em;
}
