/* ============================================================
   HELP WIDGET — components/help-widget.css
   Floating "Help" launcher (bottom-right) and its panel: search the
   knowledge base, jump to the right place, or contact the team.
   Markup and logic in help-widget.js (injected into <body>).
   Same dark surface and icon tiles as the nav panels.
   ============================================================ */

.hw {
  --hw-bg: #211A14;
  --hw-raised: #2A221A;
  --hw-border: rgba(255, 255, 255, 0.09);
  --hw-text: var(--text-on-dark, #F2F0ED);
  --hw-soft: rgba(242, 240, 237, 0.74);      /* 10:1 on --hw-bg */
  --hw-gap: 24px;                            /* distance from the viewport edges */
  --hw-lift: 0px;                            /* set by JS above fixed bars (cookie banner, cart bar) */
  --hw-z: 1900;                              /* above the nav, below the cookie modal (2010) */
  --hw-ease: var(--ease-out);
  --focus-ring: var(--primary-on-dark, #FFA98A);

  position: fixed;
  right: var(--hw-gap);
  bottom: calc(var(--hw-gap) + var(--hw-lift));
  z-index: var(--hw-z);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: var(--font-body);
  color: var(--hw-text);
  transition: bottom 0.3s var(--hw-ease);
  pointer-events: none;                      /* only the launcher, teaser and panel take clicks */
}
.hw > * { pointer-events: auto; }

/* The mobile menu takes over the screen: step aside */
.nav-locked .hw { display: none; }

/* ============================================================
   LAUNCHER
   ============================================================ */
.hw-launcher {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 50px;
  padding: 0 20px 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-pill, 99px);
  background: var(--hw-bg);
  color: var(--hw-text);
  font: inherit;
  font-size: 15px;
  font-weight: var(--fw-medium, 500);
  box-shadow: 0 12px 32px rgba(22, 18, 13, 0.32), 0 2px 6px rgba(22, 18, 13, 0.2);
  cursor: pointer;
  transition: background-color var(--transition), border-color var(--transition), transform var(--transition);
}
.hw-launcher:hover { background: var(--hw-raised); border-color: rgba(255, 255, 255, 0.24); }
.hw-launcher:active { transform: scale(0.97); }

.hw-launcher-icon { position: relative; display: grid; place-items: center; width: 20px; height: 20px; }
.hw-launcher-icon svg {
  position: absolute;
  transition: opacity 0.18s ease, transform 0.25s var(--hw-ease);
}
.hw-launcher-icon .hw-i-close { opacity: 0; transform: rotate(-45deg) scale(0.6); }
.hw.is-open .hw-launcher-icon .hw-i-help { opacity: 0; transform: rotate(45deg) scale(0.6); }
.hw.is-open .hw-launcher-icon .hw-i-close { opacity: 1; transform: none; }

/* ============================================================
   GREETING TEASER — once per visitor, desktop only (JS decides)
   ============================================================ */
.hw-teaser {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  width: 300px;
  padding: 4px 4px 4px 0;
  border: 1px solid var(--hw-border);
  border-radius: 16px 16px 4px 16px;
  background: var(--hw-bg);
  box-shadow: 0 18px 48px rgba(22, 18, 13, 0.38);
  opacity: 0;
  transform: translateY(8px);
  visibility: hidden;
  transition: opacity 0.3s ease, transform 0.45s var(--hw-ease), visibility 0s linear 0.45s;
}
.hw-teaser.is-visible { opacity: 1; transform: none; visibility: visible; transition-delay: 0s; }

.hw-teaser-open {
  flex: 1;
  min-width: 0;
  padding: 12px 4px 12px 16px;
  border-radius: 12px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.hw-teaser-title { display: block; margin-bottom: 3px; font-size: var(--fs-small, 14px); font-weight: var(--fw-bold, 600); }
.hw-teaser-text { display: block; font-size: var(--fs-meta, 13px); line-height: 1.45; color: var(--hw-soft); }

.hw-teaser-close {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--hw-soft);
  transition: background-color var(--transition), color var(--transition);
}
.hw-teaser-close:hover { background: rgba(255, 255, 255, 0.07); color: var(--hw-text); }

/* ============================================================
   PANEL — non-modal dialog anchored to the launcher
   ============================================================ */
.hw-panel {
  display: flex;
  flex-direction: column;
  width: 384px;
  max-height: min(760px, calc(100vh - 110px - var(--hw-lift)));
  max-height: min(760px, calc(100dvh - 110px - var(--hw-lift)));
  overflow: hidden;
  border: 1px solid var(--hw-border);
  border-radius: 20px;
  background: var(--hw-bg);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 32px 80px -12px rgba(22, 18, 13, 0.6), 0 8px 24px rgba(22, 18, 13, 0.25);
  transform-origin: 100% 100%;
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  visibility: hidden;
  transition: opacity 0.18s ease, transform 0.3s var(--hw-ease), visibility 0s linear 0.3s;
}
.hw.is-open .hw-panel { opacity: 1; transform: none; visibility: visible; transition-delay: 0s; }

/* ── Head: greeting + search ── */
.hw-head {
  position: relative;
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--hw-border);
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(255, 90, 31, 0.12), transparent 55%),
    var(--hw-bg);
}
.hw-eyebrow {
  margin-bottom: 4px;
  font-size: var(--fs-label, 12px);
  font-weight: var(--fw-bold, 600);
  letter-spacing: var(--tr-caps, 0.08em);
  text-transform: uppercase;
  color: var(--primary-on-dark, #FFA98A);
}
.hw-title {
  margin-bottom: 16px;
  font-size: 22px;
  font-weight: var(--fw-bold, 600);
  letter-spacing: var(--tr-h3, -0.015em);
  line-height: 1.2;
  color: var(--hw-text);
}
.hw-title:focus { outline: none; }

.hw-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: var(--hw-soft);
  transition: background-color var(--transition), color var(--transition);
}
.hw-close:hover { background: rgba(255, 255, 255, 0.07); color: var(--hw-text); }

