/* ═══════════════════════════════════════════════════════════
   TimePaints Card Generator — app.css
   Arabic-first RTL SPA
═══════════════════════════════════════════════════════════ */

/* ─── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --brand-deep:    #001845;
    --brand-primary: #002869;
    --brand-mid:     #263997;
    --brand-light:   #4a6fd4;

    --text-primary:   #1a1e35;
    --text-secondary: #4a506b;
    --text-muted:     #8890a8;

    --bg-page:   #f7f9fd;
    --bg-card:   #ffffff;

    --border-base:  #dde3f0;
    --border-input: #bdc8e8;
    --border-focus: #263997;

    --shadow-card: 0 4px 24px rgba(38, 57, 151, 0.13),
                   0 1px 4px  rgba(0, 40, 105, 0.08);
    --shadow-btn:  0 4px 18px rgba(0, 40, 105, 0.30);
    --shadow-btn-hover: 0 6px 24px rgba(0, 40, 105, 0.42);

    --radius-input: 32px;
    --radius-btn:   32px;
    --radius-card:  16px;

    --color-bar-h: 20px;

    --font: 'Cairo', 'Tajawal', tahoma, sans-serif;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg-page);
    color: var(--text-primary);
    min-height: 100dvh;

    /* Subtle geometric tint in background */
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(38, 57, 151, 0.06) 0%, transparent 70%);
    background-attachment: fixed;
}


/* ─── App shell ─────────────────────────────────────────── */
.app {
    min-height: 100dvh;
}


/* ─── Views ─────────────────────────────────────────────── */
.view {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    position: relative;
    padding-bottom: calc(var(--color-bar-h) + 8px);
}

[hidden] { display: none !important; }


/* ─── Site Header ───────────────────────────────────────── */
.site-header {
    border-top: 6px solid var(--brand-primary);
    text-align: center;
    padding: 36px 20px 16px;
    background: #ffffff;
    box-shadow: 0 1px 0 var(--border-base);
    position: relative;
}

.site-logo {
    width: 100%;
    max-width: 300px;
    height: auto;
    display: inline-block;
}

/* Lang toggle inside site-header (form view) */
.site-header .lang-toggle {
    position: absolute;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
}


/* ─── Form view content ─────────────────────────────────── */
.form-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 24px 60px;
    max-width: 820px;
    margin: 0 auto;
    width: 100%;
}

.greeting-text {
    font-size: 1.15rem;
    font-weight: 400;
    line-height: 2;
    color: var(--text-secondary);
    max-width: 680px;
    margin-bottom: 28px;
    font-family: 'Tajawal', var(--font);
}

.form-headline {
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1.7;
    color: var(--brand-primary);
    margin-bottom: 36px;
    max-width: 580px;
}

.occasion-highlight {
    color: var(--brand-mid);
    display: inline;
}


/* ─── Input ─────────────────────────────────────────────── */
.field-wrap {
    width: 100%;
    max-width: 520px;
    margin-bottom: 28px;
}

.name-input {
    width: 100%;
    height: 68px;
    font-size: 1.2rem;
    font-family: var(--font);
    font-weight: 500;
    text-align: center;
    padding: 0 24px;

    background: var(--bg-card);
    border: 2px solid var(--border-input);
    border-radius: var(--radius-input);
    color: var(--text-primary);
    outline: none;

    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.name-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.name-input:hover {
    border-color: var(--brand-light);
}

.name-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 4px rgba(38, 57, 151, 0.12);
}

.name-input.is-error {
    border-color: #d64040;
    box-shadow: 0 0 0 4px rgba(214, 64, 64, 0.10);
}

.error-msg {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #c23333;
    font-weight: 500;
    animation: errorPop 0.2s ease;
}

@keyframes errorPop {
    0%   { opacity: 0; transform: translateY(-4px); }
    100% { opacity: 1; transform: translateY(0); }
}


/* ─── Buttons ───────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 60px;
    padding: 0 36px;
    width: 100%;
    max-width: 360px;
    font-family: var(--font);
    font-size: 1.05rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-btn);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: 0.01em;
}

.btn-icon,
.btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    pointer-events: none;
}

.btn--primary {
    background: var(--brand-primary);
    color: #ffffff;
    /*box-shadow: var(--shadow-btn);*/
}

.btn--primary:hover,
.btn--primary:focus-visible {
    background: var(--brand-deep);
    box-shadow: var(--shadow-btn-hover);
    transform: translateY(-1px);
}

.btn--primary:active {
    transform: translateY(0);
    box-shadow: var(--shadow-btn);
}

.btn--secondary {
    background: transparent;
    color: var(--brand-primary);
    border: 2px solid var(--brand-mid);
    box-shadow: none;
}

