/* ============================================================================
   Lancalot — My Calendar multi-calendar chrome (#11–#13)
   ----------------------------------------------------------------------------
   ADDITIVE ONLY. Loaded after styles.css. Reuses .calendar / .calendar__corner /
   __head / __name / __body / .booking-layer / .booking-item / day headers /
   weekend bands. Adds: the stacked multi-row Timeline grid, per-calendar rail
   chrome (name / public-private / delete), the "+ New calendar" affordance, the
   Month rail selector, the empty state, and the create/confirm modal. No token
   or core class is overridden.
   ========================================================================== */

/* ── Timeline: stacked editable rows (rows set inline by app.js) ──────────────── */
.calendar--multi {
  grid-template-columns: var(--gutter) 1fr;
  align-content: start;
}
.calendar--multi .calendar__name,
.calendar--multi .calendar__body {
  border-top: 1px solid var(--head-border);
  min-height: 0;
  height: 100%;
}
.calendar--multi .calendar__name.is-first,
.calendar--multi .calendar__body[data-row="0"] {
  border-top: none;
}

/* Per-calendar rail chrome */
.cal-rail {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  height: 100%;
  padding: 12px 14px;
}
/* Action icons are lifted out of the name's row into the top-right corner so
   the name gets the full gutter width to itself. They fade in on rail hover. */
