/**
 * KINVA Artist OS - Studio Framer
 * Ultimate Edition - Pure CSS Frame Rendering
 * Based on "The Carpenter Method" (4 DIVs with mitre joints)
 * 
 * @version 1.0.0
 */

/* ═══════════════════════════════════════════════════════════════════
   CSS VARIABLES (Dynamic - controlled by JS)
   ═══════════════════════════════════════════════════════════════════ */

:root {
    /* Frame */
    --framer-frame-width: 26px;
    --framer-frame-base-color: #3d0e0b;
    --framer-frame-texture-opacity: 0.05;
    
    /* Profile gradient - THE SECRET SAUCE */
    /* This creates the 3D illusion of the Sara profile shape */
    --framer-profile-gradient: linear-gradient(
        to right, 
        rgba(0,0,0,0.5) 0%,        /* Shadow (wall side) */
        rgba(255,255,255,0.05) 5%, 
        rgba(255,255,255,0.25) 12%, /* Main highlight */
        rgba(255,255,255,0.1) 20%,
        rgba(0,0,0,0.1) 40%,        /* Curve down */
        rgba(0,0,0,0.4) 75%,        /* Valley */
        rgba(255,255,255,0.1) 82%, /* Inner edge */
        rgba(0,0,0,0.7) 100%       /* Inner shadow */
    );
    
    /* Matte */
    --framer-matte-width: 50px;
    --framer-matte-color: #fcfbf9;
    --framer-matte-texture: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
}

/* ═══════════════════════════════════════════════════════════════════
   FRAMER CONTAINER
   ═══════════════════════════════════════════════════════════════════ */

.kinva-framer {
    padding: 20px;
}

.kinva-framer__stage {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 60px;
    background-color: #e8e0d5;
    background-image: radial-gradient(#d4ccc0 1px, transparent 1px);
    background-size: 16px 16px;
    border-radius: 8px;
    transition: background 0.2s, outline 0.2s;
}

/* Dropzone active state (drag over) */
.kinva-framer__stage.dragover {
    background: rgba(37, 99, 235, 0.1);
    outline: 3px dashed #2563eb;
}

/* ═══════════════════════════════════════════════════════════════════
   THE FRAME ASSEMBLY
   ═══════════════════════════════════════════════════════════════════ */

.kinva-framer__assembly {
    position: relative;
    display: inline-flex;
    
    /* Wall shadow - realistic depth */
    box-shadow: 
        15px 20px 40px rgba(0,0,0,0.35),
        0 0 0 1px rgba(0,0,0,0.08);
    
    /* Smooth transitions for sliders */
    transition: box-shadow 0.2s ease-out;
}

/* ═══════════════════════════════════════════════════════════════════
   THE 4 RAILS (Wood strips with mitre joints)
   ═══════════════════════════════════════════════════════════════════ */

.kinva-framer__rail {
    position: absolute;
    z-index: 10;
    overflow: hidden;
    
    /* Base wood color */
    background-color: var(--framer-frame-base-color);
    
    /* Smooth transitions */
    transition: background-color 0.3s ease;
}

/* ─────────────────────────────────────────────────────────────────
   LAYER 1: Wood Grain Texture (::before)
   SVG Noise + subtle striping = simulated wood grain
   ───────────────────────────────────────────────────────────────── */

.kinva-framer__rail::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    
    /* Generated wood grain */
    background-image: 
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='2' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E"),
        linear-gradient(to bottom, rgba(0,0,0,0.1), rgba(0,0,0,0.2));
    
    /* Material-dependent opacity */
    opacity: var(--framer-frame-texture-opacity);
    mix-blend-mode: multiply;
}

/* ─────────────────────────────────────────────────────────────────
   LAYER 2: Profile Lighting (::after)
   This creates the 3D shape illusion - THE SECRET SAUCE!
   ───────────────────────────────────────────────────────────────── */

.kinva-framer__rail::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    z-index: 2;
    
    /* The magic gradient */
    background: var(--framer-profile-gradient);
    
    /* Overlay blend burns light/shadow onto the wood */
    mix-blend-mode: overlay;
    opacity: 0.9;
}

/* ─────────────────────────────────────────────────────────────────
   45° MITRE JOINTS (clip-path cuts)
   ───────────────────────────────────────────────────────────────── */

/* TOP RAIL - brightest (light from above) */
.kinva-framer__rail--top {
    top: 0;
    left: 0;
    right: 0;
    height: var(--framer-frame-width);
    filter: brightness(1.2) contrast(1.1);
    
    /* Trapezoid: /__\ */
    clip-path: polygon(
        0 0, 
        100% 0, 
        calc(100% - var(--framer-frame-width)) 100%, 
        var(--framer-frame-width) 100%
    );
}

.kinva-framer__rail--top::after {
    transform: rotate(90deg);
}

/* BOTTOM RAIL - darkest (shadow from above) */
.kinva-framer__rail--bottom {
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--framer-frame-width);
    filter: brightness(0.6) contrast(1.1);
    
    /* Trapezoid: \__/ */
    clip-path: polygon(
        var(--framer-frame-width) 0, 
        calc(100% - var(--framer-frame-width)) 0, 
        100% 100%, 
        0 100%
    );
}

.kinva-framer__rail--bottom::after {
    transform: rotate(-90deg);
}

/* LEFT RAIL - normal brightness */
.kinva-framer__rail--left {
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--framer-frame-width);
    filter: brightness(0.95);
    
    /* Parallelogram */
    clip-path: polygon(
        0 0, 
        100% var(--framer-frame-width), 
        100% calc(100% - var(--framer-frame-width)), 
        0 100%
    );
}

