/**
 * Smart Catering — Cookie Consent component
 *
 * Uses design tokens from tokens.css. Reuses .sc-button from button.css
 * (scoped under body.scc-fase0) — buttons are NOT redefined here.
 */

/* ============================================================
   Banner — fixed bottom bar
   ============================================================ */

.scc-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 500;
  background: var(--color-cream, #F8F7F2);
  border-top: 1px solid var(--color-border, #e8e3d8);
  box-shadow: 0 -4px 24px rgba(5, 4, 24, 0.10);
  font-family: var(--font-sans, Overpass), sans-serif;
  color: var(--color-ink, #2b2b2b);

  /* Visible by default — the server decides whether to add .scc-banner--dismissed.
     This means LiteSpeed-deferred JS never gates visibility. */
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  visibility: visible;
  transition:
    opacity var(--transition-base, 280ms cubic-bezier(0.16, 1, 0.3, 1)),
    transform var(--transition-base, 280ms cubic-bezier(0.16, 1, 0.3, 1)),
    visibility 0s linear var(--transition-base, 280ms);
}

/* Server sets this class when the visitor already has valid consent.
   Also set by JS after the visitor accepts/rejects during this session. */
.scc-banner--dismissed {
  opacity: 0;
  transform: translateY(100%);
  pointer-events: none;
  visibility: hidden;
  transition:
    opacity var(--transition-base, 280ms cubic-bezier(0.16, 1, 0.3, 1)),
    transform var(--transition-base, 280ms cubic-bezier(0.16, 1, 0.3, 1)),
    visibility 0s linear var(--transition-base, 280ms);
}

/* Fallback: early-inline script adds .scc-consent-resolved when a valid cookie
   is present and JS runs before the banner becomes interactive.
   Belt-and-suspenders — the server-gated class is the primary gate. */
html.scc-consent-resolved .scc-banner {
  display: none;
}

.scc-banner__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.scc-banner__content {
  flex: 1 1 280px;
  min-width: 0;
}

.scc-banner__title {
  font-weight: 700;
  font-size: 0.95rem;
  margin: 0 0 0.25rem;
  line-height: 1.3;
}

.scc-banner__body {
  font-size: 0.85rem;
  color: var(--color-mute, #767676);
  margin: 0;
  line-height: 1.5;
}

.scc-banner__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* ============================================================
   Floating "manage consent" tab — bottom-left
   ============================================================ */

/* Hidden by default; revealed only once consent is resolved (the <html>
   .scc-consent-resolved class). Sits below the banner (500) and prefs (600)
   so it never overlaps them — and they're never visible at the same time
   anyway (tab = post-consent, banner = pre-consent). */
.scc-cookie-fab {
  position: fixed;
  bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
  left: max(1.25rem, env(safe-area-inset-left, 0px));
  z-index: 480;

  display: none; /* shown via html.scc-consent-resolved below */
  align-items: center;
  gap: 0.5rem;

  padding: 0.6rem 0.95rem;
  background: var(--color-cream, #F8F7F2);
  color: var(--color-ink, #2b2b2b);
  border: 1px solid var(--color-border, #e8e3d8);
  border-radius: 999px;
  box-shadow: 0 4px 18px rgba(5, 4, 24, 0.12);

  font-family: var(--font-sans, Overpass), sans-serif;
  font-size: var(--fs-sm, 0.875rem);
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

html.scc-consent-resolved .scc-cookie-fab {
  display: inline-flex;
}

.scc-cookie-fab:hover,
.scc-cookie-fab:focus-visible {
  color: var(--color-gold, #D99E39);
  border-color: var(--color-gold, #D99E39);
  box-shadow: 0 6px 22px rgba(5, 4, 24, 0.16);
  transform: translateY(-1px);
}

.scc-cookie-fab__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Mobile: collapse to an icon-only circular tap target (≥44px), keep the
   label accessible to screen readers, and respect the notch safe areas. */
@media (max-width: 640px) {
  .scc-cookie-fab {
    bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    left: max(1rem, env(safe-area-inset-left, 0px));
    width: 44px;
    height: 44px;
    padding: 0;
    gap: 0;
    justify-content: center;
    border-radius: 50%;
  }

  .scc-cookie-fab__text {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }
}

/* ============================================================
   Preferences panel — fixed overlay + centered dialog
   ============================================================ */

.scc-prefs {
  position: fixed;
  inset: 0;
  z-index: 600;

  /* Hidden by default */
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition:
    opacity var(--transition-base, 280ms cubic-bezier(0.16, 1, 0.3, 1)),
    visibility 0s linear var(--transition-base, 280ms);
}

.scc-prefs--visible {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transition:
    opacity var(--transition-base, 280ms cubic-bezier(0.16, 1, 0.3, 1)),
    visibility 0s linear 0s;
}

.scc-prefs__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 4, 24, 0.55);
  cursor: pointer;
}

.scc-prefs__dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--color-cream, #F8F7F2);
  border-radius: var(--radius-lg, 8px);
  box-shadow: var(--shadow-lg, 0 16px 40px rgba(5, 4, 24, 0.12));
  width: min(560px, calc(100vw - 2rem));
  max-height: min(90dvh, 640px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-sans, Overpass), sans-serif;
  color: var(--color-ink, #2b2b2b);
}

.scc-prefs__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--color-border, #e8e3d8);
  flex-shrink: 0;
}

.scc-prefs__heading {
  font-family: var(--font-sans, Overpass), sans-serif;
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
}

.scc-prefs__close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-mute, #767676);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-lg, 8px);
  transition: color var(--transition-base, 280ms cubic-bezier(0.16, 1, 0.3, 1));
}

.scc-prefs__close:hover,
.scc-prefs__close:focus-visible {
  color: var(--color-ink, #2b2b2b);
}

.scc-prefs__body {
  overflow-y: auto;
  padding: 1rem 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.scc-prefs__footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border, #e8e3d8);
  flex-shrink: 0;
}

/* ============================================================
   Category rows
   ============================================================ */

.scc-prefs__category {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border, #e8e3d8);
}

.scc-prefs__category:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.scc-prefs__category-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.scc-prefs__category-desc {
  font-size: 0.82rem;
  color: var(--color-mute, #767676);
  margin: 0;
  line-height: 1.5;
}

/* ============================================================
   Toggle switch
   ============================================================ */

.scc-toggle-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
}

.scc-toggle-label--disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.scc-toggle-label__text {
  font-size: 0.9rem;
  font-weight: 600;
}

.scc-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.scc-toggle input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.scc-toggle__track {
  display: block;
  width: 40px;
  height: 22px;
  border-radius: var(--radius-full, 9999px);
  background: #ccc;
  transition: background var(--transition-base, 280ms cubic-bezier(0.16, 1, 0.3, 1));
}

.scc-toggle__thumb {
  position: absolute;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  transition: transform var(--transition-base, 280ms cubic-bezier(0.16, 1, 0.3, 1));
}

/* Checked state — gold track, thumb slides right */
.scc-toggle input[type="checkbox"]:checked ~ .scc-toggle__track {
  background: var(--color-gold, #D99E39);
}

.scc-toggle input[type="checkbox"]:checked ~ .scc-toggle__thumb {
  transform: translateX(18px);
}

/* Focus ring on the visible track (for keyboard navigation) */
.scc-toggle input[type="checkbox"]:focus-visible ~ .scc-toggle__track {
  outline: 2px solid var(--color-gold, #D99E39);
  outline-offset: 2px;
}

/* ============================================================
   Badge — "Siempre activas"
   ============================================================ */

.scc-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full, 9999px);
  background: var(--color-gold, #D99E39);
  color: #000;
  line-height: 1.4;
}

/* ============================================================
   Inline link inside banner body text
   ============================================================ */

.scc-link {
  color: var(--color-gold-ink, #a87410);
  text-decoration: underline;
  font-size: inherit;
}

.scc-link:hover,
.scc-link:focus-visible {
  color: var(--color-ink, #2b2b2b);
}

/* ============================================================
   Button spacing helper
   ============================================================ */

/* .scc-btn is used as an additional class on .sc-button elements.
   It does NOT redefine .sc-button — just adds gap/margin context. */
.scc-btn {
  flex-shrink: 0;
}

/* ============================================================
   Responsive — mobile
   ============================================================ */

@media (max-width: 640px) {
  .scc-banner__bar {
    flex-direction: column;
    align-items: stretch;
    padding: 1rem;
  }

  .scc-banner__actions {
    flex-direction: column;
  }

  .scc-banner__actions .sc-button,
  .scc-banner__actions .scc-btn {
    width: 100%;
    justify-content: center;
  }

  .scc-prefs__footer {
    flex-direction: column;
    align-items: stretch;
  }

  .scc-prefs__footer .sc-button,
  .scc-prefs__footer .scc-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ============================================================
   Reduced motion
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  .scc-banner,
  .scc-banner--dismissed,
  .scc-prefs,
  .scc-prefs--visible,
  .scc-toggle__track,
  .scc-toggle__thumb,
  .scc-cookie-fab {
    transition: none;
  }
}
