:root {
    --background: 0 0% 100%;
    --foreground: 240 10% 3.9%;
    --card: 0 0% 100%;
    --card-foreground: 240 10% 3.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 240 10% 3.9%;
    --primary: 24 100% 50%;
    --primary-foreground: 0 0% 98%;
    --secondary: 240 4.8% 95.9%;
    --secondary-foreground: 240 5.9% 10%;
    --muted: 240 4.8% 95.9%;
    --muted-foreground: 240 3.8% 46.1%;
    --accent: 240 4.8% 95.9%;
    --accent-foreground: 240 5.9% 10%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 5.9% 90%;
    --input: 240 5.9% 90%;
    --ring: 24 100% 50%;
    --radius: 0.5rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'DM Sans', sans-serif;
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    line-height: 1.6;
}

.font-space-grotesk {
    font-family: 'Space Grotesk', sans-serif;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header Styles */
.header {
    border-bottom: 1px solid hsl(var(--border));
    background-color: hsl(var(--card) / 0.5);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo h1, .logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: hsl(var(--foreground));
}

.nav {
    display: none;
    align-items: center;
    gap: 1.5rem;
}

.nav a {
    color: hsl(var(--muted-foreground));
    text-decoration: none;
    transition: color 0.2s;
}

.nav a:hover {
    color: hsl(var(--foreground));
}

@media (min-width: 768px) {
    .nav {
        display: flex;
    }
}

/* Hero Section */
.hero {
    padding: 2rem 1rem 0;
    text-align: center;
    /* Add margin top on mobile to account for fixed header */
    margin-top: 1rem;
}

@media (max-width: 768px) {
    .hero {
        padding-top: 1rem;
        margin-top: 0;
    }
}

.hero h1, .hero h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.hero .highlight {
    color: hsl(var(--primary));
}

.hero p {
    font-size: 1rem;
    color: hsl(var(--muted-foreground));
    max-width: 42rem;
    margin: 0 auto 1rem;
}

@media (min-width: 768px) {
    .hero h1, .hero h2 {
        font-size: 2.75rem;
    }
}

/* Status Message */
#status {
    font-size: 1.25rem;
    color: hsl(var(--primary));
    margin: 1rem 0;
    font-weight: 500;
}

/* Control Panel */
.control-panel {
    background-color: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1.5rem;
    margin: 1rem auto;
    max-width: 42rem;
}

.control-panel h5 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.controls-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.form-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    min-width: 100px;
    flex-shrink: 0;
}

.form-control {
    padding: 0.5rem 0.75rem;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 2px);
    background-color: hsl(var(--background));
    font-size: 0.875rem;
    transition: border-color 0.2s;
    width: 80px;
    flex-shrink: 0;
}

.form-control:focus {
    outline: none;
    border-color: hsl(var(--primary));
}

/* Upload and Result Grid */
.main-grid {
    display: grid;
    gap: 2rem;
    align-items: start;
    margin-top: 2rem;
    /* Ensure content is not hidden behind header on mobile */
    scroll-margin-top: 4rem;
}

@media (min-width: 768px) {
    .main-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.card {
    background-color: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    /* Add scroll margin for better mobile navigation */
    scroll-margin-top: 5rem;
    /* Prevent horizontal overflow on mobile */
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .card {
        padding: 0.75rem;
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }
}

.upload-area {
    border: 2px dashed hsl(var(--border));
    border-radius: var(--radius);
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
}

.upload-area:hover {
    border-color: hsl(var(--primary) / 0.5);
}

.upload-area.has-image img {
    max-width: 100%;
    height: 16rem;
    object-fit: contain;
    margin: 0 auto;
    border-radius: var(--radius);
}
.upload-area img {
    max-width: 500px;
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.upload-placeholder p {
    margin: 0;
}

.upload-placeholder .main-text {
    font-size: 1.125rem;
    font-weight: 500;
    color: hsl(var(--foreground));
}

.upload-placeholder .sub-text {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
}

.hidden {
    display: none !important;
}

/* Canvas Styles */
.canvas-container {
    margin: 1rem 0;
    text-align: center;
    /* Add scroll margin for mobile */
    scroll-margin-top: 5rem;
}

.canvas-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: hsl(var(--foreground));
}

canvas {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    /* border: 1px solid hsl(var(--border)); */
    background-color: white;
    display: block;
    margin: 0 auto;
    /* Ensure canvas maintains aspect ratio */
    object-fit: contain;
}

/* Mobile specific canvas adjustments */
@media (max-width: 768px) {
    canvas {
        max-width: calc(100vw - 3rem);
        width: 100%;
        height: auto;
        /* Maintain square aspect ratio on mobile */
        aspect-ratio: 1 / 1;
    }
    
    /* Ensure canvas containers don't overflow on mobile */
    .canvas-container {
        overflow-x: hidden;
        padding: 0.5rem;
    }
    
    /* Result card specific adjustments */
    #resultCard {
        overflow-x: hidden;
    }
    
    #canvasOutput2, #canvasOutput3 {
        /* Force square display on mobile */
        width: 100%;
        max-width: min(calc(100vw - 3rem), 500px);
        height: auto;
    }
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    font-family: inherit;
}

