/* Custom Font Declarations */
/* Clash Display Font - Using @font-face for better Cloudflare Pages compatibility */
@font-face {
    font-family: 'Clash';
    src: url('/assets/fonts/clash/ClashDisplay-Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Clash';
    src: url('/assets/fonts/clash/ClashDisplay-Semibold.otf') format('opentype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Clash';
    src: url('/assets/fonts/clash/ClashDisplay-Bold.otf') format('opentype');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

/* Fallback paths for different hosting scenarios */
@font-face {
    font-family: 'Clash';
    src: url('assets/fonts/clash/ClashDisplay-Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Clash';
    src: url('assets/fonts/clash/ClashDisplay-Semibold.otf') format('opentype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Clash';
    src: url('assets/fonts/clash/ClashDisplay-Bold.otf') format('opentype');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

/* Karla Font - Using local variable fonts for better Cloudflare Pages compatibility */
@font-face {
    font-family: 'Karla';
    src: url('/assets/fonts/karla/Karla-VariableFont_wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Karla';
    src: url('/assets/fonts/karla/Karla-Italic-VariableFont_wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: italic;
    font-display: swap;
}

/* Fallback paths for different hosting scenarios */
@font-face {
    font-family: 'Karla';
    src: url('assets/fonts/karla/Karla-VariableFont_wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Karla';
    src: url('assets/fonts/karla/Karla-Italic-VariableFont_wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: italic;
    font-display: swap;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #1a1a1a;
    color: #e0e0e0;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

h1 {
    color: #fff;
    margin-bottom: 30px;
    text-align: center;
}

h2 {
    color: #fff;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.form-section {
    background: #2a2a2a;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 25px;
}

.form-group {
    margin-bottom: 20px;
}

.font-size-selector {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

.font-size-btn {
    background: #1a1a1a;
    border: 2px solid #444;
    color: #ccc;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Clash', sans-serif;
    font-weight: 600;
    transition: all 0.2s;
    min-width: 40px;
    text-align: center;
}

.font-size-btn:hover {
    border-color: #4a9eff;
    color: #fff;
    background: #2a2a2a;
}

.font-size-btn.active {
    background: #4a9eff;
    border-color: #4a9eff;
    color: #fff;
}

.font-size-btn[data-size="small"] {
    font-size: 14px;
}

.font-size-btn[data-size="medium"] {
    font-size: 18px;
}

.font-size-btn[data-size="large"] {
    font-size: 22px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.form-row .form-group {
    margin-bottom: 0;
}

.book-covers-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.book-covers-grid .form-group {
    margin-bottom: 0;
}

.file-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.file-input-wrapper input[type="file"] {
    flex: 1;
}

.remove-image-btn {
    padding: 6px 12px;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.remove-image-btn:hover {
    background-color: #c82333;
}

.remove-image-btn:active {
    background-color: #bd2130;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #ccc;
    font-weight: 500;
}

input[type="text"],
input[type="file"] {
    width: 100%;
    padding: 8px 10px;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 14px;
}

.series-name-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.series-name-row input[type="text"] {
    flex: 1;
}

input[type="file"] {
    cursor: pointer;
}

input[type="file"]::file-selector-button {
    background: #4a9eff;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 10px;
}

input[type="file"]::file-selector-button:hover {
    background: #3a8eef;
}


button {
    background: #4a9eff;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

button:hover {
    background: #3a8eef;
}

button:disabled {
    background: #555;
    cursor: not-allowed;
}

#generateBtn {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    margin-top: 20px;
}

.hidden {
    display: none;
}

.color-options {
    margin-top: 40px;
    background: #2a2a2a;
    padding: 30px;
    border-radius: 8px;
}

.color-options h2 {
    text-align: center;
    margin-bottom: 30px;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

@media (min-width: 1200px) {
    .preview-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.preview-option {
    background: #1a1a1a;
    border: 2px solid #444;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s;
}

.preview-option:hover {
    border-color: #4a9eff;
    transform: translateY(-2px);
}

.preview-option.selected {
    border-color: #4a9eff;
    border-width: 3px;
    background: #2a3a4a;
}

.preview-option h3 {
    text-align: center;
    margin-bottom: 10px;
    color: #fff;
}

#genMoreBtn {
    display: block;
    margin: 30px auto 0;
    width: auto;
    min-width: 250px;
}

.preview-canvas {
    width: 100%;
    height: auto;
    border-radius: 4px;
    display: block;
    margin: 0 auto;
}

.final-result {
    margin-top: 40px;
    background: #2a2a2a;
    padding: 30px;
    border-radius: 8px;
}

.final-result h2 {
    text-align: center;
    margin-bottom: 20px;
}

.result-container {
    text-align: center;
}

#finalCanvas {
    max-width: 100%;
    height: auto;
    margin-bottom: 20px;
    /* Improve font rendering crispness (affects canvas display, not rendering) */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.download-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

#downloadBtnHighRes,
#downloadBtnWeb {
    padding: 12px 30px;
    font-size: 16px;
}

.loading {
    text-align: center;
    padding: 40px;
    margin-top: 40px;
}

.spinner {
    border: 4px solid #444;
    border-top: 4px solid #4a9eff;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    color: #ccc;
    font-size: 18px;
}

@media (max-width: 768px) {
    .preview-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .book-covers-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .series-name-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .series-name-row .font-size-selector {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .book-covers-grid {
        grid-template-columns: 1fr;
    }
}
