/* PT Sans Italic 400 */
@font-face {
  font-family: 'PT Sans';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/pt-sans-italic-400-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'PT Sans';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/pt-sans-italic-400-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'PT Sans';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/pt-sans-italic-400-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'PT Sans';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/pt-sans-italic-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* PT Sans Italic 700 */
@font-face {
  font-family: 'PT Sans';
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/pt-sans-italic-700-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'PT Sans';
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/pt-sans-italic-700-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'PT Sans';
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/pt-sans-italic-700-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'PT Sans';
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/pt-sans-italic-700-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* PT Sans Normal 400 */
@font-face {
  font-family: 'PT Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/pt-sans-normal-400-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'PT Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/pt-sans-normal-400-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'PT Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/pt-sans-normal-400-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'PT Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/pt-sans-normal-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* PT Sans Normal 700 */
@font-face {
  font-family: 'PT Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/pt-sans-normal-700-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'PT Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/pt-sans-normal-700-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'PT Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/pt-sans-normal-700-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'PT Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/pt-sans-normal-700-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

body {
    font-family: 'PT Sans', sans-serif;
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
}

h1 {
    text-align: center;
}

footer {
    text-align: center;
}

/* Upload Container */
.upload-container {
    margin: 20px 0;
}

/* Workflow Container */
.workflow-container {
    margin: 30px 0;
    transition: all 0.3s ease;
}

#fileInput {
    display: block;
    margin-bottom: 15px;
    font-family: 'PT Sans', sans-serif;
    padding: 8px 12px;
    border: 1px solid #333;
    border-radius: 4px;
    cursor: pointer;
}

#fileInput:hover {
    background-color: #f0f0f0;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed #666;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    background-color: #fafafa;
    transition: all 0.3s ease;
    cursor: pointer;
}

.drop-zone p {
    margin: 0;
    color: #666;
    font-size: 16px;
}

.drop-zone:hover {
    border-color: #333;
    background-color: #f0f0f0;
}

.drop-zone.drag-over {
    border-color: #333;
    background-color: #e8e8e8;
    border-style: solid;
}

/* Phase 1: Side-by-side layout (threshold controls | preview canvas) */
.workflow-container.phase-threshold .threshold-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fafafa;
}

.threshold-preview {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Hide Phase 2 elements in Phase 1 */
.workflow-container.phase-threshold .frozen-threshold-display,
.workflow-container.phase-threshold .brush-panel {
    display: none;
}

/* Phase 2: Grid layout with threshold panel spanning top */
.workflow-container.phase-brush {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 20px;
}

/* Top row: Grayed-out threshold panel (spans both columns, contains controls + frozen canvas) */
.workflow-container.phase-brush .threshold-panel {
    grid-row: 1;
    grid-column: 1 / 3;
    pointer-events: none;
    opacity: 0.6;
    filter: grayscale(0.3);
    padding: 20px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background-color: #f5f5f5;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}


.workflow-container.phase-brush .threshold-panel .threshold-controls {
    display: block;
}

/* Show frozen canvas inside threshold panel in Phase 2 */
.workflow-container.phase-brush .threshold-panel .threshold-preview {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Hide the separate frozen-threshold-display in Phase 2 (we'll move it inside threshold-panel) */
.workflow-container.phase-brush .frozen-threshold-display {
    display: none;
}

/* Bottom row: Brush panel (spans both columns, contains controls + canvas) */
.workflow-container.phase-brush .brush-panel {
    grid-row: 2;
    grid-column: 1 / 3;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fafafa;
}

/* Brush panel content layout (controls | canvas) */
.brush-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 20px;
}

/* Brush canvas container inside brush panel */
.brush-canvas-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Canvas styling for all three canvases */
.threshold-preview canvas,
.frozen-threshold-display canvas,
.brush-canvas-container canvas {
    border: 1px solid #333;
    display: block;
    max-width: 100%;
    height: auto;
}

/* Phase Transition Button */
.phase-transition-btn {
    display: block;
    margin: 20px auto;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    background-color: #333;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'PT Sans', sans-serif;
}

.phase-transition-btn:hover:not(:disabled) {
    background-color: #555;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.phase-transition-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 0.5;
}

.workflow-container.phase-brush .phase-transition-btn {
    display: none;
}

.slider-group {
    margin-bottom: 20px;
}

.slider-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.slider-group input[type="range"] {
    width: 100%;
    max-width: 300px;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    cursor: pointer;
}

.slider-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #333;
    cursor: pointer;
}

.slider-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #333;
    cursor: pointer;
    border: none;
}

.slider-group input[type="range"]:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.slider-group input[type="range"]:disabled::-webkit-slider-thumb {
    cursor: not-allowed;
}

.slider-group input[type="range"]:disabled::-moz-range-thumb {
    cursor: not-allowed;
}

/* Gradient Bars */
.gradient-bars {
    margin-top: 30px;
}

.gradient-bar-container {
    margin-bottom: 15px;
}

.gradient-bar-container label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: #666;
}

.gradient-bar-container canvas {
    display: block;
    border: 1px solid #ccc;
    border-radius: 3px;
}

/* Brush Panel Heading */
.brush-panel h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

/* Brush Settings Container */
.brush-settings {
    /* Always active in Phase 2 */
}

/* Brush Color Group */
.brush-color-group {
    margin-bottom: 20px;
}

.brush-group-label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 6px 0;
    font-size: 14px;
    color: #555;
}

