/* ============================================================
   Watermarking module — minimal geometric aesthetic
   ============================================================
   - Century Gothic for headlines (Jost as the Google Fonts fallback)
   - Inter for body text (inherited from platform)
   - Drop zone as the hero with dotted-grid texture
   - Persistent file library beneath the drop zone
   - Brand tokens only: var(--color-brand-primary), --color-brand-secondary, etc.
*/

/* Jost is the closest free Google Font to Century Gothic — used as a fallback
   for users who don't have Century Gothic installed locally. */
@import url('https://fonts.googleapis.com/css2?family=Jost:wght@300;400;500;600;700&display=swap');

/* ─── Page-scoped tokens ──────────────────────────────────── */
.wm-page {
  --wm-radius:        18px;
  --wm-radius-sm:     10px;
  --wm-radius-lg:     24px;

  --wm-tint:          rgba(166, 188, 206, 0.14);
  --wm-tint-soft:     rgba(166, 188, 206, 0.08);
  --wm-tint-strong:   rgba(166, 188, 206, 0.32);

  --wm-dashed:        rgba(166, 188, 206, 0.55);
  --wm-grid:          rgba(44, 62, 80, 0.05);

  --wm-ink:           var(--color-text-primary);
  --wm-ink-mute:      var(--color-text-secondary);
  --wm-rule:          var(--color-border);

  --wm-display:       'Century Gothic', 'CenturyGothic', 'Jost', 'Avant Garde', 'Avenir Next', 'Avenir', sans-serif;

  max-width: 1040px;
  margin: 0 auto;
  padding: clamp(1.5rem, 3vw, 3rem) clamp(1rem, 3vw, 2rem) 4rem;
  font-family: var(--font-family-primary);
  color: var(--wm-ink);
}

/* Visually-hidden utility (fallback if Bootstrap class isn't loaded) */
.wm-page .visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ─── Header ──────────────────────────────────────────────── */
.wm-header {
  margin-bottom: clamp(1.25rem, 2.5vw, 1.75rem);
}

.wm-eyebrow {
  font-family: var(--font-family-primary);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--wm-ink-mute);
  margin: 0 0 0.85rem 0;
}

.wm-display {
  font-family: var(--wm-display);
  font-weight: 500;
  letter-spacing: 0.005em;
  font-size: clamp(1.9rem, 3.6vw, 2.6rem);
  line-height: 1.05;
  color: var(--wm-ink);
  margin: 0;
}

/* ─── Composer card ───────────────────────────────────────── */
.wm-composer {
  background: white;
  border-radius: var(--wm-radius-lg);
  padding: clamp(1.5rem, 3vw, 2.5rem);
  border: 1px solid var(--wm-rule);
  box-shadow:
    0 1px 0 rgba(44, 62, 80, 0.02),
    0 12px 32px -20px rgba(44, 62, 80, 0.18);
  position: relative;
}

.wm-composer-grid {
  display: block;
}

.wm-input-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

/* ─── Drop zone ───────────────────────────────────────────── */
.wm-dropzone {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 232px;
  padding: 2.25rem 1.5rem;
  border: 1.5px dashed var(--wm-dashed);
  border-radius: var(--wm-radius);
  background:
    radial-gradient(circle at 1px 1px, var(--wm-grid) 1px, transparent 0) 0 0 / 18px 18px,
    white;
  cursor: pointer;
  transition:
    border-color 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    background-color 220ms ease,
    transform 220ms ease,
    box-shadow 220ms ease;
  text-align: center;
  margin: 0;
}

.wm-dropzone:hover {
  border-color: var(--color-brand-primary);
  background:
    radial-gradient(circle at 1px 1px, var(--wm-grid) 1px, transparent 0) 0 0 / 18px 18px,
    var(--wm-tint-soft);
}

.wm-dropzone:focus-within {
  outline: none;
  border-color: var(--color-brand-primary);
  box-shadow: 0 0 0 4px var(--wm-tint);
}

