/* ==========================================================================
   amm/card – card block (editor + frontend)
   ========================================================================== */

.wp-block-amm-card,
.amm-card {
  box-sizing: border-box;
}

.amm-card {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 16px;
  background: var(--amm-card-bg, var(--amm-palette-background));
  border: var(--amm-card-border, none);
  box-shadow: var(--amm-card-shadow, none);
  border-radius: 12px;
  height: 100%;
}

.amm-card__image {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 8px;
}

/* Standard / image hero: 1170:660 frame, object-fit cover */
.amm-card.amm-card--layout-standard .amm-card__image,
.amm-card.amm-card--layout-image .amm-card__image {
  aspect-ratio: 1170 / 660;
  background: var(--amm-card-bg, var(--amm-palette-background));
}

.amm-card.amm-card--layout-standard .amm-card__image img,
.amm-card.amm-card--layout-image .amm-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.amm-card__inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 24px;
  height: 100%;
}

/* Whole-card link (image + icon layouts) */
.amm-card > .amm-card__link {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  color: inherit;
  text-decoration: none;
  border-radius: inherit;
}

.amm-card__link:focus-visible {
  outline: 2px solid var(--amm-palette-primary-1, #0066cc);
  outline-offset: 2px;
}

.amm-card__link:hover {
  color: inherit;
  text-decoration: none;
}

/* Image layout: zero shell padding; hero fills stretched rows, intrinsic height when row is auto */
.amm-card.amm-card--layout-image {
  padding: 0;
  gap: 0;
  overflow: hidden;
  background: var(--amm-card-bg, var(--amm-palette-background));
  border: 0;
  box-shadow: none;
}

/*
 * Avoid flex: 1 1 0% + min-height: 0 on the image stack — that lets the hero shrink to 0 when
 * the grid row height is content-sized (img height: 100% has no definite base).
 * Use content-based flex-basis + min-height: auto so intrinsic image height establishes the card.
 */
.amm-card.amm-card--layout-image > .amm-card__link {
  flex: 1 1 auto;
  min-height: auto;
  height: 100%;
}

.amm-card.amm-card--layout-image .amm-card__inner {
  flex: 1 1 auto;
  min-height: auto;
  gap: 0;
  height: 100%;
}

.amm-card.amm-card--layout-image .amm-card__image {
  flex: 1 1 auto;
  min-height: auto;
  align-self: stretch;
  border-radius: 0;
  height: 100%;
}

/* Video layout: 360:270 (4:3) aspect ratio, scales with grid column — not a fixed pixel size */
.amm-card.amm-card--layout-video {
  --amm-card-video-aspect: 360 / 270;

  width: 100%;
  align-self: stretch;
  height: auto;
  min-height: 0;
  padding: 0;
  gap: 0;
  overflow: hidden;
  background: var(--amm-card-bg, var(--amm-palette-background));
  border: 0;
  box-shadow: none;
}

/*
 * Modal thumbnail path uses only absolutely positioned children (trigger + tag).
 * Establish frame size on __inner so the poster/thumb is not collapsed to 0 height in the grid.
 */
.amm-card.amm-card--layout-video .amm-card__inner {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  aspect-ratio: var(--amm-card-video-aspect);
  height: auto;
  gap: 0;
}

.amm-card__video {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 0;
  background: var(--amm-palette-background-secondary, #f2f2f7);
}

.amm-card.amm-card--layout-video .amm-card__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: unset;
  min-height: 0;
  flex: unset;
  align-self: stretch;
}

.amm-card__video img,
.amm-card__video video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border: 0;
}

.amm-card__video iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
}

.amm-card__video--inline .amm-card__video-player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
}

.amm-card__video--inline .amm-card__video-embed,
.amm-card__video--inline .amm-card__video-file {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.amm-card__video--inline .amm-card__video-embed > * {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: none;
  padding: 0 !important;
  margin: 0;
}

.amm-card__video--inline .amm-card__video-embed iframe,
.amm-card__video--inline .amm-card__video-file {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.amm-card__video--inline .amm-card__video-file {
  object-fit: contain;
}

.amm-card__video--video-modal {
  display: block;
}

.amm-card__video--video-modal .amm-video-modal__embed-template {
  display: none;
}

/* Slightly lighter overlay so the poster remains visible in the small card frame */
.amm-card__video--video-modal .amm-video-modal__overlay {
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.08) 0%,
    rgba(0, 0, 0, 0.22) 50%,
    rgba(0, 0, 0, 0.45) 100%
  );
}

.amm-card__video--inline.has-poster .amm-card__video-poster {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  cursor: pointer;
  background: transparent;
}

.amm-card__video-poster {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  cursor: pointer;
  background: transparent;
}

.amm-card__video-poster img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.amm-card__video--video-modal .amm-video-modal__trigger {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.amm-card__video-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: rgba(0, 87, 98, 0.9);
  color: #fff;
}

.amm-card__video-play .material-icons {
  font-size: 34px;
}

.amm-card__video .amm-card__tag {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  max-width: calc(100% - 24px);
  pointer-events: none;
}

/*
 * Icon layout (rebuilt)
 * — In the grid, icon cards use `height: 100%` like standard cards; inner flex so the row height
 *   fills the shell while the scene + copy keep natural height (extra space stays below the scene).
 * — Scene uses a simple `min-height` floor only (no `container-type` / `100cqi` on the scene: self-referential
 *   container query units broke published-page grid column width in some engines while the editor looked fine).
 * — Icon card root avoids `min-width: 0` so the grid item keeps a sane min-content width (badge + padding).
 * — Copy block grows with content (no flex “fill rest” + scroll, which reads as a max-height cap).
 */