.radio-label input[type="radio"] {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    cursor: pointer;
}

.color-swatch {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 3px;
    margin-right: 8px;
    border: 1px solid #999;
}

.radio-label:hover {
    color: #333;
}

/* Canvas hover states for brush mode */
#brushCanvas.brush-active {
    cursor: crosshair;
}

#brushCanvas.brush-painting {
    cursor: none;
}

/* Disabled state for locked sliders - removed label */
.slider-group.locked {
    opacity: 0.5;
    position: relative;
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Phase 1: Stack controls above canvas */
    .workflow-container.phase-threshold .threshold-panel {
        grid-template-columns: 1fr;
    }

    /* Phase 2: Stack all panels vertically */
    .workflow-container.phase-brush {
        grid-template-columns: 1fr;
    }

    .workflow-container.phase-brush .threshold-panel {
        grid-column: 1;
        grid-template-columns: 1fr;
    }

    .workflow-container.phase-brush .brush-panel {
        grid-column: 1;
    }

    /* Stack brush controls above canvas on mobile */
    .brush-content {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   PHASE 3: 3D EXTRUSION
   ======================================== */

/* Hide Phase 3 elements in Phase 1 */
.workflow-container.phase-threshold .frozen-brush-display,
.workflow-container.phase-threshold .extrusion-panel,
.workflow-container.phase-threshold .phase2-transition-btn {
    display: none;
}

/* Hide Phase 3 elements and show Phase 2 transition button in Phase 2 */
.workflow-container.phase-brush .frozen-brush-display,
.workflow-container.phase-brush .extrusion-panel {
    display: none;
}

.workflow-container.phase-brush .phase2-transition-btn {
    display: block;
    grid-column: 1 / 3;  /* Span both columns to center properly */
}

/* Phase 3: Three-row layout with grayed-out threshold and brush panels */
.workflow-container.phase-extrusion {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 20px;
}

/* Row 1: Grayed-out threshold panel (spans both columns) */
.workflow-container.phase-extrusion .threshold-panel {
    grid-row: 1;
    grid-column: 1 / 3;
    pointer-events: none;
    opacity: 0.6;
    filter: grayscale(0.3);
    padding: 20px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background-color: #f5f5f5;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

/* Row 2: Grayed-out brush panel (spans both columns) */
.workflow-container.phase-extrusion .brush-panel {
    grid-row: 2;
    grid-column: 1 / 3;
    pointer-events: none;
    opacity: 0.6;
    filter: grayscale(0.3);
    padding: 20px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background-color: #f5f5f5;
}

/* Brush content stays in grid layout even when grayed */
.workflow-container.phase-extrusion .brush-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

/* Row 3: Active extrusion panel (spans both columns) */
.workflow-container.phase-extrusion .extrusion-panel {
    grid-row: 3;
    grid-column: 1 / 3;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fafafa;
}

/* Hide transition buttons and frozen displays in Phase 3 */
.workflow-container.phase-extrusion .phase-transition-btn,
.workflow-container.phase-extrusion .phase2-transition-btn,
.workflow-container.phase-extrusion .frozen-threshold-display,
.workflow-container.phase-extrusion .frozen-brush-display {
    display: none;
}

/* Extrusion panel heading */
.extrusion-panel h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

/* Extrusion content layout (controls | canvas) */
.extrusion-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 20px;
}

/* Extrusion canvas container */
.extrusion-canvas-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Extrusion canvas styling */
.extrusion-canvas-container canvas {
    border: 1px solid #333;
    display: block;
    max-width: 100%;
    height: auto;
}

/* Export button group */
.export-group {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.export-btn {
    width: 100%;
    padding: 12px 24px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.export-btn:hover {
    background-color: #45a049;
}

.export-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.export-btn:active {
    transform: translateY(1px);
}

/* Frozen brush display (hidden in Phase 3) */
.frozen-brush-display {
    display: none;
}

.frozen-brush-display label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #666;
}

.frozen-brush-display canvas {
    border: 1px solid #333;
    display: block;
    max-width: 100%;
    height: auto;
}

/* ========================================
   RESPONSIVE DESIGN - PHASE 3
   ======================================== */

@media (max-width: 768px) {
    /* Phase 3: Stack all panels vertically on mobile */
    .workflow-container.phase-extrusion {
        grid-template-columns: 1fr;
    }

    .workflow-container.phase-extrusion .threshold-panel,
    .workflow-container.phase-extrusion .brush-panel,
    .workflow-container.phase-extrusion .extrusion-panel {
        grid-column: 1;
        grid-template-columns: 1fr;
    }

    .workflow-container.phase-extrusion .brush-content,
    .workflow-container.phase-extrusion .extrusion-content {
        grid-template-columns: 1fr;
    }
}