.wm-dropzone[data-wm-state="dragover"] {
  border-style: solid;
  border-color: var(--color-brand-primary);
  background:
    radial-gradient(circle at 1px 1px, rgba(166,188,206,0.25) 1px, transparent 0) 0 0 / 18px 18px,
    var(--wm-tint-strong);
  transform: scale(1.004);
  box-shadow: 0 12px 28px -18px rgba(44, 62, 80, 0.35);
}

.wm-dropzone[data-wm-state="filled"] {
  padding: 1.1rem 1.25rem;
  min-height: 0;
  border-style: solid;
  border-color: var(--wm-rule);
  background:
    radial-gradient(circle at 1px 1px, var(--wm-grid) 1px, transparent 0) 0 0 / 18px 18px,
    var(--wm-tint-soft);
  text-align: left;
  cursor: default;
}

.wm-dropzone-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  pointer-events: none;
}

.wm-dropzone-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: white;
  border: 1px solid var(--wm-tint-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--color-brand-primary);
  margin-bottom: 0.6rem;
  transition: transform 220ms ease, box-shadow 220ms ease, background-color 220ms ease;
  box-shadow: 0 6px 14px -8px rgba(44, 62, 80, 0.18);
}

.wm-dropzone[data-wm-state="dragover"] .wm-dropzone-icon {
  transform: translateY(-4px) scale(1.05);
  background: var(--color-brand-primary);
  color: white;
  border-color: var(--color-brand-primary);
}

.wm-dropzone-headline {
  font-family: var(--wm-display);
  font-weight: 500;
  font-size: 1.3rem;
  letter-spacing: 0.005em;
  color: var(--wm-ink);
  margin: 0;
  line-height: 1.1;
}

.wm-dropzone-sub {
  font-size: 0.95rem;
  color: var(--wm-ink-mute);
  margin: 0.1rem 0 0 0;
}

.wm-dropzone-meta {
  font-size: 0.74rem;
  color: var(--wm-ink-mute);
  margin: 0.5rem 0 0 0;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
}

.wm-link {
  color: var(--color-brand-primary);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--color-brand-secondary);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
  pointer-events: auto;
  transition: color 160ms ease, text-decoration-color 160ms ease;
}

.wm-link:hover,
.wm-link:focus-visible {
  color: #1d2c3a;
  text-decoration-color: var(--color-brand-primary);
  outline: none;
}

/* ─── File chip (filled state) ────────────────────────────── */
.wm-dropzone-filled {
  display: flex;
  align-items: center;
  gap: 0.95rem;
  width: 100%;
  animation: wm-slide-in 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.wm-file-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: white;
  border: 1px solid var(--wm-rule);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  color: var(--color-error);
  flex-shrink: 0;
}

.wm-file-info {
  flex: 1;
  min-width: 0;
}

.wm-file-name {
  font-weight: 600;
  margin: 0 0 0.15rem 0;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--wm-ink);
}

.wm-file-meta {
  font-size: 0.74rem;
  color: var(--wm-ink-mute);
  margin: 0;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
}

.wm-file-clear {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--wm-rule);
  background: white;
  cursor: pointer;
  color: var(--wm-ink-mute);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 180ms ease;
  flex-shrink: 0;
  font-size: 0.85rem;
}

.wm-file-clear:hover,
.wm-file-clear:focus-visible {
  border-color: var(--color-error);
  color: var(--color-error);
  background: rgba(239, 68, 68, 0.06);
  outline: none;
}

@keyframes wm-slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── File library (recent uploads) ───────────────────────── */
.wm-library {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.wm-library-eyebrow {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  justify-content: space-between;
  margin: 0;
}

.wm-library-hint {
  text-transform: none;
  letter-spacing: 0.01em;
  font-weight: 500;
  font-size: 0.72rem;
  color: var(--wm-ink-mute);
}

.wm-library-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.wm-library-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0.85rem;
  background: white;
  border: 1px solid var(--wm-rule);
  border-radius: var(--wm-radius-sm);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
  text-align: left;
  outline: none;
}

.wm-library-item:hover {
  border-color: var(--color-brand-secondary);
  background: var(--wm-tint-soft);
}

