/* =========================================================
    CALENDAR PAGE  —  Boundary Prime
    Self-contained trio stylesheet. core.css (global reset)
    is loaded first by base.html.

    The whole page is themed through CSS variables: the dark
    palette lives in :root, and body.light-mode swaps the same
    tokens for a warm light palette. Default is dark (matches
    the Events sibling); the toggle follows the booking page.
    ========================================================= */

:root {
    /* Surfaces & text */
    --ink: #f4f2ec;
    --ink-soft: #c3c9d4;
    --slate: #8c98ab;
    --bg: #0a0e17;
    --bg-glow: rgba(201, 165, 92, 0.05);
    --panel: #0f1626;
    --panel-2: #141d30;
    --cell: #131b2c;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.18);

    /* Brand gold (this page's own value family) */
    --accent: #c9a55c;
    --accent-ink: #d8b873;       /* gold text on dark */
    --accent-soft: rgba(201, 165, 92, 0.16);
    --accent-line: rgba(201, 165, 92, 0.55);

    /* Availability states */
    --open: #5cab82;
    --open-soft: rgba(92, 171, 130, 0.14);
    --open-ink: #b9e3cc;
    --limited: #d6a441;
    --limited-soft: rgba(214, 164, 65, 0.16);
    --limited-ink: #ecd39a;
    --full: #c06d7a;
    --full-soft: rgba(192, 109, 122, 0.13);
    --full-ink: #e6b2ba;

    /* Depth */
    --card-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    --cell-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
    --header-scroll-bg: rgba(10, 14, 23, 0.96);

    --serif: 'Playfair Display', serif;
    --display: 'Cinzel', serif;
    --body: 'Montserrat', sans-serif;
}

body.light-mode {
    --ink: #2a2520;
    --ink-soft: #4d463d;
    --slate: #8b8170;
    --bg: #ece6da;
    --bg-glow: rgba(154, 111, 31, 0.06);
    --panel: #fbf9f4;
    --panel-2: #f4efe5;
    --cell: #f6f2ea;
    --border: rgba(42, 37, 32, 0.10);
    --border-strong: rgba(42, 37, 32, 0.22);

    --accent: #9a6f1f;
    --accent-ink: #875f15;
    --accent-soft: rgba(154, 111, 31, 0.12);
    --accent-line: rgba(154, 111, 31, 0.5);

    --open: #2f7d57;
    --open-soft: rgba(47, 125, 87, 0.10);
    --open-ink: #2c6f4c;
    --limited: #a9791a;
    --limited-soft: rgba(169, 121, 26, 0.12);
    --limited-ink: #8c6414;
    --full: #a23b4a;
    --full-soft: rgba(162, 59, 74, 0.09);
    --full-ink: #8f3340;

    --card-shadow: 0 24px 60px rgba(74, 56, 28, 0.12);
    --cell-shadow: 0 10px 24px rgba(74, 56, 28, 0.12);
    --header-scroll-bg: rgba(251, 249, 244, 0.96);
}

body {
    font-family: var(--body);
    background-color: var(--bg);
    background-image: radial-gradient(120% 80% at 50% -10%, var(--bg-glow), transparent 60%);
    background-attachment: fixed;
    color: var(--ink);
    line-height: 1.6;
    transition: background-color 0.45s ease, color 0.45s ease;
}

a { text-decoration: none; color: inherit; }

/* =========================================================
    TOP NAVIGATION HEADER  (markup untouched; themed for both modes)
    ========================================================= */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 36px 60px;
    z-index: 1000;
    transition: background-color 0.3s ease, padding 0.3s ease, box-shadow 0.3s ease;
}

.top-nav.header-scroll {
    background-color: var(--header-scroll-bg);
    padding: 14px 60px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(8px);
}

.top-nav .logo {
    font-family: var(--display);
    font-size: 1.8rem;
    color: var(--ink);
    letter-spacing: 3px;
    text-transform: uppercase;
    transition: color 0.3s;
}

.top-nav .logo:hover { color: var(--accent); }

.top-nav .nav-links { display: flex; gap: 30px; }

.top-nav .nav-links a {
    font-size: 0.8rem;
    color: var(--ink);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 500;
    transition: color 0.3s;
}

.top-nav .nav-links a:hover { color: var(--accent); }

