@import 'main.css';

/* Base layout constraints */
body {
    margin: 0;
    padding: 0;
    min-width: 320px; /* Minimum width for very small devices */
    overflow-x: hidden; /* Prevent horizontal scroll */
    box-sizing: border-box;
}

*, *:before, *:after {
    box-sizing: inherit; /* Ensure padding is included in width calculations */
}

/* Sketch Layout */
.layout {
    display: grid;
    grid-template-columns: minmax(400px, 1.5fr) minmax(400px, 1fr);
    gap: 2rem;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    box-sizing: border-box;
}

.content {
    padding-right: 2rem;
    overflow-y: auto;
}

.sketch-container {
    background: var(--color-dark);
    padding: 0.5rem;
    position: relative;
    transition: all 0.3s ease;
    opacity: 0.9;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    aspect-ratio: 4/3;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
}

.sketch-container.expanded {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100;
    background: rgba(16, 42, 67, 0.98);
    padding: 2rem;
    opacity: 1;
    aspect-ratio: auto;
    overflow: auto;
}

.sketch-holder {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transform-origin: center;
    position: relative;
    aspect-ratio: 4/3;
}

.sketch-holder canvas {
    transition: transform 0.3s ease, max-width 0.3s ease, max-height 0.3s ease;
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.sketch-container.expanded .sketch-holder {
    margin-bottom: 1rem;
    max-height: calc(100vh - 120px);
    aspect-ratio: 4/3;
}

/* Controls */
.controls {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(26, 95, 122, 0.9);
    padding: 1rem;
    border-radius: 8px;
    display: none;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 1rem;
    backdrop-filter: blur(5px);
    z-index: 1000;
    width: auto;
    max-width: 90vw;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Show controls when expanded */
.sketch-container.expanded .controls {
    display: flex;
    opacity: 1;
    visibility: visible;
}

/* Hide the native color picker input but keep it functional */
.color-picker input[type="color"] {
    opacity: 0;
    width: 0;
    height: 0;
    padding: 0;
    margin: 0;
    position: absolute;
}

/* Style all control buttons consistently */
.control-btn {
    background: var(--color-accent);
    border: none;
    color: var(--color-dark);
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: var(--color-secondary);
    transform: scale(1.1);
}

.controls ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: row;
    gap: 1rem;
    flex-wrap: nowrap;
}

.controls li {
    margin: 0;
    white-space: nowrap;
}

.key {
    background: var(--color-accent);
    color: var(--color-dark);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9rem;
}

.expand-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--color-accent);
    border: none;
    color: var(--color-dark);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    z-index: 10;
    opacity: 0.8;
    backdrop-filter: blur(2px);
}

.expand-button:hover {
    background: var(--color-secondary);
    color: var(--color-background);
    opacity: 1;
}

.sketch-container:hover .expand-button {
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 1000px) {
    .layout {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    .content {
        padding-right: 0;
        padding-bottom: 1rem;
    }

    .sketch-container {
        width: 100%;
        max-width: 100%;
        aspect-ratio: 4/3;
    }

    .sketch-holder {
        aspect-ratio: 4/3;
    }
}

.pattern-container {
    margin: 1em 0;
    padding: 0.5em;
    border: 1px solid #eee;
    border-radius: 4px;
    background: #fafafa;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    box-sizing: border-box;
}

.pattern-container .editor-wrapper {
    width: 100%;
    max-width: 500px;
    overflow-x: auto;
    padding: 0 0.5em;
    box-sizing: border-box;
}

.pattern-container .code-preview {
    width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.9em;
}

.pattern-container pre {
    margin: 0;
    padding: 1em;
}

.pattern-output {
    margin: 0.5em 0;
    padding: 0.5em;
    background: white;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 500px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}

.pattern-output svg {
    width: 100%;
    height: auto;
    max-width: 100%;
    display: block;
}

@media (max-width: 1000px) {
    .layout {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    .content {
        padding-right: 0;
        padding-bottom: 1rem;
    }

    .pattern-container {
        padding: 0.25em;
        margin: 0.5em 0;
    }

    .pattern-container .editor-wrapper {
        max-width: 400px;
        padding: 0 0.25em;
    }

    .pattern-output {
        max-width: 400px;
        padding: 0.25em;
        margin: 0.25em 0;
    }
}

@media (max-width: 600px) {
    .layout {
        padding: 0.5rem;
    }

    .pattern-container {
        padding: 0.25em;
        margin: 0.25em 0;
    }

    .pattern-container .editor-wrapper {
        max-width: 300px;
        padding: 0 0.25em;
    }

    .pattern-output {
        max-width: 300px;
        padding: 0.25em;
        margin: 0.25em 0;
    }

    .pattern-container .code-preview {
        font-size: 0.8em;
    }
}

.pattern-editor-controls {
    display: flex;
    gap: 0.5em;
    padding: 0.5em;
    background: #f5f5f5;
    border-top: 1px solid #ddd;
    align-items: center;
}

.pattern-editor-controls button {
    padding: 0.3em 0.8em;
    font-size: 0.9em;
    font-family: 'JetBrains Mono', monospace;
    background: #2c5282;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.2s;
    height: 32px;
    line-height: 1;
}

.pattern-editor-controls button:hover {
    background: #2b6cb0;
}

.pattern-editor-controls button.edit {
    background: #2c5282;
}

.pattern-editor-controls button.edit:hover {
    background: #2b6cb0;
}

.pattern-editor-controls button.download-svg {
    background: #2f855a;
}

.pattern-editor-controls button.download-svg:hover {
    background: #38a169;
}

.pattern-editor-controls button.download-ps {
    background: #805ad5;
} 