/*
 * ═══════════════════════════════════════════════════════════════
 *  HongYuan · Geo-Aware Cookie Consent  v3.0
 *  Strict Mode  → EU/EEA/UK users  → centered card + backdrop
 *  Basic Mode   → all other users  → bottom-right notification
 * ═══════════════════════════════════════════════════════════════
 */

/* ── CSS tokens ────────────────────────────────────────────────────── */
:root {
  --hy-radius:        16px;
  --hy-radius-sm:     10px;
  --hy-font:          -apple-system, BlinkMacSystemFont, 'SF Pro Text',
                      'Inter', 'Segoe UI', sans-serif;

  /* Light surfaces */
  --hy-bg:            rgba(255, 255, 255, 0.96);
  --hy-border:        rgba(0, 0, 0, 0.08);
  --hy-shadow-strict: 0 24px 60px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.08);
  --hy-shadow-basic:  0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  --hy-text:          #1d1d1f;
  --hy-text-muted:    #6e6e73;
  --hy-surface:       rgba(0,0,0,0.04);
  --hy-surface-bd:    rgba(0,0,0,0.06);

  /* Brand blue — matches site's blue-600 */
  --hy-blue:          #2563eb;
  --hy-blue-hover:    #1d4ed8;

  /* Toggle */
  --hy-toggle-off:    #d1d1d6;
  --hy-toggle-on:     #34c759;
}

@media (prefers-color-scheme: dark) {
  :root {
    --hy-bg:            rgba(28, 28, 30, 0.96);
    --hy-border:        rgba(255,255,255,0.10);
    --hy-shadow-strict: 0 24px 60px rgba(0,0,0,0.55), 0 4px 16px rgba(0,0,0,0.3);
    --hy-shadow-basic:  0 8px 32px rgba(0,0,0,0.45);
    --hy-text:          #f5f5f7;
    --hy-text-muted:    #98989d;
    --hy-surface:       rgba(255,255,255,0.06);
    --hy-surface-bd:    rgba(255,255,255,0.08);
    --hy-toggle-off:    #3a3a3c;
    --hy-toggle-on:     #30d158;
  }
}

/* ── Scoped reset ──────────────────────────────────────────────────── */
#hy-consent-banner *,
#hy-consent-banner *::before,
#hy-consent-banner *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Shared backdrop (Strict only) ─────────────────────────────────── */
#hy-consent-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0,0,0,0.32);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.36s ease;
}
#hy-consent-overlay.hy-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ════════════════════════════════════════════════════════════════════
   STRICT MODE  —  EU/EEA/UK  — centered card above bottom
   ════════════════════════════════════════════════════════════════════ */
#hy-consent-banner.hy-strict {
  position: fixed;
  bottom: 28px;
  left: 50%;
  z-index: 9999;
  width: min(500px, calc(100vw - 32px));

  background: var(--hy-bg);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--hy-border);
  border-radius: var(--hy-radius);
  box-shadow: var(--hy-shadow-strict);

  font-family: var(--hy-font);
  color: var(--hy-text);
  -webkit-font-smoothing: antialiased;

  /* Hidden: drops below viewport */
  transform: translateX(-50%) translateY(calc(100% + 36px));
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.46s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.3s ease;
}
#hy-consent-banner.hy-strict.hy-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
#hy-consent-banner.hy-strict.hy-hiding {
  transform: translateX(-50%) translateY(calc(100% + 36px));
  opacity: 0;
  pointer-events: none;
}

/* Card inner padding */
.hy-card {
  padding: 24px;
}

/* Header row */
.hy-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.hy-card-icon {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}
.hy-card-title {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.2px;
  color: var(--hy-text);
}
.hy-card-sub {
  font-size: 11px;
  color: var(--hy-text-muted);
  margin-top: 2px;
}

/* Description */
.hy-card-desc {
  font-size: 13px;
  line-height: 1.6;
  color: var(--hy-text-muted);
  margin-bottom: 18px;
}
.hy-card-desc a {
  color: var(--hy-blue);
  text-decoration: none;
}
.hy-card-desc a:hover { text-decoration: underline; }

/* ── Granular toggles (hidden by default, expands on "Manage") ── */
.hy-toggles {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition:
    max-height 0.38s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.28s ease,
    margin 0.28s ease;
  margin-bottom: 0;
}
.hy-toggles.hy-expanded {
  max-height: 260px;
  opacity: 1;
  margin-bottom: 16px;
}

.hy-toggle-group {
  background: var(--hy-surface);
  border: 1px solid var(--hy-surface-bd);
  border-radius: var(--hy-radius-sm);
  padding: 4px;
}
.hy-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 8px;
  transition: background 0.16s;
}
.hy-toggle-row:hover { background: var(--hy-surface); }
.hy-toggle-info { flex: 1; min-width: 0; }
.hy-toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--hy-text);
}
.hy-toggle-desc {
  font-size: 11px;
  color: var(--hy-text-muted);
  margin-top: 2px;
}
.hy-toggle-divider {
  height: 1px;
  background: var(--hy-surface-bd);
  margin: 0 12px;
}
.hy-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: var(--hy-surface);
  color: var(--hy-text-muted);
  border: 1px solid var(--hy-surface-bd);
  padding: 2px 6px;
  border-radius: 4px;
}