.btn-primary {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.btn-primary:hover:not(:disabled) {
    background-color: hsl(var(--primary) / 0.9);
}

.btn-secondary {
    background-color: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}

.btn-secondary:hover:not(:disabled) {
    background-color: hsl(var(--secondary) / 0.9);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-full {
    width: 100%;
    margin-top: 1.5rem;
}

.btn-group {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .btn-group {
        gap: 0.5rem;
    }
    
    .btn-group .btn {
        flex: 1 1 calc(50% - 0.25rem);
        min-width: 120px;
        padding: 0.65rem 1rem;
        font-size: 0.8rem;
    }
}

/* Text Area */
.pins-textarea {
    width: 100%;
    min-height: 150px;
    padding: 1rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    font-family: monospace;
    font-size: 0.875rem;
    resize: vertical;
    background-color: hsl(var(--secondary));
    /* Prevent horizontal overflow on mobile */
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .pins-textarea {
        font-size: 0.75rem;
        padding: 0.75rem;
        min-height: 120px;
    }
}

/* Info Text */
.info-text {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    margin: 1rem 0;
    line-height: 1.5;
}

/* How It Works Section */
.how-it-works {
    padding: 5rem 1rem;
    background-color: hsl(var(--card) / 0.3);
}

.how-it-works h3 {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 3rem;
}

.steps-grid {
    display: grid;
    gap: 2rem;
    max-width: 64rem;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .steps-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.step {
    text-align: center;
}

.step-icon {
    width: 4rem;
    height: 4rem;
    background-color: hsl(var(--primary) / 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.step h4 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.step p {
    color: hsl(var(--muted-foreground));
}

/* Gallery Section */
.gallery {
    padding: 5rem 1rem;
}

.gallery h3 {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 3rem;
}

.gallery-grid {
    display: grid;
    gap: 2rem;
}

@media (min-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.gallery-item {
    overflow: hidden;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    transition: box-shadow 0.2s;
}

.gallery-item:hover {
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}


/* Footer */
.footer {
    background-color: hsl(var(--card) / 0.5);
    border-top: 1px solid hsl(var(--border));
    padding: 3rem 1rem;
    margin-top: 5rem;
}

.footer-content {
    text-align: center;
    max-width: 64rem;
    margin: 0 auto;
}

.footer-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.footer-logo span {
    font-size: 1.25rem;
    font-weight: 700;
}

.footer p {
    color: hsl(var(--muted-foreground));
    max-width: 42rem;
    margin: 0 auto 1.5rem;
}

/* Animations */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Draw Status */
#drawStatus {
    font-size: 0.875rem;
    color: hsl(var(--primary));
    margin: 0.5rem 0;
}

/* Step Counter */
#incrementalCurrentStep {
    font-size: 1.125rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin: 1rem 0;
}

/* Demo Slideshow Styles */
.demo-card {
    text-align: center;
}

.demo-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: hsl(var(--foreground));
}

.demo-video-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto 1.5rem;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.demo-image {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
    background-color: #f8f9fa;
}

.demo-video {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
    background-color: #f8f9fa;
    border-radius: var(--radius);
}

.demo-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: white;
    padding: 1.5rem 1rem 1rem;
    margin: 0;
    font-weight: 500;
    font-size: 1.125rem;
}



/* Slide Animation */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Responsive Demo */
@media (max-width: 768px) {
    /* Mobile adjustments for main grid */
    .main-grid {
        margin-top: 1rem;
    }
    
    .demo-video-container {
        max-width: 100%;
        margin: 0 auto 1rem;
    }
    
    .demo-image,
    .demo-video {
        height: auto;
        max-height: 400px;
    }
    
    .demo-title {
        font-size: 1.5rem;
    }
    
    .demo-caption {
        font-size: 1rem;
        padding: 1rem 0.75rem 0.75rem;
    }
}

/* Content Sections */
.content-section {
    padding: 4rem 1rem;
}

.content-section.bg-muted {
    background-color: hsl(var(--muted) / 0.3);
}

.content-text {
    max-width: 100%;
    margin: 0 auto;
    line-height: 1.8;
    margin-top: 1rem;
}

.content-text p {
    margin-bottom: 1.5rem;
    font-size: 1.125rem;
    color: hsl(var(--foreground));
}

/* HowTo Styles */
.howto-grid {
    display: grid;
    gap: 2rem;
    margin: 2rem 0;
}

@media (min-width: 768px) {
    .howto-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.howto-materials,
.howto-safety {
    background-color: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 2rem;
}

.howto-materials h4,
.howto-safety h4 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: hsl(var(--foreground));
}

.materials-list,
.safety-list {
    list-style: none;
    padding: 0;
}

.materials-list li,
.safety-list li {
    margin-bottom: 0.75rem;
    padding-left: 1rem;
    position: relative;
}

.materials-list li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: hsl(var(--primary));
    font-weight: bold;
}

.safety-list li::before {
    content: "⚠";
    position: absolute;
    left: 0;
    color: hsl(var(--destructive));
}

.safety-box {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background-color: hsl(var(--destructive) / 0.1);
    border: 1px solid hsl(var(--destructive) / 0.2);
    border-radius: var(--radius);
    padding: 1rem;
}

/* Detailed Steps */
.steps-detailed {
    margin-top: 3rem;
}

.steps-detailed h4 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 2rem;
    text-align: center;
}

