/**
 * Modern WordPress Share Suite - Front-End Stylesheet
 *
 * Implements WCAG 2.2 AA compliant Action Dialog modal, inline button bar,
 * 44x44px touch targets, and responsive bottom-sheet presentation.
 */

:root {
  --mwp-share-bg: var(--wp--preset--color--surface, #1e1e1e);
  --mwp-share-text: var(--wp--preset--color--contrast, #f4f4f4);
  --mwp-share-muted: var(--wp--preset--color--muted, #94a3b8);
  --mwp-share-border: var(--wp--preset--color--border, #334155);
  --mwp-share-primary: #15868f;
  --mwp-share-primary-hover: #136e75;
  --mwp-share-focus: #38bdf8;
  --mwp-share-overlay: rgba(0, 0, 0, 0.65);
  --mwp-share-radius: 12px;
}

:root[data-theme="light"] {
  --mwp-share-bg: var(--wp--preset--color--surface, #ffffff);
  --mwp-share-text: var(--wp--preset--color--contrast, #0f172a);
  --mwp-share-muted: var(--wp--preset--color--muted, #64748b);
  --mwp-share-border: var(--wp--preset--color--border, #e2e8f0);
  --mwp-share-primary: #15868f;
  --mwp-share-primary-hover: #136e75;
  --mwp-share-focus: #0284c7;
  --mwp-share-overlay: rgba(15, 23, 42, 0.45);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --mwp-share-bg: var(--wp--preset--color--surface, #ffffff);
    --mwp-share-text: var(--wp--preset--color--contrast, #0f172a);
    --mwp-share-muted: var(--wp--preset--color--muted, #64748b);
    --mwp-share-border: var(--wp--preset--color--border, #e2e8f0);
    --mwp-share-primary: #15868f;
    --mwp-share-primary-hover: #136e75;
    --mwp-share-focus: #0284c7;
    --mwp-share-overlay: rgba(15, 23, 42, 0.45);
  }
}

:root[data-theme="dark"] {
  --mwp-share-bg: var(--wp--preset--color--surface, #181818);
  --mwp-share-text: var(--wp--preset--color--contrast, #ffffff);
  --mwp-share-muted: var(--wp--preset--color--muted, #a3a3a3);
  --mwp-share-border: var(--wp--preset--color--divider, rgba(255, 255, 255, 0.12));
  --mwp-share-primary: #15868f;
  --mwp-share-primary-hover: #136e75;
  --mwp-share-focus: #38bdf8;
  --mwp-share-overlay: rgba(0, 0, 0, 0.65);
}

/* ==========================================================================
   Inline Share Bar & Trigger Affordances
   ========================================================================== */

.mwp-share-container {
  margin: 2rem 0;
  padding: 1.25rem 0;
  border-top: 1px solid var(--mwp-share-border);
  border-bottom: 1px solid var(--mwp-share-border);
  text-align: center;
}

.mwp-share-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.mwp-share-trigger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.5rem;
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem 1.25rem;
  background-color: var(--mwp-share-primary);
  color: #ffffff !important;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  border: 2px solid #2a2a2a;
  border-radius: 8px;
  box-shadow: 3px 3px 0px 0px #2a2a2a;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
}

.mwp-share-trigger-btn:hover {
  background-color: var(--mwp-share-primary-hover);
  transform: translateY(-1px);
  box-shadow: 4px 4px 0px 0px #2a2a2a;
}

.mwp-share-trigger-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0px 0px #2a2a2a;
}

.mwp-share-trigger-btn:focus-visible,
.mwp-share-quick-copy-btn:focus-visible,
.mwp-share-channel-btn:focus-visible,
.mwp-action-dialog-close-btn:focus-visible,
.mwp-share-copy-btn:focus-visible,
.mwp-action-dialog-dismiss-btn:focus-visible {
  outline: 2px solid var(--mwp-share-focus) !important;
  outline-offset: 2px !important;
}

.mwp-share-btn-icon {
  flex-shrink: 0;
}

.mwp-share-quick-copy-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem;
  background-color: transparent;
  color: var(--mwp-share-text);
  border: 1px solid var(--mwp-share-border);
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.mwp-share-quick-copy-btn:hover {
  background-color: rgba(21, 134, 143, 0.1);
  border-color: var(--mwp-share-primary);
}

.mwp-share-quick-copy-btn.copied {
  background-color: rgba(34, 197, 94, 0.15);
  border-color: #22c55e;
  color: #22c55e;
}

/* ==========================================================================
   Action Dialog Modal Architecture (Unified Dialog Modal Pattern)
   ========================================================================== */

body.mwp-action-dialog-open {
  overflow: hidden;
}

.mwp-action-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.mwp-action-dialog-backdrop {
  position: absolute;
  inset: 0;
  background-color: var(--mwp-share-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: mwpFadeIn 0.2s ease-out;
}

.mwp-action-dialog-frame {
  position: relative;
  width: 100%;
  max-width: 480px;
  background-color: var(--mwp-share-bg);
  color: var(--mwp-share-text);
  border: 1px solid var(--mwp-share-border);
  border-radius: var(--mwp-share-radius);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  animation: mwpScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

/* Dialog Header */
.mwp-action-dialog-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--mwp-share-border);
}

.mwp-action-dialog-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background-color: rgba(21, 134, 143, 0.15);
  color: var(--mwp-share-primary);
  border-radius: 8px;
  flex-shrink: 0;
}

.mwp-action-dialog-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  flex-grow: 1;
  color: var(--mwp-share-text);
  letter-spacing: -0.01em;
}

.mwp-action-dialog-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 0;
  background: transparent;
  color: var(--mwp-share-muted);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.mwp-action-dialog-close-btn:hover {
  color: var(--mwp-share-text);
  background-color: rgba(255, 255, 255, 0.08);
}

/* Dialog Body */
.mwp-action-dialog-body {
  padding: 1.5rem;
  max-height: calc(85vh - 140px);
  overflow-y: auto;
}

/* Copy Link Row */
.mwp-share-copy-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.mwp-share-copy-input {
  flex-grow: 1;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  background-color: rgba(0, 0, 0, 0.04);
  color: var(--mwp-share-text);
  border: 1px solid var(--mwp-share-border);
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: inherit;
}

:root[data-theme="dark"] .mwp-share-copy-input {
  background-color: rgba(255, 255, 255, 0.05);
}

.mwp-share-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 72px;
  padding: 0.5rem 1rem;
  background-color: var(--mwp-share-primary);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.mwp-share-copy-btn:hover {
  background-color: var(--mwp-share-primary-hover);
}

.mwp-share-copy-btn.copied {
  background-color: #16a34a;
}

/* Channels Grid */
.mwp-share-channels-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.mwp-share-channel-item {
  display: flex;
}

.mwp-share-channel-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 68px;
  padding: 0.75rem 0.5rem;
  background-color: rgba(255, 255, 255, 0.03);
  color: var(--mwp-share-text);
  border: 1px solid var(--mwp-share-border);
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.mwp-share-channel-btn:hover {
  background-color: rgba(21, 134, 143, 0.1);
  border-color: var(--mwp-share-primary);
  transform: translateY(-2px);
  color: var(--mwp-share-text);
}

.mwp-share-channel-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Sovereign QR Code Drawer */
.mwp-share-qr-drawer {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--mwp-share-border);
  text-align: center;
  animation: mwpFadeIn 0.2s ease-out;
}

.mwp-share-qr-heading {
  margin: 0 0 1rem 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--mwp-share-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mwp-share-qr-container {
  display: inline-flex;
  padding: 0.75rem;
  background-color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.mwp-share-qr-svg {
  display: block;
}

/* Mobile Bottom Sheet Presentation */
.mwp-mobile-only {
  display: none;
}

@media (max-width: 640px) {
  .mwp-action-dialog-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .mwp-action-dialog-frame {
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 90vh;
    animation: mwpSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .mwp-action-dialog-footer {
    display: block;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--mwp-share-border);
  }

  .mwp-action-dialog-dismiss-btn {
    width: 100%;
    min-height: 48px;
    padding: 0.75rem;
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--mwp-share-text);
    border: 1px solid var(--mwp-share-border);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
  }

  .mwp-share-channels-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Keyframe Animations */
@keyframes mwpFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes mwpScaleUp {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes mwpSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .mwp-action-dialog-backdrop,
  .mwp-action-dialog-frame,
  .mwp-share-trigger-btn,
  .mwp-share-channel-btn,
  .mwp-share-qr-drawer {
    animation: none !important;
    transition: none !important;
  }
}
