:root {
    --ebnj-white: #F1EBE3;
    --ebnj-white-darker: #E5DBCF;
    --ebnj-black: #140F0F;
    --ebnj-blue: #21324F;
    --ebnj-red: #480902;
    --ebnj-orange: #CE7939;
    --ebnj-green: #686830;
    --ebnj-yellow: #E7AE5B;
    --ebnj-blue-sky: #B3D8EF;
    --ebnj-grey: #AEA8A2;

    --gutter: clamp(16px, 4vw, 32px);
    --radius: 10px;
}

* {
    margin: 0;
    box-sizing: border-box;
}

*[data-state="hidden"] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--ebnj-white);
    color: var(--ebnj-black);
    overflow-x: hidden;
}

/* Reset for every <button> so it looks like the old divs/links */
button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

:focus-visible {
    outline: 2px solid var(--ebnj-blue);
    outline-offset: 3px;
}

main {
    position: relative;
    background-color: var(--ebnj-white);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 100vh;
    min-height: 100dvh;
    opacity: 0;
    transition: opacity .7s ease-in-out;
}

/* ---------- top bar ---------- */

.top-bar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: max(15px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
    z-index: 3;
}

.brand {
    flex: 0 1 200px;
    min-width: 120px;
    display: flex;
}

.logo {
    width: 100%;
    max-width: 200px;
    height: auto;
}

.separator {
    background-color: var(--ebnj-black);
    height: 20px;
    width: 2px;
    flex-shrink: 0;
}

.user-section {
    display: flex;
    align-items: center;
    gap: 15px;
    min-width: 0;
}

.user-logo-div {
    display: inline-flex;
    align-items: center;
    min-width: 0;
}

.current-user {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 22ch;
}

.user-logo {
    height: 1.2em;
    width: auto;
    margin-left: 10px;
    flex-shrink: 0;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;

    svg {
        width: 40px;
        height: 40px;
    }
}

.nav {
    position: relative;
    padding: 4px 0;
    white-space: nowrap;
}

.nav::after {
    content: "";
    bottom: 0;
    left: 0;
    position: absolute;
    width: 100%;
    height: 2px;
    background-color: var(--ebnj-black);
    z-index: 2;
    transform-origin: left;
    transition: transform .3s ease;
}

.nav[data-selected="true"]::after {
    transform: scaleX(1);
}

.nav[data-selected="false"]::after {
    transform: scaleX(0);
}

/* ---------- phone menu ---------- */

.alt-menu {
    position: fixed;
    inset: 0;
    background-color: var(--ebnj-white-darker);
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 25px;
    justify-content: center;
    align-items: center;
    padding: var(--gutter);
    transition: transform .6s ease, visibility .6s;
    font-size: 1.5rem;

    .current-user {
        max-width: 80vw;
    }
}

.alt-menu[data-state="open"] {
    transform: translateX(0);
    visibility: visible;
}

.alt-menu[data-state="closed"] {
    transform: translateX(100%);
    visibility: hidden;
}

#menu-close-btn {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
}

/* ---------- content ---------- */

.middle {
    width: min(1200px, 100% - 2 * var(--gutter));
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    isolation: isolate;
}

.bg-txt {
    position: absolute;
    left: 0;
    top: 50%;
    width: auto;
    height: min(90vh, 900px);
    transform: translateY(-50%);
    z-index: -2;
    pointer-events: none;
}

.title {
    margin-bottom: 1.5em;
    text-align: center;

    h1 {
        font-size: clamp(22px, 5vw, 32px);
        font-weight: normal;
        line-height: 1.25;
        text-wrap: balance;
    }
}

/* Current / next month buttons under the title */
.month-switch {
    display: inline-flex;
    gap: 4px;
    margin-top: 12px;
    padding: 4px;
    border-radius: 100px;
    background-color: var(--ebnj-white-darker);

    button {
        padding: .35rem 1.1rem;
        border-radius: 100px;
        transition: background-color .3s ease, color .3s ease;
    }

    button[aria-pressed="true"] {
        background-color: var(--ebnj-black);
        color: var(--ebnj-white);
    }
}

.empty-note {
    text-align: center;
    max-width: 36ch;
    margin: 0 auto 20px;
    padding: .8rem 1.2rem;
    border-radius: var(--radius);
    background-color: var(--ebnj-white-darker);
    line-height: 1.4;
}

.title .empty-note {
    margin-top: 14px;
    margin-bottom: 0;
    font-size: 1rem;
}

.calendar-grid.is-empty {
    display: none;
}

/* The member's own Sundays */
.content-cell .text.is-me {
    background-color: var(--ebnj-black);
    color: var(--ebnj-white);
}

#dispo.is-locked .choice-cell {
    cursor: default;
    opacity: .55;
}

#dispo.is-locked .choice-cell:active {
    scale: 1;
}

