:root {
    --primary-font: "Inter", sans-serif;
    --background-color: #ffffff;
    --drag-highlight-bg: #f2f2f2;
    --text-color: #222222;
    --accent-color: #666666;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

body {
    font-family: var(--primary-font);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.4;
    min-height: 100vh;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    overflow: hidden; /* Prevent body scrolling */
    position: fixed; /* Fix body in place */
    width: 100%; /* Ensure body takes full width */
    height: 100%; /* Ensure body takes full height */
}

.container {
    display: flex;
    flex-direction: column;
    height: 100%; /* Use 100% height instead of min-height */
    margin: 0 auto;
    padding: 0rem;
    overflow: hidden; /* Prevent container scrolling */
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    padding: 0.5rem 1rem;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    font-size: 0.65rem;
    height: 3rem;
    background-color: #ffffff;
}

h1 {
    font-weight: 400;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    margin: 0;
}

.upload-container {
    position: relative;
}

.upload-button {
    display: inline-block;
    padding: 0;
    background-color: #ffffff;
    cursor: pointer;
    font-family: var(--primary-font);
    font-size: 0.65rem;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.upload-button:hover {
    transform: scale(1.02);
}

.upload-button:active {
    transform: translateY(0);
    box-shadow: none;
}

input[type="file"] {
    position: absolute;
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    z-index: -1;
}

main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    overflow: visible;
    margin-top: 3.5rem; /* Add space for fixed header */
    /* Use the custom viewport height variable */
    height: calc(var(--vh, 100vh) - 3.5rem - 100px);
    min-height: 300px;
    /* Add bottom margin to account for footer/swatches */
    margin-bottom: 100px;
    transition: background-color 0.3s ease;
}

main.highlight-drop {
    background-color: transparent;
}

body.highlight-drop {
    background-color: var(--drag-highlight-bg);
}

body.highlight-drop header,
body.highlight-drop footer,
body.highlight-drop .upload-button {
    background-color: var(--drag-highlight-bg);
}

/* Large screen specific styles */
@media (min-width: 769px) {
    main {
        /* Adjust vertical centering to account for header and footer */
        padding-bottom: 100px; /* Match footer height */
        height: calc(var(--vh, 100vh) - 3.5rem - 100px);
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .container {
        /* Center content more precisely on large screens */
        /* max-width: 1400px; */
        margin: 0 auto;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        height: 100%;
    }
}

/* Media query for smaller screens */
@media (max-width: 768px) {
    main {
        align-items: flex-start; /* Align content to the top instead of center */
        justify-content: center;
        padding-top: 0.5rem;
        height: auto; /* Let height be determined by content */
        max-height: calc(var(--vh, 100vh) - 3.5rem - 100px); /* Maximum height to fit available space */
        min-height: 200px; /* Minimum height */
        overflow-y: hidden; /* Prevent vertical scrolling */
        margin-bottom: 0; /* Remove margin bottom on mobile */
    }
    
    .image-container {
        max-height: calc(var(--vh, 100vh) - 3.5rem - 100px - 1rem); /* Adjusted max height */
        margin-top: 0;
    }
    
    footer {
        height: 100px; /* Fixed height for footer on mobile */
    }
}

.image-container {
    position: relative;
    overflow: visible;
    background-color: transparent;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), height 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* Set max dimensions using the custom viewport height variable */
    max-height: calc(var(--vh, 100vh) - 3.5rem - 100px - 2rem);
}

.placeholder {
    position: fixed;
    left: 1rem;
    bottom: calc(100px + 1rem);
    width: min(200px, calc(100vw - 2rem));
    height: auto;
    display: block;
    color: var(--accent-color);
    font-size: 0.7rem;
    min-height: 0;
    transition: all 0.3s ease;
    text-align: left;
    padding: 0;
    border: none;
    background-color: transparent;
    border-radius: 0px;
    text-transform: none;
    pointer-events: none;
    z-index: 120;
}

#image-placeholder {
    text-transform: none !important;
}

