/* ---------------------------------------------------------------
 * Palette: matches ppc-puzzle-designer.css
 * ------------------------------------------------------------- */
.c-main-cn {
    --c-color: #6495ed;      /* same as --pd-color */
    --c-panel: lightgray;
    --c-tile: whitesmoke;
    --c-tile-weekend: darkgray;     /* Saturdays and Sundays */
    --c-open-outline: var(--c-accent); /* outline on open signup days */
    --c-hover: lightsteelblue;
    --c-text: #3A4F66;
    --c-text-muted: #3A4F6677;
    --c-accent: #3EB489;            /* designer's price / active-tab green */
    --c-radius: 1rem;
    --c-underline: 4px;             /* green underline thickness, drawn as an inset shadow so it takes no space */
}

/* ---------------------------------------------------------------
 * Layout
 * ------------------------------------------------------------- */
.c-main-cn {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: var(--c-color);
    border-radius: var(--c-radius);
    padding: 1rem;
    user-select: none;
}
.c-main-cn *,
.c-main-cn *::before,
.c-main-cn *::after {
    box-sizing: border-box;
    color: var(--c-text);
}
.c-main-cn *:not(.material-symbols-rounded) {
    font-family: 'Jost', sans-serif;
}
.c-main {
    display: flex;
    flex-direction: row;
    gap: 1rem;
}
h1, h2, h3, h4, h5, h6, p, ul, ol, figure {
    padding: 0 auto;
    margin: 0 auto;
}
.c-hidden {
    display: none;
}

/* page header: title centered, Help button on the right */
.c-main-cn-hr {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--c-panel);
    border-radius: var(--c-radius);
    padding: 0.5rem;
}
.c-main-cn-hr p {
    margin: 0 auto;
    font-size: 2rem;
    font-weight: bold;
    text-align: center;
}
.c-main-h-cn {
    grid-column: 2;
}
.c-header-btn {
    grid-column: 3;
    justify-self: end;
}

/* ---------------------------------------------------------------
 * Buttons: same as the designer's .pd-btn
 * ------------------------------------------------------------- */
.c-btn {
    display: flex;
    flex-flow: row;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    background-color: var(--c-tile);
    border-radius: var(--c-radius);
    padding: 0.5rem;
    font-size: 1rem;
    cursor: pointer;
}
.c-btn:hover {
    background-color: var(--c-hover);
}
.c-btn:active,
.c-btn:active span {
    background-color: var(--c-color);
    color: white;
}

/* ---------------------------------------------------------------
 * Popover: same as the designer's .pd-popover
 * ------------------------------------------------------------- */
.c-popover:popover-open {
    display: flex;
}
.c-main-cn .c-popover {
    /* restate the browser's popover centering in case the theme resets div margins */
    position: fixed;
    inset: 0;
    margin: auto;
    z-index: 99;
    flex-flow: column nowrap;
    gap: 0.5rem;
    width: min(340px, calc(100vw - 2rem));
    height: max-content;
    max-height: calc(100vh - 2rem);
    background-color: var(--c-panel);
    border: 2px solid var(--c-text);
    border-radius: var(--c-radius);
    padding: 1rem;
}
.c-popover-close {
    display: flex;
    flex-flow: row nowrap;
    gap: 0.5rem;
}
.c-popover-close h2 {
    flex-grow: 1;
    margin: 0;
    background-color: var(--c-tile);
    border-radius: var(--c-radius);
    padding: 0.5rem;
    font-size: 1.5rem;
    line-height: 1;
    text-align: center;
}
.c-popover-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
    background-color: var(--c-tile);
    border-radius: var(--c-radius);
    padding: 0.75rem 1rem;
    user-select: text;
}
.c-popover-text h5 {
    margin: 0.5rem 0 0;
    font-size: 1rem;
    font-weight: bold;
}
.c-popover-text h5:first-child {
    margin-top: 0;
}
.c-popover-text p {
    margin: 0;
    line-height: 1.4;
}
.c-main-cn .c-popover-text a {
    color: var(--c-color);
    font-weight: bold;
}

/* left and right panels */
.c-cn-left,
.c-cn-right {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0.5rem;
    min-width: 0;   /* let the panels shrink below their content on narrow screens */
    background-color: var(--c-panel);
    border-radius: var(--c-radius);
    padding: 0.5rem;
}

