/* ==========================================================================
   notify.css - agent:notifications (TASK 5, customer side)

   Styles for two things and nothing else:

     1. .notify-modal*   the delivery pop-up built by static/js/notify.js
     2. .order-history*  the customer order history in templates/orders.php

   WHY ITS OWN MODAL AND NOT admin.css's .acher-modal
   admin.css (which defines .acher-modal / .acher-modal-panel) and admin.js
   (which owns the .modal focus trap) are NOT loaded on public pages - only
   main.css, search.css, product.css, accounts.css and payment.css are. main.css
   does ship a public .modal, but hanging this pop-up off it would let a
   document-level handler from another script open/close it behind notify.js's
   back, and the mark-read call would be skipped. So the pop-up carries its own
   class names and its own trap, styled to match the admin modal exactly.

   NO HARD-CODED HEX. Every colour is an --acher-* token from main.css section 01.
   Fallbacks are given only for the rgb() channel triplets, where a missing
   variable would otherwise break the whole declaration.
   ========================================================================== */

/* ==========================================================================
   01. The pop-up shell
   ========================================================================== */

.notify-delivery-toast {
  position: fixed;
  top: 84px;
  right: 18px;
  z-index: var(--z-modal, 900);
  width: min(390px, calc(100vw - 32px));
  padding: var(--space-4) 52px var(--space-4) var(--space-5);
  border: 1px solid rgba(var(--acher-primary-rgb, 0, 255, 65), 0.45);
  border-radius: var(--radius);
  background: var(--acher-surface);
  box-shadow: var(--shadow-lg), 0 0 24px rgba(var(--acher-primary-rgb, 0, 255, 65), 0.16);
  color: var(--acher-text);
  cursor: pointer;
  animation: notify-delivery-in 180ms ease-out both;
}

.notify-delivery-toast:hover {
  border-color: var(--acher-primary);
  transform: translateY(-2px);
}

.notify-delivery-kicker,
.notify-delivery-title,
.notify-delivery-text,
.notify-delivery-time {
  margin: 0;
}

.notify-delivery-kicker {
  color: var(--acher-primary);
  font-family: var(--acher-font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
}

.notify-delivery-title {
  margin-top: var(--space-2);
  font-family: var(--acher-font-display);
  font-size: var(--fs-base);
  font-weight: 400;
  letter-spacing: 0.05em;
}

.notify-delivery-text {
  margin-top: var(--space-2);
  color: var(--acher-dim);
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
}

.notify-delivery-time {
  margin-top: var(--space-2);
  color: var(--acher-muted);
  font-family: var(--acher-font-mono);
  font-size: var(--fs-xs);
}

.notify-delivery-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--acher-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--acher-dim);
  font-size: 1.1rem;
  cursor: pointer;
}

.notify-delivery-close:hover {
  border-color: var(--acher-danger);
  color: var(--acher-danger-soft);
}

@keyframes notify-delivery-in {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.notify-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal, 900);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition), visibility var(--transition);
}

.notify-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* notify.js also sets [hidden] while closed, so the node is inert for AT even
   if this stylesheet fails to load. */
.notify-modal[hidden] {
  display: none;
}

.notify-backdrop {
  position: absolute;
  inset: 0;
  background: var(--color-overlay, rgba(3, 3, 3, 0.86));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.notify-panel {
  position: relative;
  z-index: 1;
  width: min(640px, 100%);
  max-height: min(85vh, 900px);
  overflow-y: auto;
  padding: var(--space-6);
  border: 1px solid var(--acher-border-strong);
  border-radius: var(--radius);
  background: var(--acher-surface);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(var(--acher-primary-rgb, 0, 255, 65), 0.1);
  transform: scale(0.94) translateY(12px);
  opacity: 0;
  transition: transform var(--transition-slow), opacity var(--transition);
}

.notify-modal.is-open .notify-panel {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* The green rule across the top edge - same signature as the admin modal. */
.notify-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    var(--acher-primary) 0%,
    rgba(var(--acher-primary-rgb, 0, 255, 65), 0.25) 45%,
    transparent 100%
  );
  pointer-events: none;
}

/* ==========================================================================
   02. Header
   ========================================================================== */

.notify-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--acher-border);
}

.notify-head-text {
  min-width: 0;
}

.notify-title {
  margin: 0;
  color: var(--acher-text);
  font-family: var(--acher-font-display);
  font-size: var(--fs-lg);
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.notify-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-2) 0 0;
  color: var(--acher-muted);
  font-family: var(--acher-font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
}

.notify-queue {
  color: var(--acher-primary-soft);
}