main.highlight-drop .placeholder {
    border-color: rgba(0, 0, 0, 0.2);
    transform: scale(1.05);
    background-color: transparent;
}

#uploaded-image {
    display: block;
    /* Max dimensions removed - now controlled by JS */
}

#color-dots-container {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: all;
}

.color-dot {
    --plus-offset-y: 0px;
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: grab;
    pointer-events: auto;
    transform: translate(-50%, -50%);
    z-index: 10;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease;
}

.color-dot::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    color: #222;
    display: block;
    width: 10px;
    height: 1.5px;
    background-color: #222;
    border-radius: 1px;
    transform-origin: 50% 50%;
    transition: transform 0.15s ease;
    transform: translate(-50%, calc(-50% + var(--plus-offset-y))) rotate(0deg);
}

.color-dot::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    display: block;
    width: 10px;
    height: 1.5px;
    background-color: #222;
    border-radius: 1px;
    transform-origin: 50% 50%;
    transition: transform 0.15s ease;
    transform: translate(-50%, calc(-50% + var(--plus-offset-y))) rotate(90deg);
}

.color-dot:hover::before {
    transform: translate(-50%, calc(-50% + var(--plus-offset-y))) rotate(90deg);
}

.color-dot:hover::after {
    transform: translate(-50%, calc(-50% + var(--plus-offset-y))) rotate(180deg);
}

/* Safari-specific glyph baseline correction for the plus icon */
.is-safari .color-dot {
    --plus-offset-y: 0.5px;
}

.color-dot.dragging {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
    z-index: 20;
}

.color-dot.highlight {
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.8), 0 0 8px rgba(0, 0, 0, 0.3);
    z-index: 20;
}

.color-dot.dimmed {
    opacity: 0.3;
}

.color-dot.selected {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.12);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
    z-index: 25;
}

.color-dot.pulse {
    animation: pulse 1s ease-in-out;
    z-index: 30;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.3);
        box-shadow: 0 0 15px rgba(255, 255, 255, 0.8), 0 0 8px rgba(0, 0, 0, 0.3);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
    }
}

footer {
    padding: 0;
    position: fixed; /* Change from sticky to fixed */
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--background-color);
    z-index: 100;
}

.color-swatches {
    display: flex;
    gap: 0;
    overflow-x: auto;
    padding: 0;
    scrollbar-width: none;
    width: 100%;
    height: 100px; /* Fixed height instead of min-height */
}

.color-swatches::-webkit-scrollbar {
    display: none;
}

.color-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
    margin: 0;
    cursor: pointer;
    transition: transform 0.2s ease;
    position: relative;
}

.color-swatch:hover {
    transform: translateY(-3px);
    z-index: 10;
}

.color-swatch:active {
    transform: translateY(-1px);
}

.swatch-preview {
    width: 100px;
    height: 100px;
    border-radius: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    box-shadow: none;
    transition: all 0.2s ease;
}

