/* Beguile Giveaway Widget — Designed with intention */
/* Aesthetic: Refined editorial with subtle warmth and confident typography */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=DM+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

.gw-widget {
    /* Inherit from parent theme where possible, with strong fallbacks */
    --gw-bg: var(--bg-alt, var(--giveaway-bg, #faf9f7));
    --gw-text: var(--text, var(--giveaway-text, #1a1a1a));
    --gw-text-muted: var(--text-muted, var(--giveaway-text-muted, #6b6560));
    --gw-border: var(--border, var(--giveaway-border, #e8e4df));
    --gw-surface: var(--bg, var(--giveaway-surface, #f0eeeb));
    --gw-primary: var(--accent, var(--giveaway-primary, #c45d2c));
    --gw-primary-hover: color-mix(in srgb, var(--gw-primary) 85%, #000);
    --gw-primary-text: #ffffff;
    --gw-primary-glow: color-mix(in srgb, var(--gw-primary) 15%, transparent);
    --gw-accent: var(--primary, var(--giveaway-accent, #15803d));
    --gw-error: #c33;
    --gw-success: var(--primary, #15803d);
    --gw-radius: 16px;
    --gw-font-display: 'DM Serif Display', Georgia, serif;
    --gw-font-body: 'DM Sans', -apple-system, sans-serif;
    --gw-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 6px 24px rgba(0,0,0,0.08), 0 20px 60px rgba(0,0,0,0.06);

    container-type: inline-size;
    position: relative;
    background: var(--gw-bg);
    color: var(--gw-text);
    border-radius: var(--gw-radius);
    font-family: var(--gw-font-body);
    padding: 0;
    max-width: 580px;
    margin: 2.5rem auto;
    box-shadow: var(--gw-shadow);
    overflow: hidden;
    border: 1px solid var(--gw-border);
}

/* Decorative top accent bar */
.gw-widget::before {
    content: '';
    display: block;
    height: 4px;
    background: linear-gradient(90deg, var(--gw-primary), var(--gw-accent), var(--gw-primary));
    background-size: 200% 100%;
    animation: gw-gradient-shift 6s ease infinite;
}

@keyframes gw-gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Inner padding container (after accent bar) */
.gw-active, .gw-entered, .gw-scheduled, .gw-paused, .gw-ended, .gw-cancelled, .gw-error {
    padding: 2rem 2rem 1.5rem;
}

/* Dark mode — inherits from parent theme automatically via var(--bg), var(--text) etc.
   These overrides only handle shadow intensity and glow opacity for dark contexts. */
[data-theme="dark"] .gw-widget {
    --gw-shadow: 0 2px 6px rgba(0,0,0,0.4), 0 12px 32px rgba(0,0,0,0.5), 0 24px 64px rgba(0,0,0,0.25);
    --gw-primary-glow: color-mix(in srgb, var(--gw-primary) 12%, transparent);
}

@media (prefers-color-scheme: dark) {
    .gw-widget:not([data-theme="light"] .gw-widget) {
        --gw-shadow: 0 2px 6px rgba(0,0,0,0.4), 0 12px 32px rgba(0,0,0,0.5), 0 24px 64px rgba(0,0,0,0.25);
    }
}

/* === SKELETON === */
.gw-skeleton {
    min-height: 240px;
    padding: 2rem;
}
.gw-skeleton-bar {
    background: linear-gradient(90deg, var(--gw-surface) 25%, var(--gw-border) 50%, var(--gw-surface) 75%);
    background-size: 200% 100%;
    animation: gw-shimmer 1.8s ease-in-out infinite;
    border-radius: 8px;
    margin-bottom: 1rem;
}
.gw-skeleton-bar:nth-child(1) { height: 20px; width: 40%; }
.gw-skeleton-bar:nth-child(2) { height: 28px; width: 75%; margin-bottom: 1.5rem; }
.gw-skeleton-bar:nth-child(3) { height: 48px; width: 100%; border-radius: 12px; }

@keyframes gw-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* === BADGE === */
.gw-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--gw-font-body);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gw-primary);
    background: var(--gw-primary-glow);
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    margin-bottom: 0.75rem;
    border: 1px solid color-mix(in srgb, var(--gw-primary) 20%, transparent);
}
.gw-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gw-primary);
    animation: gw-pulse 2s ease-in-out infinite;
}
@keyframes gw-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}
.gw-badge-success {
    color: var(--gw-success);
    background: rgba(21, 128, 61, 0.1);
    border-color: rgba(21, 128, 61, 0.2);
}
.gw-badge-success::before { background: var(--gw-success); }

/* === IMAGE === */
.gw-image {
    width: calc(100% + 4rem);
    margin-left: -2rem;
    margin-right: -2rem;
    max-height: 220px;
    object-fit: cover;
    margin-bottom: 1.5rem;
}
.gw-image-muted { filter: grayscale(50%) opacity(0.6); }

/* === TYPOGRAPHY === */
.gw-title {
    font-family: var(--gw-font-display);
    font-size: 1.65rem;
    font-weight: 400;
    line-height: 1.2;
    margin: 0 0 0.6rem 0;
    letter-spacing: -0.01em;
    color: var(--gw-text); /* Explicit — never inherit from parent that might be muted */
}
.gw-description {
    font-size: 0.92rem;
    color: var(--gw-text-muted);
    line-height: 1.6;
    margin: 0 0 1.25rem 0;
}

/* === META (countdown + entries) — always inline === */
.gw-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: nowrap;
}

/* Countdown — bold, standalone presence */
.gw-countdown {
    font-family: var(--gw-font-body);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--gw-primary);
    background: var(--gw-primary-glow);
    border: 1px solid color-mix(in srgb, var(--gw-primary) 25%, transparent);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0;
}
.gw-countdown::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gw-primary);
    flex-shrink: 0;
    animation: gw-pulse 2s ease-in-out infinite;
}

/* === SECTION LABEL === */
.gw-section-label {
    font-family: var(--gw-font-body);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--gw-text-muted);
    margin: 1.5rem 0 0.75rem 0;
    padding-bottom: 0;
    border-bottom: none;
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.gw-section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gw-border);
}

/* === FORM FIELDS === */
.gw-field { margin-bottom: 0.65rem; }
.gw-input {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: var(--gw-font-body);
    font-size: 0.9rem;
    border: 1.5px solid var(--gw-border);
    border-radius: 10px;
    background: var(--gw-bg);
    color: var(--gw-text);
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.gw-input::placeholder {
    color: color-mix(in srgb, var(--gw-text-muted) 60%, transparent);
}
.gw-input:focus {
    outline: none;
    border-color: var(--gw-primary);
    box-shadow: 0 0 0 4px var(--gw-primary-glow);
}
.gw-input-error {
    color: var(--gw-error);
    font-size: 0.78rem;
    margin-top: 0.3rem;
    min-height: 1.1em;
    font-weight: 500;
}

/* === BONUS ENTRY METHODS === */
.gw-methods { margin-bottom: 1rem; }
.gw-method {
    display: flex;
    align-items: center;
    padding: 0.7rem 0.85rem;
    border: 1.5px solid var(--gw-border);
    border-radius: 10px;
    margin-bottom: 0.45rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 48px;
    gap: 0.6rem;
    background: transparent;
}
.gw-method:hover {
    border-color: color-mix(in srgb, var(--gw-primary) 50%, var(--gw-border));
    background: var(--gw-primary-glow);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.gw-method-selected {
    border-color: var(--gw-success);
    background: rgba(21, 128, 61, 0.06);
}
.gw-method-check {
    width: 22px;
    height: 22px;
    border: 2px solid var(--gw-border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.75rem;
    transition: all 0.2s;
}
.gw-method-selected .gw-method-check {
    border-color: var(--gw-success);
    background: var(--gw-success);
    color: #fff;
}
.gw-method-selected .gw-method-check::after { content: '\2713'; }
.gw-method-label {
    flex: 1;
    font-size: 0.88rem;
    font-weight: 500;
}
.gw-method-badge {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--gw-primary);
    background: var(--gw-primary-glow);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

/* === CONSENT === */
.gw-consent {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    font-size: 0.8rem;
    color: var(--gw-text-muted);
    margin-bottom: 1.25rem;
    cursor: pointer;
    line-height: 1.4;
}
.gw-consent input[type="checkbox"] {
    margin-top: 0.1rem;
    min-width: 18px;
    min-height: 18px;
    accent-color: var(--gw-primary);
}

/* === SUBMIT BUTTON === */
.gw-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.85rem 1.5rem;
    font-family: var(--gw-font-body);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--gw-primary-text);
    background: var(--gw-primary);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    min-height: 52px;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}
.gw-submit::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.1) 50%, transparent 60%);
    background-size: 250% 250%;
    animation: gw-btn-sheen 4s ease-in-out infinite;
}
@keyframes gw-btn-sheen {
    0%, 100% { background-position: 200% 200%; }
    50% { background-position: -50% -50%; }
}
.gw-submit:hover {
    background: var(--gw-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--gw-primary-glow), 0 2px 6px rgba(0,0,0,0.1);
}
.gw-submit:active { transform: translateY(0); }
.gw-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.gw-submit:disabled::after { animation: none; }
.gw-submit:focus-visible {
    outline: 2px solid var(--gw-primary);
    outline-offset: 3px;
}

/* === FOOTER / LEGAL === */
.gw-footer {
    margin-top: 1.25rem;
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid var(--gw-border);
}
.gw-legal {
    display: block;
    font-size: 0.65rem;
    color: var(--gw-text-muted);
    margin-bottom: 0.2rem;
    letter-spacing: 0.02em;
    opacity: 0.7;
}
.gw-rules-link {
    background: none;
    border: none;
    color: var(--gw-primary);
    font-family: var(--gw-font-body);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    padding: 8px 0;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    transition: opacity 0.15s;
}
.gw-rules-link:hover { opacity: 0.7; }

/* === PROGRESS BAR === */
.gw-progress {
    margin: 1.25rem 0;
    background: var(--gw-surface);
    border-radius: 999px;
    overflow: hidden;
    height: 8px;
}
.gw-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--gw-accent), var(--gw-primary));
    border-radius: 999px;
    transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.gw-progress-text {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--gw-text-muted);
    margin-top: 0.4rem;
    display: block;
}