.wm-library-item:focus-visible {
  border-color: var(--color-brand-primary);
  box-shadow: 0 0 0 3px var(--wm-tint);
}

.wm-library-item.is-selected {
  border-color: var(--color-brand-primary);
  background: var(--wm-tint);
  box-shadow: inset 0 0 0 1px var(--color-brand-primary);
}

.wm-library-item.is-selected::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-brand-primary);
  flex-shrink: 0;
  margin-right: -0.2rem;
}

.wm-library-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.06);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-error);
  font-size: 0.92rem;
  flex-shrink: 0;
}

.wm-library-meta {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  gap: 0.1rem;
}

.wm-library-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--wm-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wm-library-sub {
  font-size: 0.72rem;
  color: var(--wm-ink-mute);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
}

.wm-library-delete {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--wm-ink-mute);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 160ms ease;
  flex-shrink: 0;
  font-size: 0.78rem;
  opacity: 0.55;
}

.wm-library-item:hover .wm-library-delete,
.wm-library-item.is-selected .wm-library-delete {
  opacity: 1;
}

.wm-library-delete:hover,
.wm-library-delete:focus-visible {
  border-color: var(--color-error);
  color: var(--color-error);
  background: rgba(239, 68, 68, 0.08);
  opacity: 1;
  outline: none;
}

.wm-library-empty {
  font-size: 0.85rem;
  color: var(--wm-ink-mute);
  margin: 0;
  padding: 0.6rem 0.85rem;
  font-style: italic;
}

/* ─── Client name field ───────────────────────────────────── */
.wm-field {
  display: flex;
  flex-direction: column;
}

.wm-label {
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 0.5rem;
  color: var(--wm-ink);
  letter-spacing: -0.005em;
}

.wm-input {
  font-family: var(--font-family-primary);
  font-size: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--wm-rule);
  border-radius: var(--wm-radius-sm);
  background: white;
  color: var(--wm-ink);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
  width: 100%;
}

