/* LifeLoggerz Books completion calendar — light public view */

:root {
  --books-calendar-accent: #405cf5;
  --books-calendar-accent-dark: #263ebd;
  --books-calendar-accent-soft: #eef1ff;
  --books-calendar-ink: #0e121b;
  --books-calendar-muted: #626a78;
  --books-calendar-border: #e2e6ee;
  --books-calendar-panel: rgba(255, 255, 255, 0.95);
  --books-calendar-panel-solid: #ffffff;
  --books-calendar-shadow: 0 18px 48px rgba(15, 23, 42, 0.1);
}

.books-calendar,
.books-calendar-dialog,
.books-calendar select,
.books-calendar button {
  color-scheme: light;
}

.books-calendar[hidden] {
  display: none !important;
}

.books-calendar {
  width: 100%;
  padding-inline: clamp(12px, 3vw, 48px);
  color: var(--books-calendar-ink);
  animation: booksCalendarReveal 220ms ease-out;
}

@keyframes booksCalendarReveal {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.books-calendar-shell {
  width: min(1600px, 100%);
  margin-inline: auto;
  padding: clamp(14px, 2vw, 24px);
  border: 1px solid rgba(226, 230, 238, 0.98);
  border-radius: 24px;
  background: var(--books-calendar-panel-solid);
  box-shadow: var(--books-calendar-shadow);
}

.books-calendar-heading,
.books-calendar-dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.books-calendar-heading {
  margin-bottom: 16px;
}

.books-calendar-eyebrow {
  margin: 0 0 4px;
  color: var(--books-calendar-accent-dark);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.books-calendar-title,
.books-calendar-dialog h2 {
  margin: 0;
  color: var(--books-calendar-ink);
  font-size: clamp(1.25rem, 2vw, 1.75rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.books-calendar-description {
  max-width: 72ch;
  margin: 6px 0 0;
  color: var(--books-calendar-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.books-calendar-close,
.books-calendar-dialog-close {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid var(--books-calendar-border);
  border-radius: 999px;
  background: #ffffff;
  color: var(--books-calendar-muted);
  font: inherit;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, color 140ms ease;
}

.books-calendar-close:hover,
.books-calendar-dialog-close:hover {
  transform: translateY(-1px);
  border-color: rgba(64, 92, 245, 0.42);
  color: var(--books-calendar-accent-dark);
}

.books-calendar button:focus-visible,
.books-calendar select:focus-visible,
.books-calendar a:focus-visible,
.books-calendar-dialog button:focus-visible,
.books-calendar-dialog a:focus-visible {
  outline: 2px solid var(--books-calendar-accent);
  outline-offset: 2px;
}

.books-calendar-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}

.books-calendar-nav,
.books-calendar-latest {
  min-height: 38px;
  border: 1px solid var(--books-calendar-border);
  border-radius: 11px;
  background: #ffffff;
  color: var(--books-calendar-ink);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.books-calendar-nav {
  width: 40px;
  padding: 0;
  font-size: 1rem;
}

.books-calendar-latest {
  padding: 8px 12px;
  color: var(--books-calendar-accent-dark);
  font-size: 0.78rem;
}

.books-calendar-nav:hover,
.books-calendar-latest:hover {
  border-color: rgba(64, 92, 245, 0.38);
  background: var(--books-calendar-accent-soft);
}

.books-calendar-nav:disabled,
.books-calendar-latest:disabled {
  opacity: 0.38;
  cursor: default;
}

.books-calendar-picker select {
  min-width: 180px;
  min-height: 38px;
  padding: 7px 34px 7px 12px;
  border: 1px solid var(--books-calendar-border);
  border-radius: 11px;
  background: #ffffff;
  color: var(--books-calendar-ink);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 750;
  text-align: center;
}

.books-calendar-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.books-calendar-metrics > div {
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid var(--books-calendar-border);
  border-radius: 14px;
  background: #f9faff;
  text-align: center;
}

.books-calendar-metrics span {
  display: block;
  color: var(--books-calendar-muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.books-calendar-metrics strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--books-calendar-ink);
  font-size: clamp(1rem, 2vw, 1.32rem);
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.books-calendar-desktop {
  position: relative;
  overflow: visible;
}

.books-calendar-weekdays,
.books-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.books-calendar-weekdays {
  border: 1px solid var(--books-calendar-border);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  background: #f7f8fc;
}

.books-calendar-weekdays span {
  padding: 9px 6px;
  color: var(--books-calendar-muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
}

.books-calendar-grid {
  position: relative;
  overflow: visible;
  border-top: 1px solid var(--books-calendar-border);
  border-left: 1px solid var(--books-calendar-border);
  border-radius: 0 0 16px 16px;
  background: #ffffff;
}

.books-calendar-day {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: clamp(150px, 11vw, 194px);
  padding: 8px;
  overflow: visible;
  border-right: 1px solid var(--books-calendar-border);
  border-bottom: 1px solid var(--books-calendar-border);
  background: #ffffff;
  transition: z-index 0s, background 150ms ease, box-shadow 150ms ease;
}

.books-calendar-day--blank {
  background: #f6f7fa;
}

.books-calendar-day[data-has-books="true"] {
  background: linear-gradient(180deg, #f5f7ff 0, #ffffff 40%);
}

.books-calendar-day:has(.is-stack:hover),
.books-calendar-day:has(.is-stack:focus-within),
.books-calendar-day[data-stack-expanded="true"] {
  z-index: 30;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16);
}

.books-calendar-day-number {
  position: relative;
  z-index: 42;
  display: inline-flex;
  min-width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--books-calendar-muted);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 800;
}

button.books-calendar-day-number {
  background: var(--books-calendar-accent);
  color: #ffffff;
  cursor: pointer;
}

.books-calendar-day-covers {
  position: absolute;
  inset: 36px 8px 8px;
  min-width: 0;
}

.books-calendar-cover,
.books-calendar-agenda-cover {
  display: block;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.books-calendar-cover img,
.books-calendar-agenda-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 1px solid rgba(205, 211, 225, 0.98);
  border-radius: 7px;
  background: #eef0f5;
  box-shadow: 0 5px 13px rgba(15, 23, 42, 0.16);
}

/* A single completion uses the available cell instead of becoming a thumbnail. */
.books-calendar-day-covers.is-single {
  display: grid;
  place-items: center;
}

.books-calendar-day-covers.is-single .books-calendar-cover {
  width: auto;
  height: 100%;
  max-width: 88%;
  max-height: 148px;
  aspect-ratio: 2 / 3;
  transition: transform 150ms ease, filter 150ms ease;
}

.books-calendar-day-covers.is-single .books-calendar-cover:hover,
.books-calendar-day-covers.is-single .books-calendar-cover:focus-visible {
  transform: translateY(-3px) scale(1.025);
  filter: drop-shadow(0 8px 12px rgba(15, 23, 42, 0.15));
}

/* Multiple completions collapse into a stack and fan out on hover, focus, or click. */
.books-calendar-day-covers.is-stack {
  inset-bottom: 26px;
  pointer-events: none;
}

.books-calendar-day-covers.is-stack .books-calendar-cover {
  position: absolute;
  left: 50%;
  bottom: 0;
  z-index: calc(var(--stack-index) + 1);
  width: min(57%, 76px);
  aspect-ratio: 2 / 3;
  pointer-events: auto;
  transform:
    translateX(calc(-50% + var(--collapsed-shift)))
    rotate(var(--collapsed-rotation));
  transform-origin: 50% 100%;
  transition:
    transform 230ms cubic-bezier(.2,.75,.2,1),
    filter 180ms ease;
}

.books-calendar-day-covers.is-stack:hover .books-calendar-cover,
.books-calendar-day-covers.is-stack:focus-within .books-calendar-cover,
.books-calendar-day-covers.is-stack.is-expanded .books-calendar-cover {
  transform:
    translateX(calc(-50% + var(--splay-shift)))
    translateY(-5px)
    rotate(var(--splay-rotation));
}

.books-calendar-day-covers.is-stack .books-calendar-cover:hover,
.books-calendar-day-covers.is-stack .books-calendar-cover:focus-visible {
  z-index: 80;
  filter: drop-shadow(0 9px 13px rgba(15, 23, 42, 0.22));
  transform:
    translateX(calc(-50% + var(--splay-shift)))
    translateY(-11px)
    rotate(0deg)
    scale(1.08);
}

.books-calendar-stack-toggle {
  position: absolute;
  right: 7px;
  bottom: 6px;
  z-index: 45;
  min-height: 23px;
  padding: 3px 7px;
  border: 1px solid rgba(64, 92, 245, 0.24);
  border-radius: 999px;
  background: #ffffff;
  color: var(--books-calendar-accent-dark);
  font: inherit;
  font-size: 0.63rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.08);
}

.books-calendar-stack-toggle:hover,
.books-calendar-stack-toggle[aria-expanded="true"] {
  border-color: var(--books-calendar-accent);
  background: var(--books-calendar-accent-soft);
}

.books-calendar-agenda {
  display: none;
}

.books-calendar-empty {
  margin: 14px 0 0;
  padding: 18px;
  border: 1px dashed var(--books-calendar-border);
  border-radius: 14px;
  color: var(--books-calendar-muted);
  font-size: 0.84rem;
  text-align: center;
}

.books-calendar-empty[hidden] {
  display: none;
}

.books-calendar-dialog {
  width: min(650px, calc(100vw - 28px));
  max-height: min(82vh, 760px);
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--books-calendar-border);
  border-radius: 22px;
  background: #ffffff;
  color: var(--books-calendar-ink);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.26);
}

.books-calendar-dialog::backdrop {
  background: rgba(13, 18, 31, 0.42);
  backdrop-filter: blur(3px);
}

.books-calendar-dialog-shell {
  max-height: min(82vh, 760px);
  overflow-y: auto;
  padding: 20px;
  background: #ffffff;
}

.books-calendar-dialog-heading {
  margin-bottom: 14px;
}

.books-calendar-dialog-heading p[data-calendar-dialog-summary] {
  margin: 5px 0 0;
  color: var(--books-calendar-muted);
  font-size: 0.8rem;
}

.books-calendar-dialog-list {
  display: grid;
  gap: 9px;
}

.books-calendar-dialog-book {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--books-calendar-border);
  border-radius: 13px;
  background: #f8f9fc;
  color: inherit;
  text-decoration: none;
  transition: transform 130ms ease, border-color 130ms ease, background 130ms ease;
}

.books-calendar-dialog-book:hover {
  transform: translateY(-1px);
  border-color: rgba(64, 92, 245, 0.34);
  background: var(--books-calendar-accent-soft);
}

.books-calendar-dialog-book img {
  display: block;
  width: 54px;
  height: 81px;
  object-fit: cover;
  border-radius: 6px;
  background: #eef0f5;
}

.books-calendar-dialog-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.books-calendar-dialog-copy strong,
.books-calendar-dialog-copy span,
.books-calendar-dialog-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.books-calendar-dialog-copy strong {
  font-size: 0.9rem;
}

.books-calendar-dialog-copy span,
.books-calendar-dialog-copy small {
  color: var(--books-calendar-muted);
  font-size: 0.74rem;
}

.books-calendar-dialog-cue {
  color: var(--books-calendar-accent-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.books-calendar-button-icon {
  font-size: 0.92rem;
  line-height: 1;
}

/* Preserve the original List layout; only emphasize its existing completion text. */
.grid[data-book-view="list"] .book-finished-date {
  color: var(--ink, #0e121b);
  font-weight: 900;
}

@media (max-width: 1100px) and (min-width: 761px) {
  .books-calendar-day {
    min-height: 142px;
  }

  .books-calendar-day-covers.is-stack .books-calendar-cover {
    width: min(60%, 66px);
  }

  .books-calendar-stack-toggle {
    font-size: 0.58rem;
  }
}

@media (max-width: 900px) {
  .view-toggle {
    display: flex !important;
    width: max-content;
    max-width: calc(100vw - 20px);
    justify-content: flex-start !important;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
  }

  .view-toggle::-webkit-scrollbar {
    display: none;
  }

  .view-toggle .view-button {
    flex: 0 0 auto;
  }
}

@media (max-width: 760px) {
  .books-calendar {
    padding-inline: 10px;
  }

  .books-calendar-shell {
    padding: 13px;
    border-radius: 18px;
  }

  .books-calendar-heading {
    gap: 10px;
    margin-bottom: 12px;
  }

  .books-calendar-title {
    font-size: 1.2rem;
  }

  .books-calendar-description {
    font-size: 0.79rem;
  }

  .books-calendar-controls {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 38px auto;
    gap: 6px;
  }

  .books-calendar-picker select {
    width: 100%;
    min-width: 0;
    font-size: 0.8rem;
  }

  .books-calendar-metrics {
    gap: 6px;
    margin-bottom: 12px;
  }

  .books-calendar-metrics > div {
    padding: 9px 6px;
  }

  .books-calendar-metrics span {
    font-size: 0.61rem;
  }

  .books-calendar-metrics strong {
    font-size: 0.92rem;
  }

  .books-calendar-desktop {
    display: none;
  }

  .books-calendar-agenda {
    display: grid;
    gap: 8px;
  }

  .books-calendar-agenda-day {
    display: grid;
    grid-template-columns: 52px 88px minmax(0, 1fr);
    gap: 9px;
    align-items: center;
    min-width: 0;
    padding: 8px;
    border: 1px solid var(--books-calendar-border);
    border-radius: 13px;
    background: #ffffff;
  }

  .books-calendar-agenda-date,
  .books-calendar-agenda-copy {
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
  }

  .books-calendar-agenda-date {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 10px;
    background: var(--books-calendar-accent-soft);
    color: var(--books-calendar-accent-dark);
  }

  .books-calendar-agenda-date strong {
    font-size: 1.15rem;
    line-height: 1;
  }

  .books-calendar-agenda-date span {
    margin-top: 3px;
    font-size: 0.62rem;
    font-weight: 750;
  }

  .books-calendar-agenda-covers {
    display: flex;
    min-width: 0;
    align-items: center;
  }

  .books-calendar-agenda-cover {
    width: 31px;
    flex: 0 0 31px;
    margin-left: -7px;
  }

  .books-calendar-agenda-cover:first-child {
    margin-left: 0;
  }

  .books-calendar-agenda-cover img {
    aspect-ratio: 2 / 3;
    border: 2px solid #ffffff;
    border-radius: 5px;
  }

  .books-calendar-agenda-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
    padding: 4px 0;
    text-align: left;
  }

  .books-calendar-agenda-copy strong,
  .books-calendar-agenda-copy span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .books-calendar-agenda-copy strong {
    font-size: 0.76rem;
  }

  .books-calendar-agenda-copy span {
    color: var(--books-calendar-muted);
    font-size: 0.67rem;
  }

  .books-calendar-dialog-shell {
    padding: 15px;
  }

  .books-calendar-dialog-book {
    grid-template-columns: 46px minmax(0, 1fr) auto;
    gap: 9px;
  }

  .books-calendar-dialog-book img {
    width: 46px;
    height: 69px;
  }
}

@media (max-width: 480px) {
  .books-calendar-controls {
    grid-template-columns: 36px minmax(0, 1fr) 36px;
  }

  .books-calendar-latest {
    grid-column: 1 / -1;
    min-height: 32px;
  }

  .books-calendar-agenda-day {
    grid-template-columns: 48px 72px minmax(0, 1fr);
    gap: 7px;
  }

  .books-calendar-agenda-cover {
    width: 27px;
    flex-basis: 27px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .books-calendar,
  .books-calendar-cover,
  .books-calendar-close,
  .books-calendar-dialog-close,
  .books-calendar-dialog-book {
    animation: none !important;
    transition: none !important;
  }
}