/* =========================================================
    THEME TOGGLE  (page-level control, clears the fixed header)
    ========================================================= */
.theme-toggle {
    position: absolute;
    top: 112px;
    right: 8%;
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--panel);
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    color: var(--ink);
    cursor: pointer;
    box-shadow: var(--cell-shadow);
    transition: color 0.25s, border-color 0.25s, transform 0.25s, background 0.25s;
    z-index: 5;
}

.theme-toggle:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-2px); }
.theme-toggle .moon-icon { display: none; }
body.light-mode .theme-toggle .sun-icon { display: none; }
body.light-mode .theme-toggle .moon-icon { display: block; }

/* =========================================================
    PAGE SHELL + CENTERED INTRO
    ========================================================= */
.calendar-page {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    padding: 150px 6% 110px;
}

.cal-intro {
    text-align: center;
    max-width: 680px;
    margin: 0 auto 60px;
}

.cal-eyebrow {
    display: block;
    font-family: var(--display);
    font-size: 0.72rem;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--accent-ink);
    margin-bottom: 18px;
}

.cal-heading {
    font-family: var(--serif);
    font-size: 3rem;
    font-weight: 400;
    line-height: 1.15;
    letter-spacing: 0.5px;
    margin-bottom: 18px;
}

.cal-directions {
    color: var(--slate);
    font-weight: 300;
    font-size: 1.02rem;
    line-height: 1.8;
    max-width: 560px;
    margin: 0 auto;
}

.cal-rule {
    display: block;
    width: 56px;
    height: 2px;
    margin: 32px auto 0;
    background: linear-gradient(90deg, transparent, var(--accent-line), transparent);
}

/* =========================================================
    LAYOUT
    ========================================================= */
.cal-layout {
    display: grid;
    grid-template-columns: 1.45fr 1fr;
    gap: 32px;
    align-items: start;
}

/* ---------- Month panel ---------- */
.cal-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 34px 34px 28px;
    box-shadow: var(--card-shadow);
}

.cal-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.cal-month-label {
    flex: 1;
    text-align: center;
    font-family: var(--display);
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--ink);
}

.cal-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--ink);
    cursor: pointer;
    transition: border-color 0.25s, color 0.25s, transform 0.25s, background 0.25s;
}

.cal-nav-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
}

.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.cal-weekdays span {
    text-align: center;
    font-size: 0.64rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--slate);
    font-weight: 600;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    touch-action: pan-y;
}

/* A single day cell */
.cal-day {
    position: relative;
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: var(--cell);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--ink);
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.cal-day .day-num {
    font-family: var(--serif);
    font-size: 1.12rem;
    line-height: 1;
}

.cal-day:hover {
    border-color: var(--accent-line);
    transform: translateY(-3px);
    box-shadow: var(--cell-shadow);
}

.cal-day.is-blank {
    background: transparent;
    border-color: transparent;
    cursor: default;
}
.cal-day.is-blank:hover { transform: none; box-shadow: none; }

/* Status dot under the number */
.cal-day .day-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: transparent;
    transition: background 0.2s;
}

.cal-day.is-open .day-dot { background: var(--open); }
.cal-day.is-limited .day-dot { background: var(--limited); }
.cal-day.is-full .day-dot { background: var(--full); }

.cal-day.is-full,
.cal-day.is-past {
    color: var(--slate);
    cursor: not-allowed;
    background: transparent;
    border-color: var(--border);
    opacity: 0.6;
}
.cal-day.is-full:hover,
.cal-day.is-past:hover { transform: none; box-shadow: none; border-color: var(--border); }
.cal-day.is-past .day-num { opacity: 0.7; }

.cal-day.is-today {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.cal-day.is-selected {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-ink);
    box-shadow: 0 0 0 1px var(--accent), var(--cell-shadow);
}
.cal-day.is-selected .day-num { color: var(--accent-ink); }
.cal-day.is-selected .day-dot { background: var(--accent); }

/* Legend */
.cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 22px;
    margin-top: 26px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-size: 0.76rem;
    color: var(--slate);
    letter-spacing: 0.5px;
}

.legend-swatch { width: 9px; height: 9px; border-radius: 50%; }
.legend-swatch.is-open { background: var(--open); }
.legend-swatch.is-limited { background: var(--limited); }
.legend-swatch.is-full { background: var(--full); }
.legend-swatch.is-past { background: var(--slate); opacity: 0.55; }

