/**
 * Month calendar — toggle sits on .presence-clock__meta with .presence-clock__date
 */

/* Same type rhythm as .presence-clock__date — larger tap target, icon scales with row */
.presence-calendar-btn {
  flex-shrink: 0;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  min-height: 38px;
  margin: 0;
  padding: 7px 8px;
  font-family: var(--font-ui, sans-serif);
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.07em;
  line-height: 1;
  color: rgba(255, 255, 255, 0.52);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.presence-calendar-btn:hover {
  color: rgba(255, 255, 255, 0.82);
  background: rgba(255, 255, 255, 0.06);
}

.presence-calendar-btn:active {
  background: rgba(255, 255, 255, 0.08);
}

.presence-calendar-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(12, 12, 14, 0.9), 0 0 0 4px rgba(255, 200, 160, 0.35);
}

.presence-calendar-btn[aria-expanded='true'] {
  color: rgba(255, 232, 214, 0.95);
  background: rgba(255, 255, 255, 0.08);
}

.presence-calendar-btn__icon {
  display: block;
  pointer-events: none;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

/* Popout — centered, cozy: warm glass, soft blur, roomy padding */
.calendar-popout {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom));
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}

.calendar-popout.is-open {
  opacity: 1;
  visibility: visible;
}

.calendar-popout.is-open .calendar-popout__card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Nearly transparent — keeps the sightseeing photo visible; light dim + soft blur */
.calendar-popout__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.12);
  -webkit-backdrop-filter: blur(4px) saturate(1.05);
  backdrop-filter: blur(4px) saturate(1.05);
  cursor: pointer;
}

.calendar-popout__card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(304px, 94vw);
  padding: 22px 20px 18px;
  background: linear-gradient(
    155deg,
    rgba(38, 32, 30, 0.88) 0%,
    rgba(22, 18, 17, 0.93) 42%,
    rgba(14, 14, 16, 0.96) 100%
  );
  -webkit-backdrop-filter: blur(32px);
  backdrop-filter: blur(32px);
  border-radius: 18px;
  border: 1px solid rgba(255, 210, 185, 0.16);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 2px 24px rgba(255, 160, 120, 0.06),
    0 28px 64px rgba(0, 0, 0, 0.38);
  transform: translateY(12px) scale(0.98);
  opacity: 0;
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease;
}

.calendar-month__header {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 2px 4px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.calendar-month__title {
  margin: 0;
  min-width: 0;
  text-align: center;
  font-family: var(--font-display, Georgia, serif);
  font-size: 1.08rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: rgba(255, 248, 242, 0.98);
}

.calendar-month__nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.calendar-month__nav:hover {
  color: rgba(255, 236, 220, 0.98);
  background: rgba(255, 210, 185, 0.12);
  border-color: rgba(255, 200, 160, 0.28);
}

.calendar-month__nav:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(255, 200, 160, 0.35);
}

.calendar-month__body {
  padding: 16px 4px 8px;
}

.calendar-month__dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  margin: 0 0 10px;
  padding: 0 2px;
}

.calendar-month__dow span {
  text-align: center;
  font-family: var(--font-ui, sans-serif);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 220, 200, 0.42);
}

.calendar-month__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  padding: 0;
}

.calendar-month__cell {
  aspect-ratio: 1;
  max-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui, sans-serif);
  font-size: 0.78rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.calendar-month__cell--muted {
  color: rgba(255, 255, 255, 0.22);
  background: transparent;
}

.calendar-month__cell--today {
  color: rgba(255, 252, 248, 0.99);
  background: rgba(255, 200, 160, 0.22);
  border-color: rgba(255, 200, 160, 0.45);
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(255, 200, 160, 0.12);
}

.calendar-month__hint {
  margin: 10px 0 0;
  padding: 0 8px;
  font-family: var(--font-body, sans-serif);
  font-size: 0.6rem;
  line-height: 1.55;
  letter-spacing: 0.02em;
  color: rgba(255, 224, 210, 0.38);
  text-align: center;
}

