/*
 * The post footer (inc/post-footer.php): Share on the left, Report a problem on
 * the right, under a hairline, above the related feed. STYLING.md § The post
 * footer.
 */

/* Width and side gutters come from Blocksy's own .is-width-constrained, the
   class the learning pills row uses, so the row lines up with the content at
   every width. */
.pp-post-footer {
  margin: 24px auto 0;
  padding-top: 16px;
  border-top: 1px solid rgba(var(--pp-steel-7-rgb), 0.12);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-sizing: border-box;
}

/* CAP's fullscreen player covers the page; nothing of the post footer shows
   through it. */
html.cap-fs-open .pp-post-footer {
  display: none;
}

.pp-post-footer__share {
  position: relative;
}

/* Alone (a logged-out visitor has no Report), Share moves to the right. */
.pp-post-footer__share:only-child {
  margin-left: auto;
}

/* ---- Share: an outlined pill, lighter than the learning pills above it ---- */

.pp-post-footer .pp-post-footer__share-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid rgba(var(--pp-accent-rgb), 0.28);
  border-radius: 999px;
  background: none;
  box-shadow: none;
  color: var(--theme-palette-color-5);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.pp-post-footer .pp-post-footer__share-toggle:hover,
.pp-post-footer .pp-post-footer__share-toggle[aria-expanded="true"] {
  background: rgba(var(--pp-steel-7-rgb), 0.05);
  border-color: rgba(var(--pp-accent-rgb), 0.46);
  color: var(--theme-palette-color-5);
}

.pp-post-footer .pp-post-footer__share-toggle:focus-visible {
  outline: 2px solid var(--pp-focus-ring);
  outline-offset: 2px;
}

.pp-post-footer__share-toggle svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

/* ---- The share menu: STYLING.md § A small dropdown menu ---- */

.pp-post-footer__share-menu:not([hidden]) {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: calc(var(--pp-z-bottom-nav, 900) + 1);
  min-width: 200px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  background: var(--theme-palette-color-8);
  border: 1px solid rgba(var(--pp-steel-7-rgb), 0.12);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(var(--pp-steel-7-rgb), 0.20);
  box-sizing: border-box;
  animation: pp-post-footer-fade 0.18s ease;
}

/* Opens upward when there is no room between the toggle and the bottom nav
   (measured in js/post-footer.js on open). */
.pp-post-footer__share-menu.is-upward:not([hidden]) {
  top: auto;
  bottom: calc(100% + 8px);
}

.pp-post-footer .pp-post-footer__share-item {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  box-shadow: none;
  color: var(--pp-steel-7);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.3;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.pp-post-footer .pp-post-footer__share-item:hover {
  background: rgba(var(--pp-steel-7-rgb), 0.05);
  color: var(--pp-steel-7);
}

.pp-post-footer .pp-post-footer__share-item:focus-visible {
  outline: 2px solid var(--pp-focus-ring);
  outline-offset: -2px;
}

/* Copy link is the first and most used row. */
.pp-post-footer .pp-post-footer__share-item[data-copy-url] {
  font-weight: 600;
}

@media (max-width: 768px) {
  .pp-post-footer .pp-post-footer__share-item {
    min-height: 44px;
  }
}

/* ---- Report a problem: a labelled text control, findable at a glance ---- */

.pp-post-footer .pp-post-footer__report {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  margin-left: auto;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--pp-steel-5);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: color 0.18s ease;
}

.pp-post-footer .pp-post-footer__report:hover {
  background: none;
  color: var(--pp-steel-7);
}

.pp-post-footer .pp-post-footer__report:focus-visible {
  outline: 2px solid var(--pp-focus-ring);
  outline-offset: 2px;
}

/* The flag keeps the pink-red members already know it by. A new role for
   --pp-red-3 (STYLING.md § The post footer). */
.pp-post-footer__report svg,
.pp-report-modal__title svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--pp-red-3);
}

/* ---- The Report dialog: STYLING.md § Modals and dialogs ---- */

.pp-report-modal:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

html.pp-report-modal-open {
  overflow: hidden;
}

.pp-report-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(var(--pp-steel-7-rgb), 0.44);
}

.pp-report-modal__dialog {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
  border-radius: 14px;
  background: var(--theme-palette-color-8);
  box-shadow: 0 18px 50px rgba(var(--pp-steel-7-rgb), 0.24);
  color: var(--pp-steel-7);
  box-sizing: border-box;
  animation: pp-post-footer-fade 0.18s ease;
}

.pp-report-modal__dialog:focus {
  outline: none;
}

.pp-report-modal .pp-report-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(var(--pp-steel-7-rgb), 0.06);
  box-shadow: none;
  color: var(--pp-steel-4);
  cursor: pointer;
}

.pp-report-modal .pp-report-modal__close:hover {
  background: rgba(var(--pp-steel-7-rgb), 0.12);
  color: var(--pp-steel-7);
}

.pp-report-modal .pp-report-modal__close:focus-visible {
  outline: 2px solid var(--pp-focus-ring);
  outline-offset: 2px;
}

.pp-report-modal__close svg {
  width: 16px;
  height: 16px;
}

.pp-report-modal__title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 40px 12px 0;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--pp-steel-7);
}

.pp-report-modal__title svg {
  width: 20px;
  height: 20px;
}

.pp-report-modal__intro {
  margin: 0 0 16px;
  color: var(--pp-steel-5);
}

/* A field that summons the keyboard: full screen on a phone. */
@media (max-width: 768px) {
  .pp-report-modal:not([hidden]) {
    padding: 0;
  }

  .pp-report-modal__dialog {
    display: flex;
    flex-direction: column;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    padding: calc(18px + env(safe-area-inset-top, 0px)) 18px calc(18px + env(safe-area-inset-bottom, 0px));
  }

  /* Full-screen, so the close is the only way out: the full-screen tier of
     STYLING.md › The dismiss cross. */
  .pp-report-modal .pp-report-modal__close {
    top: calc(12px + env(safe-area-inset-top, 0px));
    width: 44px;
    height: 44px;
  }

  .pp-report-modal__close svg {
    width: 20px;
    height: 20px;
  }

  .pp-report-modal__body {
    width: 100%;
    margin: auto;
  }

  .pp-report-modal__title {
    margin-bottom: 20px;
  }
}

@keyframes pp-post-footer-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .pp-post-footer__share-menu:not([hidden]),
  .pp-report-modal__dialog {
    animation: none;
  }

  .pp-post-footer .pp-post-footer__share-toggle,
  .pp-post-footer .pp-post-footer__report {
    transition: none;
  }
}
