/* Global responsive baseline for ultra-narrow viewports (down to ~32px) */
*,*::before,*::after{box-sizing:border-box}
/*html,body{height:100%}*/
html{overflow-x:hidden}
body{font-family:Arial,Helvetica,sans-serif;margin:0;color:#222;word-wrap:break-word;overflow-wrap:anywhere;min-height:85vh}
a {color:#0d6efd;text-decoration:none;font-weight:600}
img,video,svg{max-width:100%;height:auto}
.logo{height:45px}
:where(input,select,textarea,button){max-width:100%}

/* Scope sticky header to front pages only; backoffice has its own header rules */
body:not(.back-shell) header{border-bottom:1px solid #eee;background:#fff;position:sticky;top:0;z-index:10}
html { scroll-padding-top: 80px; } /* Adjust 80px to match your navbar height */
.container{max-width:1100px;margin:0 auto;padding:0 16px;min-width:0}
.navbar{display:flex;align-items:center;justify-content:space-between;padding:12px 0;gap:6px;flex-wrap:wrap}
.brand{display:flex;align-items:center;gap:6px;text-decoration:none;color:#222;font-weight:700;min-width:0}
.brand img{height:16px;width:auto}
.nav-links{display:flex;flex-wrap:wrap;gap:4px}
.nav-links a{margin:0;text-decoration:none;color:#444;font-size:12px}
.nav-links a.active{font-weight:bold}
main{min-height:70vh}
footer{border-top:1px solid #eee;padding:12px 0;background:#fafafa;color:#666}
footer a{color:#999;text-decoration:none}
.hero{background:linear-gradient(135deg,#f0f7ff,#fff)}
.hero h1{font-size:18px}
.grid{display:grid;grid-template-columns:1fr;gap:8px}
@media (min-width:260px){.grid{grid-template-columns:repeat(auto-fill,minmax(220px,1fr))}}
.card{border:1px solid #eee;border-radius:8px;overflow:hidden;background:#fff;display:flex;flex-direction:column}
.card img{width:100%;height:100px;object-fit:cover}
.card-body{padding:8px}
/* Simple custom modal used on front */
.modal.custom{position:fixed;inset:0;background:rgba(0,0,0,.45);display:none;align-items:center;justify-content:center}
.modal.custom.open{display:flex}
.modal-card{background:#fff;max-width:900px;width:100%;max-height:85vh;overflow:auto;border-radius:10px}
.modal-header{display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid #eee}
.modal-content{}
.event-row{display:grid;grid-template-columns:32px 1fr;gap:6px;align-items:center;border-bottom:1px solid #f2f2f2}
.event-row img{width:32px;aspect-ratio:16/9;object-fit:cover;border-radius:4px}
.calendar-header{display:grid;grid-template-columns:repeat(2,1fr);gap:4px;margin-bottom:4px;color:#666;font-size:10px}
.calendar-header .dow{min-width:75px}
@media (min-width:260px){.calendar-header{grid-template-columns:repeat(7,1fr)}}
.calendar{display:grid;grid-template-columns:repeat(2,1fr);gap:4px}
@media (min-width:260px){.calendar{grid-template-columns:repeat(7,1fr)}}
.day{border:1px solid #eee;border-radius:6px;min-height:40px;display:flex;flex-direction:column}
.day .date{font-size:10px;color:#999}
.badge{display:inline-block;background:#eef5ff;color:#0d6efd;border-radius:4px;font-size:9px}

/* Backoffice responsive helpers and structure */
.back-layout{display:grid;grid-template-columns:240px 1fr;gap:16px;min-width:0}
@media (max-width:600px){.back-layout{display:block!important}}
.back-sidebar{position:relative;border-right:1px solid #eee;padding-right:12px;transition:width .2s ease, transform .2s ease}
@media (max-width:600px){.back-sidebar{position:static!important;border-right:none!important;padding-right:0!important}}
.back-title-row{display:flex;justify-content:space-between;align-items:center;gap:8px;flex-wrap:wrap}
.back-table-wrap{overflow:auto;margin-top:8px}
.table-admin{border-collapse:collapse;min-width:700px;width:100%}
.table-admin th{ text-align:left;border-bottom:1px solid #eee;padding:6px}
.table-admin td{ border-bottom:1px solid #f5f5f5;padding:6px}
.table-admin .muted{color:#555}
.table-admin .row-actions{display:flex;gap:6px;flex-wrap:wrap}
.alert-warning{border:1px solid #ffc107;background:#fff8e1;padding:8px;border-radius:6px;color:#8a6d3b;margin-bottom:8px}
.form-grid{display:grid;gap:8px;max-width:700px}
.form-grid label{display:grid;gap:4px}
.actions-row{display:flex;gap:6px;align-items:center}

/* Additions for backoffice nav links and toggle positioning */
.sidebar-toggle-pos{position:absolute;top:6px;right:6px}
.side-link{text-decoration:none;color:#444}
.side-link.active{font-weight:bold;color:#0d6efd}
/* Utility */
.title-sm{margin:0 0 6px 0;font-size:18px}

/* Calendar robustness overrides to prevent long titles from breaking the grid */
.calendar,.calendar .day{min-width:75px}
.calendar .badge{display:block;max-width:100%;white-space:normal;overflow-wrap:anywhere;word-break:break-word}
/* Clamp long calendar titles to two lines and show custom ellipsis marker */
.calendar .badge>div:first-child{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;line-height:1.2;position:relative;padding-right:18px}


/* Event card two-column layout and 16:9 media wrapper */
.event-card{display:grid;grid-template-columns:1fr;gap:12px;align-items:start}
@media (min-width:768px){.event-card{grid-template-columns:1fr 1fr}}
.event-card__left{display:grid;gap:6px}
.event-card__right{display:grid;gap:8px;align-content:start}
.event-card__meta{font-size:12px;color:#555}
.event-card__right .when{font-size:12px;color:#666}
.event-card__right .also-on{font-size:12px;color:#666}
/* 16:9 media container; ensures image keeps the aspect and covers */
.media-16x9{position:relative;width:100%;aspect-ratio:16/9;background:#f5f5f5;overflow:hidden;border-radius:6px}
.media-16x9>img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:block}
/* Override base .card img height for event card images */
.card .media-16x9>img{height:100%}

/* Preserve line breaks in event description */
.event-card__desc{white-space:normal;overflow-wrap:anywhere;line-height:1.4}
.event-card__desc br {
    display: block;
    content: "";
    margin-top: 0.5em;
}

/* Placeholder styles for events without images */
.media-16x9.placeholder{display:flex;align-items:center;justify-content:center;text-align:center;color:#6b7280;background:#f5f7fb;border:1px dashed #cbd5e1;border-radius:6px;padding:8px;cursor:auto;}
.media-16x9.placeholder>span{max-width:90%;font-size:12px;line-height:1.3}
/* Tiny thumbnail placeholder used in the modal list */
.thumb-16x9.placeholder{width:32px;aspect-ratio:16/9;background:#f0f2f5;border:1px dashed #dcdfe6;border-radius:4px;cursor:auto;}


/* Hero with background image: ensure text is readable over image */
.hero.has-bg{color:#fff}
.hero.has-bg h1, .hero.has-bg p {
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.6);
}

.hero.has-bg a:not(.btn){color:#e6f0ff;text-decoration:underline}
.hero.has-bg .btn{box-shadow:0 2px 6px rgba(0,0,0,.25)}


/* Hero section: allow height to grow with content while keeping vertical padding */
.hero{position:relative}
.hero > .container{position:relative;}
.hero > .container .btn-see-all{position:relative;margin-top:1rem;display:inline-block}

/* Modal stacking and layout stability overrides */
/* Ensure Bootstrap modal/backdrop sit above any backoffice sidebar/layout stacking contexts */
.modal-backdrop{z-index:1055 !important}
.modal{z-index:1060 !important}
/* Reduce horizontal layout shift when body scrollbar disappears on modal open */
html{scrollbar-gutter:stable}

/* Improved calendar styles */
.calendar-header {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    margin-bottom: 4px;
    color: #666;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

@media (min-width: 260px) {
    .calendar-header {
        grid-template-columns: repeat(7, 1fr);
    }
}

.calendar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

@media (min-width: 260px) {
    .calendar {
        grid-template-columns: repeat(7, 1fr);
    }
}

.day {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    background: #fff;
    transition: all 0.2s ease;
}

.day:hover {
    border-color: #0d6efd;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.day .date {
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    padding: 4px;
    align-self: flex-start;
}

/* Improved event badges */
.badge {
    display: block;
    background: #e7f1ff;
    color: #0a58ca;
    border-radius: 6px;
    font-size: 10px;
    padding: 4px 6px;
    margin-bottom: 2px;
    border-left: 3px solid #0d6efd;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.badge:hover, .badge:focus {
    background: #d0e2ff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.badge:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 1px;
}

/* Current day highlight */
.day.current-day {
    background: #f8f9fa;
    border-color: #0d6efd;
}

.day.current-day .date {
    background: #0d6efd;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2px;
}

/* Improved modal */
.modal.custom {
    backdrop-filter: blur(2px);
}

.modal-card {
    background: #fff;
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    overflow: auto;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

/* Better event rows in modal */
.event-row {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 12px;
    align-items: start;
    padding: 12px;
    border-bottom: 1px solid #f1f3f4;
    transition: background-color 0.2s ease;
}

.event-row:hover {
    background: #f8f9fa;
}

.event-row img {
    width: 40px;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 6px;
}

/* Improved hero section */
.hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-size: cover;
    background-position: center;
    color: white;
    min-height: 450px;
    display: flex;
    /* Ensure children fill the height */
    align-items: stretch;
    text-align: left;
    overflow: hidden;
    /* Add vertical padding so the button never sticks to the edges */
    padding: 48px 0;
    /* Container query support for preview scaling */
    container-type: inline-size;
    container-name: hero;
}


.hero > .container {
    width: 100%;
    display: flex;
    flex-direction: column;
}

.hero-text-wrapper {
    flex-grow: 0.5;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hero h1 {
    /* Slightly smaller than before to fit the new height better */
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    line-height: 1.2;
}

.hero p {
    font-size: 1.25rem;
    opacity: 0.95;
    margin-bottom: 2rem;
    line-height: 1.6;
}

.hero .btn-primary {
    background: rgba(255,255,255,0.2);
    border: 2px solid white;
    color: white;
    padding: 12px 30px;
    font-weight: 600;
    border-radius: 50px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    align-self: flex-start;
}

.hero .btn-primary:hover {
    background: white;
    color: #667eea;
    transform: translateY(-2px);
}

/* Better event card */
.card {
    border: 1px solid #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

/* Responsive improvements */
@media (max-width: 768px) {
    .hero {
        padding: 40px 0; /* maintain bottom spacing on smaller screens */
    }

    .calendar-header .dow {
        font-size: 10px;
    }

    .day {
        min-height: 60px;
    }
}

@container hero (max-width: 768px) {
    .hero h1 {
        font-size: 2.25rem;
    }

    .hero p {
        font-size: 1.05rem;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 32px 0; /* safe spacing from the bottom */
    }
}

@container hero (max-width: 480px) {
    .hero h1 {
        font-size: 1.8rem;
    }

    .hero p {
        font-size: 0.95rem;
        margin-bottom: 1.5rem;
    }

    .hero .btn-primary {
        padding: 10px 24px;
        font-size: 0.9rem;
    }
}

/* Loading states */
.day.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

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

/* Focus improvements for accessibility */
a:focus, button:focus, .badge:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Empty state for calendar */
.calendar-empty {
    text-align: center;
    padding: 3rem;
    color: #6c757d;
}

.calendar-empty .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Clamp modal event descriptions to two lines with explicit "(...)" when truncated */
#eventsModal .event-description{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;line-height:1.3;position:relative;padding-right:18px;max-height:calc(2 * 1.3em)}

.share-event-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    transition: all 0.2s ease;
    border: 1px solid #dee2e6;
    background-color: #fff;
    color: #6c757d;
    flex-shrink: 0;
}
.share-event-btn:hover {
    background-color: #f8f9fa;
    color: #0d6efd;
    border-color: #0d6efd;
}
.share-event-btn svg {
    width: 14px !important;
    height: 14px !important;
    display: block;
}

/* About section styling */
.about-image-wrapper {
    max-width: 450px;
    width: 100%;
}
.about-image-wrapper img {
    aspect-ratio: 16 / 9;
    object-fit: cover;
    width: 100%;
}
.about-content strong {
    font-weight: 700;
}
@media (min-width: 768px) {
    .about-image-wrapper {
        width: 40%;
    }
}
@media (max-width: 767.98px) {
    .about-image-wrapper {
        float: none !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}