/* ---------- Day detail island ---------- */
.day-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px;
    box-shadow: var(--card-shadow);
    position: sticky;
    top: 104px;
    min-height: 440px;
    display: flex;
    flex-direction: column;
}

/* Persistent head with the space dropdown (replaces the scrollable tab) */
.day-panel-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 22px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.day-panel-label {
    font-family: var(--display);
    font-size: 0.66rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--slate);
    flex-shrink: 0;
}

.select-wrap { position: relative; flex: 1; }

/* Custom dropdown (native <select> can't be themed for a dark popup) */
.space-dropdown { position: relative; flex: 1; }

.space-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    background: var(--panel-2);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    color: var(--ink);
    font-family: var(--body);
    font-size: 0.9rem;
    letter-spacing: 0.4px;
    padding: 12px 14px 12px 16px;
    cursor: pointer;
    transition: border-color 0.25s, box-shadow 0.25s;
    text-align: left;
}

.space-trigger:hover { border-color: var(--accent-line); }
.space-trigger[aria-expanded="true"] {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.space-trigger .select-chevron {
    flex-shrink: 0;
    color: var(--slate);
    transition: transform 0.25s ease;
}
.space-trigger[aria-expanded="true"] .select-chevron { transform: rotate(180deg); }

.space-options {
    list-style: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 20;
    background: var(--panel);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 6px;
    box-shadow: var(--card-shadow);
    max-height: 280px;
    overflow-y: auto;
}

.space-option {
    padding: 11px 14px;
    border-radius: 6px;
    font-size: 0.88rem;
    letter-spacing: 0.3px;
    color: var(--ink-soft);
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
}

.space-option:hover,
.space-option.is-active {
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.space-option.is-selected {
    color: var(--accent-ink);
    font-weight: 600;
}

.select-chevron {
    color: var(--slate);
    pointer-events: none;
}

/* Empty state */
.day-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 16px;
    color: var(--slate);
    padding: 30px 0;
}
.day-empty svg { color: var(--border-strong); }
.day-empty p { font-weight: 300; }

/* Detail */
.day-detail { padding-top: 24px; }

.day-detail-date {
    font-family: var(--serif);
    font-size: 1.55rem;
    font-weight: 400;
    color: var(--ink);
    line-height: 1.2;
}

.day-detail-sub {
    font-size: 0.78rem;
    color: var(--accent-ink);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-top: 6px;
}

.slot-times {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 24px 0 4px;
}

.slot-time-head {
    text-align: center;
    font-size: 0.6rem;
    letter-spacing: 1px;
    color: var(--slate);
    line-height: 1.5;
}
.slot-time-head strong {
    display: block;
    color: var(--ink);
    font-family: var(--display);
    font-size: 0.68rem;
    letter-spacing: 1.5px;
    margin-bottom: 3px;
}

.space-row {
    border-top: 1px solid var(--border);
    padding: 16px 0;
}
.space-row:last-child { border-bottom: 1px solid var(--border); }

.space-row-name {
    font-size: 0.86rem;
    letter-spacing: 0.4px;
    color: var(--ink);
    margin-bottom: 11px;
    font-weight: 500;
}

.slot-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.slot-cell {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 11px 6px;
    font-size: 0.68rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-align: center;
    background: var(--cell);
    color: var(--slate);
    cursor: default;
    font-weight: 500;
}

.slot-cell.is-open {
    background: var(--open-soft);
    border-color: rgba(92, 171, 130, 0.4);
    color: var(--open-ink);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.slot-cell.is-open:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-ink);
    transform: translateY(-2px);
    box-shadow: var(--cell-shadow);
}

.slot-cell.is-booked {
    background: var(--full-soft);
    border-color: rgba(192, 109, 122, 0.32);
    color: var(--full-ink);
    text-decoration: line-through;
}

/* Partly booked: some of the window is taken, but bookable time remains.
   Amber to sit between open (green) and booked (red). Clickable — the
   inquiry page then restricts the times to what is actually free. */
.slot-cell.is-partial {
    background: var(--limited-soft);
    border-color: rgba(214, 164, 65, 0.45);
    color: var(--limited-ink);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.slot-cell.is-partial:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-ink);
    transform: translateY(-2px);
    box-shadow: var(--cell-shadow);
}

