/**
 * Shared: truncated clickable description + Materialize modal with scrollable body.
 */

.desc-clickable-wrap {
  position: relative;
  width: 100%;
  margin: 0.75rem auto;
  cursor: pointer;
  padding: 0.5rem 0;
  border-radius: 8px;
  transition: background-color 0.2s ease;
  box-sizing: border-box;
}

.desc-clickable-wrap:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

.desc-clickable-truncated {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

.desc-clickable-truncated::after {
  content: ' \2026 Read more';
  font-size: 0.9rem;
  font-weight: 600;
}

.desc-clickable-full {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/**
 * Materialize's .modal is the positioned shell (often ~70% viewport tall).
 * base.html applies html.theme-dark .modal { background: var(--surface) } which
 * paints that whole shell dark — fix: keep the shell transparent; only the inner
 * .desc-modal__content is the visible card. Shrink-wrap height so short copy
 * does not leave a towering empty panel.
 */
.desc-modal.modal,
html.theme-dark .modal.desc-modal {
  max-width: 520px !important;
  width: 90% !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  margin-left: auto !important;
  margin-right: auto !important;
  border-radius: 0;
  overflow: visible !important;
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

.desc-modal .desc-modal__content,
.desc-modal .modal-content.desc-modal__content {
  position: relative;
  padding: 2.25rem 2.5rem 1.5rem 1.5rem;
  overflow: hidden;
  max-height: min(85vh, 100dvh - 2rem);
  width: 100%;
  box-sizing: border-box;
  border: none !important;
  border-radius: 12px !important;
  -webkit-border-radius: 12px !important;
  background: #fff;
  display: flex;
  flex-direction: column;
  flex: 0 1 auto;
  box-shadow: 0 24px 38px 3px rgba(0, 0, 0, 0.14), 0 9px 46px 8px rgba(0, 0, 0, 0.12),
    0 11px 15px -7px rgba(0, 0, 0, 0.2);
}

.desc-modal__close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  font-size: 1.75rem;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.2s ease, background 0.2s ease;
}

.desc-modal__close:hover {
  color: #1f2a37;
  background: rgba(0, 0, 0, 0.06);
}

.desc-modal__title {
  margin: 0 0 1rem 0;
  padding: 0 2rem 0 0;
  font-size: 1.35rem;
  color: #1f2a37;
  text-align: center;
  flex-shrink: 0;
}

.desc-modal__body {
  line-height: 1.6;
  color: #475569;
  max-height: min(55vh, calc(85vh - 9rem));
  min-height: 0;
  flex: 0 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 0 1rem 0;
  margin: 0;
  -webkit-overflow-scrolling: touch;
  text-align: center;
}

.desc-modal__body p {
  margin: 0.5rem 0;
  text-align: center;
}

.desc-modal-website {
  margin-top: 1rem;
  font-weight: 600;
  text-align: center;
}

.desc-modal-website-link {
  color: #0f4aa0;
  text-decoration: none;
}

.desc-modal-website-link:hover {
  color: #0d3d8a;
  text-decoration: underline;
}

html.theme-dark .desc-modal .desc-modal__content,
html.theme-dark .desc-modal .modal-content.desc-modal__content {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
}

html.theme-dark .desc-modal__title,
html.theme-dark .desc-modal__body {
  color: var(--text) !important;
}

html.theme-dark .desc-modal__close {
  color: var(--muted, #9aa4af);
}

html.theme-dark .desc-modal__close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

html.theme-dark .desc-modal-website-link {
  color: #1fd47e;
}

html.theme-dark .desc-modal-website-link:hover {
  color: #0f9d58;
}

.desc-modal.open {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1003;
  background: rgba(0, 0, 0, 0.5);
  padding: 2rem;
  overflow: auto;
}

.desc-modal.open .desc-modal__content {
  margin: 0;
  flex-shrink: 0;
  width: 100%;
  max-width: 520px;
  box-sizing: border-box;
}