.hw-search { position: relative; display: flex; align-items: center; }
.hw-search-icon { position: absolute; left: 14px; color: var(--hw-soft); pointer-events: none; }
.hw-search-input {
  width: 100%;
  height: 48px;
  padding: 0 52px 0 42px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--hw-text);
  font: inherit;
  font-size: var(--fs-body, 16px);        /* never below 16px: iOS zooms */
  transition: border-color var(--transition), background-color var(--transition);
}
.hw-search-input::placeholder { color: rgba(242, 240, 237, 0.6); }
.hw-search-input:hover { border-color: rgba(255, 255, 255, 0.24); }
.hw-search-input:focus-visible { outline: none; border-color: var(--primary-on-dark, #FFA98A); background: rgba(0, 0, 0, 0.35); }
.hw-search-input::-webkit-search-cancel-button { display: none; }
.hw-search-btn {
  position: absolute;
  right: 4px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--hw-text);
  transition: background-color var(--transition);
}
.hw-search-btn:hover { background: rgba(255, 255, 255, 0.14); }

/* ── Body: routes ── */
.hw-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 10px 10px;
}
.hw-group + .hw-group { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--hw-border); }
.hw-label {
  padding: 10px 12px 6px;
  font-size: var(--fs-label, 12px);
  font-weight: var(--fw-bold, 600);
  letter-spacing: var(--tr-caps, 0.08em);
  text-transform: uppercase;
  color: var(--hw-soft);
}

.hw-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 10px;
  border-radius: 12px;
  color: var(--hw-text);
  transition: background-color var(--transition);
}
.hw-item:hover, .hw-item:focus-visible { background: rgba(255, 255, 255, 0.05); }