.calendar-month__footer {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.calendar-month__today,
.calendar-month__done {
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 12px;
  font-family: var(--font-ui, sans-serif);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.calendar-month__today {
  color: rgba(255, 232, 214, 0.92);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 200, 160, 0.28);
}

.calendar-month__today:hover {
  color: rgba(255, 255, 255, 0.98);
  background: rgba(255, 210, 185, 0.12);
  border-color: rgba(255, 200, 160, 0.42);
}

.calendar-month__done {
  color: rgba(12, 12, 14, 0.92);
  background: linear-gradient(180deg, rgba(255, 236, 224, 0.98) 0%, rgba(255, 200, 170, 0.88) 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset;
}

.calendar-month__done:hover {
  background: linear-gradient(180deg, rgba(255, 244, 236, 1) 0%, rgba(255, 210, 185, 0.95) 100%);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.3) inset;
}

.calendar-month__today:focus-visible,
.calendar-month__done:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(255, 200, 160, 0.35);
}

/* Light theme — match muted date line */
body.theme-light .presence-calendar-btn {
  color: rgba(15, 23, 42, 0.48);
  background: transparent;
}

body.theme-light .presence-calendar-btn:hover {
  color: rgba(15, 23, 42, 0.78);
  background: rgba(15, 23, 42, 0.05);
}

body.theme-light .presence-calendar-btn[aria-expanded='true'] {
  color: rgba(15, 23, 42, 0.88);
  background: rgba(15, 23, 42, 0.06);
}

body.theme-light .calendar-popout__backdrop {
  background: rgba(255, 255, 255, 0.06);
  -webkit-backdrop-filter: blur(3px) saturate(1.02);
  backdrop-filter: blur(3px) saturate(1.02);
}

body.theme-light .calendar-popout__card {
  background: linear-gradient(
    155deg,
    rgba(255, 253, 250, 0.98) 0%,
    rgba(255, 248, 242, 0.96) 45%,
    rgba(250, 245, 240, 0.98) 100%
  );
  border-color: rgba(251, 191, 36, 0.18);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.8) inset,
    0 2px 20px rgba(251, 191, 36, 0.08),
    0 24px 52px rgba(15, 23, 42, 0.1);
}

body.theme-light .calendar-month__title {
  color: rgba(15, 23, 42, 0.94);
}

body.theme-light .calendar-month__dow span {
  color: rgba(15, 23, 42, 0.38);
}

body.theme-light .calendar-month__cell {
  color: rgba(15, 23, 42, 0.88);
  background: rgba(15, 23, 42, 0.03);
}

body.theme-light .calendar-month__cell--muted {
  color: rgba(15, 23, 42, 0.22);
  background: transparent;
}

body.theme-light .calendar-month__cell--today {
  color: rgba(15, 23, 42, 0.95);
  background: rgba(251, 191, 36, 0.18);
  border-color: rgba(245, 158, 11, 0.45);
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.1);
}

body.theme-light .calendar-month__hint {
  color: rgba(15, 23, 42, 0.4);
}

body.theme-light .calendar-month__nav {
  color: rgba(15, 23, 42, 0.45);
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.06);
}

body.theme-light .calendar-month__nav:hover {
  color: rgba(180, 83, 9, 0.95);
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(245, 158, 11, 0.22);
}

body.theme-light .calendar-month__header {
  border-bottom-color: rgba(15, 23, 42, 0.08);
}

body.theme-light .calendar-month__footer {
  border-top-color: rgba(15, 23, 42, 0.08);
}

body.theme-light .calendar-month__today {
  color: rgba(146, 64, 14, 0.95);
  border-color: rgba(245, 158, 11, 0.32);
}

body.theme-light .calendar-month__today:hover {
  color: rgba(15, 23, 42, 0.95);
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(245, 158, 11, 0.42);
}

body.theme-light .calendar-month__done {
  color: rgba(255, 255, 255, 0.98);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.92) 0%, rgba(30, 41, 59, 0.95) 100%);
  border: 1px solid rgba(15, 23, 42, 0.2);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset;
}

body.theme-light .calendar-month__done:hover {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.98) 0%, rgba(15, 23, 42, 0.98) 100%);
  border-color: rgba(15, 23, 42, 0.28);
}

@media (max-width: 480px) {
  .presence-calendar-btn {
    font-size: 0.62rem;
    min-width: 36px;
    min-height: 36px;
    padding: 6px 7px;
  }

  .presence-calendar-btn__icon {
    width: 17px;
    height: 17px;
  }

  .calendar-popout__card {
    width: min(300px, 94vw);
    padding: 20px 16px 16px;
  }

  .calendar-month__body {
    padding: 14px 2px 6px;
  }

  .calendar-month__cell {
    max-height: 36px;
    font-size: 0.75rem;
  }
}
