/* Today in History Widget — Card Grid + Modal */

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

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: #2D2926;
    font-size: 17px;
    line-height: 1.7;
    padding: 24px 20px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Container ── */
.history-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

/* ── 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); }
}

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

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

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

.header-main {
    display: flex;
    align-items: center;
    gap: 18px;
}

.date-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #7C2D3E;
    color: #fff;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(124, 45, 62, 0.25);
}

.date-badge .month {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    line-height: 1;
    margin-bottom: 2px;
}

.date-badge .day {
    font-size: 26px;
    font-weight: 700;
    font-family: Georgia, serif;
    line-height: 1;
}

.header-text h1 {
    font-family: Georgia, serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: #2D2926;
    line-height: 1.2;
    margin-bottom: 2px;
}

.header-text .subtitle {
    color: #6B5E57;
    font-size: 0.95rem;
    font-style: italic;
}

.header-rule {
    margin-top: 18px;
    height: 2px;
    background: linear-gradient(to right, #7C2D3E, #C4A882, transparent);
    border-radius: 1px;
}

/* ═══ Card Grid ═══ */
.history-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ═══ Grid Card ═══ */
.grid-card {
    background: #FDFBF9;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #E8E0D8;
    cursor: pointer;
    transition: box-shadow 0.25s ease, border-color 0.25s ease, transform 0.2s ease;
    animation: fadeIn 0.4s ease-out both;
}

.grid-card:nth-child(1) { animation-delay: 0.05s; }
.grid-card:nth-child(2) { animation-delay: 0.1s; }
.grid-card:nth-child(3) { animation-delay: 0.15s; }
.grid-card:nth-child(4) { animation-delay: 0.2s; }
.grid-card:nth-child(5) { animation-delay: 0.25s; }
.grid-card:nth-child(6) { animation-delay: 0.3s; }

.grid-card:hover {
    box-shadow: 0 6px 20px rgba(124, 45, 62, 0.12);
    border-color: #C4A882;
    transform: translateY(-2px);
}

.grid-card-image {
    width: 100%;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    display: block;
    background: #EDE7DF;
}

.grid-card-placeholder {
    width: 100%;
    aspect-ratio: 3 / 2;
    background: linear-gradient(135deg, #F5F0EB 0%, #EDE7DF 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
}

.grid-card-body {
    padding: 14px 16px;
}

.grid-card-year {
    display: inline-block;
    background: #7C2D3E;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 12px;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.grid-card-title {
    font-family: Georgia, serif;
    font-size: 1rem;
    font-weight: 700;
    color: #2D2926;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.grid-card-category {
    display: inline-block;
    font-size: 0.65rem;
    color: #7C2D3E;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
    margin-top: 6px;
    opacity: 0.7;
}

/* ═══ Modal Overlay ═══ */
.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: #FDFBF9;
    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 */
.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 */
.modal-body {
    padding: 28px 28px 32px;
}

.modal-year {
    display: inline-block;
    background: #7C2D3E;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 4px 16px;
    border-radius: 20px;
    margin-bottom: 14px;
    letter-spacing: 0.5px;
}

.modal-title {
    font-family: Georgia, serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #2D2926;
    line-height: 1.3;
    margin-bottom: 14px;
}

.modal-summary {
    font-size: 1rem;
    color: #4A433D;
    line-height: 1.7;
    margin-bottom: 16px;
}

.modal-description {
    font-size: 0.95rem;
    color: #5C554F;
    line-height: 1.75;
    padding-top: 16px;
    border-top: 1px solid #E8E0D8;
    margin-bottom: 16px;
}

.modal-category {
    display: inline-block;
    font-size: 0.7rem;
    color: #7C2D3E;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    padding: 4px 12px;
    background: rgba(124, 45, 62, 0.08);
    border-radius: 4px;
}

/* ═══ Loading ═══ */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 20px;
    text-align: center;
    grid-column: 1 / -1;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #E8E0D8;
    border-top-color: #7C2D3E;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin-bottom: 16px;
}

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

.loading p {
    color: #6B5E57;
    font-size: 0.95rem;
    font-style: italic;
}

/* ═══ Empty / Error ═══ */
.no-events {
    text-align: center;
    padding: 64px 20px;
    grid-column: 1 / -1;
}

.no-events h2 {
    font-family: Georgia, serif;
    color: #2D2926;
    font-size: 1.3rem;
    margin-bottom: 8px;
}

.no-events p {
    color: #6B5E57;
    font-size: 1rem;
}

.error {
    text-align: center;
    padding: 64px 20px;
    background: rgba(124, 45, 62, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(124, 45, 62, 0.15);
    grid-column: 1 / -1;
}

.error h2 {
    font-family: Georgia, serif;
    color: #7C2D3E;
    font-size: 1.2rem;
    margin-bottom: 6px;
}

.error p {
    color: #6B5E57;
    font-size: 1rem;
}

/* ═══ Responsive ═══ */

@media (max-width: 480px) {
    body {
        padding: 16px;
    }

    .header-main {
        gap: 14px;
    }

    .date-badge {
        width: 56px;
        height: 56px;
    }

    .date-badge .month {
        font-size: 10px;
    }

    .date-badge .day {
        font-size: 22px;
    }

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

    .history-content {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .grid-card-body {
        padding: 10px 12px;
    }

    .grid-card-title {
        font-size: 0.9rem;
    }

    .modal-overlay {
        padding: 12px;
    }

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

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

    .modal-title {
        font-size: 1.3rem;
    }
}

@media (min-width: 600px) {
    .history-content {
        grid-template-columns: repeat(3, 1fr);
        gap: 18px;
    }
}

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

    .date-badge {
        width: 76px;
        height: 76px;
    }

    .date-badge .month {
        font-size: 12px;
    }

    .date-badge .day {
        font-size: 30px;
    }

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

    .grid-card-title {
        font-size: 1.05rem;
    }
}

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

    .history-content {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
}
