﻿/* ==========================================================================
   Sherbet Cookie Consent – Styles
   Matches the clean card UI shown in the design reference screenshots.
   ========================================================================== */

/* ── Custom properties ──────────────────────────────────────────────────── */
:root {
  --scc-bg:            #ffffff;
  --scc-surface:       #f7f7f7;
  --scc-border:        #d8d8d8;
  --scc-text:          #1a1a1a;
  --scc-text-muted:    #555555;
  --scc-accent:        #1a1a1a;        /* primary button fill   */
  --scc-accent-hover:  #333333;
  --scc-link:          #1a1a1a;
  --scc-link-hover:    #555555;
  --scc-toggle-on:     #1a1a1a;
  --scc-toggle-off:    #c8c8c8;
  --scc-radius:        24px;
  --scc-radius-sm:     16px;
  --scc-shadow:        0 4px 24px rgba(0,0,0,0.07), 0 24px 64px rgba(0,0,0,0.14);
  --scc-transition:    0.2s ease;
  --scc-z-overlay:     99998;
  --scc-z-banner:      99999;
  --scc-z-modal:       100000;
  --scc-z-float:       99997;
}

/* ── Reset scoped to our elements ───────────────────────────────────────── */
/* Use :where() so specificity = 0, letting class rules always win          */
:where(#sherbet-cc-banner, #sherbet-cc-modal) *,
:where(#sherbet-cc-float-btn) {
  box-sizing: border-box;
  margin:     0;
  padding:    0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               Oxygen, Ubuntu, sans-serif;
}

/* ── Overlay (modal only – not shown for the banner) ───────────────────── */
.sherbet-cc-overlay {
  display:    none;
  position:   fixed;
  inset:      0;
  background: rgba(0, 0, 0, 0.45);
  z-index:    var(--scc-z-overlay);
  animation:  scc-fade-in var(--scc-transition) both;
}

.sherbet-cc-overlay.is-visible {
  display: block;
}

/* ── Banner (first layer – bottom right) ───────────────────────────────── */
.sherbet-cc-banner {
  display:        none;
  position:       fixed;
  bottom:         28px;
  right:          28px;
  left:           auto;
  top:            auto;
  transform:      none;
  width:          min(520px, calc(100vw - 40px));
  background:     var(--scc-bg);
  border:         1px solid var(--scc-border);
  border-radius:  var(--scc-radius);
  box-shadow:     var(--scc-shadow);
  padding:        32px 28px 28px;
  z-index:        var(--scc-z-banner);
  text-align:     left;
  animation:      scc-slide-in-right var(--scc-transition) both;
}

.sherbet-cc-banner.is-visible {
  display: block;
}

.sherbet-cc-banner__icon {
  display: none;
}

.sherbet-cc-banner__title {
  font-size:     1.2rem;
  font-weight:   700;
  color:         var(--scc-text);
  margin-bottom: 16px;
  line-height:   1.35;
}

.sherbet-cc-banner__text {
  font-size:   0.9rem;
  line-height: 1.75;
  color:       var(--scc-text-muted);
  margin-bottom: 22px;
}

.sherbet-cc-policy-link {
  display:         inline-block;
  font-size:       0.85rem;
  color:           var(--scc-link);
  text-decoration: underline;
  text-underline-offset: 3px;
  margin-bottom:   20px;
  transition:      color var(--scc-transition);
  border:          none !important;
  outline:         none;
  box-shadow:      none;
  background:      none;
  padding:         0;
}

.sherbet-cc-policy-link:hover {
  color: var(--scc-link-hover);
}

/* Button row */
.sherbet-cc-banner__actions {
  display:         flex;
  align-items:     center;
  justify-content: flex-start;
  gap:             10px;
  flex-wrap:       nowrap;
}

/* ── Shared button styles ───────────────────────────────────────────────── */
.sherbet-cc-btn {
  display:        inline-flex;
  align-items:    center;
  justify-content: center;
  height:         auto;
  padding:        11px 16px;
  border-radius:  10px;
  font-size:      0.875rem;
  font-weight:    600;
  letter-spacing: 0.01em;
  cursor:         pointer;
  transition:     background var(--scc-transition), color var(--scc-transition),
                  border-color var(--scc-transition), opacity var(--scc-transition);
  white-space:    nowrap;
  border:         1.5px solid transparent;
  line-height:    1.3;
  text-decoration: none;
}

/* Primary – solid dark */
.sherbet-cc-btn--primary {
  background:   var(--scc-accent);
  color:        #ffffff;
  border-color: var(--scc-accent);
}

.sherbet-cc-btn--primary:hover {
  background:   var(--scc-accent-hover);
  border-color: var(--scc-accent-hover);
}

/* Outline */
.sherbet-cc-btn--outline {
  background:   transparent;
  color:        var(--scc-text);
  border-color: #b8b8b8;
}

.sherbet-cc-btn--outline:hover {
  background:   var(--scc-surface);
  border-color: #999999;
}

/* Text / ghost */
.sherbet-cc-btn--text {
  background:   transparent;
  color:        var(--scc-text-muted);
  border-color: transparent;
  padding:      11px 10px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.sherbet-cc-btn--text:hover {
  color: var(--scc-text);
}

/* ── Preferences Modal (second layer) ───────────────────────────────────── */
.sherbet-cc-modal {
  position:       fixed;
  left:           50%;
  top:            50%;
  transform:      translate(-50%, -50%);
  width:          min(540px, calc(100vw - 40px));
  max-height:     calc(100vh - 48px);
  overflow-y:     auto;
  background:     var(--scc-bg);
  border-radius:  var(--scc-radius);
  box-shadow:     var(--scc-shadow);
  z-index:        var(--scc-z-modal);
  animation:      scc-slide-up var(--scc-transition) both;

  /* scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--scc-border) transparent;
}

.sherbet-cc-modal[hidden] {
  display: none;
}

.sherbet-cc-modal__inner {
  padding: 48px 40px 36px;
}

.sherbet-cc-modal__close {
  position:      absolute;
  top:           20px;
  right:         20px;
  background:    none;
  border:        1.5px solid var(--scc-border);
  cursor:        pointer;
  font-size:     1.15rem;
  color:         var(--scc-text-muted);
  width:         42px;
  height:        42px;
  padding:       0;
  display:       flex;
  align-items:   center;
  justify-content: center;
  line-height:   1;
  border-radius: 50%;
  transition:    color var(--scc-transition), background var(--scc-transition),
                 border-color var(--scc-transition);
}

.sherbet-cc-modal__close:hover {
  color:        var(--scc-text);
  background:   var(--scc-surface);
  border-color: #bbbbbb;
}

.sherbet-cc-modal__icon {
  display:         flex;
  justify-content: center;
  margin-bottom:   24px;
  color:           var(--scc-text);
}

.sherbet-cc-modal__title {
  font-size:     1.45rem;
  font-weight:   700;
  color:         var(--scc-text);
  text-align:    center;
  margin-bottom: 12px;
  line-height:   1.3;
}

.sherbet-cc-modal__intro {
  font-size:     0.9rem;
  color:         var(--scc-text-muted);
  text-align:    center;
  line-height:   1.7;
  margin-bottom: 32px;
}

/* Cookie category rows */
.sherbet-cc-category {
  border-top: 1px solid var(--scc-border);
  padding:    22px 0;
}

.sherbet-cc-category:last-of-type {
  border-bottom: 1px solid var(--scc-border);
}

.sherbet-cc-category__header {
  display:     flex;
  align-items: center;
  gap:         24px;
}

.sherbet-cc-category__info {
  flex: 1;
}

.sherbet-cc-category__name {
  font-size:     1rem;
  font-weight:   700;
  color:         var(--scc-text);
  margin-bottom: 10px;
}

.sherbet-cc-category__desc {
  font-size:   0.875rem;
  color:       var(--scc-text-muted);
  line-height: 1.7;
}

/* "Always active" badge */
.sherbet-cc-badge {
  flex-shrink:   0;
  font-size:     0.78rem;
  font-weight:   600;
  color:         #2e6e2e;
  background:    #e2f3e2;
  border:        1px solid #b8ddb8;
  border-radius: 100px;
  padding:       7px 16px;
  white-space:   nowrap;
  margin-top:    2px;
}

/* Toggle switch */
.sherbet-cc-toggle {
  flex-shrink: 0;
  display:     inline-flex;
  align-items: center;
  cursor:      pointer;
  margin-top:  2px;
}

.sherbet-cc-toggle input[type="checkbox"] {
  position: absolute;
  width:    1px;
  height:   1px;
  opacity:  0;
  overflow: hidden;
  clip:     rect(0 0 0 0);
}

.sherbet-cc-toggle__track {
  position:      relative;
  display:       block;
  width:         58px;
  height:        32px;
  border-radius: 100px;
  background:    var(--scc-toggle-off);
  transition:    background var(--scc-transition);
}

.sherbet-cc-toggle__thumb {
  position:      absolute;
  top:           4px;
  left:          4px;
  width:         24px;
  height:        24px;
  border-radius: 50%;
  background:    #ffffff;
  box-shadow:    0 1px 6px rgba(0,0,0,0.28);
  transition:    transform var(--scc-transition);
}

.sherbet-cc-toggle input:checked ~ .sherbet-cc-toggle__track {
  background: var(--scc-toggle-on);
}

.sherbet-cc-toggle input:checked ~ .sherbet-cc-toggle__track .sherbet-cc-toggle__thumb {
  transform: translateX(26px);
}

.sherbet-cc-toggle input:focus-visible ~ .sherbet-cc-toggle__track {
  outline:        2px solid var(--scc-accent);
  outline-offset: 2px;
}

/* Modal action buttons */
.sherbet-cc-modal__actions {
  display:         flex;
  align-items:     center;
  justify-content: flex-end;
  gap:             12px;
  flex-wrap:       wrap;
  margin-top:      32px;
  padding-top:     20px;
  border-top:      1px solid var(--scc-border);
}

/* ── Floating Preferences Button ────────────────────────────────────────── */
.sherbet-cc-float-btn {
  position:       fixed;
  bottom:         32px;
  right:          32px;
  left:           auto;
  display:        inline-flex;
  align-items:    center;
  gap:            10px;
  padding:        14px 24px;
  border-radius:  12px;
  background:     #1a1a1a;
  color:          #ffffff;
  font-size:      0.9375rem;
  font-weight:    600;
  border:         none;
  cursor:         pointer;
  box-shadow:     0 4px 20px rgba(0,0,0,0.32);
  z-index:        var(--scc-z-float);
  transition:     background var(--scc-transition), transform var(--scc-transition),
                  box-shadow var(--scc-transition);
}

.sherbet-cc-float-btn__icon {
  flex-shrink: 0;
  display:     block;
}

.sherbet-cc-float-btn:hover {
  background:  #333333;
  transform:   translateY(-2px);
  box-shadow:  0 6px 20px rgba(0,0,0,0.32);
}

.sherbet-cc-float-btn[hidden] {
  display: none;
}

/* ── Animations ─────────────────────────────────────────────────────────── */
@keyframes scc-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scc-slide-up {
  from {
    opacity:   0;
    transform: translate(-50%, calc(-50% + 16px));
  }
  to {
    opacity:   1;
    transform: translate(-50%, -50%);
  }
}

@keyframes scc-slide-in-right {
  from {
    opacity:   0;
    transform: translateY(12px);
  }
  to {
    opacity:   1;
    transform: translateY(0);
  }
}

/* ── Responsive: mobile adjustments ─────────────────────────────────────── */
@media (max-width: 600px) {
  .sherbet-cc-banner {
    right:          0;
    bottom:         0;
    left:           0;
    top:            auto;
    width:          auto;
    max-width:      none;
    transform:      none;
    max-height:     80vh;
    overflow-y:     auto;
    border-radius:  var(--scc-radius) var(--scc-radius) 0 0;
    border-left:    none;
    border-right:   none;
    border-bottom:  none;
    padding:        28px 20px max(24px, env(safe-area-inset-bottom));
  }

  .sherbet-cc-modal {
    width:          calc(100vw - 24px);
    max-width:      100%;
    border-radius:  var(--scc-radius-sm);
    max-height:     calc(100vh - 32px);
  }

  .sherbet-cc-modal__inner {
    padding: 44px 20px 28px;
  }

  .sherbet-cc-banner__actions {
    flex-direction: column;
    align-items:    stretch;
    gap:            8px;
  }

  .sherbet-cc-banner__actions .sherbet-cc-btn {
    width:           100%;
    justify-content: center;
  }

  .sherbet-cc-modal__actions {
    flex-direction: column;
    align-items:    stretch;
  }

  .sherbet-cc-modal__actions .sherbet-cc-btn {
    width:           100%;
    justify-content: center;
  }

  .sherbet-cc-float-btn {
    bottom: max(18px, env(safe-area-inset-bottom));
    right:  18px;
    left:   auto;
  }
}

/* ── Reduced motion ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .sherbet-cc-banner,
  .sherbet-cc-modal,
  .sherbet-cc-overlay {
    animation: none;
  }
}
