/* Base styles */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    /* Smooth fade between light/dark themes */
    transition: background-color 0.35s ease, color 0.35s ease;
}

body {
    margin: 0;
    padding: 0;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 18px;
    line-height: 1.5;
    color: #111111;
    background-color: #f4f4f4;
    transition: background-color 0.35s ease, color 0.35s ease;
}

a {
    color: #140D6D;
    text-decoration: none;
}

a:hover,
a:focus {
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
    transition: filter 0.35s ease;
}

/* Layout */
.site-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1 0 auto;
}

/* Skip link */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background-color: #ffffff;
    color: #000000;
    padding: 8px 16px;
    z-index: 1000;
}

.skip-link:focus {
    left: 8px;
    top: 8px;
    outline: 2px solid #140D6D;
}

/* Header & navigation */
.site-header {
    background-color: #140D6D;
    color: #ffffff;
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
}

.logo-square {
    width: 65px;
    height: auto;
    border-radius: 8px;
    background-color: #ffffff;
    color: #140D6D;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 12px;
}

.logo-text {
    font-size: 20px;
    font-weight: bold;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.main-nav a {
    color: #ffffff;
    font-weight: 600;
}

.main-nav a:focus,
.main-nav a:hover {
    text-decoration: underline;
}

/* Search button */
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-button {
    border: 1px solid #ffffff;
    background: transparent;
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
}

.search-button:focus {
    outline: 2px solid #ffffff;
}

/* MOBILE MENU */
.mobile-menu-btn,
#mobile-menu-button {
    display: none;
    border: 1px solid #ffffff;
    background: transparent;
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 20px;
}

.mobile-menu-btn:focus,
#mobile-menu-button:focus {
    outline: 2px solid #ffffff;
}

@media (max-width: 768px) {
    .mobile-menu-btn,
    #mobile-menu-button {
        display: inline-block;
    }

    .main-nav {
        display: none !important;
    }
}

/* Backdrop */
#mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: none;
    justify-content: center;
    align-items: flex-start;
    padding-top: 80px;
    z-index: 9999;
}

#mobile-menu-backdrop[hidden] {
    display: none;
}

/* Dialog panel */
/* Dialog panel */
#mobile-menu-dialog {
    background: #ffffff;
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    padding: 20px;
    outline: none;

    /* FIX: make the dialog itself scroll on small screens */
    max-height: calc(100vh - 120px); /* 80px top padding + a little breathing room */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Close button */
#mobile-menu-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    float: right;
    cursor: pointer;
    color: #140D6D;
}

#mobile-menu-close:focus {
    outline: 2px solid #140D6D;
}

/* Menu list */
.mobile-menu-nav ul {
    list-style: none;
    padding: 0;
    margin: 20px 0 0;
}

.mobile-menu-nav a {
    display: block;
    padding: 14px 0;
    font-size: 20px;
    font-weight: 600;
    border-bottom: 1px solid #dddddd;
    color: #140D6D;
}

.mobile-menu-nav a:hover,
.mobile-menu-nav a:focus {
    background: #f0f0ff;
    text-decoration: none;
}

/* SEARCH DIALOG */
.search-dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1500;
}

.search-dialog {
    background-color: #ffffff;
    padding: 20px;
    max-width: 500px;
    width: 90%;
    border-radius: 8px;
}

/* Content layout */
.page-section {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 16px 24px 16px;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    transition: background-color 0.35s ease, color 0.35s ease;
}

.page-section h1 {
    margin-top: 0;
    padding-top: 16px;
}

/* Card layout */
.item-list {
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 20px;
}

.item {
    border-top: 1px solid #dddddd;
    background-color: #ffffff;
    border: 1px solid #dddddd;
    border-radius: 10px;
    padding: 20px !important;
    margin-bottom: 20px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    transition: background-color 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
}

.item-title a,
.item-image a {
    text-decoration: none !important;
}

.item-layout {
    gap: 20px !important;
}

.item-image img {
    border-radius: 6px;
}

.item-summary,
.item-meta {
    margin-bottom: 12px !important;
}

/* Focus visible */
:focus-visible {
    outline: 3px solid #ff9900 !important;
    outline-offset: 4px !important;
    border-radius: 6px;
}

/* BLOG matching */
.page-section ul.item-list .read-more {
    padding: 8px 14px;
    font-size: 18px;
}

/* SEARCH results matching */
.search-results .item {
    border-radius: 10px;
    padding: 20px !important;
}

/* ============================================================
   DARK MODE — TOGGLE + SMOOTH TRANSITION
   ============================================================ */

.dark-mode body,
.dark-mode .page-section,
.dark-mode .item,
.dark-mode input,
.dark-mode textarea,
.dark-mode select {
    transition: background-color 0.35s ease, color 0.35s ease, border-color 0.35s ease;
}

.dark-mode body {
    background-color: #121212;
    color: #f2f2f2;
}

.dark-mode .page-section {
    background-color: #1c1c1c;
    color: #ffffff;
}

.dark-mode .item {
    background-color: #1a1a1a;
    border-color: #333333;
    box-shadow: 0 2px 6px rgba(0,0,0,0.6);
}

.dark-mode a {
    color: #9db7ff;
}

.dark-mode .item-summary,
.dark-mode .item-meta {
    color: #dddddd;
}

.dark-mode input,
.dark-mode textarea,
.dark-mode select {
    background-color: #1d1d1d;
    color: #ffffff;
    border-color: #444444;
}

