/* css/availability.css
 *
 * The availability calendar of the customer-journey redesign.
 *
 * COLOR MEANS AVAILABLE (inverted 2026-08-11 on Jeroen's feedback -- filled
 * tiles for occupancy read counter-intuitive). Each apartment has its own
 * tint from the brand family: the house is the footer mauve, the studio a
 * Piemonte sage. Top-left triangle = house, bottom-right = studio. Under a
 * single-apartment filter the whole tile carries that apartment's tint when
 * it is free; an occupied day is pale and quiet.
 */

.cigno-availability {
    --ca-house: #7D727B;          /* brand mauve */
    --ca-studio: #97A97C;         /* sage, distinct at a glance */
    --ca-taken: #F3F1EE;          /* occupied: quiet, receding */
    --ca-line: rgba(125, 114, 123, 0.18);
    --ca-radius: 10px;

    font-family: var(--font-primary, 'Nunito', sans-serif);
    color: var(--color-text-primary, #333);
    max-width: 46rem;
    margin: 0 auto;
}

/* ------------------------------------------------------------------ *
 * Toolbar: unit chips left, month navigation right.
 * ------------------------------------------------------------------ */

.ca-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.ca-units { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.ca-unit-chip {
    font: inherit;
    font-size: 0.9rem;
    padding: 0.45rem 1rem;
    border: 1px solid var(--ca-line);
    border-radius: 999px;
    background: #fff;
    color: inherit;
    cursor: pointer;
    transition: border-color 0.25s ease, background 0.25s ease,
                color 0.25s ease, transform 0.15s ease;
}

.ca-unit-chip:hover { border-color: var(--ca-house); transform: translateY(-1px); }

.ca-unit-chip.is-active {
    background: var(--ca-house);
    border-color: var(--ca-house);
    color: #FDFDED;
}

.ca-unit-chip[data-unit="studio"].is-active {
    background: var(--ca-studio);
    border-color: var(--ca-studio);
    color: #fff;
}

.ca-nav { display: flex; gap: 0.4rem; }

.ca-prev, .ca-next {
    width: 2.4rem;
    height: 2.4rem;
    border: 1px solid var(--ca-line);
    border-radius: 50%;
    background: #fff;
    color: var(--ca-house);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.25s ease, color 0.25s ease, transform 0.15s ease;
}

.ca-prev:hover, .ca-next:hover {
    background: var(--ca-house);
    color: #FDFDED;
    transform: translateY(-1px);
}

/* ------------------------------------------------------------------ *
 * Months.
 * ------------------------------------------------------------------ */

.ca-months {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
    gap: 2rem;
    /* Dragging a range must not select text or scroll the page sideways. */
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-y;
}

@keyframes ca-swap-left  { from { opacity: 0; transform: translateX(24px);  } to { opacity: 1; transform: none; } }
@keyframes ca-swap-right { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }

.ca-months.ca-swap-left  { animation: ca-swap-left  0.35s ease both; }
.ca-months.ca-swap-right { animation: ca-swap-right 0.35s ease both; }

.ca-month-title {
    font-family: var(--font-secondary, 'Libre Bodoni', serif);
    font-size: 1.15rem;
    text-align: center;
    margin-bottom: 0.75rem;
    text-transform: capitalize;
}

.ca-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.ca-dow {
    text-align: center;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-secondary, #888);
    padding-bottom: 0.35rem;
}

/* ------------------------------------------------------------------ *
 * Day tiles. Base = occupied (quiet); color appears where something is
 * still free. That way "more availability" literally means more color.
 * ------------------------------------------------------------------ */

.ca-day {
    position: relative;
    aspect-ratio: 1;
    border: 1px solid var(--ca-line);
    border-radius: var(--ca-radius);
    background: var(--ca-taken);
    padding: 0;
    font: inherit;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.2s ease,
                border-color 0.2s ease, background 0.3s ease;
}

.is-view-only .ca-day { cursor: default; }

.ca-day:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(125, 114, 123, 0.25);
    z-index: 1;
}

/* The number sits on a soft pill so it stays readable on every fill. */
.ca-num {
    position: relative;
    z-index: 2;
    font-size: 0.8rem;
    color: #4a4348;
    background: rgba(255, 255, 255, 0.78);
    border-radius: 999px;
    padding: 0.1rem 0.42rem;
}

/* Every view is binary: `is-free` means bookable under the active choice.
 * The single views tint the whole tile; the combined view uses its own
 * identity, the mauve/sage diagonal split carried by the two triangles. */
.ca-tri {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.ca-tri-house {
    clip-path: polygon(0 0, 100% 0, 0 100%);
    background: var(--ca-house);
}

.ca-tri-studio {
    clip-path: polygon(100% 0, 100% 100%, 0 100%);
    background: var(--ca-studio);
}

.is-mode-both .ca-day.is-free .ca-tri { opacity: 1; }

.is-mode-house .ca-day.is-free {
    background: var(--ca-house);
    border-color: var(--ca-house);
}

.is-mode-studio .ca-day.is-free {
    background: var(--ca-studio);
    border-color: var(--ca-studio);
}

/* PARTIAL availability (2026-08-18): a day the active choice cannot deliver,
 * but where one apartment is still free, hints with THAT apartment's own
 * triangle in a transparent tint -- the triangle only, never the whole tile.
 * Full color keeps meaning "bookable under this choice"; the faint corner
 * says "not this choice, but not everything is gone either". */
.is-mode-both .ca-day:not(.is-free).is-house-free  .ca-tri-house  { opacity: 0.35; }
.is-mode-both .ca-day:not(.is-free).is-studio-free .ca-tri-studio { opacity: 0.35; }

.is-mode-house  .ca-day:not(.is-free).is-studio-free .ca-tri-studio { opacity: 0.35; }
.is-mode-studio .ca-day:not(.is-free).is-house-free  .ca-tri-house  { opacity: 0.35; }

/* Past days and days outside the allowed window. */
.ca-day.is-out {
    opacity: 0.3;
    cursor: default;
    background: transparent;
}

.ca-day.is-out .ca-tri { opacity: 0.35; }

.ca-pad { aspect-ratio: 1; }

/* ------------------------------------------------------------------ *
 * Selection (committed and while dragging).
 *
 * The whole run has to read as ONE band, not as two marked ends: a solid
 * charcoal fill over every selected night, bridging the grid gaps towards
 * neighbours that are selected too (has-prev/next-selected), rounded only
 * on the outer edges. The availability tint stays visible underneath at the
 * ends via the ring, and the number flips to cream.
 * ------------------------------------------------------------------ */

.ca-day.is-selected {
    z-index: 2;
    border-color: transparent;
}

/* The band itself, drawn under the number (which sits at z-index 2). */
.ca-day.is-selected::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background: #4a4348;
    border-radius: var(--ca-radius);
    z-index: 1;
    animation: ca-band 0.2s ease both;
}

/* The band animates its SHAPE only. It used to fade in as well, and
 * `animation-fill-mode: both` then pinned opacity at 1 -- which silently
 * overrode the lighter departure treatment below. */

/* Bridge the 4px grid gap, but only towards a selected neighbour. */
.ca-day.has-prev-selected::before { left: -5px; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.ca-day.has-next-selected::before { right: -5px; border-top-right-radius: 0; border-bottom-right-radius: 0; }

@keyframes ca-band {
    from { transform: scaleY(0.6); }
    to   { transform: none; }
}

.ca-day.is-selected .ca-num {
    background: transparent;
    color: #FDFDED;
    font-weight: 600;
}

/* The two ends carry a ring so arrival and departure stay identifiable. */
.ca-day.is-arrival::after,
.ca-day.is-departure::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid #FDFDED;
    border-radius: var(--ca-radius);
    z-index: 2;
    pointer-events: none;
}

/* Departure is not a night, so it carries half the band: you leave that
 * morning. A full fill would claim a night that is not being sold. */
.ca-day.is-departure::before { background: rgba(74, 67, 72, 0.45); }

/* A selected night the active choice cannot deliver -- a typed or dragged
 * range over an occupied day. Warning tint instead of the charcoal band:
 * the problem must be visible where it sits, not only in the hint below. */
.ca-day.is-selected.is-conflict::before { background: #A05252; }

.ca-day.is-departure .ca-num { color: #4a4348; background: rgba(253, 253, 237, 0.85); }
.ca-day.is-departure::after { border-color: #4a4348; }

/* ------------------------------------------------------------------ *
 * Legend and hint.
 * ------------------------------------------------------------------ */

.ca-legend {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--color-text-secondary, #888);
}

.ca-legend-item { display: inline-flex; align-items: center; gap: 0.45rem; }

.ca-legend-tile {
    position: relative;
    width: 1.15rem;
    height: 1.15rem;
    border: 1px solid var(--ca-line);
    border-radius: 4px;
    overflow: hidden;
    background: var(--ca-taken);
    display: inline-block;
}

.ca-legend-tile .ca-tri { opacity: 0; }
.ca-legend-tile.is-free.is-both .ca-tri { opacity: 1; }
.ca-legend-tile.is-free.is-house  { background: var(--ca-house); }
.ca-legend-tile.is-free.is-studio { background: var(--ca-studio); }

/* The partial legend tile mirrors the tiles: faint triangle(s) on the quiet
 * occupied base. */
.ca-legend-tile.is-partial.is-both .ca-tri { opacity: 0.35; }
.ca-legend-tile.is-partial.is-house  .ca-tri-house  { opacity: 0.35; }
.ca-legend-tile.is-partial.is-studio .ca-tri-studio { opacity: 0.35; }

.ca-hint {
    text-align: center;
    margin-top: 0.9rem;
    font-size: 0.9rem;
    min-height: 1.3em;
    color: var(--color-text-secondary, #888);
    transition: color 0.25s ease;
}

.ca-hint.is-warning { color: #a05252; }

/* ------------------------------------------------------------------ */

@media (max-width: 640px) {
    .ca-months { grid-template-columns: 1fr; }
    .ca-toolbar { justify-content: center; }
}