.cal-rail__actions {
  position: absolute;
  top: 10px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.cal-rail__top {
  display: flex;
  align-items: center;
  min-width: 0;
}
.cal-rail__name {
  flex: 1;
  min-width: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  cursor: text;
  border-radius: 6px;
  padding: 1px 3px;
  margin: -1px -3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-rail__name:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.cal-rail__name-input {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  width: 100%;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 2px 5px;
  background: var(--card);
}
.cal-rail__del {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.cal-rail__del svg { width: 15px; height: 15px; }
.cal-rail:hover .cal-rail__del,
.cal-rail__del:focus-visible { opacity: 1; }
.cal-rail__del:hover {
  color: #cf4034;
  border-color: color-mix(in srgb, #cf4034 32%, transparent);
  background: color-mix(in srgb, #cf4034 8%, transparent);
}

/* #14 manage-access control on owned rails (same fade-in treatment as the bin,
   accent hover instead of red). It takes the auto margin so the pair sits
   flush-right; the bin drops its own to stay adjacent. */
.cal-rail__share {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.cal-rail__share svg { width: 15px; height: 15px; }
.cal-rail:hover .cal-rail__share,
.cal-rail__share:focus-visible { opacity: 1; }
.cal-rail__share:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 32%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.cal-rail__share + .cal-rail__del { margin-left: 0; }

/* Public/Private toggle */
.cal-vis {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 3px 10px 3px 8px;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.cal-vis svg { width: 13px; height: 13px; }
.cal-vis:hover { filter: brightness(0.97); }
.cal-vis--public {
  color: #2f6b4f;
  background: color-mix(in srgb, #2f9e6b 14%, transparent);
  border: 1px solid color-mix(in srgb, #2f9e6b 30%, transparent);
}
.cal-vis--private {
  color: var(--muted);
  background: color-mix(in srgb, var(--text) 6%, transparent);
  border: 1px solid var(--head-border);
}

/* "+ New calendar" footer rail (spans the gutter; body cell stays blank) */
.cal-rail-add {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border-top: 1px solid var(--head-border);
}
.cal-rail-add-body { border-top: 1px solid var(--head-border); }
.cal-add-btn {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s ease;
}
.cal-add-btn:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* ── Granted (shared-with-me) rows ────────────────────────────────────────────
   #14: my own bookings on a granted row render as normal editable cards; only
   OTHER people's bookings get the read-only/masked treatment below. */
.calendar--multi .calendar__body { position: relative; }
.calendar__body--ro .booking-layer { cursor: grab; }
.calendar__body--ro .booking-layer:active { cursor: grabbing; }

.booking-item--ro { cursor: default; }
.booking-item--ro:hover { box-shadow: var(--shadow-rest); }
.booking-item--ro:active { cursor: default; }
.booking-status--static { cursor: default; pointer-events: none; }
.booking-status--static:hover { box-shadow: none; }

/* ── #15 masking: other people's bookings on a granted calendar ──────────────
   A pale, inert echo of the owner's "unavailable" card: washed-out tint, dashed
   edge, flat (no shadow, no hover lift), and pointer-events none — so it reads
   as unclickable and the timeline pan starts even when grabbing over a card. */
.booking-item--masked {
  background: color-mix(in srgb, #e8736a 6%, var(--card));
  border: 1px dashed color-mix(in srgb, #c43b30 30%, transparent);
  border-left: 3px solid color-mix(in srgb, #cf4034 35%, transparent);
  box-shadow: none;
  pointer-events: none;
}
.booking-item--masked:hover { box-shadow: none; }
.booking-item--masked .booking-title {
  color: color-mix(in srgb, #6b1f1c 48%, var(--card));
  font-weight: 600;
}
.booking-item--masked .booking-dates { color: color-mix(in srgb, #a8534c 55%, var(--card)); }
.booking-item--masked .booking-status {
  background: color-mix(in srgb, #cf4034 38%, var(--card));
  box-shadow: none;
}

/* #14b locked card: MY booking on a View-only grant — keeps its real type
   colours + title (I always see my own detail) but is inert: no affordances,
   no hover lift, and pans start through it like a masked card. */
.booking-item--locked {
  pointer-events: none;
  box-shadow: none;
}
.booking-item--locked:hover { box-shadow: none; }

/* #14 provenance: small "Placed by <email>" line on bookings a grantee placed
   (rendered on the owner's editable cards only). */
.booking-placed-by {
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-rail--granted .cal-rail__name { cursor: default; }
.cal-rail--granted .cal-rail__name:hover { background: transparent; }
.cal-rail__owner {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-rail__badge {
  align-self: flex-start;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 2px 9px;
}
.cal-rail__badge--ro {
  color: var(--muted);
  background: color-mix(in srgb, var(--text) 7%, transparent);
  border: 1px solid var(--head-border);
}
.cal-rail__badge--pending {
  color: #8a6d1a;
  background: color-mix(in srgb, #e8b62c 18%, transparent);
  border: 1px solid color-mix(in srgb, #e8b62c 40%, transparent);
}

/* Pending placeholder filling a row / the month body */
.row-pending {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  pointer-events: none;
}
.row-pending--month { position: relative; min-height: 120px; }

/* Add-calendar chooser (Create vs. find someone's) */
.add-choice { display: flex; flex-direction: column; gap: 10px; }
.add-choice__btn {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  font: inherit;
  background: var(--card);
  border: 1px solid var(--head-border);
  border-radius: 11px;
  padding: 14px 15px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.add-choice__btn:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.add-choice__btn strong { font-size: 0.92rem; color: var(--text); }
.add-choice__btn span { font-size: 0.8rem; color: var(--muted); }

.month-rail__item--granted .month-rail__vis { color: var(--muted); }

/* ── Empty state (no calendars yet) ─────────────────────────────────────────── */
.calendar-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 64px 24px;
  text-align: center;
  color: var(--muted);
}
.calendar-empty svg { width: 36px; height: 36px; opacity: 0.5; }
.calendar-empty h2 { margin: 0; font-size: 1rem; font-weight: 700; color: var(--text); }
.calendar-empty p { margin: 0; font-size: 0.88rem; max-width: 320px; }
.calendar-empty button {
  margin-top: 4px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 16px;
  cursor: pointer;
}
.calendar-empty button:hover { filter: brightness(0.95); }

/* ── Month rail (calendar selector list) ────────────────────────────────────── */
.calendar--month > .calendar-month__rail { grid-area: name; }
.calendar-month__rail {
  background: var(--gutter-bg);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 10px;
  border-right: 1px solid var(--head-border);
}
.month-rail__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  font: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 11px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.month-rail__item:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.month-rail__item.is-active {
  background: var(--card);
  border-color: var(--head-border);
  box-shadow: var(--shadow-rest);
}
.month-rail__name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.month-rail__vis { font-size: 0.7rem; font-weight: 600; color: var(--muted); }
.month-rail__add {
  margin-top: 4px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 8px;
  padding: 7px 11px;
  cursor: pointer;
}
.month-rail__add:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* ── Modal (create calendar / delete confirm) ───────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: color-mix(in srgb, #1a1410 45%, transparent);
  backdrop-filter: blur(2px);
}
.modal {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 18px 50px -12px rgba(20, 16, 12, 0.4);
  padding: 22px;
}
.modal__title { margin: 0 0 14px; font-size: 1.05rem; font-weight: 700; color: var(--text); }
.modal__body { display: flex; flex-direction: column; gap: 14px; }
.modal-text { margin: 0; font-size: 0.9rem; color: var(--text); line-height: 1.5; }
.modal-field { display: flex; flex-direction: column; gap: 6px; }
.modal-field > span { font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.modal-field input {
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--head-border);
  border-radius: 9px;
  padding: 9px 11px;
}
.modal-field input:focus { outline: none; border-color: var(--accent); }
/* Two fields side-by-side (#18 edit-profile: first + last name). */
.modal-field-row { display: flex; gap: 10px; }
.modal-field-row .modal-field { flex: 1; min-width: 0; }
.modal-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 0.84rem;
  color: var(--text);
  line-height: 1.45;
}
.modal-check input { margin-top: 2px; flex-shrink: 0; }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-btn {
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  border-radius: 9px;
  padding: 8px 16px;
  cursor: pointer;
  border: 1px solid transparent;
}
.modal-btn--ghost { color: var(--muted); background: transparent; border-color: var(--head-border); }
.modal-btn--ghost:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.modal-btn--primary { color: var(--on-accent); background: var(--accent); }
.modal-btn--primary:hover { filter: brightness(0.95); }
.modal-btn--danger { color: #fff; background: #cf4034; }
.modal-btn--danger:hover { filter: brightness(0.95); }
.modal-btn:disabled { opacity: 0.6; cursor: default; }

/* #14 manage-access modal: one row per grantee */
.access-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}
.access-row__who { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.access-row__controls { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* #14b per-grantee tier toggle (Can book | View only) */
.access-toggle {
  display: inline-flex;
  border: 1px solid var(--head-border);
  border-radius: 999px;
  padding: 2px;
  background: color-mix(in srgb, var(--text) 4%, transparent);
}
.access-toggle.is-busy { opacity: 0.6; pointer-events: none; }
.access-toggle__btn {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.access-toggle__btn:hover { color: var(--text); }
.access-toggle__btn.is-active {
  color: var(--on-accent);
  background: var(--accent);
  cursor: default;
}
.access-row__name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.access-row__email {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.access-row__remove { flex-shrink: 0; }

/* #17 transfer-ownership section at the bottom of the manage-access modal */
.transfer-sec {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--head-border);
}
.transfer-sec__title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.transfer-form { display: flex; gap: 8px; }
.transfer-form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--head-border);
  border-radius: 9px;
  padding: 8px 11px;
}
.transfer-form input:focus { outline: none; border-color: var(--accent); }
.transfer-hint { margin: 0; font-size: 0.8rem; color: #a04b42; line-height: 1.4; }