/* ---------------------------------------------------------------
 * Month navigation
 * ------------------------------------------------------------- */
.c-hr {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.c-header-title {
    display: flex;
    flex-direction: row;
    flex-grow: 1;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background-color: var(--c-tile);
    border-radius: var(--c-radius);
    padding: 0.5rem;
    font-size: 1.5rem;
    font-weight: bold;
}
.c-prev,
.c-next {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--c-tile);
    border-radius: var(--c-radius);
    padding: 0.5rem;
    cursor: pointer;
}
.c-prev:hover,
.c-next:hover {
    background-color: var(--c-hover);
}
.c-prev:active,
.c-next:active,
.c-prev:active span,
.c-next:active div {
    background-color: var(--c-color);
    color: white;
}
.c-prev.c-nav-disabled,
.c-next.c-nav-disabled {
    pointer-events: none;
    cursor: default;
    opacity: 0.4;
}

/* ---------------------------------------------------------------
 * Calendar grid
 * ------------------------------------------------------------- */
.c-weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.5rem;
    padding: 0 0.5rem;
    text-align: center;
}
.c-weekdays div {
    color: var(--c-text-muted);
    font-weight: bold;
    border-bottom: 2px solid var(--c-text-muted);
}
.c-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: repeat(6, 1fr);
    flex: 1;
    gap: 0.5rem;
    padding: 0.5rem;
}
.c-days div {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--c-tile);
    border-radius: var(--c-radius);
    padding: 1rem;
}

/* Saturdays and Sundays */
.c-days div.weekend {
    background-color: var(--c-tile-weekend);
}

/* open signup days: outlined so they stand out from closed ones */
.c-days div.available {
    outline: 2px solid #6495ed77;
}
.c-days div:not(.disabled):hover {
    cursor: pointer;
    background-color: var(--c-hover);
}

/* closed days */
.c-days div.disabled {
    pointer-events: none;
    cursor: default;
    opacity: 0.4;
}

/* days from the neighboring months */
.c-days div.prev-date,
.c-days div.next-date {
    pointer-events: none;
    cursor: default;
    background-color: transparent;
    opacity: 0.4;
}

/* today: green underline, like the designer's active tab */
.c-days div.today {
    font-weight: bold;
    box-shadow: inset 0 calc(var(--c-underline) * -1) 0 var(--c-accent);
}

/* chosen day: same as a checked .pd-btn */
.c-days div.selected,
.c-days div.selected:hover {
    background-color: var(--c-color);
    color: white;
    font-weight: bold;
}

/* ---------------------------------------------------------------
 * Selected date
 * ------------------------------------------------------------- */
.c-selected-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    background-color: var(--c-tile);
    border-radius: var(--c-radius);
    padding: 0.75rem 1rem;
    text-align: center;
}
.c-selected-date-label {
    font-size: 0.85rem;
    font-weight: bold;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--c-text-muted);
}
.c-main-cn .c-selected-date-value {
    font-size: 1rem;
    color: var(--c-text-muted);
}
.c-main-cn .c-selected-date-value.has-date {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--c-text);
}
.c-selected-date:has(.has-date) {
    box-shadow: inset 0 calc(var(--c-underline) * -1) 0 var(--c-accent);
}

/* ---------------------------------------------------------------
 * Signup form
 * ------------------------------------------------------------- */
