/* 65Nation Senior Laughs — Card + Modal Design */

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

/* ── Base ── */
html {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: transparent;
    min-height: 100%;
    color: #2D2D2D;
    font-size: 17px;
    line-height: 1.7;
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Animations ── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* ── Utility ── */
.hidden {
    display: none !important;
}

/* ── Container ── */
.laughs-widget {
    width: 100%;
    max-width: 100%;
    padding: 24px 20px;
    animation: fadeIn 0.4s ease-out both;
}

/* ═══ Header ═══ */
.widget-header {
    margin-bottom: 28px;
    animation: fadeIn 0.4s ease-out;
}

.header-top {
    margin-bottom: 14px;
}

.header-logo {
    height: 36px;
    width: auto;
    display: block;
}

.header-accent-bar {
    width: 56px;
    height: 4px;
    background: #F59E0B;
    border-radius: 2px;
    margin-bottom: 14px;
}

.header-title-row h1 {
    font-family: Georgia, serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: #1A1A1A;
    line-height: 1.25;
    margin-bottom: 4px;
}

.header-subtitle {
    font-size: 0.9rem;
    color: #888;
    font-weight: 500;
}

/* ═══ Joke Card (clickable) ═══ */
.joke-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #E8E8E8;
    cursor: pointer;
    transition: box-shadow 0.25s ease, border-color 0.25s ease, transform 0.2s ease;
    margin-bottom: 24px;
    animation: fadeIn 0.5s ease-out 0.1s both;
}

.joke-card:hover {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
    border-color: #F59E0B;
    transform: translateY(-2px);
}

.joke-image-wrap {
    width: 100%;
    overflow: hidden;
}

.joke-card-image {
    width: 100%;
    height: auto;
    display: block;
}

.joke-card-body {
    padding: 20px 24px;
}

.joke-text {
    font-size: 1.1rem;
    line-height: 1.7;
    color: #1A1A1A;
    font-weight: 500;
    white-space: pre-line;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.joke-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #f0e6d0;
}

.joke-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.joke-badge.ai {
    background: #e0e7ff;
    color: #4338ca;
}

.joke-badge.original {
    background: #fef3c7;
    color: #92400e;
}

.joke-tap-hint {
    display: inline-block;
    margin-top: 10px;
    font-size: 0.8rem;
    color: #F59E0B;
    font-weight: 600;
}

/* ═══ Modal (for full joke view) ═══ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: modalFadeIn 0.25s ease-out;
    overflow-y: auto;
}

.modal-content {
    background: #fff;
    border-radius: 16px;
    max-width: 640px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    animation: modalSlideUp 0.3s ease-out;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.2s;
    line-height: 1;
}

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

.modal-content:not(:has(.modal-image-wrap)) .modal-close {
    background: rgba(0, 0, 0, 0.08);
    color: #333;
}

.modal-content:not(:has(.modal-image-wrap)) .modal-close:hover {
    background: rgba(0, 0, 0, 0.15);
}

.modal-image-wrap {
    width: 100%;
    border-radius: 16px 16px 0 0;
    overflow: hidden;
}

.modal-image {
    width: 100%;
    height: auto;
    display: block;
}

/* Scroll hint — sticky overlay at bottom of modal */
.modal-scroll-hint {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    text-align: center;
    padding: 16px 20px 18px;
    background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, rgba(0,0,0,0.35) 60%, transparent 100%);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    animation: bounceDown 1.5s ease-in-out infinite;
    transition: opacity 0.4s ease;
    pointer-events: none;
    border-radius: 0 0 16px 16px;
}

.scroll-icon {
    display: inline-block;
    font-size: 1.3rem;
    margin-right: 6px;
    vertical-align: middle;
}

@keyframes bounceDown {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(5px); }
}

.modal-body {
    padding: 28px 28px 32px;
}

.modal-joke-text {
    font-size: 1.15rem;
    line-height: 1.8;
    color: #1A1A1A;
    font-weight: 500;
    white-space: pre-line;
    margin-bottom: 16px;
}

.modal-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.modal-badge.ai {
    background: #e0e7ff;
    color: #4338ca;
}

.modal-badge.original {
    background: #fef3c7;
    color: #92400e;
}

/* Modal share buttons */
.modal-share {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #f0e6d0;
}

.modal-share-label {
    font-size: 0.8rem;
    color: #888;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
}

.modal-share-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.modal-share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    min-height: 40px;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.modal-share-btn:hover {
    opacity: 0.85;
}

