/* EtchingGallery – Intaglio Printmaking Widget */
/* Version: 1.0.0 */

:root {
    --eg-ink: #0d0a06;
    --eg-wax: #1a1008;
    --eg-copper: #b8860b;
    --eg-zinc: #9ca3a8;
    --eg-acid: #2d5a1b;
    --eg-acid-bubble: rgba(120, 200, 80, 0.6);
    --eg-paper: #f5f0e8;
    --eg-platemark: rgba(0,0,0,0.18);
    --eg-ui-bg: rgba(10, 8, 4, 0.82);
    --eg-ui-text: #d4c9a8;
    --eg-ui-border: rgba(180, 140, 60, 0.3);
    --eg-accent: #c8a84b;
    --eg-danger: #cc3300;
    --eg-radius: 4px;
    --eg-font-mono: 'Courier New', 'Lucida Console', monospace;
    --eg-font-serif: Georgia, 'Times New Roman', serif;
}

/* ============ WRAPPER ============ */
.etching-gallery-wrapper {
    font-family: var(--eg-font-serif);
    color: var(--eg-ui-text);
    background: var(--eg-ink);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    user-select: none;
}

/* ============ HEADER ============ */
.etching-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 14px 20px 10px;
    border-bottom: 1px solid var(--eg-ui-border);
    background: rgba(255,255,255,0.02);
}

.etching-title {
    font-family: var(--eg-font-serif);
    font-size: 1.25rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    color: var(--eg-accent);
    margin: 0;
    text-transform: uppercase;
}

.etching-technique-badge {
    font-family: var(--eg-font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    color: var(--eg-zinc);
    text-transform: uppercase;
    opacity: 0.8;
}

/* ============ CANVAS WRAPPER ============ */
.etching-canvas-wrapper {
    position: relative;
    width: 100%;
    height: 600px;
    background: #0a0805;
    cursor: crosshair;
    overflow: hidden;
}

.etching-canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    position: absolute;
    top: 0; left: 0;
}

/* ============ UI OVERLAY ============ */
.etching-ui-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 10;
}

/* ============ PHASE DOTS ============ */
.etching-phase-indicator {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.phase-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
    position: relative;
}

.phase-dot::after {
    content: attr(title);
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-family: var(--eg-font-mono);
    font-size: 0.6rem;
    color: var(--eg-ui-text);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.phase-dot:hover::after { opacity: 1; }

.phase-dot.active {
    background: var(--eg-accent);
    border-color: var(--eg-accent);
    box-shadow: 0 0 8px var(--eg-accent);
}

.phase-dot.completed {
    background: rgba(200, 168, 75, 0.4);
    border-color: var(--eg-accent);
}

/* ============ INSTRUCTIONS ============ */
.etching-instructions {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.instruction-text {
    font-family: var(--eg-font-mono);
    font-size: 0.68rem;
    color: rgba(200, 185, 150, 0.6);
    white-space: nowrap;
    margin: 0;
    letter-spacing: 0.05em;
}

.instruction-text kbd {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: var(--eg-font-mono);
    font-size: 0.65rem;
    color: var(--eg-accent);
}

/* ============ CONTROLS ============ */
.etching-controls {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.etching-btn {
    font-family: var(--eg-font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    padding: 7px 16px;
    background: rgba(10, 8, 4, 0.75);
    color: var(--eg-ui-text);
    border: 1px solid var(--eg-ui-border);
    border-radius: var(--eg-radius);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
    backdrop-filter: blur(4px);
    white-space: nowrap;
}

.etching-btn:hover {
    background: rgba(200, 168, 75, 0.12);
    border-color: var(--eg-accent);
    color: var(--eg-accent);
}

.etching-btn-primary {
    background: rgba(200, 168, 75, 0.15);
    border-color: var(--eg-accent);
    color: var(--eg-accent);
}

.etching-btn-primary:hover {
    background: rgba(200, 168, 75, 0.3);
    box-shadow: 0 0 14px rgba(200, 168, 75, 0.25);
}

/* ============ SAFETY ALARM ============ */
.etching-safety-alarm {
    position: absolute;
    top: 14px;
    right: 14px;
    background: rgba(180, 20, 0, 0.9);
    border: 1px solid #ff4422;
    border-radius: var(--eg-radius);
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--eg-font-mono);
    font-size: 0.72rem;
    color: #ffccbb;
    pointer-events: auto;
    animation: alarm-pulse 1.2s ease-in-out infinite;
    z-index: 20;
}

@keyframes alarm-pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(255,50,0,0.5); }
    50%       { box-shadow: 0 0 20px rgba(255,50,0,0.9); }
}

.alarm-icon { font-size: 1rem; }

.alarm-dismiss {
    background: transparent;
    border: none;
    color: #ffccbb;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 0 0 6px;
    line-height: 1;
}

/* ============ CROSS-SECTION ============ */
.etching-crosssection {
    position: absolute;
    bottom: 70px;
    right: 16px;
    background: rgba(10, 8, 4, 0.88);
    border: 1px solid var(--eg-ui-border);
    border-radius: var(--eg-radius);
    padding: 10px 12px 8px;
    z-index: 15;
    pointer-events: auto;
}

.etching-crosssection canvas {
    display: block;
    border-radius: 2px;
}

.etching-crosssection p {
    font-family: var(--eg-font-mono);
    font-size: 0.6rem;
    color: var(--eg-ui-text);
    margin: 6px 0 0;
    text-align: center;
    letter-spacing: 0.08em;
    opacity: 0.7;
}

/* ============ GALLERY THUMBNAILS ============ */
.etching-gallery-thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--eg-ui-border);
    background: rgba(0,0,0,0.3);
}

