/*
 * The cookie notice and the Cookie preferences dialog (js/consent.js).
 *
 * The notice is a non-modal region fixed to the foot of the window: the kit's
 * overlay look (white ground, a hairline edge, the overlay shadow), the two
 * choices as secondary buttons of equal weight, then Manage preferences as a
 * link. While it is up, js/consent.js sets html's scroll-padding-bottom and a
 * spacer at the end of the body to its height, so nothing on the page is
 * stranded behind it. The dialog is the kit's dialog in its own overlay (the
 * same scrim and placement as .modal--kit), and a bottom sheet on a phone.
 *
 * Layered under every dialog (the AI Designer's 150 and 160, the pricing
 * add-on dialog's 200, the kit's modals at 300, the payment terms at 400) and
 * over the page's own sticky parts (the masthead is 100). Color comes
 * only from theme.css tokens.
 */

/* ---------- The notice ---------- */

.consent-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 140;
  border-top: 1px solid var(--color-edge-strong);
  background: var(--color-ground);
  color: var(--color-ink);
  box-shadow: var(--shadow-overlay);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.consent-banner__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4) var(--space-6);
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 32px 22px;
}

.consent-banner__body {
  display: flex;
  flex: 1 1 520px;
  flex-direction: column;
  gap: 6px;
  max-width: 760px;
  min-width: 0;
}

.consent-banner__title {
  margin: 0;
  font: var(--text-title-sm);
  letter-spacing: var(--tracking-title-sm);
  color: var(--color-ink);
}

.consent-banner__text {
  margin: 0;
  font: var(--text-body);
  letter-spacing: var(--tracking-body);
  color: var(--color-ink);
}

.consent-banner .consent-banner__confirm:focus,
.consent-banner .consent-banner__confirm:focus-visible {
  outline: none;
  box-shadow: none;
}

/* A grid, so the two choices are always the same width as well as the same
   style: neither is drawn as the default. */
.consent-banner__actions {
  display: grid;
  flex: none;
  grid-template-columns: 1fr 1fr auto;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

/* A button drawn as the kit's action link: the link's own type and color, no
   button chrome. */
.consent-banner__manage {
  padding: 0 var(--space-1);
  border: 0;
  background: none;
  cursor: pointer;
}

/* The space the notice covers, kept at the end of the page while it is up. */
.consent-spacer {
  display: block;
  flex: none;
  width: 100%;
  pointer-events: none;
}

/* ---------- The dialog ---------- */

.consent-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 136px 16px 24px;
  background: var(--color-scrim);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.consent-dialog {
  width: 600px;
  max-width: 100%;
  max-height: calc(100dvh - 160px);
}

/* The dialog itself takes focus on open so its name and introduction are read
   first; it is not a control, so it draws no ring. */
.consent-overlay .consent-dialog:focus,
.consent-overlay .consent-dialog:focus-visible {
  outline: none;
  box-shadow: var(--shadow-overlay);
}

.consent-dialog__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  gap: var(--space-4);
  padding-top: var(--space-3);
  color: var(--color-ink);
}

.consent-dialog__intro {
  margin: 0;
  font: var(--text-body);
  color: var(--color-ink);
}

.consent-dialog__note {
  margin: 0;
  padding: 10px 12px;
  border-left: 2px solid var(--color-info);
  background: var(--color-info-tint);
  font: var(--text-body-sm);
  color: var(--color-ink);
}

.consent-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: var(--space-3);
  border-top: var(--rule-hair);
}

.consent-row__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 32px;
}

.consent-row__title {
  margin: 0;
  font: var(--text-button);
  letter-spacing: var(--tracking-button);
  color: var(--color-ink);
}

.consent-row__state {
  font: var(--text-label);
  letter-spacing: var(--tracking-label);
  color: var(--color-ink-2);
}

.consent-row__text {
  margin: 0;
  font: var(--text-body-sm);
  letter-spacing: var(--tracking-body-sm);
  color: var(--color-ink-2);
}

/* The kit's switch, as a button (role="switch"): the track and the state word,
   without the button chrome. The ring is drawn on the track only. */
.consent-switch {
  flex: none;
  align-items: center;
  margin: 0;
  padding: 6px 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
}

.consent-switch .tt-switch__track,
.consent-switch .tt-switch__state {
  margin-top: 0;
}

.consent-switch .tt-switch__state {
  min-width: 24px;
  text-align: left;
}

.consent-dialog .consent-switch:focus,
.consent-dialog .consent-switch:focus-visible {
  outline: none;
  box-shadow: none;
}

.consent-dialog .consent-switch:not(:focus-visible) .tt-switch__track {
  box-shadow: none;
}

.consent-dialog .consent-switch:focus-visible .tt-switch__track {
  box-shadow: 0 0 0 2px var(--color-ground), 0 0 0 4px var(--color-focus);
}

.consent-dialog__foot {
  flex-wrap: wrap;
}

.consent-dialog__policy {
  margin-right: auto;
}

/* ---------- Cookie preferences controls placed in pages ---------- */

/* A standalone Cookie preferences link inside a column of page notes. */
.consent-entry {
  align-self: flex-start;
}

/* The same link at the far end of a footer row. */
.consent-entry--end {
  margin-left: auto;
}

/* ---------- Phone ---------- */

[data-layout='mobile'] .consent-banner__inner {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: var(--space-3);
  padding: 16px 16px 18px;
}

[data-layout='mobile'] .consent-banner__body {
  flex: none;
  max-width: none;
}

[data-layout='mobile'] .consent-banner__text {
  font: var(--text-body-sm);
  letter-spacing: var(--tracking-body-sm);
}

[data-layout='mobile'] .consent-banner__actions {
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: var(--space-2);
}

[data-layout='mobile'] .consent-banner__btn {
  width: 100%;
  height: var(--size-control-phone);
  font: var(--text-button-lg);
}

[data-layout='mobile'] .consent-banner__manage {
  justify-content: center;
  min-height: var(--size-control-phone);
}

[data-layout='mobile'] .consent-overlay {
  align-items: flex-end;
  padding: 0;
}

[data-layout='mobile'] .consent-dialog {
  width: 100%;
  max-width: none;
  max-height: 92dvh;
  border-bottom: 0;
  border-radius: var(--radius-overlay) var(--radius-overlay) 0 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

[data-layout='mobile'] .consent-dialog .tt-dialog__head {
  padding: 12px 8px 0 16px;
}

[data-layout='mobile'] .consent-dialog__close {
  width: var(--size-control-phone);
  height: var(--size-control-phone);
}

[data-layout='mobile'] .consent-dialog__body {
  padding: 8px 16px 4px;
}

[data-layout='mobile'] .consent-switch {
  min-height: var(--size-control-phone);
}

[data-layout='mobile'] .consent-dialog__foot {
  flex-direction: column-reverse;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: var(--space-2);
  padding: 16px;
}

[data-layout='mobile'] .consent-dialog__foot .tt-btn {
  width: 100%;
  height: var(--size-control-phone);
  font: var(--text-button-lg);
}

[data-layout='mobile'] .consent-dialog__policy {
  justify-content: center;
  min-height: var(--size-control-phone);
  margin-right: 0;
}

[data-layout='mobile'] .consent-entry {
  min-height: var(--size-control-phone);
}
