/**
 * OTM Team Members - front-end styles.
 *
 * The plugin is a guest in the client's theme: everything is prefixed
 * .otm-team-, fonts and base colors are inherited, and this file is only
 * enqueued on pages that render the shortcode or a profile page.
 *
 * The hover overlay color/opacity comes from plugin settings as the
 * --otm-team-overlay custom property printed on the .otm-team wrapper.
 */

.otm-team {
  --otm-team-overlay-fallback: rgba(255, 255, 255, 0.7);
  --otm-team-cat-fallback: #1a365d;
  --otm-team-cat-text-fallback: #ffffff;
  --otm-team-role-fallback: #012c43;
  --otm-team-div-start-fallback: #be1e2d;
  --otm-team-div-end-fallback: #ffc40e;
}

.otm-team-section {
  margin: 0 0 3rem;
}

.otm-team-section:last-child {
  margin-bottom: 0;
}

.otm-team-section-title {
  margin: 0 0 1.5rem;
  padding: 0.6em 1em;
  border-radius: 4px;
  color: #ffffff;
  font-size: 1.35rem;
  line-height: 1.3;
  text-align: center;
}

.otm-team-grid {
  display: grid;
  grid-template-columns: repeat(var(--otm-team-columns, 3), minmax(0, 1fr));
  gap: 1.25rem;
}

.otm-team-card {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  text-align: center;
}

/* Full-width square photo at the top of the card. */

.otm-team-photo {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  flex-shrink: 0;
}

.otm-team-photo .otm-team-photo-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.otm-team-photo-overlay {
  position: absolute;
  inset: 0;
  background: var(--otm-team-overlay, var(--otm-team-overlay-fallback));
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.otm-team-card:hover .otm-team-photo-overlay,
.otm-team-card:focus-within .otm-team-photo-overlay {
  opacity: 1;
}

.otm-team-photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e9e9e9;
  color: #666666;
  font-size: 3rem;
  font-weight: 600;
}

/*
 * Name ribbon: a pill in the category color, centered and overlapping the
 * photo's bottom edge, with a thin full-width strap behind it.
 */

.otm-team-ribbon {
  position: relative;
  display: flex;
  justify-content: center;
  padding: 0 1rem;
  margin-top: -1.25em;
  z-index: 1;
}

.otm-team-ribbon::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(50% - 3px);
  height: 6px;
  background: var(--otm-team-cat, var(--otm-team-cat-fallback));
}

.otm-team-name {
  position: relative;
  margin: 0;
  padding: 0.45em 1.3em;
  background: var(--otm-team-cat, var(--otm-team-cat-fallback));
  color: var(--otm-team-cat-text, var(--otm-team-cat-text-fallback));
  border-radius: 8px;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.25;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.otm-team-card-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-grow: 1;
  padding: 1rem 1.25rem 1.5rem;
}

.otm-team-role {
  margin: 0 0 0.75rem;
  color: var(--otm-team-role, var(--otm-team-role-fallback));
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
}

/* Small gradient divider: fixed site-wide colors, the same on every card. */

.otm-team-divider {
  display: block;
  width: 64px;
  height: 3px;
  margin: 0 0 1rem;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    var(--otm-team-div-start, var(--otm-team-div-start-fallback)),
    var(--otm-team-div-end, var(--otm-team-div-end-fallback))
  );
}

.otm-team-desc {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  text-align: left;
}

.otm-team-desc p {
  margin: 0 0 0.75em;
  font-size: inherit;
  line-height: inherit;
}

.otm-team-desc p:last-child {
  margin-bottom: 0;
}

.otm-team-cta {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.45em 1.1em;
  border: 1px solid currentColor;
  border-radius: 4px;
  color: var(--otm-team-cat, var(--otm-team-cat-fallback));
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

.otm-team-cta:hover,
.otm-team-cta:focus {
  text-decoration: underline;
}

.otm-team-cta:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/*
 * Bio popup: used when profile pages are off and the bio display setting
 * is a popup. The dialog is moved to <body> by the script, so it repeats
 * the color custom properties it needs as its own fallbacks.
 */

.otm-team-card--modal .otm-team-cta {
  margin-top: auto;
}

.otm-team-modal-trigger {
  background: none;
  cursor: pointer;
  font-family: inherit;
}

.otm-team-modal {
  --otm-team-cat-fallback: #1a365d;
  --otm-team-cat-text-fallback: #ffffff;
  --otm-team-role-fallback: #012c43;
  --otm-team-div-start-fallback: #be1e2d;
  --otm-team-div-end-fallback: #ffc40e;
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.otm-team-modal.is-open {
  opacity: 1;
}

/* The hidden attribute has to win over the display above. */

.otm-team-modal[hidden] {
  display: none;
}

.otm-team-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.otm-team-modal-dialog {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 2rem;
  align-items: start;
  width: 100%;
  max-width: 900px;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  padding: 2.25rem;
  border-radius: 8px;
  background: var(--otm-team-cat, var(--otm-team-cat-fallback));
  color: var(--otm-team-cat-text, var(--otm-team-cat-text-fallback));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

/* A dialog with no photo gives the text the full width. */

.otm-team-modal-dialog--no-photo {
  grid-template-columns: minmax(0, 1fr);
}

.otm-team-modal-media {
  margin: 0;
}

.otm-team-modal-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
}

.otm-team-modal-body {
  text-align: left;
}

.otm-team-modal-name {
  margin: 0 0 0.35rem;
  color: inherit;
  font-size: 1.5rem;
  line-height: 1.25;
}

.otm-team-modal-role {
  margin: 0 0 0.75rem;
  color: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  opacity: 0.85;
}

.otm-team-modal-desc {
  font-size: 1rem;
}

.otm-team-modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  padding: 0.1em 0.35em;
  border: 0;
  background: none;
  color: inherit;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

.otm-team-modal-close:focus-visible,
.otm-team-modal-trigger:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Keep the page behind the dialog from scrolling. */

html.otm-team-modal-open,
html.otm-team-modal-open body {
  overflow: hidden;
}

/* Themes usually ship this, but the dialog cannot rely on it. */

.otm-team-modal .screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Single profile page */

.otm-team-profile-role {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.otm-team-profile-lede {
  font-size: 1.1em;
}

/* Responsive: 4 to 2 to 1 columns */

@media (max-width: 900px) {
  .otm-team-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .otm-team-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 700px) {
  .otm-team-modal {
    padding: 1rem;
  }

  .otm-team-modal-dialog {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
    padding: 2rem 1.5rem 1.5rem;
  }

  .otm-team-modal-media {
    max-width: 240px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .otm-team-photo-overlay,
  .otm-team-modal {
    transition: none;
  }
}