.etching-thumb {
    position: relative;
    width: calc(25% - 9px);
    aspect-ratio: 3/4;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid rgba(180,140,60,0.2);
    border-radius: 2px;
    transition: border-color 0.25s, transform 0.2s;
}

.etching-thumb:hover {
    border-color: var(--eg-accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}

.etching-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: sepia(0.25) contrast(1.1);
    transition: filter 0.3s;
}

.etching-thumb:hover img {
    filter: sepia(0.1) contrast(1.2);
}

/* Plate mark on thumbnails */
.thumb-platemark {
    position: absolute;
    inset: 6px;
    border: 1px solid rgba(0,0,0,0.2);
    pointer-events: none;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.15);
}

/* ============ LIGHTBOX ============ */
.etching-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-overlay {
    position: absolute;
    inset: 0;
    background: rgba(42, 42, 42, 0.96);
    cursor: pointer;
}

.lightbox-content {
    position: relative;
    z-index: 1;
    max-width: min(90vw, 900px);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.lightbox-close {
    position: absolute;
    top: -44px;
    right: 0;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.25);
    color: rgba(255,255,255,0.8);
    font-size: 1.5rem;
    line-height: 1;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-close:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

/* Plate mark in lightbox */
.lightbox-platemark {
    position: absolute;
    inset: -8px;
    border: 2px solid rgba(0,0,0,0.35);
    pointer-events: none;
    box-shadow:
        inset 2px 2px 6px rgba(0,0,0,0.3),
        inset -2px -2px 6px rgba(0,0,0,0.3),
        0 0 0 1px rgba(200,168,75,0.08);
    z-index: 2;
}

.lightbox-image-wrap {
    position: relative;
    max-height: 70vh;
    overflow: hidden;
    border-radius: 2px;
    box-shadow:
        0 0 0 1px rgba(0,0,0,0.8),
        0 0 60px rgba(0,0,0,0.9),
        inset 0 0 30px rgba(0,0,0,0.3);
}

.lightbox-image {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    filter: contrast(1.15) brightness(0.95);
}

/* Navigation */
.lightbox-navigation {
    display: flex;
    align-items: center;
    gap: 20px;
}

.lightbox-nav {
    font-family: var(--eg-font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    padding: 8px 18px;
    background: rgba(255,255,255,0.05);
    color: var(--eg-ui-text);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--eg-radius);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.lightbox-nav:hover {
    background: rgba(200, 168, 75, 0.12);
    border-color: var(--eg-accent);
    color: var(--eg-accent);
}

.lightbox-nav:disabled {
    opacity: 0.3;
    cursor: default;
}

.lightbox-counter {
    font-family: var(--eg-font-mono);
    font-size: 0.72rem;
    color: rgba(200, 185, 150, 0.55);
    letter-spacing: 0.1em;
    min-width: 50px;
    text-align: center;
}

/* ============ ACID BUBBLE ANIMATION ============ */
@keyframes bubble-rise {
    0%   { transform: translateY(0) scale(1);   opacity: 0.8; }
    80%  { transform: translateY(-60px) scale(1.3); opacity: 0.4; }
    100% { transform: translateY(-80px) scale(0.5); opacity: 0; }
}

.acid-bubble {
    position: absolute;
    border-radius: 50%;
    background: var(--eg-acid-bubble);
    animation: bubble-rise linear infinite;
    pointer-events: none;
}

/* ============ PRESS ANIMATION ============ */
@keyframes press-squeeze {
    0%   { transform: scaleY(1); }
    40%  { transform: scaleY(0.96); }
    100% { transform: scaleY(1); }
}

.etching-canvas-wrapper.pressing .etching-canvas {
    animation: press-squeeze 1.2s ease-in-out;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .etching-thumb {
        width: calc(50% - 6px);
    }

    .etching-controls {
        gap: 6px;
    }

    .etching-btn {
        font-size: 0.65rem;
        padding: 6px 10px;
    }

    .instruction-text {
        font-size: 0.6rem;
    }

    .etching-canvas-wrapper {
        height: 350px;
    }
}

@media (max-width: 480px) {
    .etching-thumb {
        width: calc(50% - 6px);
    }

    .etching-header {
        flex-direction: column;
        gap: 4px;
    }
}

/* ============ REDUCED MOTION ============ */
@media (prefers-reduced-motion: reduce) {
    .alarm-pulse,
    .acid-bubble,
    .etching-btn,
    .etching-thumb,
    .phase-dot {
        animation: none !important;
        transition: none !important;
    }
}
