/*
 * The cookie banner - LN Equipos "Industrial Motion" skin.
 *
 * A file rather than inline styles, for the same reason the configuration is a
 * JSON block rather than generated JavaScript: no inline anything, so a
 * Content-Security-Policy stays possible.
 *
 * Everything is namespaced under .consent and nothing here is a global rule, so
 * dropping this into a project cannot restyle the site around it. It uses no
 * framework, so the plain and tailwind flavors share one file.
 *
 * The markup, the classes and the behavior live in /static/js/analytics/consent.js
 * and are not touched here - this file only changes how it looks. It borrows the
 * site tokens defined in /static/styles.css (with fallbacks, in case this file
 * is ever reused in a project that does not define them).
 */

.consent {
  /* Site tokens, resolved once so the rules below stay readable. The fallbacks
     are the values from /static/styles.css. */
  --c-carbon: var(--carbon, #1B1B1D);
  --c-elevated: var(--carbon-elevated, #2A2A2D);
  --c-deep: var(--carbon-deep, #141416);
  --c-ocre: var(--ocre, #C77B14);
  --c-ocre-dark: var(--ocre-dark, #8A5006);
  --c-navy: var(--navy, #073984);
  --c-navy-light: var(--navy-light, #3D6BB0);
  --c-navy-accent: var(--navy-accent, #6A93D0);
  --c-on-dark: var(--on-dark, #F5F3EF);
  --c-muted: var(--on-dark-muted, #B9B6AE);
  --c-hairline: var(--hairline, rgba(231, 216, 176, .16));
  --c-hairline-soft: var(--hairline-soft, rgba(231, 216, 176, .09));
  --c-r: var(--r, 4px);
  --c-ease: var(--ease, cubic-bezier(.16, 1, .3, 1));

  position: fixed;
  inset: auto 0 0 0;
  z-index: 9999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  /* The site faces: Inter for the running text, Archivo for the title and the
     condensed caps of every control. The system stack is the fallback only. */
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--c-on-dark);
}

@media (min-width: 640px) {
  .consent { padding: 24px; }
}

/*
 * The preferences dialog is modal (aria-modal="true" is set by the script), so
 * it lifts into a centered overlay and dims the page behind it. The first
 * banner is a notice, not a modal, and stays docked at the bottom with the page
 * still reachable - matching what the script announces to assistive tech.
 */
.consent[aria-modal="true"] {
  inset: 0;
  align-items: center;
  background: color-mix(in srgb, var(--c-deep) 72%, transparent);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.consent__panel {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 40rem;
  box-sizing: border-box;
  padding: 24px;
  border: 1px solid var(--c-hairline-soft);
  border-radius: var(--c-r);
  background: var(--c-elevated);
  color: var(--c-on-dark);
  /* One of the three shadows in the system: a floating surface over content. */
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}

/* The ocre rule that opens a card, same gesture as .mv-card. */
.consent__panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--c-ocre);
}

.consent[aria-modal="true"] .consent__panel {
  max-width: 34rem;
  max-height: min(90vh, 44rem);
  overflow-y: auto;
}

.consent__title {
  margin: 0 0 8px;
  font-family: Archivo, system-ui, sans-serif;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.01em;
}

.consent__body {
  margin: 0 0 12px;
  color: var(--c-muted);
  max-width: 52ch;
}

.consent__policy {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--c-ocre);
  font-family: "Roboto Condensed", sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--c-ocre) 45%, transparent);
  padding-bottom: 2px;
  transition: border-color .25s var(--c-ease), color .25s var(--c-ease);
}

.consent__policy:hover {
  color: var(--c-navy-accent);
  border-bottom-color: var(--c-navy-accent);
}

.consent__categories {
  margin: 0 0 16px;
  border-top: 1px solid var(--c-hairline-soft);
}

.consent__category {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px 0;
  border-bottom: 1px solid var(--c-hairline-soft);
}

.consent__category input {
  /* 1.15rem rather than the default: the checkbox is the control the whole
     dialog exists for, and the default is a small target on a phone. */
  width: 1.15rem;
  height: 1.15rem;
  margin: .25rem 0 0;
  flex: 0 0 auto;
  accent-color: var(--c-ocre);
}

.consent__category input:disabled {
  /* Necessary is shown as on and not editable. Dimmed, not hidden: the visitor
     should see everything that runs, including what they cannot refuse. */
  opacity: .55;
}

.consent__category-name {
  display: block;
  font-family: Archivo, system-ui, sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--c-on-dark);
  cursor: pointer;
}

.consent__category-info {
  margin: 4px 0 0;
  color: var(--c-muted);
  font-size: 14px;
  line-height: 1.55;
}

.consent__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.consent__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 24px;
  border: 1px solid transparent;
  border-radius: var(--c-r);
  font-family: "Roboto Condensed", sans-serif;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  /* 44px of touch target, which is the smallest a control should be on a
     phone - and this one is shown to every visitor on every device. */
  min-height: 44px;
  transition: background-color .25s var(--c-ease), border-color .25s var(--c-ease),
    color .25s var(--c-ease), transform .25s var(--c-ease);
}

.consent__button:active {
  transform: translateY(1px);
}

/*
 * Accept and reject are the same size and the same weight on purpose.
 *
 * A refusal that is smaller, quieter or further away than an acceptance is not
 * a free choice, and several supervisory authorities have said exactly that.
 * If this ever needs restyling, that symmetry is the part to keep. Both are
 * solid blocks here: ocre carries the action, navy carries the decision next to
 * it - neither is dressed as the lesser option.
 */
.consent__button--primary {
  background: var(--c-ocre);
  color: #1B1B1D;
}

.consent__button--primary:hover {
  background: var(--c-ocre-dark);
  color: var(--c-on-dark);
}

.consent__button--secondary {
  background: var(--c-navy);
  color: var(--c-on-dark);
  /* The ocre buttons read as having a dark edge because the 1px transparent
     border lets the panel show through. Navy is dark enough that the same trick
     disappears, so reject gets an explicit dark rim to match them. */
  border-color: var(--c-deep);
}

.consent__button--secondary:hover {
  background: var(--c-navy-light);
  color: var(--c-on-dark);
}

.consent__button--quiet {
  padding-inline: 0;
  background: transparent;
  color: var(--c-muted);
  border-color: transparent;
  text-decoration: underline;
  text-underline-offset: 4px;
  transition: color .25s var(--c-ease);
  /* Preferences is the only control that may be quieter: it opens a choice
     rather than making one. */
  margin-right: auto;
}

.consent__button--quiet:hover {
  color: var(--c-ocre);
}

.consent__button:focus-visible {
  /* Never remove this. The dialog traps focus, so a visitor navigating by
     keyboard with no visible focus ring would be stuck in an invisible box. */
  outline: 2px solid var(--c-ocre);
  outline-offset: 3px;
}

/*
 * The banner focuses this control first when it appears, and the browser reports
 * that programmatic focus as :focus-visible - so the ocre ring flashed as a
 * stray border on every first visit. The quiet control still signals focus, but
 * as a colour shift instead of the box outline. The ring stays on every other
 * button, which is what a keyboard visitor tabbing through the dialog sees.
 */
.consent__button--quiet:focus-visible {
  outline: none;
  color: var(--c-ocre);
}

/*
 * In the preferences dialog Save, reject and accept share one row, and each is
 * sized to its own label - so reject and accept, which differ by a character,
 * ended up visibly different widths. Both take the same minimum width, wide
 * enough for the longer label, so the pair reads as a single size without
 * stretching to fill the row. Above the phone breakpoint only; the banner is
 * excluded because its quiet Preferences link keeps the pair right-aligned.
 */
@media (min-width: 521px) {
  .consent__actions:not(:has(> .consent__button--quiet)) > :nth-last-child(-n+2) {
    flex: 0 0 auto;
    min-width: 10rem;
  }
}

/*
 * On a phone the three actions do not fit on one line. The last pair - reject
 * and accept, the two that carry the decision - keep a row to themselves and
 * split it in half, so neither ends up wider or more prominent than the other.
 * The first control (Preferences, or Save in the dialog) takes its own
 * full-width row above them.
 */
@media (max-width: 520px) {
  .consent__actions > :nth-child(1):not(:nth-last-child(-n+2)) {
    flex: 1 0 100%;
    margin-right: 0;
  }

  .consent__actions > :nth-last-child(-n+2) {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 8px;
    font-size: 12px;
  }
}

/*
 * The reopen control that the layout drops at the end of the document. Styled to
 * read as a quiet footer link in caps, which is what the rest of the chrome
 * uses - not a browser-default button.
 */
.consent-reopen {
  display: block;
  margin: 0 auto 24px;
  padding: 8px;
  background: transparent;
  border: 0;
  color: var(--c-muted, #B9B6AE);
  font-family: "Roboto Condensed", sans-serif;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .2s var(--c-ease, cubic-bezier(.16, 1, .3, 1));
}

.consent-reopen:hover {
  color: var(--c-ocre, #C77B14);
}

@media (prefers-reduced-motion: no-preference) {
  .consent__panel {
    animation: consent-in 160ms var(--c-ease, ease-out);
  }

  @keyframes consent-in {
    from { transform: translateY(0.5rem); opacity: 0; }
    to   { transform: none; opacity: 1; }
  }
}