.btn--secondary:hover,
.btn--secondary:focus-visible {
    background: rgba(38, 57, 151, 0.06);
    border-color: var(--brand-primary);
}


/* ─── Top bar (back + lang toggle) ──────────────────────── */
.view-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 8px;
    max-width: 820px;
    margin: 0 auto;
    width: 100%;
}

/* ─── Back button ───────────────────────────────────────── */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 18px 8px 14px;
    font-family: var(--font);
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--brand-primary);
    background: transparent;
    border: 1.5px solid var(--border-input);
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn-back svg {
    width: 18px;
    height: 18px;
}

/* RTL: flip arrow to point right → (back = right in Arabic UI) */
html[dir="rtl"] .btn-back svg {
    transform: scaleX(-1);
}

.btn-back:hover,
.btn-back:focus-visible {
    background: rgba(38, 57, 151, 0.06);
    border-color: var(--brand-mid);
}

/* ─── Language toggle button ─────────────────────────────── */
.lang-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    height: 34px;
    padding: 0 14px;
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--brand-mid);
    background: transparent;
    border: 1.5px solid var(--border-input);
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.lang-toggle:hover,
.lang-toggle:focus-visible {
    background: rgba(38, 57, 151, 0.06);
    border-color: var(--brand-mid);
    color: var(--brand-primary);
}

/* ─── LTR layout overrides ───────────────────────────────── */
html[dir="ltr"] .color-bar {
    flex-direction: row;
}

html[dir="ltr"] .site-header .lang-toggle {
    left: auto;
    right: 20px;
}


/* ─── Card area ─────────────────────────────────────────── */
.card-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 24px 60px;
    max-width: 820px;
    margin: 0 auto;
    width: 100%;
}


/* ─── Skeleton ──────────────────────────────────────────── */
.skeleton-card {
    width: 85%;
    max-width: 500px;
    aspect-ratio: 4 / 5;
    border-radius: var(--radius-card);
    overflow: hidden;
    background: #e8edf5;
    position: relative;
}

.skeleton-shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        rgba(232, 237, 245, 0)   0%,
        rgba(200, 214, 240, 0.9) 50%,
        rgba(232, 237, 245, 0)   100%
    );
    background-size: 600px 100%;
    animation: shimmer 1.6s ease-in-out infinite;
}

@keyframes shimmer {
    0%   { background-position: -600px 0; }
    100% { background-position:  600px 0; }
}

.skeleton-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    margin-top: 28px;
    width: 85%;
    max-width: 500px;
}

.skeleton-btn {
    height: 56px;
    width: 100%;
    max-width: 360px;
    border-radius: 32px;
    background: #e4e9f4;
    position: relative;
    overflow: hidden;
}

.skeleton-btn--sm {
    max-width: 280px;
    height: 52px;
    opacity: 0.7;
}

.skeleton-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent      0%,
        rgba(200, 214, 240, 0.8) 50%,
        transparent      100%
    );
    background-size: 600px 100%;
    animation: shimmer 1.6s ease-in-out infinite;
    animation-delay: 0.1s;
}


/* ─── Card image ────────────────────────────────────────── */
.card-image {
    display: block;
    width: 85%;
    max-width: 650px;
    max-height: 600px;
    height: auto;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    animation: cardReveal 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes cardReveal {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}


/* ─── Result action buttons ─────────────────────────────── */
.result-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    margin-top: 28px;
    width: 85%;
    max-width: 500px;
}

.result-actions .btn {
    animation: btnReveal 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.result-actions .btn:nth-child(1) { animation-delay: 0.15s; }
.result-actions .btn:nth-child(2) { animation-delay: 0.25s; }

@keyframes btnReveal {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}


/* ─── Color brand bar ───────────────────────────────────── */
.color-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--color-bar-h);
    display: flex;
    flex-direction: row-reverse;
}

.color-bar span {
    flex: 1;
    display: block;
}


/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 480px) {
    .site-header {
        padding: 24px 16px 16px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    /* Remove absolute positioning — toggle flows below logo */
    .site-header .lang-toggle,
    html[dir="ltr"] .site-header .lang-toggle {
        position: static;
        transform: none;
        left: auto;
        right: auto;
    }

    .site-logo {
        max-width: 240px;
    }

    .form-content {
        padding: 28px 16px 56px;
    }

    .greeting-text {
        font-size: 1rem;
        line-height: 1.9;
    }

    .form-headline {
        font-size: 1.2rem;
    }

    .name-input {
        height: 60px;
        font-size: 1.05rem;
    }

    .btn {
        height: 56px;
        font-size: 1rem;
    }

    .card-image,
    .skeleton-card {
        width: 94%;
    }

    .result-actions,
    .skeleton-actions {
        width: 94%;
    }
}