.day-detail-foot {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    font-size: 0.76rem;
    color: var(--slate);
    line-height: 1.65;
}
.day-detail-foot strong { color: var(--accent-ink); font-weight: 600; }

.day-status {
    text-align: center;
    color: var(--slate);
    padding: 50px 0;
    font-weight: 300;
}

/* =========================================================
    MOBILE
    ========================================================= */
.mobile-menu-btn, .mobile-close-btn { display: none; }

@media (max-width: 980px) {
    .cal-layout { grid-template-columns: 1fr; gap: 24px; }
    .day-panel { position: static; min-height: 0; }
}

@media (max-width: 900px) {
    .top-nav { padding: 15px 20px; }
    .top-nav.header-scroll { padding: 15px 20px; }
    .top-nav .logo { font-size: 1.2rem; position: relative; z-index: 101; }

    .mobile-menu-btn {
        display: flex; flex-direction: column; align-items: center;
        background: none; border: none; color: var(--ink); cursor: pointer;
        position: relative; z-index: 101;
    }
    .mobile-menu-btn span { font-size: 0.55rem; margin-top: 4px; letter-spacing: 1px; }

    .nav-links {
        position: fixed; top: 0; left: 0; width: 100%; height: 100vh;
        background: var(--bg); flex-direction: column; justify-content: center;
        align-items: center; gap: 40px; z-index: 1001;
        opacity: 0; visibility: hidden; transition: all 0.3s ease;
    }
    body.menu-open .nav-links { opacity: 1; visibility: visible; }
    body.menu-open { overflow: hidden; }

    .mobile-close-btn {
        display: block; position: absolute; top: 20px; right: 20px;
        background: none; border: none; color: var(--ink); font-size: 2rem; cursor: pointer;
    }

    .top-nav .nav-links a { font-size: 1.2rem; }

    .calendar-page { padding: 120px 6% 70px; }
    .theme-toggle { top: 80px; right: 6%; width: 42px; height: 42px; }
    .cal-heading { font-size: 2.2rem; }
    .cal-panel { padding: 22px 20px; }
    .day-panel { padding: 22px 20px; }
    .cal-grid, .cal-weekdays { gap: 7px; }
    .cal-day .day-num { font-size: 1rem; }
}

@media (max-width: 460px) {
    .cal-heading { font-size: 1.9rem; }
    .cal-day { aspect-ratio: auto; min-height: 50px; gap: 5px; }
    .day-panel-head { flex-direction: column; align-items: stretch; gap: 10px; }
    .day-panel-label { letter-spacing: 1.5px; }
    .slot-cell { font-size: 0.6rem; padding: 9px 3px; letter-spacing: 1px; }
}

/* =========================================================
    A11Y FLOOR
    ========================================================= */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
    .cal-day:hover, .slot-cell.is-open:hover, .slot-cell.is-partial:hover, .cal-nav-btn:hover, .theme-toggle:hover { transform: none; }
}
/* ============================================
   BETA PATCH — SWIPE PEEK ANIMATION
   The month grid follows the finger during a swipe and the adjacent month
   slides in beside it. The live drag offset is the --swipe-dx custom
   property set on the viewport by calendar.js; all visuals live here.
   ============================================ */
.cal-grid-viewport {
    position: relative;
    overflow: hidden;
    touch-action: pan-y;
}
.cal-grid-viewport .cal-grid {
    transform: translateX(var(--swipe-dx, 0px));
}
/* No easing while the finger is down (the grid tracks 1:1) or during the
   post-swipe reset; easing only on the commit / snap-back glide. */
.cal-grid-viewport.is-dragging .cal-grid,
.cal-grid-viewport.no-anim .cal-grid {
    transition: none;
}
.cal-grid-viewport.is-animating .cal-grid {
    transition: transform 0.28s ease;
}
/* The incoming month, parked one grid-width (plus a gap) to the side so it
   peeks in as you drag. Percentages resolve against the ghost's own width,
   which equals the viewport width. */
.cal-grid-ghost {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    pointer-events: none;
}
.cal-grid-viewport .cal-grid-ghost.ghost-next {
    transform: translateX(calc(100% + 24px + var(--swipe-dx, 0px)));
}
.cal-grid-viewport .cal-grid-ghost.ghost-prev {
    transform: translateX(calc(-100% - 24px + var(--swipe-dx, 0px)));
}
