/* --- Template Selection Screen --- */
.template-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f8fafc;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    transition: transform 0.5s ease, opacity 0.5s ease;
}

.template-screen.hidden {
    transform: translateY(-20px);
    opacity: 0;
    pointer-events: none;
}

.template-header {
    background: #fff;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.template-title h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--primary);
}

.template-title p {
    margin: 0.2rem 0 0 0;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.template-controls {
    display: flex;
    gap: 1rem;
}

/* Category Pills & Buttons */
/* Moved to style.css for global reuse */

.template-grid-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background: #f1f5f9;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* Card Style based on Gutenverse Demo */
.demo-wrapper {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    border: 1px solid transparent;
}

.demo-wrapper:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    border-color: var(--accent);
}

.demo-thumbnail-wrapper {
    height: 240px;
    /* Adjusted for card balance */
    overflow: hidden;
    position: relative;
    background: #e2e8f0;
}

.demo-thumbnail-wrapper img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 1.5s ease-in-out;
    /* Smooth scroll effect, faster */
}

/* Scroll Effect on Hover */
.demo-wrapper:hover .demo-thumbnail-wrapper img {
    /* JavaScript needs to verify image height, but pure CSS calc can work if aspect ratio is predictable */
    /* Using specific translate technique from analysis */
    transform: translateY(calc(-100% + 240px));
}

.demo-info {
    padding: 1rem;
    border-top: 1px solid #f1f5f9;
}

.demo-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary);
    margin: 0 0 0.2rem 0;
}

.demo-tags {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.demo-tag {
    font-size: 0.7rem;
    color: #64748b;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Preview Icon (Top Right) */
.demo-preview-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 10;
    color: var(--accent);
    text-decoration: none;
}

.demo-wrapper:hover .demo-preview-btn {
    opacity: 1;
}

.demo-preview-btn:hover {
    transform: scale(1.1);
    background: #fff;
}

/* Custom Card Special Style */
.demo-wrapper.custom-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 2px dashed #cbd5e1;
    color: #64748b;
    min-height: 300px;
}

.demo-wrapper.custom-card:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: #f8fafc;
}

.custom-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.large-input {
    font-size: 1rem;
    padding: 0.8rem;
}