/* Neutral 36px tile, as in the nav; hover/focus turns the glyph orange */
.hw-tile {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: #E2E0DC;  /* opaque (#F2F0ED at 0.92 on the tile): no seams on the duotone layer */
  transition: color var(--transition), border-color var(--transition), background-color var(--transition);
}
.hw-tile img { width: 36px; height: 36px; border-radius: 10px; }
.hw-tile--app { border: 0; background: none; }
.hw-item:hover .hw-tile:not(.hw-tile--app),
.hw-item:focus-visible .hw-tile:not(.hw-tile--app) {
  color: var(--primary-on-dark, #FFA98A);
  border-color: rgba(255, 90, 31, 0.35);
  background: rgba(255, 90, 31, 0.08);
}

.hw-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.hw-item-title { font-size: var(--fs-small, 14px); font-weight: var(--fw-bold, 600); line-height: 1.3; }
.hw-item-desc { font-size: var(--fs-meta, 13px); line-height: 1.4; color: var(--hw-soft); }

.hw-meta {
  flex-shrink: 0;
  padding: 3px 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-pill, 99px);
  font-size: var(--fs-label, 12px);
  font-weight: var(--fw-medium, 500);
  color: var(--hw-soft);
  white-space: nowrap;
}
.hw-arrow { flex-shrink: 0; color: var(--hw-soft); transition: transform var(--transition), color var(--transition); }
@media (hover: hover) and (pointer: fine) { .hw-item:hover .hw-arrow { transform: translateX(2px); color: var(--hw-text); } }

/* ── Foot: talk to the team ── */
.hw-foot {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--hw-border);
  background: var(--hw-raised);
}
.hw-foot-text { margin-bottom: 12px; font-size: var(--fs-meta, 13px); line-height: 1.5; color: var(--hw-soft); }
.hw-foot-text strong { color: var(--hw-text); font-weight: var(--fw-bold, 600); }
.hw-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill, 99px);
  font-size: var(--fs-small, 14px);
  font-weight: var(--fw-medium, 500);
  white-space: nowrap;
  transition: background-color var(--transition), border-color var(--transition);
}
.hw-btn--primary { background: var(--hw-text); color: var(--text-primary, #211A14); }
.hw-btn--primary:hover { background: #fff; }
.hw-btn--ghost { border-color: rgba(255, 255, 255, 0.18); color: var(--hw-text); }
.hw-btn--ghost:hover { border-color: rgba(255, 255, 255, 0.34); background: rgba(255, 255, 255, 0.05); }

/* ── Back-to-top buttons share the corner: they move above the launcher ── */
.has-help .legal-top,
.has-help .sm-top { bottom: calc(24px + 50px + 16px); }

/* ============================================================
   MOBILE — round launcher, panel as a bottom sheet
   ============================================================ */
@media (max-width: 560px) {
  .hw { --hw-gap: 16px; }
  .hw-launcher { width: 52px; height: 52px; padding: 0; justify-content: center; }
  .hw-launcher-label {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .hw-panel {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(8px + var(--hw-lift));
    width: auto;
    max-height: calc(100vh - 72px - var(--hw-lift));
    max-height: calc(100dvh - 72px - var(--hw-lift));
    transform-origin: 50% 100%;
    transform: translateY(24px);
  }
  .hw.is-open .hw-launcher { visibility: hidden; }
  .hw-teaser { display: none; }
  .has-help .legal-top,
  .has-help .sm-top { bottom: calc(16px + 52px + 12px); }
}

@media (prefers-reduced-motion: reduce) {
  .hw { transition: none; }
  /* Panel, teaser and icon swap keep a short fade, never movement */
  .hw-panel,
  .hw-teaser { transition: opacity 0.15s ease, visibility 0s linear 0.15s !important; }
  .hw.is-open .hw-panel,
  .hw-teaser.is-visible { transition: opacity 0.15s ease, visibility 0s !important; }
  .hw-launcher-icon svg { transition: opacity 0.15s ease !important; }
  .hw-panel, .hw-teaser, .hw-launcher-icon svg { transform: none !important; }
}

@media (forced-colors: active) {
  .hw-launcher, .hw-panel, .hw-teaser { border: 1px solid CanvasText; }
}