/* === REFERRAL SECTION === */
.gw-referral { margin-top: 1.25rem; }
.gw-referral-row {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}
.gw-referral-input {
    flex: 1;
    padding: 0.6rem 0.85rem;
    font-family: var(--gw-font-body);
    font-size: 0.82rem;
    border: 1.5px solid var(--gw-border);
    border-radius: 10px;
    background: var(--gw-surface);
    color: var(--gw-text);
    box-sizing: border-box;
}
.gw-referral-copy {
    padding: 0.6rem 1rem;
    font-family: var(--gw-font-body);
    font-size: 0.82rem;
    font-weight: 700;
    background: var(--gw-primary);
    color: var(--gw-primary-text);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    transition: all 0.15s;
}
.gw-referral-copy:hover { background: var(--gw-primary-hover); }
.gw-referral-count {
    font-size: 0.82rem;
    color: var(--gw-text-muted);
    text-align: center;
    margin-top: 0.5rem;
    font-weight: 500;
}

/* === SOCIAL SHARE === */
.gw-share {
    display: flex;
    gap: 0.45rem;
    justify-content: center;
    margin: 0.75rem 0;
}
.gw-share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    text-decoration: none;
    color: #fff;
    transition: all 0.2s;
}
.gw-share-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.gw-share-twitter { background: #0f1419; }
.gw-share-facebook { background: #1877F2; }
.gw-share-linkedin { background: #0A66C2; }
.gw-share-email { background: var(--gw-text-muted); }

/* === WINNER === */
.gw-winner-name {
    font-family: var(--gw-font-display);
    font-size: 1.3rem;
    color: var(--gw-primary);
    text-align: center;
    margin: 0.75rem 0;
}

/* === ENTRY COUNT === */
.gw-entry-count {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--gw-text-muted);
    background: var(--gw-surface);
    padding: 0.4rem 0.85rem;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.gw-entry-count::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--gw-accent);
}
.gw-entry-count-zero { display: none; }

/* === NOTE === */
.gw-note {
    font-size: 0.82rem;
    color: var(--gw-text-muted);
    font-style: italic;
}

/* === RULES MODAL === */
.gw-rules-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1.5rem;
    animation: gw-fade-in 0.2s ease;
}
@keyframes gw-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
.gw-rules-content {
    background: var(--gw-bg);
    color: var(--gw-text);
    border-radius: var(--gw-radius);
    padding: 2.5rem;
    max-width: 560px;
    max-height: 80vh;
    overflow-y: auto;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    font-family: var(--gw-font-body);
    line-height: 1.6;
}
.gw-rules-close {
    margin-top: 1.5rem;
    padding: 0.65rem 1.5rem;
    font-family: var(--gw-font-body);
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--gw-surface);
    border: 1.5px solid var(--gw-border);
    border-radius: 10px;
    cursor: pointer;
    color: var(--gw-text);
    min-height: 44px;
    transition: all 0.15s;
}
.gw-rules-close:hover { background: var(--gw-border); }

/* === ERROR STATE === */
.gw-error { text-align: center; padding: 3rem 2rem; }

/* === SCREEN READER ONLY === */
.gw-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
    .gw-widget::before { animation: none; }
    .gw-skeleton-bar { animation: none; }
    .gw-badge::before { animation: none; }
    .gw-submit::after { animation: none; }
    .gw-progress-bar { transition: none; }
    .gw-method { transition: none; }
    .gw-input { transition: none; }
    .gw-submit { transition: none; }
    .gw-share-btn { transition: none; }
    .gw-rules-modal { animation: none; }
}

/* === RESPONSIVE === */
@container (max-width: 400px) {
    .gw-active, .gw-entered, .gw-scheduled, .gw-paused, .gw-ended, .gw-cancelled, .gw-error {
        padding: 1.5rem 1.25rem 1.25rem;
    }
    .gw-title { font-size: 1.35rem; }
    .gw-image { width: calc(100% + 2.5rem); margin-left: -1.25rem; margin-right: -1.25rem; }
    .gw-share { flex-wrap: wrap; }
}
@container (min-width: 480px) {
    .gw-title { font-size: 1.75rem; }
}