.dark-mode .site-header {
    background-color: #111133;
}

.dark-mode .site-footer {
    background-color: #000000;
    color: #dddddd;
}

/* Dark pagination */
.dark-mode .pagination a {
    background-color: #222222;
    color: #ffffff;
}

.dark-mode .pagination a[aria-current="page"] {
    background-color: #140D6D;
    color: #ffffff !important;
}

/* Search + dialogs */
.dark-mode .search-dialog {
    background-color: #1c1c1c;
    color: #ffffff;
}

.dark-mode .search-dialog input {
    background-color: #0f0f0f;
    color: #ffffff;
    border-color: #444444;
}

/* ============================================================
   DARK MODE TOGGLE BUTTON (DESKTOP)
   ============================================================ */

#dark-mode-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    background-color: #140D6D;
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 54px;
    height: 54px;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

#dark-mode-toggle:hover,
#dark-mode-toggle:focus {
    background-color: #5557a0;
    outline: 3px solid #ff9900;
    outline-offset: 3px;
}

.dark-mode #dark-mode-toggle {
    background-color: #f0f0f0;
    color: #111111;
}

/* ============================================================
   MOBILE DARK MODE LINK (inline)
   ============================================================ */

#dark-mode-mobile-link {
    display: none;
    color: #ffffff;
    font-size: 16px;
    margin-left: 12px;
    text-decoration: underline;
}

#dark-mode-mobile-link:hover,
#dark-mode-mobile-link:focus {
    text-decoration: none;
    outline: 2px solid #ff9900;
    outline-offset: 3px;
}

.dark-mode #dark-mode-mobile-link {
    color: #9db7ff;
}

@media (max-width: 768px) {
    #dark-mode-toggle {
        display: none !important;
    }
    #dark-mode-mobile-link {
        display: inline-block !important;
    }
}


/* =========================
   Resources Page
   ========================= */

/* Layout */
.resource-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: flex-end;
}

.resource-filters label {
    display: flex;
    flex-direction: column;
    font-weight: 600;
    font-size: 0.95rem;
}

.resource-filters input,
.resource-filters select {
    padding: 0.5rem;
    font-size: 1rem;
    border-radius: 6px;
    border: 1px solid #999;
    background: #fff;
    color: #000;
}

.resource-filters button {
    padding: 0.55rem 1rem;
    border-radius: 6px;
    border: none;
    background: #5a4db2; /* accessible purple */
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
}

.resource-filters button:focus,
.resource-filters input:focus,
.resource-filters select:focus {
    outline: 3px solid #000;
    outline-offset: 2px;
}

/* Resource list */
.resource-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.resource-item {
    padding: 1.25rem;
    border-radius: 10px;
    background: #f5f5f7;
    border: 1px solid #ddd;
}

.resource-item h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

.resource-item p {
    margin: 0.5rem 0;
    line-height: 1.5;
}

.resource-item a {
    color: #333365;
    font-weight: 600;
}

.resource-item a:focus {
    outline: 3px solid #000;
    outline-offset: 2px;
}

/* Pagination */
.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination a {
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    border: 1px solid #999;
    text-decoration: none;
    background: #fff;
    color: #000;
}

.pagination a.active {
    background: #5a4db2;
    color: #fff;
    border-color: #5a4db2;
}

.pagination a:focus {
    outline: 3px solid #000;
    outline-offset: 2px;
}

/* =========================
   Dark Mode Support
   ========================= */

/* Manual toggle support */
body.dark-mode .resource-item,
[data-theme="dark"] .resource-item {
    background: #1f1f24;
    border-color: #444;
}

body.dark-mode .resource-filters input,
body.dark-mode .resource-filters select,
[data-theme="dark"] .resource-filters input,
[data-theme="dark"] .resource-filters select {
    background: #121216;
    color: #fff;
    border-color: #555;
}

body.dark-mode .resource-filters button,
[data-theme="dark"] .resource-filters button {
    background: #7a6cff;
}

body.dark-mode .resource-item a,
[data-theme="dark"] .resource-item a {
    color: #9fa8ff;
}

body.dark-mode .pagination a,
[data-theme="dark"] .pagination a {
    background: #121216;
    color: #fff;
    border-color: #555;
}

body.dark-mode .pagination a.active,
[data-theme="dark"] .pagination a.active {
    background: #7a6cff;
    border-color: #7a6cff;
}

/* System preference fallback */
@media (prefers-color-scheme: dark) {
    body:not(.light-mode) .resource-item {
        background: #1f1f24;
        border-color: #444;
    }
}

/* ============================================================
   Calendar (Month View Layout Fixes) — add to END of stylesheet
   ============================================================ */

.calendar-wrap {
    width: 75%;
    max-width: 1100px;
    margin: 0 auto;
}

/* Ensure lists/cards align cleanly inside the centered container */
.calendar-wrap .item-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.calendar-wrap .item {
    margin: 0 0 12px;
}

.calendar-wrap .calendar-item {
    width: 100%;
}

/* Keep the bar and bottom nav inside the same centered width */
.calendar-wrap .cal-bar,
.calendar-wrap .cal-bottom-nav {
    width: 100%;
}

/* Mobile: full width */
@media (max-width: 768px) {
    .calendar-wrap {
        width: 100%;
        max-width: 100%;
    }
}