.color-swatch:hover .swatch-preview {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.swatch-details {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
    text-align: left;
    padding: 0.7rem;
    background-color: transparent;
}

.swatch-hex, .swatch-rgb {
    font-size: 0.55rem;
    font-weight: 400;
    margin-bottom: 0.1rem;
    letter-spacing: 0.3px;
}

/* Split view for color palette */
.split-view {
    display: none; /* Hidden by default */
    position: fixed;
    top: 2.5rem; /* Below header */
    left: 0;
    width: 100%;
    height: calc(var(--vh, 100vh) - 3.5rem - 100px);
    z-index: 90;
    background-color: var(--background-color);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.split-view.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

/* Hide the main content when split view is active */
.split-view.active + main .image-container,
.split-view.active ~ main .image-container {
    opacity: 0;
    visibility: hidden;
}

.split-view-left {
    width: 60%;
    height: 100%;
    overflow: hidden;
    border-right: none;
    padding: 1rem;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.split-view-left .image-container {
    position: relative;
    height: auto;
    width: auto;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
}

.split-view-left img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.split-view-right {
    width: 40%;
    height: 100%;
    overflow-y: auto;
    padding: 1rem 1rem 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 0;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.split-view.active .split-view-left,
.split-view.active .split-view-right {
    opacity: 1;
    transform: translateX(0);
}

.palette-section {
    margin-bottom: 0;
    position: relative;
    padding-top: 2.5rem;
    margin-top: 0.5rem;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.split-view.active .palette-section {
    opacity: 1;
    transform: translateY(0);
    transition-delay: calc(var(--section-index, 0) * 0.1s + 0.3s);
}

.palette-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.split-view.active .palette-header {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.2s;
}

.selected-color {
    display: flex;
    align-items: center;
    gap: 0;
}

.color-preview {
    width: 100px;
    height: 100px;
    border-radius: 0;
    background-color: rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
}

.color-info {
    font-size: 0.55rem;
    background-color: transparent;
    padding: 0.5rem;
    width: 100%;
    text-align: left;
}

.close-palette {
    background: none;
    border: none;
    font-size: 1.1rem;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    color: var(--text-color);
    font-family: var(--primary-font);
    transition: transform 0.2s ease, opacity 0.2s ease;
    -webkit-font-smoothing: antialiased;
    text-rendering: geometricPrecision;
}

.close-palette:hover {
    opacity: 0.7;
    transform: rotate(90deg);
}

.palette-section h3 {
    font-size: 0.55rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: absolute;
    top: 1rem;
    left: 0.3rem;
    z-index: 10;
    background-color: transparent;
    color: #222222;
    padding: 0.5rem 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: calc(100% - 0.6rem);
}

.palette-header-icons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.download-palette {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    width: 0.8rem;
    height: 0.8rem;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    color: var(--accent-color);
}

.download-palette:hover {
    opacity: 1;
}

.add-variant {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    width: 0.8rem;
    height: 0.8rem;
    opacity: 0.7;
    transition: opacity 0.2s ease, transform 0.2s ease;
    color: var(--accent-color);
}

.add-variant:hover {
    opacity: 1;
}

.add-variant:active {
    transform: scale(0.9);
}

.download-palette svg,
.add-variant svg {
    width: 100%;
    height: 100%;
}

.color-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0;
    margin-bottom: 0;
}

/* Custom grid layouts for each palette type */
.complementary-grid {
    display: grid;
    grid-template-columns: 1.6fr repeat(4, 1fr);
    gap: 0;
}

.analogous-grid {
    display: grid;
    grid-template-columns: 1.6fr repeat(4, 1fr);
    gap: 0;
}

.triadic-grid {
    display: grid;
    grid-template-columns: 1.6fr repeat(4, 1fr);
    gap: 0;
}

.square-grid,
.compound-grid,
.tetradic-grid {
    display: grid;
    grid-template-columns: 1.3fr repeat(3, 1fr);
    gap: 0;
}

.splitComplementary-grid {
    display: grid;
    grid-template-columns: 1.6fr repeat(4, 1fr);
    gap: 0;
}

.monochromatic-grid {
    display: grid;
    grid-template-columns: 2fr repeat(2, 1fr);
    grid-template-rows: 1fr 1fr;
    gap: 0;
}

.monochromatic-grid .large-color {
    grid-row: span 2;
}

.monochromatic-grid .palette-color:nth-child(even):not(.large-color) {
    grid-column: 3;
}

.monochromatic-grid .palette-color:nth-child(odd):not(.large-color) {
    grid-column: 2;
}

.shades-grid {
    display: grid;
    grid-template-columns: 2fr repeat(4, 1fr);
    gap: 0;
}

.tints-grid {
    display: grid;
    grid-template-columns: 2fr repeat(4, 1fr);
    grid-template-rows: 1fr;
    gap: 0;
}

.tints-grid .large-color {
    grid-column: 1;
    grid-row: 1;
    height: 120px;
}

.tints-grid .palette-color:not(.large-color) {
    height: 120px;
    display: flex;
    width: 100%;
}

.tints-grid .palette-color:not(.large-color) .palette-color-name {
    font-size: 0.6rem;
}

.tints-grid .palette-color:not(.large-color) .palette-color-preview {
    padding: 0.8rem 0.8rem 3rem 0.5rem;
}

.tones-grid {
    display: grid;
    grid-template-columns: 1.5fr repeat(2, 1fr);
    grid-template-rows: 1fr 1fr;
    gap: 0;
}

.tones-grid .large-color {
    grid-row: span 2;
}

.accent-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Base color container (first row) */
.accent-grid .large-color {
    width: 100%;
    height: 120px;
    margin-bottom: 0;
    position: relative;
    z-index: 1;
}

/* Container for all accent colors (second row) */
.accent-grid .accent-colors-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    width: 100%;
}

.accent-grid .palette-color:not(.large-color) {
    height: 60px;
    width: 100%;
}

/* Adjust accent palette layout for better visibility */
.accent-grid .palette-color-name {
    display: block;
    margin-bottom: 0.5rem;
}

.accent-grid .large-color .palette-color-label {
    bottom: 0;
    padding-bottom: 1rem;
}

.palette-color {
    width: 100%;
    height: 120px;
    display: flex;
    flex-direction: column;
    position: relative;
    border: none;
    outline: none;
    overflow: hidden;
    transition: transform 0.2s ease, opacity 0.2s ease;
    opacity: 0;
    transform: scale(0.95);
    cursor: pointer;
}

.split-view.active .palette-color {
    opacity: 1;
    transform: scale(1);
    transition-delay: calc(var(--color-index, 0) * 0.05s + 0.5s);
}

.palette-color:hover {
    z-index: 1;
    transition: transform 0.2s ease !important;
    transform: scale(0.9) !important;
}

.large-color {
    grid-column: span 1;
    grid-row: span 1;
    height: 120px;
}

.palette-color-preview {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.8rem 0.8rem 3rem 0.5rem;
}

.palette-color-name {
    font-size: 0.55rem;
    font-weight: 400;
    margin-bottom: 0.5rem;
}

.large-color .palette-color-name {
    font-size: 0.55rem;
}

.palette-color-label {
    font-size: 0.55rem;
    text-align: left;
    background-color: transparent;
    padding: 0.5rem;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
}

/* Mobile adjustments for split view */
@media (max-width: 768px) {
    .split-view {
        flex-direction: column;
    }
    
    .split-view-left, 
    .split-view-right {
        width: 100%;
    }
    
    .split-view-left {
        display: none; /* Hide the image completely on mobile */
    }
    
    .split-view-right {
        height: 100%; /* Take up the full height */
        transform: translateY(20px); /* Slide up animation on mobile */
        opacity: 0;
    }
    
    .split-view.active .split-view-right {
        transform: translateY(0);
        opacity: 1;
        transition-delay: 0.1s;
    }
    
    .palette-color {
        height: 100px;
    }
    
    .large-color {
        height: 100px;
    }
    
    .palette-color-name {
        font-size: 0.55rem;
    }
    
    .large-color .palette-color-name {
        font-size: 0.55rem;
    }
    
    .palette-color-preview {
        padding: 0.5rem 0.5rem 2.5rem 0.5rem;
    }
    
    .palette-section {
        padding-top: 2rem;
        margin-top: 0.5rem;
    }
    
    .palette-section h3 {
        top: 0.7rem;
        padding: 0.4rem 0;
    }
    
    .download-palette {
        width: 0.7rem;
        height: 0.7rem;
    }
}

.palettes-container {
    display: grid;
    grid-auto-rows: min-content;
    gap: 0;
    width: 100%;
    margin-top: 0;
    padding-bottom: 20px;
}

/* Hide main content when split view is active */
body.split-view-active main > .image-container {
    opacity: 0;
    visibility: hidden;
    position: absolute;
    pointer-events: none;
} 
