:root
{
    --navbar-background: var(--navbar-background-simple);
    --navbar-border-height: 0px;
}

/* hide the navbar border when it is not open */
#portalNavbar.navbar-open
{
    /* // TODO: I don't want to use magic number 4px. */
    --navbar-border-height: 4px;
}

.content-container
{
    margin: 0;
}

#calendarContainer
{
    display: flex;
    flex-wrap: wrap;
    
    background: var(--panel-border);
}

#currentTime
{
    border-radius: 0;
    box-shadow: 1px 0 #337AB7;
    
    text-align: center;
    
    display: flex;
    justify-content: space-between;
    align-items: center;
    
    width: 15%;
    height: 38px;
    
    white-space: nowrap;
    
    color: white;
    background-color: var(--bg-primary);
}

#currentTime a
{
    color: white;
    padding: 10px;
    
    transition: background-color var(--transition-time);
}

#currentTime a:hover,
#currentTime a:focus
{
    background-color: var(--bg-primary-hover); /* make this a variable */
}

#calendarHeading
{
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-gap: 1px;
    
    background-color: var(--bg-primary);
    
    width: 85%;
    height: 38px;
    
    white-space: nowrap;
}

#calendarHeading > span
{
    text-align: center;
    text-transform: uppercase;
    padding: 10px 6px;
    color: whitesmoke;
    font-size: 13px;
}

#calendarSidebar
{
    width: calc(15% - 1px);
    height: calc(100vh - (var(--navbar-height) + 38px));
    
    background-color: var(--panel-heading);
    
    padding: 10px;
    margin-right: 1px;
    
    overflow-y: auto;
}

#calendarSidebar .btn-block
{
    margin: 0;
}

#calendarSidebar hr
{
    margin: calc(var(--margin) / 1.5) 0;
}

#calendarSidebar .group-color-preview
{
    display: inline-block;
    
    position: relative;
    top: 1px;
    
    width: 12px;
    height: 12px;
    
    border: 1px solid black;
    border-radius: 3px;
}

#calendar
{
    box-sizing: border-box;
    
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    /*grid-template-rows: min-content;*/
    grid-gap: 1px;
    
    width: 85%;
    /* the navbar is usually 54px, but here it's only 50 because we disable the bottom border */
    /* maybe use a navbar height variable? */
    min-height: calc(100vh - var(--navbar-height) - 38px);
    max-height: calc(100vh - var(--navbar-height) - 38px);
    
    overflow-y: auto;
}

.day
{
    --day-background-color: var(--panel-body);
    
    background-color: var(--day-background-color);
    padding: 4px;
}

.day .day-titlebar
{
    text-align: center;
    padding-bottom: 3px;
    white-space: nowrap;
    color: var(--text-muted);
}

/* hide on unless on mobile */
.day .day-titlebar .name,
.day .day-titlebar .month
{
    display: none;
}

.day.other-month
{
    --day-background-color: var(--panel-heading);
}

.day .day-titlebar .weather-forecast-type .weather-icon
{
    margin: -15px -12px;
    transform: scale(0.6);
    filter: brightness(0.8); /* // TODO: find a way to do this without filter */
}

.day .day-titlebar .weather-forecast-temp
{
    font-weight: var(--font-weight-light);
}

.day .nothing-today
{
    color: var(--text-muted);
}

.day .event
{
    background-color: var(--event-color);
    color: var(--event-text);
    padding: 4px;
    border-radius: 5px;
    width: 100%;
    font-size: 13px;
}

.day > a:not(:last-child) .event
{
    margin-bottom: 4px;
}

.day .event .event-details
{
    display: flex;
}

.day .event .event-details .event-desc
{
    flex-grow: 1;
}

.day > a:hover,
.day > a:focus
{
    text-decoration: none;
}

.event.task .event-desc::before
{
    display: inline-block;
    font-style: normal;
    font-variant: normal;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    
    font: var(--fa-font-regular);
}

@keyframes event-icon
{
    from
    {
        opacity: 0.5;
    }
    
    to
    {
        opacity: 1;
    }
}

.event.has-description .event-desc::before
{
    font: var(--fa-font-solid);
    content: "\f075";
}

.event.repeats .event-desc::before
{
    font: var(--fa-font-solid);
    content: "\f363";
}

.event.task .event-desc::before
{
    font: var(--fa-font-regular);
    content: "\f111";
}