.modal-share-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.modal-share-btn.fb { background: #1877f2; }
.modal-share-btn.tw { background: #0f1419; }
.modal-share-btn.em { background: #ea4335; }
.modal-share-btn.cp { background: #57534e; }

/* ═══ Share Section (below card) ═══ */
.share-section {
    margin-bottom: 24px;
    animation: fadeIn 0.5s ease-out 0.15s both;
}

.share-label {
    font-size: 0.8rem;
    color: #888;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
}

.share-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 10px;
    min-height: 44px;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.15s ease;
}

.share-btn:hover { opacity: 0.9; }
.share-btn:active { transform: scale(0.97); }
.share-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.share-facebook { background: #1877f2; }
.share-twitter  { background: #0f1419; }
.share-email    { background: #ea4335; }
.share-copy     { background: #57534e; }

/* ═══ History Toggle ═══ */
.history-toggle-wrapper {
    margin-bottom: 8px;
    animation: fadeIn 0.5s ease-out 0.2s both;
}

.history-toggle-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    min-height: 44px;
    background: #fff;
    border: 2px solid #F59E0B;
    border-radius: 10px;
    color: #92400e;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.history-toggle-btn:hover {
    background: #fffbeb;
}

.history-toggle-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ═══ History Panel ═══ */
.history-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.history-overlay:not(.hidden) {
    opacity: 1;
}

.history-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 420px;
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.history-panel:not(.hidden) {
    transform: translateX(0);
    pointer-events: auto;
}

.history-panel-inner {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: -4px 0 32px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 2px solid #fde68a;
    flex-shrink: 0;
}

.history-header h3 {
    font-family: Georgia, serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: #1A1A1A;
}

.history-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #f5f5f4;
    color: #57534e;
    cursor: pointer;
    transition: background 0.2s ease;
}

.history-close-btn:hover {
    background: #e7e5e4;
}

.history-close-btn svg {
    width: 20px;
    height: 20px;
}

/* History Controls */
.history-controls {
    padding: 16px 20px;
    background: #fefce8;
    border-bottom: 1px solid #fde68a;
    flex-shrink: 0;
}

.history-date-picker label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
}

.date-input-group {
    display: flex;
    gap: 0;
}

.date-input-group input[type="date"] {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #d6d3d1;
    border-right: none;
    border-radius: 8px 0 0 8px;
    font-family: inherit;
    font-size: 1rem;
    color: #292524;
    background: #fff;
    min-height: 44px;
}

.date-input-group input[type="date"]:focus {
    outline: none;
    border-color: #F59E0B;
}

.date-load-btn {
    padding: 10px 16px;
    min-height: 44px;
    border: none;
    border-radius: 0 8px 8px 0;
    background: #F59E0B;
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease;
}

.date-load-btn:hover {
    background: #d97706;
}

.history-nav {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.nav-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    min-height: 44px;
    border: 1px solid #d6d3d1;
    border-radius: 8px;
    background: #fff;
    color: #57534e;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.nav-btn:hover {
    background: #fefce8;
    border-color: #F59E0B;
    color: #92400e;
}

.nav-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* History Content */
.history-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

.history-placeholder {
    text-align: center;
    color: #999;
    font-size: 0.95rem;
    padding: 40px 20px;
}

.history-joke-item {
    padding: 16px 18px;
    border-radius: 10px;
    margin-bottom: 14px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 4px solid #F59E0B;
}

.history-joke-item .date {
    font-weight: 700;
    color: #92400e;
    font-size: 0.88rem;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.history-joke-item .content {
    color: #1A1A1A;
    font-size: 1rem;
    line-height: 1.6;
}

.history-joke-item .badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.history-joke-item .badge.ai {
    background: #e0e7ff;
    color: #4338ca;
}

.history-joke-item .badge.original {
    background: #fef3c7;
    color: #92400e;
}

/* ═══ Spinner ═══ */
.spinner {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    z-index: 2000;
}

.spinner p {
    margin-top: 14px;
    font-size: 0.95rem;
    color: #888;
}

.spinner-ring {
    width: 40px;
    height: 40px;
    border: 4px solid #fde68a;
    border-top-color: #F59E0B;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ═══ Toast ═══ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #292524;
    color: #fff;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    z-index: 3000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    animation: fadeIn 0.25s ease-out both;
    max-width: calc(100% - 32px);
    text-align: center;
}

.toast p { margin: 0; }

/* ═══ Weekend Notice ═══ */
.weekend-notice {
    background: #fffbeb;
    border: 2px solid #F59E0B;
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 20px;
    text-align: center;
}

.weekend-notice-title {
    font-family: Georgia, serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: #92400e;
    margin-bottom: 4px;
}

.weekend-notice-body {
    font-size: 0.95rem;
    color: #78716c;
    line-height: 1.5;
}

/* ═══ Responsive ═══ */
@media (max-width: 480px) {
    .laughs-widget {
        padding: 16px;
    }

    .header-title-row h1 {
        font-size: 1.35rem;
    }

    .joke-card-body {
        padding: 16px 18px;
    }

    .joke-text {
        font-size: 1rem;
    }

    .share-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .modal-body {
        padding: 20px 18px 24px;
    }

    .modal-share-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .modal-overlay {
        padding: 12px;
    }

    .modal-content {
        max-height: 90vh;
        border-radius: 12px;
    }

    .history-panel {
        max-width: 100%;
    }
}

@media (min-width: 768px) {
    .laughs-widget {
        padding: 28px 36px;
    }

    .header-title-row h1 {
        font-size: 1.85rem;
    }

    .joke-card-body {
        padding: 24px 28px;
    }

    .joke-text {
        font-size: 1.15rem;
    }
}

@media (min-width: 1024px) {
    .laughs-widget {
        padding: 32px 48px;
    }
}
