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

:root {
    --primary: #7B1F3A;
    --primary-light: #A0344F;
    --primary-dark: #5A1629;
    --gold: #C9A84C;
    --gold-light: #E8D48B;
    --gold-dark: #A88B3D;
    --cream: #FFF8F0;
    --warm-white: #FFFDF9;
    --text: #3D2222;
    --text-light: #6B4F4F;
    --green: #1B6B4A;
    --green-light: #2D8F65;
    --shadow: rgba(123, 31, 58, 0.12);
    --radius: 16px;
    --radius-sm: 10px;
}

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--cream);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.7;
}

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

/* ===== Header ===== */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 50%, #3D0F1E 100%);
    color: white;
    padding: 50px 0 60px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M30 30l15-15v30L30 30zM30 30L15 15v30l15-15z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

.header::after {
    content: '✦ ✦ ✦ ✦ ✦';
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    letter-spacing: 16px;
    color: var(--gold);
    opacity: 0.6;
}

.header-content {
    position: relative;
    z-index: 1;
}

.logo {
    width: 180px;
    height: auto;
    margin-bottom: 24px;
    filter: brightness(0) invert(1);
    transition: transform 0.3s ease;
}

.logo:hover {
    transform: scale(1.05);
}

.site-title {
    font-size: 2.4rem;
    font-weight: 800;
    margin-bottom: 10px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.site-subtitle {
    font-size: 1.15rem;
    font-weight: 300;
    opacity: 0.85;
    letter-spacing: 1px;
}

/* Decorative lanterns */
.header-decoration {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.lantern {
    position: absolute;
    width: 30px;
    height: 50px;
    border: 2px solid var(--gold);
    border-radius: 0 0 50% 50%;
    opacity: 0.15;
}

.lantern::before {
    content: '';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 15px;
    background: var(--gold);
}

.lantern::after {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 8px;
    border: 2px solid var(--gold);
    border-radius: 4px 4px 0 0;
}

.lantern-1 { top: 10px; right: 10%; animation: sway 4s ease-in-out infinite; }
.lantern-2 { top: 5px; right: 25%; animation: sway 5s ease-in-out infinite 1s; }
.lantern-3 { top: 15px; left: 15%; animation: sway 4.5s ease-in-out infinite 0.5s; }

@keyframes sway {
    0%, 100% { transform: rotate(-3deg); }
    50% { transform: rotate(3deg); }
}

/* ===== Name Section (Top of Page) ===== */
.name-section {
    padding: 30px 0 10px;
}

.name-box {
    background: white;
    border-radius: var(--radius);
    padding: 20px 28px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: 0 4px 20px var(--shadow);
    border: 2px solid var(--gold-light);
    max-width: 600px;
    margin: 0 auto;
}

.name-box-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.name-box-content {
    flex: 1;
}

.name-box-content label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 8px;
    line-height: 1.4;
}

.name-box-content input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #eee;
    border-radius: var(--radius-sm);
    font-family: 'Tajawal', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    transition: border-color 0.2s ease;
    direction: rtl;
    text-align: right;
}

.name-box-content input:focus {
    outline: none;
    border-color: var(--gold);
}

.name-box-content input::placeholder {
    font-weight: 400;
    color: #bbb;
}

/* ===== Main Content ===== */
.main {
    padding: 30px 0 80px;
}

/* ===== Cards Grid ===== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.card-item {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 4px 20px var(--shadow);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    aspect-ratio: 1;
}

.card-item:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 40px rgba(123, 31, 58, 0.2);
}

.card-item canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.card-item .card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: linear-gradient(transparent, rgba(61, 15, 30, 0.85));
    color: white;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.card-item:hover .card-overlay {
    opacity: 1;
}

.card-overlay span {
    font-size: 0.95rem;
    font-weight: 500;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(4px);
    padding: 8px 20px;
    border-radius: 30px;
    border: 1px solid rgba(255,255,255,0.2);
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(61, 15, 30, 0.7);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    position: relative;
    background: white;
    border-radius: var(--radius);
    max-width: 580px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-close {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(0, 0, 0, 0.06);
    color: var(--text);
    font-size: 1.4rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 2;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.12);
}

.modal-body canvas {
    width: 100%;
    display: block;
    border-radius: var(--radius) var(--radius) 0 0;
}

.modal-actions {
    padding: 20px 24px;
}

.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    flex: 1;
    min-width: 120px;
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-download {
    background: var(--primary);
    color: white;
}

.btn-download:hover {
    background: var(--primary-light);
}

.btn-copy {
    background: var(--gold);
    color: var(--primary-dark);
}

.btn-copy:hover {
    background: var(--gold-light);
}

.btn-share {
    background: var(--green);
    color: white;
}

.btn-share:hover {
    background: var(--green-light);
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--green);
    color: white;
    padding: 12px 28px;
    border-radius: 30px;
    font-family: 'Tajawal', sans-serif;
    font-weight: 500;
    font-size: 0.95rem;
    z-index: 2000;
    transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.toast.show {
    bottom: 30px;
}

/* ===== Footer ===== */
.footer {
    background: var(--primary-dark);
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    padding: 40px 0 30px;
}

.footer-logo {
    width: 80px;
    filter: brightness(0) invert(1);
    margin-bottom: 12px;
    opacity: 0.5;
}

.footer p {
    font-size: 1rem;
    margin-bottom: 8px;
}

.footer-link {
    margin-bottom: 8px;
}

.footer-link a {
    color: var(--gold-light);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.footer-link a:hover {
    color: var(--gold);
    text-decoration: underline;
}

.copyright {
    font-size: 0.85rem;
    opacity: 0.6;
    margin-top: 12px;
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .site-title {
        font-size: 1.7rem;
    }

    .site-subtitle {
        font-size: 1rem;
    }

    .logo {
        width: 130px;
    }

    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 16px;
    }

    .header {
        padding: 35px 0 45px;
    }

    .name-box {
        padding: 16px 20px;
        gap: 14px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .site-title {
        font-size: 1.4rem;
    }

    .modal-content {
        max-width: 100%;
        margin: 10px;
    }

    .modal-actions {
        padding: 16px;
    }

    .name-box {
        flex-direction: column;
        text-align: center;
    }
}
