/*:::::::::::::::::::::::::::::
Basic Stuff & Styles 
:::::::::::::::::::::::::::::*/
:root {
    --calendar-header-color: #333;
    --calendar-header-highlight: #D8572A;

    --system-event-background: #DC6B41;
    --system-event-hover: #BE4C23;
    --system-event-color: #f9f9f9;
    --user-event-background: #4B2E39;
    --user-event-hover: #32021F;
    --user-event-color: #f9f9f9;
    --day-today-color: #fff3c4; /*DFF2D8*/

    --border-radius: 4px;
}

body {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    font-family: system-ui, sans-serif;
    background: #f9f9f9;
    color: #333;
    line-height: 1.4;
}

/*:::::::::::::::::::::::::::::
Calendar Layout
:::::::::::::::::::::::::::::*/
#calendar {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

/*:::::::::::::::::::::::::::::
Calendar Navigation
:::::::::::::::::::::::::::::*/
#calendar-navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin: 1rem;
}

#month-title {
    font-weight: 600;
    min-width: 120px;
    text-align: center;
}

.nav-button {
    background: none;
    color: var(--calendar-header-highlight);
    font-size: 1.6rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
}
.nav-button:hover {
    background-color: #fff3c4;
    border-radius: 10px;
    transition: background-color 0.2s ease;
}

/*:::::::::::::::::::::::::::::
Calendar Grid
:::::::::::::::::::::::::::::*/
.calendar-header, .calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-header div { /* styling the div elements inside the header */
    font-weight: 600;
    text-align: center;
    padding: 10px 0;
}

/* Modify weekend day name color*/
.calendar-header div:nth-child(6),
.calendar-header div:nth-child(7) {
    color: var(--calendar-header-highlight);
}

.calendar-grid div {
    padding: 4px;
    position: relative;
}

.day-cell {
    border: 1px solid #ddd;
}

.day-today {
    background-color: var(--day-today-color);
}

/*:::::::::::::::::::::::::::::
Events
:::::::::::::::::::::::::::::*/
.events {
    /* should I make these heights dependent on the view height, or just set them differently with @media?*/
    min-height: 80px;
    max-height: 100px;
    padding: 0px;
    font-size: 11px;
    cursor: pointer;
    border-radius: 2px;
    overflow: hidden;
}

.event {
    background-color: var(--system-event-background);
    color: var(--system-event-color);
    cursor: pointer;
    margin: 2px 0;
    border-radius: var(--border-radius);

    overflow: hidden;
    text-overflow: ellipsis;
}
.event:hover {
    background-color: var(--system-event-hover);
    transition: background-color 0.2s ease;
}

.event.user {
    background-color: var(--user-event-background);
}
.event.user:hover {
    background-color: var(--user-event-hover);
    transition: background-color 0.2s ease;
}


/*:::::::::::::::::::::::::::::
Modals
:::::::::::::::::::::::::::::*/
/* Background tint */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.5);
}

/* Modal box */
.modal-content {
    border-radius: var(--border-radius);
    background: white;
    padding: 20px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.hidden {
    display: none;
}

/* Close button */
.modal-close {
    float: right;
    background: none;
    color: var(--calendar-header-highlight);
    font-size: 1.2rem;
    border: none;
    cursor: pointer;
}
.modal-close:hover {
    background-color: #fff3c4;
    border-radius: 10px;
    transition: background-color 0.2s ease;
}

/*:::::::::::::::::::::::::::::
Event Detail & Create Form
:::::::::::::::::::::::::::::*/
h2 {
    font-size: 1.2rem;
    text-align: center;
}

#event-result {
    font-weight: 600;
    font-size: 1.4rem;
    text-align: center;
}

#event-competition, #event-sport {
    margin: 4px auto;
    font-size: 0.9rem;
    opacity: 0.8;
}

#event-create-form {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 0.75rem 1rem;
    align-items: center;
}

#event-create-form label:not(.hidden) {
    font-weight: 600;
    display: contents;
}

#event-create-form label select {
    grid-column: 2;
    border: 1px solid #ccc;
    border-radius: var(--border-radius);
}

#event-input-save {
    grid-column: 1 / -1;
    justify-self: center;
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    font-weight: 600;
    background: var(--calendar-header-highlight);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
}

#event-input-save:hover {
    background-color: var(--system-event-hover);
    transition: background-color 0.2s ease;
}

/*:::::::::::::::::::::::::::::
Responsive
:::::::::::::::::::::::::::::*/

@media (max-width: 768px) {
    /* reduce line height */
    body {
        line-height: 1.1;
        font-size: 0.9rem;
        margin: 2px;
    }

    /* take up all space not taken up by navigation and calendar header */
    #calendar {
        height: calc(100vh - 120px);
    }

    /* allow smaller width for calendar grid cells */
    .calendar-header, .calendar-grid {
        grid-template-columns: repeat(7, minmax(40px, 1fr));
    }

    .calendar-grid {
        height: 100%;
        grid-auto-rows: 1fr;
    }

    .calendar-grid div {
        padding: 2px;
        font-size: 0.7rem;
    }

    .events {
        max-height: none;
    }
    .modal-content {
        width: 85%;
        padding: 1rem;
    }

    /* should prevent iOS input zoom */
    input,
    select,
    textarea {
        font-size: 16px;
    }
}

/* Disable hover on touch devices */
@media (hover: none) {
    .nav-button:hover,
    .event:hover,
    .event.user:hover,
    .modal-close:hover,
    #event-input-save:hover {
        background-color: inherit;
    }
}