.step-detailed {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background-color: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    font-weight: 700;
    font-size: 1.25rem;
    border-radius: 50%;
    flex-shrink: 0;
}

.step-content h5 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: hsl(var(--foreground));
}

.step-content p {
    color: hsl(var(--muted-foreground));
    line-height: 1.6;
}

/* Difficulty Cards */
.difficulty-grid {
    display: grid;
    gap: 2rem;
    margin: 2rem 0;
}

@media (min-width: 768px) {
    .difficulty-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.difficulty-card {
    background-color: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 2px 4px 0 rgb(0 0 0 / 0.1);
}

.difficulty-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.difficulty-header.beginner {
    background-color: hsl(120, 60%, 95%);
    border-bottom: 2px solid hsl(120, 60%, 80%);
}

.difficulty-header.intermediate {
    background-color: hsl(45, 60%, 95%);
    border-bottom: 2px solid hsl(45, 60%, 80%);
}

.difficulty-header.advanced {
    background-color: hsl(0, 60%, 95%);
    border-bottom: 2px solid hsl(0, 60%, 80%);
}

.difficulty-header h4 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.difficulty-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    color: white;
}

.beginner .difficulty-badge {
    background-color: hsl(120, 60%, 50%);
}

.intermediate .difficulty-badge {
    background-color: hsl(45, 60%, 50%);
}

.advanced .difficulty-badge {
    background-color: hsl(0, 60%, 50%);
}

.difficulty-content {
    padding: 1.5rem;
}

.difficulty-content p {
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

.difficulty-content ul {
    list-style: none;
    padding: 0;
}

.difficulty-content li {
    margin-bottom: 0.5rem;
    padding-left: 1rem;
    position: relative;
    font-size: 0.875rem;
}

.difficulty-content li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: hsl(var(--primary));
    font-weight: bold;
}

/* Tips Section */
.tips-section {
    margin-top: 3rem;
    padding: 2rem;
    background-color: hsl(var(--secondary) / 0.5);
    border-radius: var(--radius);
}

.tips-section h4 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-align: center;
}

.tips-grid {
    display: grid;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .tips-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.tip {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.tip p {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Troubleshooting */
.troubleshoot-grid {
    display: grid;
    gap: 2rem;
    margin: 2rem 0;
}

@media (min-width: 768px) {
    .troubleshoot-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.troubleshoot-item {
    background-color: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 2rem;
}

.troubleshoot-item h4 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: hsl(var(--foreground));
}

.issue {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: hsl(var(--muted) / 0.5);
    border-left: 3px solid hsl(var(--primary));
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Credits & License */
.credits-grid {
    display: grid;
    gap: 2rem;
    margin: 2rem 0;
}

@media (min-width: 768px) {
    .credits-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.credits-section {
    background-color: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 2rem;
}

.credits-section h4 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: hsl(var(--foreground));
}

.credits-section p {
    margin-bottom: 1rem;
    font-size: 0.875rem;
    line-height: 1.6;
}

.credits-list,
.improvements-list {
    list-style: none;
    padding: 0;
}

.credits-list li,
.improvements-list li {
    margin-bottom: 0.75rem;
    padding-left: 1rem;
    position: relative;
    font-size: 0.875rem;
    line-height: 1.5;
}

.credits-list li::before,
.improvements-list li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: hsl(var(--primary));
    font-weight: bold;
}

.license-box {
    background-color: hsl(var(--secondary) / 0.5);
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1rem;
}

.license-box p {
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

/* Responsive Navigation */
@media (max-width: 768px) {
    .nav {
        display: none;
    }
    
    .content-section {
        padding: 2rem 1rem;
    }
    
    .howto-grid,
    .difficulty-grid,
    .troubleshoot-grid,
    .credits-grid {
        grid-template-columns: 1fr;
    }
    
    .step-detailed {
        flex-direction: column;
        text-align: center;
    }
    
    .tips-grid {
        grid-template-columns: 1fr;
    }
}