.wm-input::placeholder { color: #94a3b8; }

.wm-input:hover { border-color: #cbd5e1; }

.wm-input:focus {
  outline: none;
  border-color: var(--color-brand-primary);
  box-shadow: 0 0 0 4px var(--wm-tint);
  background: white;
}

.wm-hint {
  font-size: 0.82rem;
  color: var(--wm-ink-mute);
  margin: 0.55rem 0 0 0;
  line-height: 1.45;
}

/* ─── Actions row ─────────────────────────────────────────── */
.wm-actions {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--wm-rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.wm-actions-hint {
  font-size: 0.85rem;
  color: var(--wm-ink-mute);
  margin: 0;
  transition: opacity 200ms ease;
}

.wm-page[data-wm-ready="true"] .wm-actions-hint {
  opacity: 0;
  pointer-events: none;
}

.wm-submit {
  font-family: var(--font-family-primary);
  font-weight: 600;
  font-size: 0.95rem;
  background: var(--color-brand-primary);
  color: white;
  border: 0;
  border-radius: 999px;
  padding: 0.95rem 2rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  letter-spacing: 0.005em;
  transition:
    background-color 180ms ease,
    transform 180ms ease,
    box-shadow 180ms ease,
    opacity 180ms ease;
  box-shadow: 0 6px 18px -8px rgba(44, 62, 80, 0.45);
  min-width: 220px;
  justify-content: center;
  position: relative;
}

.wm-submit:hover:not(:disabled) {
  background: #1d2c3a;
  transform: translateY(-1px);
  box-shadow: 0 10px 22px -10px rgba(44, 62, 80, 0.55);
}

.wm-submit:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 4px var(--wm-tint),
    0 6px 18px -8px rgba(44, 62, 80, 0.45);
}

.wm-submit:active:not(:disabled) { transform: translateY(0); }

.wm-submit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.wm-submit-label {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.wm-submit[data-wm-state="loading"] {
  background: var(--color-brand-primary);
  opacity: 0.95;
  cursor: progress;
}

.wm-submit[data-wm-state="loading"] .wm-submit-label > .fa-solid { display: none; }

.wm-submit[data-wm-state="loading"] .wm-submit-label::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: wm-spin 0.72s linear infinite;
}

@keyframes wm-spin { to { transform: rotate(360deg); } }

/* ─── Status / alerts ─────────────────────────────────────── */
.wm-status {
  margin-top: 1.25rem;
}

.wm-status:empty { margin-top: 0; }

.wm-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.9rem 1.05rem;
  border-radius: var(--wm-radius-sm);
  font-size: 0.92rem;
  line-height: 1.5;
  animation: wm-fade-in 240ms ease;
  border: 1px solid transparent;
}

.wm-alert .fa-solid:first-child {
  margin-top: 2px;
  font-size: 1rem;
  flex-shrink: 0;
}

.wm-alert-body {
  flex: 1;
  min-width: 0;
}

.wm-alert-success {
  background: rgba(16, 185, 129, 0.07);
  border-color: rgba(16, 185, 129, 0.32);
  color: #036c4d;
}
.wm-alert-success .fa-solid:first-child { color: var(--color-success); }

.wm-alert-error {
  background: rgba(239, 68, 68, 0.06);
  border-color: rgba(239, 68, 68, 0.3);
  color: #a31619;
}
.wm-alert-error .fa-solid:first-child { color: var(--color-error); }

.wm-alert-info {
  background: var(--wm-tint-soft);
  border-color: var(--wm-tint-strong);
  color: var(--color-brand-primary);
}
.wm-alert-info .fa-solid:first-child { color: var(--color-brand-primary); }

.wm-alert-warning {
  background: rgba(245, 158, 11, 0.07);
  border-color: rgba(245, 158, 11, 0.32);
  color: #92580a;
}
.wm-alert-warning .fa-solid:first-child { color: var(--color-warning); }

.wm-reset {
  background: transparent;
  border: 0;
  font-weight: 600;
  cursor: pointer;
  font-size: inherit;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0;
  margin-left: 0.25rem;
  font-family: inherit;
}

.wm-reset:hover, .wm-reset:focus-visible {
  text-decoration-thickness: 2px;
  outline: none;
}

@keyframes wm-fade-in {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── History card ────────────────────────────────────────── */
.wm-history {
  margin-top: 2rem;
}

.wm-history .wm-eyebrow {
  margin-left: 0.25rem;
}

.wm-history-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--wm-rule);
  border-radius: var(--wm-radius);
  background: white;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.wm-history-card:hover {
  border-color: var(--color-brand-secondary);
  box-shadow: 0 8px 22px -14px rgba(44, 62, 80, 0.2);
}

.wm-history-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--wm-tint-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-error);
  font-size: 1.05rem;
  flex-shrink: 0;
}

.wm-history-body {
  flex: 1;
  min-width: 0;
}

.wm-history-name {
  font-weight: 600;
  margin: 0;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--wm-ink);
}

.wm-history-meta {
  font-size: 0.82rem;
  color: var(--wm-ink-mute);
  margin: 0.15rem 0 0 0;
}

.wm-history-link {
  color: var(--color-brand-primary);
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--wm-rule);
  background: white;
  transition: all 180ms ease;
  white-space: nowrap;
}

.wm-history-link:hover, .wm-history-link:focus-visible {
  border-color: var(--color-brand-primary);
  background: var(--wm-tint);
  color: var(--color-brand-primary);
  outline: none;
  text-decoration: none;
}

/* ─── Submitting page state ───────────────────────────────── */
.wm-page[data-wm-state="submitting"] .wm-input,
.wm-page[data-wm-state="submitting"] .wm-dropzone,
.wm-page[data-wm-state="submitting"] .wm-file-clear {
  pointer-events: none;
  opacity: 0.7;
}

/* ─── Small screens ───────────────────────────────────────── */
@media (max-width: 540px) {
  .wm-page { padding-top: 1.25rem; }

  .wm-composer { padding: 1.25rem; border-radius: var(--wm-radius); }

  .wm-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .wm-actions-hint { text-align: center; }
  .wm-submit { width: 100%; min-width: 0; }

  .wm-history-card { flex-wrap: wrap; }
  .wm-history-link { width: 100%; justify-content: center; }
}
