/* Floating view modal for desk item content */

#floating-view {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur-medium) ease-out, visibility var(--dur-medium) ease-out;
}

#floating-view[aria-hidden="false"] {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
}

/* Backdrop */
#floating-view-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 6, 4, 0.85);
  backdrop-filter: blur(4px);
}

/* Container */
#floating-view-container {
  position: relative;
  width: min(700px, 90vw);
  max-height: min(600px, 85vh);
  overflow: hidden;

  background-color: var(--color-page);
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 1px, rgba(42,21,8,0.015) 1px, rgba(42,21,8,0.015) 2px),
    repeating-linear-gradient(90deg, transparent, transparent 1px, rgba(42,21,8,0.01) 1px, rgba(42,21,8,0.01) 2px),
    radial-gradient(ellipse at 25% 25%, rgba(245,234,214,0.5) 0%, transparent 50%),
    radial-gradient(ellipse at 75% 75%, rgba(215,200,170,0.4) 0%, transparent 50%);

  border: 3px solid var(--color-wood-dark);
  border-radius: 6px;

  box-shadow:
    0 0 0 1px rgba(212,160,96,0.25),
    0 20px 60px rgba(0, 0, 0, 0.5),
    inset 0 2px 4px rgba(255, 255, 255, 0.3);

  transform: translateY(30px);
  opacity: 0;
  transition:
    transform var(--dur-slow) cubic-bezier(0.16, 1, 0.3, 1),
    opacity var(--dur-slow) ease-out;
}

#floating-view[aria-hidden="false"] #floating-view-container {
  transform: translateY(0);
  opacity: 1;
}

/* Close button */
#floating-view-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 10;

  width: 36px;
  height: 36px;
  padding: 0;

  background: rgba(42, 21, 8, 0.15);
  border: 1px solid rgba(42, 21, 8, 0.2);
  border-radius: 50%;

  font-size: 1.5rem;
  line-height: 1;
  color: var(--color-ink);

  cursor: pointer;
  transition: all var(--dur-quick) ease-out;
}

#floating-view-close:hover {
  background: rgba(42, 21, 8, 0.25);
  border-color: rgba(42, 21, 8, 0.35);
  transform: scale(1.1);
}

#floating-view-close:focus-visible {
  outline: 2px solid var(--color-candle-glow);
  outline-offset: 2px;
}

/* Content area */
#floating-view-content {
  width: 100%;
  height: 100%;
  max-height: min(600px, 85vh);
  overflow-y: auto;
  padding: 2rem 1.5rem 1.5rem;
}

/* When showing authors, use flex layout and no scroll on outer container */
#floating-view-content:has(.authors-grid) {
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Let the individual cards scroll */
}

/* Wider container for authors - no parchment backing */
#floating-view-container:has(.authors-grid) {
  width: min(1000px, 96vw);
  max-height: min(700px, 90vh);
  background: transparent;
  background-image: none;
  border: none;
  box-shadow: none;
}

/* Animation for content entering */
#floating-view-content > * {
  animation: floatingContentFadeIn 0.5s ease-out 0.2s backwards;
}

@keyframes floatingContentFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Reduced motion accessibility ---- */
@media (prefers-reduced-motion: reduce) {
  #floating-view,
  #floating-view-container {
    transition: opacity var(--dur-quick) ease-out, visibility var(--dur-quick) ease-out;
  }

  #floating-view-container {
    transform: translateY(0);
  }

  #floating-view-content > * {
    animation: none;
  }
}

/* ---- Authors Grid --- */

h2.authors-title {
  text-align: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  flex-shrink: 0;
  color: var(--color-parchment);
  font-size: 2rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  position: relative;
}

.authors-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 160px;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(232, 220, 200, 0.6) 20%,
    rgba(232, 220, 200, 0.6) 80%,
    transparent
  );
}

.authors-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  flex: 1;
  min-height: 0; /* Important for flex children to shrink */
}

.author-card {
  display: flex;
  flex-direction: column;
  background: rgba(237, 226, 204, 0.95);
  border: 2px solid rgba(212, 160, 96, 0.4);
  border-radius: 8px;
  overflow: hidden;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.2);
}

.author-card-header {
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: rgba(42, 21, 8, 0.05);
  border-bottom: 1px solid rgba(42, 21, 8, 0.1);
}

.author-photo {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  flex-shrink: 0;
}

.author-header-text {
  text-align: left;
}

.author-name {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: normal;
  color: var(--color-ink);
  margin: 0 0 0.25rem;
}

.author-traits {
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--color-ink-faded);
  margin: 0;
}

.author-card-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
}

.author-card-body::-webkit-scrollbar { width: 6px; }
.author-card-body::-webkit-scrollbar-track { background: rgba(42,21,8,0.04); }
.author-card-body::-webkit-scrollbar-thumb {
  background: var(--color-wood-medium);
  border-radius: 3px;
}
.author-card-body::-webkit-scrollbar-thumb:hover {
  background: var(--color-warm-wood);
}

.author-bio {
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--color-ink);
  margin: 0;
}

/* Responsive: stack on smaller screens */
@media (max-width: 600px) {
  .authors-grid {
    grid-template-columns: 1fr;
    height: auto;
    max-height: 70vh;
  }

  .author-card {
    max-height: 350px;
  }

  .author-photo {
    width: 60px;
    height: 60px;
  }
}