.kinva-framer__rail--left::after {
    transform: rotate(0deg);
}

/* RIGHT RAIL - darker (shadow side) */
.kinva-framer__rail--right {
    top: 0;
    bottom: 0;
    right: 0;
    width: var(--framer-frame-width);
    filter: brightness(0.75);
    
    /* Parallelogram */
    clip-path: polygon(
        100% 0, 
        100% 100%, 
        0 calc(100% - var(--framer-frame-width)), 
        0 var(--framer-frame-width)
    );
}

.kinva-framer__rail--right::after {
    transform: rotate(180deg);
}

/* ═══════════════════════════════════════════════════════════════════
   THE MATTE (Passepartout)
   ═══════════════════════════════════════════════════════════════════ */

.kinva-framer__matte {
    position: relative;
    z-index: 5;
    margin: var(--framer-frame-width);
    padding: var(--framer-matte-width);
    
    /* Matte color + texture */
    background-color: var(--framer-matte-color);
    background-image: var(--framer-matte-texture);
    
    /* Shadow from frame falling onto matte */
    box-shadow: inset 2px 2px 10px rgba(0,0,0,0.5);
    
    /* Smooth transitions */
    transition: 
        padding 0.2s ease-out,
        background-color 0.3s ease;
}

/* No matte mode */
.kinva-framer__matte--none {
    padding: 0;
    background: transparent;
    box-shadow: none;
}

/* ═══════════════════════════════════════════════════════════════════
   THE ARTWORK CONTAINER
   ═══════════════════════════════════════════════════════════════════ */

.kinva-framer__art-container {
    position: relative;
    line-height: 0;
    
    /* Shadow from matte onto artwork */
    box-shadow: inset 1px 1px 4px rgba(0,0,0,0.3);
    
    /* WHITE CORE - The museum-quality bevel cut edge */
    border: 1px solid rgba(255,255,255,0.8);
    outline: 1px solid rgba(0,0,0,0.1);
    
    /* Placeholder background */
    background: #ddd;
}

.kinva-framer__artwork {
    display: block;
    max-width: 100%;
    height: auto;
    max-height: 60vh;
}

/* ═══════════════════════════════════════════════════════════════════
   GLASS REFLECTION (Optional)
   ═══════════════════════════════════════════════════════════════════ */

.kinva-framer__glass {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    pointer-events: none;
    
    background: linear-gradient(
        135deg,
        rgba(255,255,255,0.06) 0%,
        rgba(255,255,255,0.02) 35%,
        transparent 55%
    );
}

.kinva-framer__glass--hidden {
    display: none;
}

/* ═══════════════════════════════════════════════════════════════════
   CONTROLS PANEL
   ═══════════════════════════════════════════════════════════════════ */

.kinva-framer__controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.kinva-framer__control-group {
    min-width: 200px;
}

.kinva-framer__control-group h4 {
    margin: 0 0 10px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
}

/* Color grid */
.kinva-framer__color-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
}

.kinva-framer__color-btn {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.2s;
}

.kinva-framer__color-btn:hover {
    transform: scale(1.08);
}

.kinva-framer__color-btn.active {
    border-color: #2563eb;
    transform: scale(0.92);
}

/* Sliders */
.kinva-framer__slider-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.kinva-framer__slider-label {
    font-size: 13px;
    color: #555;
}

.kinva-framer__slider-value {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    min-width: 50px;
    text-align: right;
}

.kinva-framer__slider {
    width: 100%;
    accent-color: #333;
}

/* Texture toggle */
.kinva-framer__texture-options {
    display: flex;
    gap: 8px;
}

.kinva-framer__texture-btn {
    flex: 1;
    padding: 8px 12px;
    font-size: 12px;
    border: 1px solid #ddd;
    background: #f8f8f8;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.kinva-framer__texture-btn:hover {
    border-color: #999;
}

.kinva-framer__texture-btn.active {
    background: #333;
    color: white;
    border-color: #333;
}

/* ═══════════════════════════════════════════════════════════════════
   ACTION BUTTONS
   ═══════════════════════════════════════════════════════════════════ */

.kinva-framer__actions {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    background: #f5f5f5;
    border-radius: 8px;
    margin-top: 20px;
}

.kinva-framer__btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

/* Upload button */
.kinva-framer__btn--upload {
    width: 100%;
    padding: 10px 16px;
    background: #f8f8f8;
    color: #333;
    border: 2px dashed #ccc;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.kinva-framer__btn--upload:hover {
    background: #f0f0f0;
    border-color: #999;
}

.kinva-framer__btn--primary {
    background: #2563eb;
    color: white;
}

.kinva-framer__btn--primary:hover {
    background: #1d4ed8;
}

.kinva-framer__btn--success {
    background: #059669;
    color: white;
}

.kinva-framer__btn--success:hover {
    background: #047857;
}

.kinva-framer__btn--inventory {
    background: #7c3aed;
    color: white;
}

.kinva-framer__btn--inventory:hover {
    background: #6d28d9;
}

.kinva-framer__btn--secondary {
    background: white;
    border: 1px solid #ddd;
    color: #333;
}

.kinva-framer__btn--secondary:hover {
    background: #f0f0f0;
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .kinva-framer__stage {
        padding: 30px;
    }
    
    .kinva-framer__controls {
        flex-direction: column;
    }
    
    .kinva-framer__control-group {
        width: 100%;
    }
}