.c-cn-right form {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0.5rem;
}
.c-cn-right form input,
.c-cn-right form select {
    width: 100%;
    height: auto;   /* Blocksy fixes fields at 40px, which clips the text with our padding */
    margin: 0;
    font-size: 1rem;
    line-height: 1.25;
    background-color: var(--c-tile);
    border: 2px solid transparent;
    border-radius: var(--c-radius);
    padding: 0.75rem 1rem;
    box-shadow: none;
    appearance: none;
    -webkit-appearance: none;
}
.c-cn-right form input::placeholder {
    color: var(--c-text-muted);
    opacity: 1;
}
.c-cn-right form select {
    padding-right: 3rem;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%233A4F66' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.1rem;
}
/* show the "Number of players" prompt in placeholder color until a value is picked */
.c-cn-right form select:invalid {
    color: var(--c-text-muted);
}
.c-cn-right form select option {
    color: var(--c-text);
}
.c-cn-right form input:not([type="submit"]):hover:not(:disabled),
.c-cn-right form select:hover:not(:disabled) {
    border-color: var(--c-hover);
}
/* Blocksy swaps the background to its own (transparent) focus color while typing; keep ours */
.c-cn-right form input:focus,
.c-cn-right form select:focus {
    outline: none;
    color: var(--c-text);
    background-color: var(--c-tile);
    border-color: var(--c-color);
}
/* same for the browser's autofill tint */
.c-cn-right form input:-webkit-autofill,
.c-cn-right form input:-webkit-autofill:hover,
.c-cn-right form input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--c-tile) inset;
    -webkit-text-fill-color: var(--c-text);
}
/* same as the designer's #ppcSubmitBtn */
.c-cn-right form input[type="submit"] {
    cursor: pointer;
    font-weight: bold;
    color: white;
    background-color: var(--c-color);
}
.c-cn-right form input[type="submit"]:not(:disabled):hover {
    background-color: var(--c-hover);
    color: var(--c-text);
}
.c-cn-right form input:disabled,
.c-cn-right form select:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* ---------------------------------------------------------------
 * Payment (Square)
 * ------------------------------------------------------------- */
.c-payment {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background-color: var(--c-tile);
    border-radius: var(--c-radius);
    padding: 0.75rem 1rem 0.25rem;
}
.c-price {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.4rem;
    color: var(--c-text-muted);
}
.c-main-cn .c-price strong {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--c-accent);   /* same green as the designer's price */
}
/* Square draws its own fields inside; this just reserves room while it loads */
.c-card {
    min-height: 56px;
}
.c-main-cn .c-test-mode {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    text-align: center;
    color: #996800;
}
.c-main-cn .c-receipt {
    color: var(--c-color);
    font-weight: bold;
}
.c-receipt[hidden] {
    display: none;
}

/* ---------------------------------------------------------------
 * Signup result
 * ------------------------------------------------------------- */
/* honeypot: off-screen so people never see it, but bots still fill it in */
.c-cn-right form .c-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
.c-main-cn .c-form-message {
    background-color: #fdecea;
    color: #b3261e;
    border-radius: var(--c-radius);
    padding: 0.75rem 1rem;
    font-weight: bold;
}
.c-form-message[hidden],
.c-success[hidden],
.c-form[hidden] {
    display: none;
}
.c-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--c-tile);
    border-radius: var(--c-radius);
    padding: 1.5rem 1rem;
    text-align: center;
    box-shadow: inset 0 calc(var(--c-underline) * -1) 0 var(--c-accent);
}
.c-success h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: bold;
}
.c-success p {
    margin: 0;
}
.c-success .c-btn {
    margin-top: 0.5rem;
    border: none;
    font-weight: bold;
}

/* ---------------------------------------------------------------
 * Media queries
 * ------------------------------------------------------------- */
@media (max-width: 800px) {
    .c-main {
        flex-direction: column;
    }
    .c-main-cn-hr p {
        font-size: 1.5rem;
    }
    .c-btn-text {
        display: none;
    }
}

/* phones: smaller tiles and tighter spacing so the whole month fits */
@media (max-width: 480px) {
    .c-main-cn,
    .c-main {
        gap: 0.5rem;
    }
    .c-main-cn {
        padding: 0.5rem;
    }
    /* title on the left, Help on the right */
    .c-main-cn-hr {
        grid-template-columns: 1fr auto;
    }
    .c-main-h-cn {
        grid-column: 1;
    }
    .c-header-btn {
        grid-column: 2;
    }
    .c-main-cn-hr p {
        font-size: 1.25rem;
        text-align: left;
        margin: 0 0 0 0.5rem;
    }
    .c-header-title {
        font-size: 1.25rem;
    }
    .c-weekdays {
        gap: 0.25rem;
        padding: 0;
        font-size: 0.85rem;
    }
    .c-days {
        gap: 0.25rem;
        padding: 0.25rem 0 0;
    }
    .c-days div {
        aspect-ratio: 1;
        padding: 0;
        border-radius: 0.5rem;
    }
}
