/* ============================================================================
   SWORT consent + legal confirmation surfaces
   ---------------------------------------------------------------------------
   Both surfaces are fixed-position, so opening or closing them can never
   contribute to layout shift (CLS).

   Phase 4: the cookie bar is a compact floating panel on desktop and a bottom
   sheet on phones. It is never a full-screen blocking overlay, and the two
   one-click decisions carry identical visual weight.
   ========================================================================= */

:root {
  --swc-paper:      #f2f2f2;
  --swc-ink:        #181818;
  --swc-muted:      #55595f;
  --swc-rule:       #d8d8d8;
  --swc-ease:       cubic-bezier(0.22, 1, 0.36, 1);
  --swc-dur-sheet:  0.24s;   /* within the 220-280ms band */
  --swc-dur-ctrl:   0.2s;    /* within the 180-220ms band */
}

/* ── Compact consent bar ────────────────────────────────────────────────── */
.swc-banner {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 2147483000;
  width: min(720px, calc(100vw - 32px));
  background: var(--swc-paper);
  color: var(--swc-ink);
  border: 1px solid var(--swc-rule);
  box-shadow: 0 10px 34px rgba(5, 5, 5, 0.18);
  font-family: 'DM Mono', ui-monospace, monospace;

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-50%) translateY(14px);
  transition:
    opacity    var(--swc-dur-sheet) var(--swc-ease),
    transform  var(--swc-dur-sheet) var(--swc-ease),
    visibility 0s linear var(--swc-dur-sheet);
}
.swc-banner[data-open="true"] {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
  transition-delay: 0s, 0s, 0s;
}

.swc-inner { padding: 20px 22px 18px; }