.event.task.finished .event-desc::before
{
    font: var(--fa-font-solid);
    content: "\f058";
}

.event.task.overdue .event-desc::before
{
    font: var(--fa-font-regular);
    content: "\f017";
    
    animation: event-icon 1s infinite alternate-reverse;
}

/* big screens */
/* // TODO: standardise width or stop using media queries */
@media only screen and (min-width: 1000px)
{
    /* hide the duplicate id until we get to phone screen size */
    .planner .day .event-duplicate-id
    {
        display: none;
    }
    
    .day .day-titlebar .left
    {
        float: left;
    }
    
    .day .day-titlebar .right
    {
        float: right;
    }
    
    .day.current .day-titlebar .number
    {
        font-weight: var(--font-weight-strong);
        padding: 0 8px;
        color: #fff;
        background-color: #777;
        border-radius: 10px;
    }
    
    .planner .day .nothing-today
    {
        display: block;
        text-align: center;
    }
    
    .day .event:hover
    {
        filter: brightness(0.85);
    }
    
    /* event not have rounded corners if it has events on either side */
    .planner .day .event.middle
    {
        border-radius: 0;
        
        margin-left: -5px;
        margin-right: -4px;
        width: calc(100% + 9px);
    }
    
    /* event will be flat against the edge if it runs onto a new line */
    .planner .day .event.begin
    {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
        
        width: calc(100% + 4px);
    }
    
    /* event will be flat against the edge if it runs onto a new line */
    .planner .day .event.final
    {
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
        
        margin-left: -5px;
        
        width: calc(100% + 5px);
    }
    
    .planner .day .event .event-time
    {
        /* TODO: this needs to be able to change based on the brightness of the background of the calendar */
        color: lightgray;
        mix-blend-mode: hard-light;
    }
    
    .hide-desktop
    {
        display: none;
    }
}

/* medium screen, use mobile calendar layout but keep the sidebar */
@media only screen and (max-width: 1000px)
{
    /* // TODO: this is kind of a hack but it works. 
        would rather display: none the heading instead, 
        but it's used to properly wrap the flexbox. */
    #calendarContainer.planner #calendarHeading
    {
        display: none;
    }

    #currentTime
    {
        width: 100%;
    }
    
    #calendarSidebar
    {
        min-width: 35%;
    }
    
    .planner #calendar
    {
        flex-grow: 1;
        
        width: min-content;
        
        display: inline-block;
        
        min-height: calc(100dvh - var(--navbar-height) - 38px);
        max-height: calc(100dvh - var(--navbar-height) - 38px);
        
        overflow-x: auto;
    }
    
    .planner .month-heading
    {
        font-size: 18px;
        text-transform: uppercase;
        margin: 10px 10px;
        font-weight: 300;
        letter-spacing: 3px;
    }
    
    .planner .day
    {
        padding: 8px 4px;
    }
    
    .planner .day .event-duplicate-id
    {
        display: inline-block;
    }

    .planner .day.first-event
    {
        padding-top: 2%;
    }
    
    .planner .day.last-event
    {
        padding-bottom: 2%;
    }
    
    .planner .day:not(.current).empty,
    .planner .day.other-month.empty
    {
        display: none;
    }
    
    /*
    // don't know if div was supposed to target the title bar or events
    .day > div
    {
        margin: 0 1%;
    }
    */
    
    .planner .day .nothing-today
    {
        margin-left: 10px;
    }
    
    .planner .day .day-titlebar
    {
        padding: 3px 0;
        color: var(--text-default);
        
        text-align: left;
        font-size: 16px;
        
        position: sticky;
        z-index: calc(var(--pageContentZ) + 1);
        top: 0;
        
        background-color: var(--day-background-color);
        
        border-bottom: 1px solid var(--panel-border);
        
        text-transform: uppercase;
        
        display: flex;
        gap: 5px;
    }
    
    .planner .day.past .day-titlebar
    {
        color: var(--text-muted);
    }
    
    .planner .day.current .day-titlebar .date
    {
        font-weight: 700;
        color: var(--text-primary);
    }
    
    .planner .day .day-titlebar .left
    {
        order: 1;
    }
    
    .planner .day .day-titlebar .date
    {
        order: 2;
        
        display: inline-flex;
        gap: 5px;
        
        flex-grow: 1;
    }
    
    .planner .day .day-titlebar .right
    {
        order: 3;
    }
    
    .planner .day .day-titlebar .date .name,
    .planner .day .day-titlebar .date .month
    {
        display: block;
    }
    
    .planner .day .day-titlebar .date .name:after
    {
        content: " —";
    }
    
    a:hover > .event,
    a:focus > .event
    {
        background-color: var(--panel-heading);
        border-radius: var(--border-radius);
    }
    
    /* little line of event colour to the left of the event */
    .planner .day .event::before
    {
        position: absolute;
        content: "."; /* // TODO: make this not font-width dependant e.g. it should always be 5px wide. */
        width: 5px;
        color: var(--event-color);
        background-color: var(--event-color);
        border-radius: 5px;
        height: calc(100% - 14px);
    }
    
    .planner .day .event
    {
        position: relative;
        font-size: 16px !important;
        color: var(--text-default);
        background-color: unset;
        border-radius: unset;
        margin-bottom: unset !important;
        
        padding-top: 7px;
        padding-bottom: 7px;
        
        /* because it always has 4px of bottom margin */
    }
    
    .planner .day .event
    {
        border-top: 1px solid var(--panel-border);
    }
    
    .planner .day .event .event-details
    {
        margin-left: 10px;
    }
}