.notify-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--acher-border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--acher-dim);
  font-family: var(--acher-font-mono);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: color var(--transition), background-color var(--transition),
    border-color var(--transition);
}

.notify-close:hover {
  border-color: rgba(var(--acher-danger-rgb, 255, 45, 45), 0.55);
  background: rgba(var(--acher-danger-rgb, 255, 45, 45), 0.12);
  color: var(--acher-danger-soft);
}

/* ==========================================================================
   03. Body + the credentials block
   ========================================================================== */

.notify-body {
  color: var(--acher-text);
  font-size: var(--fs-sm);
  line-height: var(--lh-base);
}

.notify-lead {
  margin: 0 0 var(--space-4);
  color: var(--acher-dim);
}

/* The terminal. Same look as .delivery-code in accounts.css so a credential
   block reads identically on the receipt, on the history page and in the
   pop-up - deliberately darker than the panel it sits on. */
.notify-creds {
  position: relative;
  margin: 0;
  padding: var(--space-4) var(--space-5);
  max-height: 340px;
  overflow: auto;
  border: 1px solid rgba(var(--acher-primary-rgb, 0, 255, 65), 0.28);
  border-radius: var(--radius);
  background: var(--acher-bg-deep);
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(var(--acher-primary-rgb, 0, 255, 65), 0.035) 0,
    rgba(var(--acher-primary-rgb, 0, 255, 65), 0.035) 1px,
    transparent 1px,
    transparent 3px
  );
  color: var(--acher-primary);
  font-family: var(--acher-font-mono);
  font-size: 0.86rem;
  line-height: 1.75;
  letter-spacing: 0.01em;
  white-space: pre-wrap;
  word-break: break-all;
  tab-size: 4;
  text-shadow: 0 0 6px rgba(var(--acher-primary-rgb, 0, 255, 65), 0.28);
  -webkit-user-select: all;
  user-select: all;
}

.notify-creds:focus-visible {
  outline: 2px solid var(--acher-primary);
  outline-offset: 2px;
}

/* Plain prose body (a non-delivery notification): readable, not a terminal. */
.notify-text {
  margin: 0;
  color: var(--acher-text);
  font-size: var(--fs-sm);
  line-height: var(--lh-base);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.notify-warning {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: var(--space-4) 0 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid rgba(var(--acher-warning-rgb, 255, 170, 0), 0.35);
  border-radius: var(--radius-sm);
  background: rgba(var(--acher-warning-rgb, 255, 170, 0), 0.08);
  color: var(--acher-warning-soft);
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
}

.notify-warning-mark {
  flex: 0 0 auto;
  font-family: var(--acher-font-display);
  font-weight: 400;
}

/* The execCommand fallback needs a real, selectable node - clipped, never
   display:none. Mirrors main.css .sr-only. */
.notify-copy-source {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.notify-status {
  margin: var(--space-3) 0 0;
  min-height: 1.2em;
  color: var(--acher-primary-soft);
  font-family: var(--acher-font-mono);
  font-size: var(--fs-xs);
}

.notify-status.is-error {
  color: var(--acher-danger-soft);
}

/* ==========================================================================
   04. Footer
   ========================================================================== */

.notify-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--acher-border);
}

.notify-foot .notify-hint {
  margin: 0;
  margin-right: auto;
  color: var(--acher-muted);
  font-size: var(--fs-xs);
}

body.notify-locked {
  overflow: hidden;
}

/* ==========================================================================
   05. Order history page (templates/orders.php)

   The receipt vocabulary comes from main.css / accounts.css via
   templates/checkout.php's classes (.card.glass, .card-body, .block-title,
   .table, .receipt-item, .badge, .summary, .delivery-code, .empty-state).
   Only the bits checkout.php has no equivalent for live here.
   ========================================================================== */

.order-history-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.order-history-head h1 {
  margin: 0;
}

.order-history-count {
  margin: var(--space-2) 0 0;
  color: var(--acher-muted);
  font-family: var(--acher-font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
}

.order-card + .order-card {
  margin-top: var(--space-5);
}

.order-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--acher-border);
}

.order-card-id {
  margin: 0;
  color: var(--acher-text);
  font-family: var(--acher-font-display);
  font-size: var(--fs-md);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.order-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  color: var(--acher-muted);
  font-family: var(--acher-font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
}

.order-card-total {
  color: var(--acher-primary);
  text-shadow: var(--acher-glow-text);
}

.order-item {
  padding: var(--space-5) 0;
  border-bottom: 1px dashed var(--acher-border);
}

.order-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.order-item-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
}

.order-item-name {
  margin: 0;
  font-size: var(--fs-base);
  font-weight: 600;
}