.amm-card.amm-card--layout-icon {
  --amm-card-icon-max-w: 546px;
  --amm-card-icon-ratio: 546 / 292;
  --amm-card-icon-pad: 24px;
  --amm-card-icon-stack-gap: 18px;
  --amm-card-icon-copy-gap: 16px;

  width: 100%;
  min-height: 0;
  height: 100%;
  padding: 0;
  gap: 0;
  text-align: left;
}

.amm-card.amm-card--layout-icon > .amm-card__inner {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: 100%;
}

/* Scene flexes to fill the row; `min-height` is a static floor (see block comment — no CQ on scene). */
.amm-card.amm-card--layout-icon .amm-card__icon-scene {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 0 1 auto;
  align-self: stretch;
  gap: var(--amm-card-icon-stack-gap);
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  margin-inline: 0;
  padding: var(--amm-card-icon-pad);
  min-height: 11rem;
  overflow: visible;
  text-align: left;
}

.amm-card.amm-card--layout-icon .amm-card__corner-badge {
  position: static;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 55px;
  height: 55px;
  box-sizing: border-box;
  background: #fff;
  border-radius: 8px;
}

.amm-card.amm-card--layout-icon .amm-card__corner-badge img {
  display: block;
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.amm-card.amm-card--layout-icon .amm-card__body {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  align-self: stretch;
  gap: var(--amm-card-icon-copy-gap);
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow-x: hidden;
  overflow-y: visible;
  overscroll-behavior: auto;
}

.amm-card.amm-card--layout-icon .amm-card__content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--amm-card-icon-copy-gap);
  width: 100%;
  min-width: 0;
}

.amm-card.amm-card--layout-icon .amm-card__title,
.amm-card.amm-card--layout-icon .amm-card__meta,
.amm-card.amm-card--layout-icon .amm-card__tag {
  margin: 0;
}

.amm-card.amm-card--layout-icon .amm-card__meta {
  color: #111;
}

.amm-card.amm-card--layout-icon .amm-card__title {
  height: auto;
  min-height: 0;
  overflow: visible;
  display: block;
  line-clamp: unset;
  -webkit-line-clamp: unset;
  -webkit-box-orient: unset;
}

/* Block editor only: no fixed scene height — let title/text fields expand freely */
.amm-card.amm-card--layout-icon.amm-card--editor .amm-card__icon-scene {
  aspect-ratio: unset;
  min-height: 0;
  height: auto;
  overflow: visible;
  container-type: normal;
}

.amm-card.amm-card--layout-icon.amm-card--editor .amm-card__body {
  flex: 0 1 auto;
  overflow: visible;
  min-height: 0;
}

.amm-card__body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  padding: 0 8px;
  flex: 1;
  min-height: 0;
  overflow: visible;
}

.amm-card__content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.amm-card__image .amm-card__tag {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1;
  max-width: calc(100% - 24px);
}

.amm-card__content .amm-card__tag {
  align-self: flex-start;
  max-width: 100%;
}

/* Title size via `--amm-card-title-scale` on the card root (editor slider / SSR) */
.amm-card .amm-card__title.subtitle {
  font-size: calc(
    16px * var(--amm-type-scale-mobile) * var(--amm-card-title-scale, 1)
  );
}

@media (min-width: 768px) {
  .amm-card .amm-card__title.subtitle {
    font-size: calc(
      18px * var(--amm-type-scale-tablet) * var(--amm-card-title-scale, 1)
    );
  }
}

@media (min-width: 1024px) {
  .amm-card .amm-card__title.subtitle {
    font-size: calc(
      18px * var(--amm-type-scale-desktop) * var(--amm-card-title-scale, 1)
    );
  }
}

.amm-card__tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  font-family: var(--amm-body-font, var(--amm-font-sans));
}

.amm-card:not(.amm-card--layout-icon) .amm-card__title {
  /* height: calc(75px * var(--amm-card-title-scale, 1)); */
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  line-clamp: 3;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.amm-card__meta {
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  color: #757575;
  font-family: var(--amm-body-font, var(--amm-font-sans));
}

.amm-card__ctas {
  display: flex;
  flex-direction: column;
  align-items: var(--amm-grid-link-align, flex-end);
  gap: 0.5rem;
  width: 100%;
  margin-top: auto;
  flex-shrink: 0;
}

.amm-card__ctas .amm-card__cta {
  margin-top: 0;
  flex-shrink: 0;
}

.amm-card__cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--amm-grid-link-color, var(--amm-palette-primary-1));
  border: 1px solid var(--amm-grid-link-border-color, transparent);
  background-color: var(
    --amm-grid-link-background,
    var(--amm-palette-primary-3)
  );
  align-self: var(--amm-grid-link-align, flex-end);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  font-family: var(--amm-body-font, var(--amm-font-sans));
  margin-top: auto;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
}

.amm-card__cta:hover {
  text-decoration: none;
  color: var(--amm-grid-link-color, var(--amm-palette-primary-1));
}

.amm-card__cta-icon {
  font-family: 'Material Icons', sans-serif;
  font-size: 18px;
  line-height: 1.4;
  font-weight: 400;
}

.amm-card__placeholder {
  font-size: 0.875rem;
  color: #999;
  padding: 0.5rem 0;
}

@media (max-width: 599px) {
  .amm-card {
    padding: 12px;
  }

  .amm-card__image {
    border-radius: 4px;
  }
}