/* Phone sized screens */
/* // TODO: standardise width or stop using media queries */
@media only screen and (max-width: 600px) 
{
    /* 
        Moves the sidebar to the top of the screen, below the
        Portal navbar but above the calendar month navabr
    */
    
    #calendarSidebar
    {
        order: 1;
        
        width: 100%;
        height: auto;
        
        margin: 0;
        
        border: none;
        
        background: var(--navbar-background);
    }
    
    #currentTime
    {
        order: 2;
        
        width: 100%;
    }
    
    #calendar
    {
        order: 3;
        
        width: 100%;
        
        /* // TODO: the 55px is the height of the sidebar in this mode. I'd like to not have it hard-coded, but don't know what to do about it. */
        min-height: calc(100dvh - var(--navbar-height) - 38px - 55px);
        max-height: calc(100dvh - var(--navbar-height) - 38px - 55px);
        
        overflow-x: auto;
    }
    
    /* 
        Planner mode shows a top to bottom list
        of days that contain events. Days with no events are hidden.
    */
    
    .planner #calendar
    {
        display: block;
    }
    
    /*  
        Big month mode shows the entire month on the screen as a list of dates, 
        rather than with events on it. Useful for picking a particular day.
    */
    
    .big-month #calendar
    {
        /* // TODO: the 55px is the height of the sidebar in this mode. I'd like to not have it hard-coded, but don't know what to do about it. */
        min-height: calc(100dvh - var(--navbar-height) - 38px - 38px - 55px);
        max-height: calc(100dvh - var(--navbar-height) - 38px - 38px - 55px);
        
        grid-gap: 1px 0;
        grid-auto-rows: min-content;
    }
    
    .big-month #calendarHeading
    {
        width: 100%;
        
        order: 3;
    }
    
    .big-month #calendarHeading span
    {
        font-size: 0;
    }
    
    .big-month #calendarHeading span::first-letter
    {
        font-size: 14px;
    }
    
    /* TODO: eventually, this will need be ordered to end of a row and made a block the width of the portal */
    .big-month .month-heading
    {
        display: none;
    }

    .big-month .day
    {
        padding: 0;
        
        padding: 6px;
        
        border-radius: var(--border-radius);
        
        transition: background-color var(--transition-time);
    }
    
    .big-month .day:hover
    {
        background-color: var(--panel-background);
    }
    
    .big-month .day.other-month
    {
        opacity: 0;
    }
    
    .big-month .day .day-titlebar
    {
        white-space: revert;
        color: var(--text-default);
        font-size: 16px;
    }
    
    .big-month .day .day-titlebar .left,
    .big-month .day .day-titlebar .right
    {
        display: none;
    }
    
    /* Mobile controls */
    
    .mobile-controls
    {
        display: flex;
        gap: 10px;
    }
    
    .mobile-controls > a
    {
        width: revert;
    }
    
    .mobile-controls > form
    {
        flex-grow: 1;
        margin-bottom: 0;
    }
    
    .hide-mobile
    {
        display: none;
    }
}