/*!
 * MCH cookie consent — banner, floating pill, and preferences UI.
 *
 * Classes are namespaced under .mch-consent / .mch-consent-pill /
 * .mch-toggle / .mch-prefs* / .mch-cookies-table so nothing collides
 * with the host page's styles. Uses CSS custom properties with sane
 * fallbacks so the file looks correct even on a page that hasn't
 * declared the MCH design tokens.
 */

/* ============================================================
   1. BANNER
   ============================================================ */

.mch-consent {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9998;
  padding: 16px;
  pointer-events: none;
  font-family: 'Inter Tight', sans-serif;
  color: var(--ink, #1a1a1a);
}

.mch-consent__inner {
  pointer-events: auto;
  max-width: 1240px;
  margin: 0 auto;
  background: var(--paper, #fbf8f1);
  border: 1px solid var(--ink, #1a1a1a);
  padding: 24px 28px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 28px;
  align-items: center;
  box-shadow: 0 14px 40px -16px rgba(26, 26, 26, 0.35);
  transform: translateY(28px);
  opacity: 0;
  transition:
    transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1),
    opacity   0.45s ease;
}

.mch-consent.is-visible .mch-consent__inner {
  transform: none;
  opacity: 1;
}

/* Brand column — three-square mark + section label, matching site motif */

.mch-consent__brand {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  flex-shrink: 0;
}

.mch-consent__mark {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
}

.mch-consent__mark span {
  display: block;
  width: 10px;
  height: 8px;
  background: var(--ink, #1a1a1a);
}

.mch-consent__mark span:nth-child(2) {
  background: var(--accent-soft, #e8c97a);
}

.mch-consent__label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-deep, #b8862a);
  white-space: nowrap;
}

/* Text column */

.mch-consent__body {
  min-width: 0;
}

.mch-consent__title {
  font-family: 'Fraunces', serif;
  font-weight: 400;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink, #1a1a1a);
  margin: 0 0 6px;
}

.mch-consent__text {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-soft, #4a4a4a);
  margin: 0;
  max-width: 640px;
}

.mch-consent__link {
  color: var(--ink, #1a1a1a);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.mch-consent__link:hover {
  color: var(--accent-deep, #b8862a);
}

/* Action column — equal-prominence buttons (PECR / GDPR requirement) */

.mch-consent__actions {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

.mch-consent__btn {
  display: inline-block;
  padding: 14px 22px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-decoration: none;
  border: 1px solid var(--ink, #1a1a1a);
  cursor: pointer;
  background: none;
  transition: background 0.2s ease, color 0.2s ease;
  white-space: nowrap;
  line-height: 1;
  min-width: 120px;
  text-align: center;
}

.mch-consent__btn--primary {
  background: var(--ink, #1a1a1a);
  color: var(--paper, #fbf8f1);
}

.mch-consent__btn--primary:hover {
  background: var(--accent-soft, #e8c97a);
  color: var(--ink, #1a1a1a);
}

.mch-consent__btn--secondary {
  color: var(--ink, #1a1a1a);
  background: transparent;
}

.mch-consent__btn--secondary:hover {
  background: var(--ink, #1a1a1a);
  color: var(--paper, #fbf8f1);
}

.mch-consent__btn:focus-visible {
  outline: 2px solid var(--accent-deep, #b8862a);
  outline-offset: 3px;
}

/* Mobile — buttons stay equal-width on a 50/50 grid */

@media (max-width: 860px) {
  .mch-consent { padding: 12px; }

  .mch-consent__inner {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 22px;
  }

  .mch-consent__brand {
    flex-direction: row;
    align-items: center;
  }

  .mch-consent__title { font-size: 19px; }
  .mch-consent__text  { font-size: 13.5px; }

  .mch-consent__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .mch-consent__btn {
    width: 100%;
    padding: 14px 18px;
    min-width: 0;
  }
}

/* ============================================================
   2. FLOATING REOPEN PILL
   ============================================================ */

.mch-consent-pill {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 9997;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 10px 12px;
  background: var(--paper, #fbf8f1);
  border: 1px solid var(--ink, #1a1a1a);
  color: var(--ink, #1a1a1a);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color      0.2s ease,
    transform  0.3s cubic-bezier(0.2, 0.7, 0.2, 1),
    opacity    0.3s ease;
  transform: translateY(10px);
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 6px 20px -10px rgba(26, 26, 26, 0.4);
}

.mch-consent-pill.is-visible {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}

.mch-consent-pill:hover {
  background: var(--ink, #1a1a1a);
  color: var(--paper, #fbf8f1);
}

.mch-consent-pill:hover .mch-consent-pill__mark span:nth-child(1),
.mch-consent-pill:hover .mch-consent-pill__mark span:nth-child(3) {
  background: var(--paper, #fbf8f1);
}

.mch-consent-pill:focus-visible {
  outline: 2px solid var(--accent-deep, #b8862a);
  outline-offset: 3px;
}

.mch-consent-pill__mark {
  display: inline-flex;
  flex-direction: column;
  gap: 1.5px;
}

.mch-consent-pill__mark span {
  display: block;
  width: 8px;
  height: 6px;
  background: var(--ink, #1a1a1a);
  transition: background 0.2s ease;
}

.mch-consent-pill__mark span:nth-child(2) {
  background: var(--accent-deep, #b8862a);
}

@media (max-width: 480px) {
  .mch-consent-pill {
    left: 12px;
    bottom: 12px;
    padding: 9px 14px 9px 11px;
  }
}

/* ============================================================
   3. PREFERENCES PAGE — toggles + actions + status
   ============================================================ */

.mch-prefs {
  border-top: 1px solid var(--ink, #1a1a1a);
  border-bottom: 1px solid var(--ink, #1a1a1a);
  margin: 32px 0 32px;
}

.mch-prefs__row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 28px;
  align-items: center;
  padding: 28px 0;
  border-bottom: 1px dashed rgba(26, 26, 26, 0.2);
}

.mch-prefs__row:last-child {
  border-bottom: none;
}

.mch-prefs__copy h3 {
  font-family: 'Fraunces', serif;
  font-weight: 400;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
  color: var(--ink, #1a1a1a);
}

.mch-prefs__copy h3 em {
  font-style: italic;
  color: var(--accent-deep, #b8862a);
}

.mch-prefs__copy p {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-soft, #4a4a4a);
  margin: 0;
  max-width: 560px;
}

.mch-prefs__tag {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-deep, #b8862a);
  margin-bottom: 6px;
}

.mch-prefs__lock {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted, #8a8580);
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mch-prefs__lock::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--ink-muted, #8a8580);
}

/* Toggle */

.mch-toggle {
  position: relative;
  display: inline-block;
  width: 56px;
  height: 30px;
  flex-shrink: 0;
}

.mch-toggle input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}

.mch-toggle input:disabled {
  cursor: not-allowed;
}

.mch-toggle__track {
  position: absolute;
  inset: 0;
  background: var(--paper, #fbf8f1);
  border: 1px solid var(--ink, #1a1a1a);
  transition: background 0.2s ease;
}

.mch-toggle__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: var(--ink, #1a1a1a);
  transition:
    transform 0.25s cubic-bezier(0.2, 0.7, 0.2, 1),
    background 0.2s ease;
  pointer-events: none;
}

.mch-toggle input:checked ~ .mch-toggle__track {
  background: var(--accent-soft, #e8c97a);
}

.mch-toggle input:checked ~ .mch-toggle__thumb {
  transform: translateX(26px);
}

.mch-toggle input:disabled ~ .mch-toggle__track {
  background: rgba(26, 26, 26, 0.1);
  border-color: rgba(26, 26, 26, 0.35);
}

.mch-toggle input:disabled ~ .mch-toggle__thumb {
  background: rgba(26, 26, 26, 0.4);
}

.mch-toggle input:focus-visible ~ .mch-toggle__track {
  outline: 2px solid var(--accent-deep, #b8862a);
  outline-offset: 3px;
}

/* Prefs action row — same button system as the banner */

.mch-prefs-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 32px;
}

.mch-prefs-actions .mch-consent__btn {
  padding: 16px 26px;
  font-size: 12px;
}

/* Status confirmation */

.mch-prefs-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-deep, #b8862a);
  margin-top: 18px;
  opacity: 0;
  transition: opacity 0.2s ease;
  min-height: 1.2em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mch-prefs-status::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--accent-deep, #b8862a);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.mch-prefs-status.is-visible {
  opacity: 1;
}

.mch-prefs-status.is-visible::before {
  opacity: 1;
}

/* ============================================================
   4. COOKIES TABLE
   ============================================================ */

.mch-cookies-table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0 48px;
  font-size: 14px;
}

.mch-cookies-table th,
.mch-cookies-table td {
  text-align: left;
  padding: 16px 20px 16px 0;
  border-bottom: 1px solid rgba(26, 26, 26, 0.15);
  vertical-align: top;
  color: var(--ink-soft, #4a4a4a);
  line-height: 1.5;
}

.mch-cookies-table th {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-deep, #b8862a);
  border-bottom: 1px solid var(--ink, #1a1a1a);
  font-weight: 400;
  padding-bottom: 14px;
}

.mch-cookies-table td:first-child {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ink, #1a1a1a);
  white-space: nowrap;
}

.mch-cookies-table tr:last-child td {
  border-bottom: none;
}

.mch-cookies-table__cat {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-deep, #b8862a);
}

.mch-cookies-table__cat--essential {
  color: var(--ink-muted, #8a8580);
}

@media (max-width: 720px) {
  .mch-cookies-table { font-size: 13px; }
  .mch-cookies-table th,
  .mch-cookies-table td { padding: 14px 12px 14px 0; }

  /* On narrow screens, drop the "Duration" column so the rest stays
     readable. Designers' choice — keep this off the policy if your
     regulator audit needs it visible. */
  .mch-cookies-table th:nth-child(4),
  .mch-cookies-table td:nth-child(4) {
    display: none;
  }
}