.swc-title {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--swc-ink);
  margin-bottom: 8px;
}
.swc-copy {
  font-size: 13px;
  line-height: 1.65;
  color: var(--swc-muted);
  margin-bottom: 16px;
}
.swc-copy a {
  color: var(--swc-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.swc-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* Accept All and Essential Only are geometrically identical: no dark pattern. */
.swc-btn {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 12px 20px;
  cursor: pointer;
  border: 1px solid var(--swc-ink);
  background: transparent;
  color: var(--swc-ink);
  min-height: 44px;
  flex: 0 0 auto;
  min-width: 150px;
  text-align: center;
  transition: background var(--swc-dur-ctrl) var(--swc-ease),
              color      var(--swc-dur-ctrl) var(--swc-ease);
}
@media (hover: hover) and (pointer: fine) {
  .swc-btn:hover { background: var(--swc-ink); color: var(--swc-paper); }
}

/* Manage is a tertiary route into detail, not a competing decision. */
.swc-btn-link {
  border-color: transparent;
  min-width: 0;
  padding: 12px 6px;
  margin-left: auto;
  color: var(--swc-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
@media (hover: hover) and (pointer: fine) {
  .swc-btn-link:hover { background: transparent; color: var(--swc-ink); }
}

.swc-banner :focus-visible,
.swc-modal :focus-visible {
  outline: 3px solid #111214;
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .swc-banner {
    left: 0; right: 0; bottom: 0;
    width: auto;
    border-left: none; border-right: none; border-bottom: none;
    transform: translateY(100%);
    box-shadow: 0 -10px 34px rgba(5, 5, 5, 0.22);
  }
  .swc-banner[data-open="true"] { transform: translateY(0); }
  .swc-inner { padding: 22px 20px calc(20px + env(safe-area-inset-bottom)); }
  .swc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .swc-btn { min-width: 0; width: 100%; }
  .swc-btn-link { grid-column: 1 / -1; margin-left: 0; text-align: center; }
}

/* ── Granular preferences (opened only from Manage) ─────────────────────── */
.swc-modal-backdrop {
  position: fixed; inset: 0; z-index: 2147483001;
  background: rgba(5, 5, 5, 0.6);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity var(--swc-dur-sheet) var(--swc-ease),
              visibility 0s linear var(--swc-dur-sheet);
}
.swc-modal-backdrop[data-open="true"] {
  opacity: 1; visibility: visible; pointer-events: auto;
  transition-delay: 0s, 0s;
}
.swc-modal {
  background: var(--swc-paper);
  color: var(--swc-ink);
  font-family: 'DM Mono', ui-monospace, monospace;
  max-width: 600px; width: 100%; max-height: 88vh; overflow-y: auto;
  border: 1px solid var(--swc-rule);
  box-shadow: 0 18px 50px rgba(5, 5, 5, 0.3);
  transform: translateY(12px);
  transition: transform var(--swc-dur-sheet) var(--swc-ease);
}
.swc-modal-backdrop[data-open="true"] .swc-modal { transform: translateY(0); }

.swc-modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--swc-rule);
}
.swc-modal-head h2 {
  font-family: 'DM Mono', monospace; font-size: 12px; font-weight: 500;
  letter-spacing: 0.2em; text-transform: uppercase;
}
.swc-close {
  background: none; border: 1px solid var(--swc-rule); color: var(--swc-ink);
  width: 38px; height: 38px; cursor: pointer; font-size: 17px; line-height: 1;
  transition: background var(--swc-dur-ctrl) var(--swc-ease),
              color      var(--swc-dur-ctrl) var(--swc-ease);
}
@media (hover: hover) and (pointer: fine) {
  .swc-close:hover { background: var(--swc-ink); color: var(--swc-paper); }
}

.swc-modal-body { padding: 20px 24px; font-size: 13px; line-height: 1.7; }
.swc-modal-body > p { margin-bottom: 16px; color: var(--swc-muted); }
.swc-modal-body a { color: #1a1c1f; text-decoration: underline; text-underline-offset: 3px; }

.swc-cat {
  border: 1px solid var(--swc-rule); background: #fafafa;
  padding: 14px 16px; margin-bottom: 10px;
}
.swc-cat-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.swc-cat-name { font-weight: 500; font-size: 13px; }
.swc-cat-desc { font-size: 12px; color: var(--swc-muted); margin-top: 6px; }
.swc-locked {
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--swc-muted); border: 1px solid var(--swc-rule);
  padding: 6px 10px; white-space: nowrap;
}

/* Native checkbox kept for full keyboard and screen-reader support */
.swc-switch { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.swc-switch input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--swc-ink); cursor: pointer; }
.swc-switch label { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer; }

.swc-modal-foot {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end;
  padding: 16px 24px; border-top: 1px solid var(--swc-rule); background: #ededed;
}
.swc-btn-dark {
  font-family: 'DM Mono', monospace; font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; padding: 12px 20px; cursor: pointer;
  border: 1px solid var(--swc-ink); background: transparent; color: var(--swc-ink);
  min-height: 44px; min-width: 140px;
  transition: background var(--swc-dur-ctrl) var(--swc-ease),
              color      var(--swc-dur-ctrl) var(--swc-ease);
}
@media (hover: hover) and (pointer: fine) {
  .swc-btn-dark:hover { background: var(--swc-ink); color: var(--swc-paper); }
}

.swc-status { font-size: 12px; color: var(--swc-muted); padding: 0 24px 14px; }

@media (max-width: 640px) {
  .swc-modal-foot { justify-content: stretch; }
  .swc-btn-dark { flex: 1 1 100%; }
}

/* ============================================================================
   Legal confirmation sheet (form submit)
   Centered restrained modal on desktop, compact bottom sheet on phones.
   ========================================================================= */
.swl-backdrop {
  position: fixed; inset: 0; z-index: 2147483002;
  background: rgba(5, 5, 5, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.22s var(--swc-ease), visibility 0s linear 0.22s;
}
.swl-backdrop[data-open="true"] {
  opacity: 1; visibility: visible; pointer-events: auto;
  transition-delay: 0s, 0s;
}

.swl-sheet {
  background: var(--swc-paper);
  color: var(--swc-ink);
  font-family: 'DM Mono', ui-monospace, monospace;
  border: 1px solid var(--swc-rule);
  box-shadow: 0 14px 40px rgba(5, 5, 5, 0.24);
  width: 100%; max-width: 440px;
  padding: 26px 26px 22px;
  transform: translateY(10px);
  transition: transform 0.22s var(--swc-ease);
}
.swl-backdrop[data-open="true"] .swl-sheet { transform: translateY(0); }
.swl-sheet:focus { outline: none; }
.swl-sheet :focus-visible { outline: 3px solid #111214; outline-offset: 2px; }

.swl-eyebrow {
  font-size: 10px; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--swc-muted); margin-bottom: 10px;
}
.swl-title {
  font-family: 'DM Mono', monospace; font-size: 15px; font-weight: 500;
  line-height: 1.45; margin-bottom: 10px;
}
.swl-copy {
  font-size: 13px; line-height: 1.7; color: var(--swc-muted); margin-bottom: 20px;
}
.swl-copy a {
  color: var(--swc-ink); text-decoration: underline; text-underline-offset: 3px;
}

/* DOM order is Continue then Go Back. Desktop reverses the row so the
   primary action sits on the right; phones stack it on top. */
.swl-actions { display: flex; flex-direction: row-reverse; gap: 10px; justify-content: flex-start; }
.swl-btn {
  font-family: 'DM Mono', monospace; font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; padding: 12px 18px; cursor: pointer;
  min-height: 44px; border: 1px solid var(--swc-ink);
  background: transparent; color: var(--swc-ink);
  transition: background var(--swc-dur-ctrl) var(--swc-ease),
              color      var(--swc-dur-ctrl) var(--swc-ease),
              border-color var(--swc-dur-ctrl) var(--swc-ease);
}
.swl-btn-primary { background: var(--swc-ink); color: var(--swc-paper); flex: 1 1 auto; }
@media (hover: hover) and (pointer: fine) {
  .swl-btn-primary:hover { background: #000; }
}
.swl-btn-ghost { border-color: var(--swc-rule); color: var(--swc-muted); flex: 0 0 auto; }
@media (hover: hover) and (pointer: fine) {
  .swl-btn-ghost:hover { border-color: var(--swc-ink); color: var(--swc-ink); }
}

@media (max-width: 640px) {
  .swl-backdrop { align-items: flex-end; padding: 0; }
  .swl-sheet {
    max-width: none;
    border-left: none; border-right: none; border-bottom: none;
    padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
    transform: translateY(100%);
  }
  .swl-actions { flex-direction: column; }
  .swl-btn { width: 100%; }
}

/* ── Reduced motion: keep the surfaces, drop the movement ───────────────── */
@media (prefers-reduced-motion: reduce) {
  .swc-banner, .swc-modal, .swc-modal-backdrop,
  .swl-backdrop, .swl-sheet,
  .swc-btn, .swc-btn-dark, .swc-close, .swl-btn {
    transition-duration: 0.01ms !important;
  }
  .swc-banner, .swc-banner[data-open="true"] { transform: translateX(-50%); }
  .swc-modal, .swl-sheet { transform: none !important; }
  @media (max-width: 640px) {
    .swc-banner, .swc-banner[data-open="true"] { transform: none; }
  }
}

@media print {
  .swc-banner, .swc-modal-backdrop, .swl-backdrop { display: none !important; }
}

/* ── Keeping the banner off the primary call to action ──────────────────────
   The banner is a fixed card at bottom:24px carrying the highest z-index on
   the page, and #hero is 100vh with its content centred. On a 900px viewport
   the hero buttons sit at 713-764 and the banner opens at 706, so the primary
   control is completely covered; because the banner is pale, it reads as a
   blank rectangle where the button should be.

   Reported as production-only. It is not. It reproduces identically on
   localhost and only ever happens on a FIRST visit, because once consent is
   stored the banner never renders again and a development browser stored it
   long ago. That difference in browser state, not any difference in build
   output, is the whole local-versus-live gap.

   THE ARITHMETIC, because it decides the approach. Hero content is a fixed
   595px. For the control to clear the banner the viewport must hold
   padding-top + 595 + banner + offset + margin. At 720px it does not, by a
   wide margin, so three things give at once and none of them may be the hero
   being cropped:

     the banner reserves space at the foot of the hero, as padding rather than
       a shorter box: shrinking #hero below its content just clips it under
       overflow:hidden, which was measured at 71-79px of lost logo,
     the hero's generous top padding relaxes while the banner is up, which
       costs nothing visually because the composition simply re-centres,
     the banner itself gets denser where vertical space is scarce, laying copy
       and actions side by side instead of stacked.

   All three are scoped to data-consent-banner="open", so the approved hero
   composition and the approved banner return unchanged the moment consent is
   given. --swc-banner-h is measured by consent.js, so this holds when the copy
   wraps to a different height. */
:root[data-consent-banner="open"] #hero {
  min-height: 0;
  padding-top: clamp(16px, 6vh, 72px);
  padding-bottom: calc(var(--swc-banner-h, 170px) + 34px);
}
#hero { transition: padding 260ms cubic-bezier(.2, .8, .2, 1); }

/* Denser banner where vertical space is scarce. Wording, choices and consent
   semantics are untouched; only the density changes. */
@media (max-height: 860px) and (min-width: 760px) {
  .swc-banner { bottom: 12px; width: min(1080px, calc(100vw - 32px)); }
  .swc-inner {
    padding: 12px 18px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 20px;
    align-items: center;
  }
  .swc-title { grid-column: 1; margin-bottom: 2px; }
  .swc-copy  { grid-column: 1; margin-bottom: 0; line-height: 1.5; }
  .swc-actions { grid-column: 2; grid-row: 1 / span 2; flex-wrap: nowrap; gap: 8px; }
  .swc-btn { min-width: 118px; padding: 12px 12px; }
  .swc-btn-link { margin-left: 0; min-width: 0; }
}

/* Below ~780px the hero's own internal rhythm is the last thing standing
   between the composition and the banner. Only while the banner is open. */
@media (max-height: 780px) {
  :root[data-consent-banner="open"] .hero-rule { margin: 8px 0 12px; }
  :root[data-consent-banner="open"] .hero-sub  { margin-bottom: 16px; }
  :root[data-consent-banner="open"] #hero { padding-bottom: calc(var(--swc-banner-h, 122px) + 26px); }
}

@media (prefers-reduced-motion: reduce) {
  #hero { transition: none; }
}