.order-item-name a {
  color: var(--acher-text);
  text-decoration: none;
}

.order-item-name a:hover {
  color: var(--acher-primary);
}

.order-item-sub {
  margin: var(--space-1) 0 0;
  color: var(--acher-muted);
  font-size: var(--fs-xs);
}

.order-item-figures {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  color: var(--acher-dim);
  font-family: var(--acher-font-mono);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.order-item-state {
  margin-top: var(--space-4);
}

/* "Awaiting confirmation" - the state a manual delivery sits in for hours, so
   it has to look deliberate rather than broken. */
.order-pending {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border: 1px solid rgba(var(--acher-warning-rgb, 255, 170, 0), 0.32);
  border-radius: var(--radius);
  background: rgba(var(--acher-warning-rgb, 255, 170, 0), 0.06);
}

.order-pending-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-top: 0.45em;
  border-radius: 50%;
  background: var(--acher-warning);
  box-shadow: 0 0 10px rgba(var(--acher-warning-rgb, 255, 170, 0), 0.6);
  animation: notify-pulse 2.2s ease-in-out infinite;
}

.order-pending-copy {
  min-width: 0;
}

.order-pending-title {
  margin: 0;
  color: var(--acher-warning-soft);
  font-family: var(--acher-font-display);
  font-size: var(--fs-sm);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.order-pending-note {
  margin: var(--space-2) 0 0;
  color: var(--acher-dim);
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
}

.order-pending-eta {
  color: var(--acher-warning-soft);
  font-family: var(--acher-font-mono);
}

.order-delivered-label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin: 0 0 var(--space-3);
  color: var(--acher-primary-soft);
  font-family: var(--acher-font-display);
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.order-delivered-note {
  margin: var(--space-3) 0 0;
  color: var(--acher-dim);
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.order-bulk-delivery {
  padding: var(--space-6);
  border: 1px solid var(--acher-border-strong);
  border-left: 4px solid var(--acher-primary);
  border-radius: var(--radius);
  background: var(--acher-surface-2);
}

.order-bulk-title {
  margin: 0;
  color: var(--acher-text);
  font-family: var(--acher-font-display);
  font-size: 1.1rem;
  font-weight: 700;
}

.order-bulk-copy {
  max-width: 72ch;
  margin: var(--space-3) 0 0;
  color: var(--acher-dim);
  line-height: var(--lh-relaxed);
}

.order-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.order-bulk-expired {
  color: var(--acher-warning-soft);
  font-size: var(--fs-sm);
}

.order-cancelled {
  padding: var(--space-4) var(--space-5);
  border: 1px solid rgba(var(--acher-danger-rgb, 255, 45, 45), 0.3);
  border-radius: var(--radius);
  background: rgba(var(--acher-danger-rgb, 255, 45, 45), 0.06);
  color: var(--acher-danger-soft);
  font-size: var(--fs-xs);
}

.order-history-foot {
  margin-top: var(--space-8);
}

.order-admin-note {
  margin-bottom: var(--space-5);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--acher-border-strong);
  border-radius: var(--radius-sm);
  background: var(--acher-surface-2);
  color: var(--acher-dim);
  font-family: var(--acher-font-mono);
  font-size: var(--fs-xs);
}

@keyframes notify-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

/* ==========================================================================
   06. Focus rings + reduced motion
   ========================================================================== */

.notify-modal :focus-visible,
.order-history :focus-visible {
  outline: 2px solid var(--acher-primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .notify-delivery-toast {
    animation: none;
  }
  .notify-modal,
  .notify-panel {
    transition: none;
  }

  .notify-panel {
    transform: none;
  }

  .order-pending-dot {
    animation: none;
  }
}

/* ==========================================================================
   07. Narrow screens
   ========================================================================== */

@media (max-width: 560px) {
  .notify-delivery-toast {
    top: 70px;
    right: 12px;
    width: calc(100vw - 24px);
  }
  .notify-panel {
    padding: var(--space-5) var(--space-4);
  }

  .notify-foot {
    justify-content: stretch;
  }

  .notify-foot .notify-hint {
    width: 100%;
    margin-right: 0;
  }

  .notify-foot .btn,
  .notify-foot .acher-btn-primary,
  .notify-foot .acher-btn-ghost {
    flex: 1 1 auto;
    justify-content: center;
  }

  .order-item-figures {
    white-space: normal;
  }

  .order-bulk-delivery {
    padding: var(--space-5) var(--space-4);
  }

  .order-bulk-actions .acher-btn-primary {
    width: 100%;
    justify-content: center;
  }
}