/* iOS switch */
.hy-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 24px;
  flex-shrink: 0;
}
.hy-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.hy-track {
  position: absolute;
  inset: 0;
  background: var(--hy-toggle-off);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.22s;
}
.hy-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.22);
  transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.hy-switch input:checked + .hy-track { background: var(--hy-toggle-on); }
.hy-switch input:checked + .hy-track::after { transform: translateX(16px); }
.hy-switch input:disabled + .hy-track { opacity: 0.42; cursor: not-allowed; }
.hy-switch input:focus-visible + .hy-track {
  outline: 2px solid var(--hy-blue);
  outline-offset: 2px;
}

/* ── Action buttons (Strict) ── */
/*
 * GDPR equal-prominence:
 * Both buttons are the same height & font size.
 * Reject = outlined  ·  Accept = filled (equally clickable area).
 */
.hy-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.hy-btn {
  font-family: var(--hy-font);
  font-size: 13.5px;
  font-weight: 650;
  padding: 13px 18px;
  border-radius: var(--hy-radius-sm);
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  letter-spacing: -0.1px;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.16s, color 0.16s, border-color 0.16s, transform 0.12s;
}
.hy-btn:active { transform: scale(0.97); }

.hy-btn-reject {
  background: transparent;
  color: var(--hy-text);
  border: 1.5px solid var(--hy-border);
}
.hy-btn-reject:hover {
  background: var(--hy-surface);
  border-color: var(--hy-text-muted);
}

.hy-btn-accept {
  background: var(--hy-blue);
  color: #fff;
  border: 1.5px solid transparent;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}
.hy-btn-accept:hover {
  background: var(--hy-blue-hover);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.45);
}

/* Manage Settings subtle link */
.hy-btn-manage-link {
  display: block;
  width: 100%;
  background: none;
  border: none;
  font-family: var(--hy-font);
  font-size: 11.5px;
  color: var(--hy-text-muted);
  text-align: center;
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.16s;
  -webkit-tap-highlight-color: transparent;
}
.hy-btn-manage-link:hover { color: var(--hy-text); }

/* ════════════════════════════════════════════════════════════════════
   BASIC MODE  —  Global non-EU  —  bottom-right notification
   ════════════════════════════════════════════════════════════════════ */
#hy-consent-banner.hy-basic {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 300px;

  background: var(--hy-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--hy-border);
  border-radius: var(--hy-radius);
  box-shadow: var(--hy-shadow-basic);

  font-family: var(--hy-font);
  color: var(--hy-text);
  -webkit-font-smoothing: antialiased;

  /* Hidden: slides right and fades */
  transform: translateX(20px);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.38s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.3s ease;
}
#hy-consent-banner.hy-basic.hy-visible {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}
#hy-consent-banner.hy-basic.hy-hiding {
  transform: translateX(20px);
  opacity: 0;
  pointer-events: none;
}

.hy-notif {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.hy-notif-text {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--hy-text-muted);
}
.hy-notif-text strong { color: var(--hy-text); }
.hy-notif-text a {
  color: var(--hy-blue);
  text-decoration: none;
  white-space: nowrap;
}
.hy-notif-text a:hover { text-decoration: underline; }

/* Basic mode accept — full width */
.hy-basic .hy-btn-accept {
  width: 100%;
  padding: 11px;
  font-size: 13px;
  box-shadow: none;
}

/* ── Geo-detecting skeleton (shown while IP check runs) ─────────── */
.hy-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  font-size: 12.5px;
  color: var(--hy-text-muted);
}
.hy-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--hy-surface-bd);
  border-top-color: var(--hy-blue);
  border-radius: 50%;
  flex-shrink: 0;
  animation: hy-spin 0.8s linear infinite;
}
@keyframes hy-spin { to { transform: rotate(360deg); } }

/* ── FAB — re-open (always bottom-left) ─────────────────────────── */
#hy-consent-fab {
  position: fixed;
  bottom: 18px;
  left: 18px;
  z-index: 9997;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--hy-border);
  background: var(--hy-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  opacity: 0;
  transform: scale(0.5);
  pointer-events: none;
  transition:
    opacity 0.24s ease,
    transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  -webkit-tap-highlight-color: transparent;
}
#hy-consent-fab.hy-visible  { opacity: 1; transform: scale(1); pointer-events: auto; }
#hy-consent-fab:hover        { transform: scale(1.1); }
#hy-consent-fab:active       { transform: scale(0.92); }

/* ── Mobile ─────────────────────────────────────────────────────── */
@media (max-width: 560px) {
  /* Strict: full-width bottom sheet */
  #hy-consent-banner.hy-strict {
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: var(--hy-radius) var(--hy-radius) 0 0;
    transform: translateY(100%);
    opacity: 1;
    transition: transform 0.42s cubic-bezier(0.16, 1, 0.3, 1);
  }
  #hy-consent-banner.hy-strict.hy-visible  { transform: translateY(0); }
  #hy-consent-banner.hy-strict.hy-hiding   { transform: translateY(100%); }

  .hy-card { padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px)); }

  /* Basic: full width at bottom on mobile */
  #hy-consent-banner.hy-basic {
    right: 0; left: 0; bottom: 0;
    width: 100%;
    border-radius: var(--hy-radius) var(--hy-radius) 0 0;
    transform: translateY(20px);
  }
  #hy-consent-banner.hy-basic.hy-hiding { transform: translateY(20px); }

  .hy-notif { padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px)); }

  #hy-consent-fab { bottom: 14px; left: 14px; }
}