.legend {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-top: 12px;
    font-size: .95rem;

    span {
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

    span::before {
        content: "";
        width: 12px;
        height: 12px;
        border-radius: 3px;
    }
}

.legend-yes::before {
    background-color: var(--ebnj-green);
}

.legend-no::before {
    background-color: var(--ebnj-red);
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 20px;
    gap: 10px;
}

/* Current month: date | name */
.calendar-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: clamp(56px, 18vw, 80px) 1fr;
    grid-auto-rows: clamp(56px, 18vw, 80px);
    width: min(440px, 100%);
}

.date-cell {
    background-color: var(--ebnj-white-darker);
    aspect-ratio: 1;
    font-size: clamp(1.4rem, 6vw, 2rem);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: var(--radius);
}

.content-cell {
    display: flex;
    min-width: 0;

    .text {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 0 12px;
        background-color: var(--ebnj-white-darker);
        border-radius: var(--radius);
        overflow-wrap: anywhere;
    }
}

/* Next month: date | yes | no */
.choice-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, 1fr);
    width: min(280px, 100%);
}

.choice-cell {
    background-color: var(--ebnj-black);
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: var(--radius);
    transition: background-color .3s ease, scale .2s ease, opacity .3s ease;

    svg {
        pointer-events: none;
    }
}

.choice-cell:active {
    scale: .9;
}

.choice-cell.positive[data-selected="true"] {
    background-color: var(--ebnj-green);
}

.choice-cell.negative[data-selected="true"] {
    background-color: var(--ebnj-red);
}

.choice-cell[data-selected="false"] {
    background-color: var(--ebnj-grey);
}

@media (hover: hover) {
    .choice-cell:hover {
        opacity: .85;
    }

    .button.hollow:hover {
        opacity: .8;
    }

    .nav[data-selected="false"]:hover::after {
        transform: scaleX(.4);
    }
}

.icon-btn {
    height: 30%;
    width: auto;
}

.button {
    text-decoration: none;
    padding: .6rem 1.5rem;
    background-color: var(--ebnj-black);
    color: var(--ebnj-white);
    border-radius: 100px;
    display: flex;
    align-items: center;
    width: fit-content;
    justify-content: center;
    gap: .5rem;
    cursor: pointer;
    transition: background-color .3s ease, color .3s ease, opacity .3s ease;

    svg {
        height: auto;
        width: 1rem;
    }
}

.button.hollow {
    opacity: .5;
    color: var(--ebnj-black);
    background-color: var(--ebnj-white);
    outline: var(--ebnj-black) 2px solid;
    outline-offset: -2px;
}

.button:disabled {
    opacity: .6;
    cursor: wait;
}

.progress {
    font-size: .8em;
    opacity: .75;
}

.progress:empty {
    display: none;
}

.progress[data-complete="true"]::after {
    content: " ✓";
}

.save-area {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-height: 4.5rem;
}

#save-btn[data-visible="false"] {
    opacity: 0;
    pointer-events: none;
}

#save-status {
    min-height: 1.2em;
    text-align: center;
}

#save-status[data-type="ok"] {
    color: var(--ebnj-green);
}

#save-status[data-type="error"] {
    color: var(--ebnj-red);
}

.bottom {
    padding-bottom: max(15px, env(safe-area-inset-bottom));
    display: flex;
    justify-content: center;
}

.notice {
    background-color: var(--ebnj-blue-sky);
    padding: .5rem 1.5rem;
    border-radius: var(--radius);
    width: 80%;
}

/* ---------- user screen ---------- */

#save-user {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: var(--gutter);
    background-color: var(--ebnj-white);
    z-index: 30;
    opacity: 0;
    transition: opacity .7s ease-in-out;

    label {
        font-size: clamp(22px, 5vw, 28px);
    }

    input {
        all: unset;
        text-align: center;
        padding: 1em;
        width: min(300px, 100%);
        background-color: white;
        color: var(--ebnj-black);
        border-radius: 15px;
        border: transparent solid 2px;
        transition: border-color .3s;
        box-sizing: border-box;
        font-size: 16px; /* 16px stops iOS from zooming on focus */
    }

    input:focus {
        border-color: var(--ebnj-black);
    }

    .button {
        transition: opacity .3s ease;
    }

    .button[data-visible="false"] {
        opacity: 0;
        pointer-events: none;
    }
}

/* ---------- breakpoints ---------- */

@media (max-width: 699px) {
    .user-section {
        display: none;
    }

    .user-section-alt {
        display: block;
    }

    .bg-txt {
        opacity: .6;
    }
}

@media (min-width: 700px) {
    .user-section-alt {
        display: none;
    }

    .alt-menu {
        display: none;
    }

    .choice-grid {
        width: min(320px, 100%);
    }
}

/* Short screens (phones in landscape) */
@media (max-height: 500px) and (orientation: landscape) {
    .bg-txt {
        display: none;
    }

    .alt-menu {
        gap: 12px;
        font-size: 1.2rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0s !important;
    }
}
