/* Bingo Card Editor - Styles */

/* Download Counter */
.download-counter {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(229, 208, 215, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(229, 208, 215, 0.2);
    border-radius: 0.5rem;
    color: #d4b8c4;
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 100;
}

.download-counter svg {
    opacity: 0.7;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
}

html {
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    background-color: #4f3947;
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #563847 0%, #4a3040 50%, #3d2635 100%);
    background-attachment: fixed;
    min-height: 100%;
    color: #f5e6eb;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Layout Utilities */
.container {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

.max-w-4xl {
    max-width: 56rem;
}

.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.p-4 { padding: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }

/* Flexbox */
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-4 { gap: 1rem; }
.justify-center { justify-content: center; }

/* Typography */
.text-center { text-align: center; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-4xl { font-size: 2.25rem; line-height: 2.5rem; }
.text-5xl { font-size: 3rem; line-height: 1; }
.font-extrabold { font-weight: 800; }

/* Colors */
.text-white { color: #f5e6eb; }
.text-gray-400 { color: #d4b8c4; }
.text-gray-500 { color: #a8899a; }

/* Gradients */
.bg-gradient-to-r {
    background-image: linear-gradient(to right, var(--tw-gradient-stops));
}

.from-white { --tw-gradient-from: #f5e6eb; --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); }
.via-gray-200 { --tw-gradient-stops: var(--tw-gradient-from), #e8d4dc, var(--tw-gradient-to); }
.to-gray-400 { --tw-gradient-to: #d4b8c4; }

.bg-clip-text {
    -webkit-background-clip: text;
    background-clip: text;
}

.text-transparent { color: transparent; }

/* Borders & Rounded */
.rounded-2xl { border-radius: 1rem; }
.overflow-hidden { overflow: hidden; }

/* Shadows */
.shadow-2xl {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* Glass effect */
.glass {
    background: rgba(229, 208, 215, 0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(229, 208, 215, 0.15);
}

/* Bingo Card */
.bingo-wrapper {
    max-width: 600px;
    margin: 0 auto;
}

.bingo-card {
    position: relative;
    width: 100%;
    aspect-ratio: 1024 / 1280;
    border-radius: 0.5rem;
    overflow: hidden;
}

.bingo-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bingo-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    /* CSS percentage padding is relative to WIDTH, not height! */
    /* So vertical padding must be expressed as % of width */
    padding-top: 29.10%;    /* 298px / 1024px width */
    padding-bottom: 20.90%; /* 214px / 1024px width */
    padding-left: 14.06%;   /* 144px / 1024px width */
    padding-right: 15.62%;  /* 160px / 1024px width */
    /* Gap between rows */
    row-gap: 0.59%;
}

.bingo-row {
    display: flex;
    /* Gap between columns */
    column-gap: 0.54%;
    /* Prevent row from growing beyond flex allocation */
    flex-shrink: 0;
    min-height: 0;
    overflow: hidden;
}

/* Row heights - actual beige cell heights */
.bingo-row:nth-child(1) { flex: 145; }
.bingo-row:nth-child(2) { flex: 154; }
.bingo-row:nth-child(3) { flex: 147; }
.bingo-row:nth-child(4) { flex: 161; }
.bingo-row:nth-child(5) { flex: 137; }

.bingo-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2px;
    font-size: 12px;
    font-weight: 600;
    color: #1a1a2e;
    background: rgba(255, 255, 255, 0.0);
    border-radius: 0;
    cursor: text;
    outline: none;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    word-break: break-all;
    hyphens: auto;
    line-height: 1.1;
    transition: background-color 0.2s, box-shadow 0.2s;
    margin: 0;
    /* Force fixed size and clip overflow */
    overflow: hidden;
    min-width: 0;
    min-height: 0;
    flex-shrink: 0;
}

/* Column widths - actual beige cell widths */
.bingo-cell:nth-child(1) { flex: 141; }
.bingo-cell:nth-child(2) { flex: 142; }
.bingo-cell:nth-child(3) { flex: 140; }
.bingo-cell:nth-child(4) { flex: 139; }
.bingo-cell:nth-child(5) { flex: 136; }

.bingo-cell:hover {
    background: rgba(255, 255, 255, 0.15);
}

.bingo-cell:focus {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
}

/* Placeholder text */
.bingo-cell:empty::before {
    content: attr(data-placeholder);
    color: rgba(86, 55, 71, 0.5);
    font-weight: 400;
    font-size: 24px;
}

.bingo-cell.hide-placeholder:empty::before {
    content: '';
}

/* Free space styling */
.bingo-cell.free-space {
    font-weight: 700;
    color: #e94560;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #8b5a6b 0%, #a97485 100%);
    color: #f5e6eb;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(139, 90, 107, 0.5);
}

.btn-secondary {
    background: rgba(229, 208, 215, 0.1);
    color: #f5e6eb;
    border: 1px solid rgba(229, 208, 215, 0.25);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(229, 208, 215, 0.2);
}

/* Controls */
.controls {
    border-top: 1px solid rgba(229, 208, 215, 0.15);
    padding-top: 1.5rem;
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .py-8 { padding-top: 1rem; padding-bottom: 1rem; }
    .mb-8 { margin-bottom: 1.5rem; }
    
    .text-4xl { font-size: 1.75rem; line-height: 2.25rem; }
    
    .bingo-cell {
        font-size: 10px;
        padding: 2px;
    }
    
    .bingo-cell:empty::before {
        font-size: 8px;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .controls .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (min-width: 481px) and (max-width: 767px) {
    .text-4xl { font-size: 2rem; line-height: 2.25rem; }
    
    .bingo-cell {
        font-size: 12px;
    }
}

@media (min-width: 768px) {
    .md\:text-5xl { font-size: 3rem; line-height: 1; }
    .md\:p-6 { padding: 1.5rem; }
    
    .bingo-cell {
        font-size: 16px;
    }
}

/* Safe area insets for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Print styles - hide controls when printing */
@media print {
    .controls {
        display: none !important;
    }
    
    header, footer {
        display: none !important;
    }
    
    .bingo-wrapper {
        box-shadow: none;
        border: none;
    }
}
