/*
 * Healing Wisdom — shared tool chrome
 *
 * Naming (boring on purpose, copy-paste friendly across tools):
 *   Prefix:  hw-tool-
 *   Blocks:  page, header, menu, body, footer, pad (spacing utility)
 *   States:  .is-open, modifiers --current, --hidden-wrapped
 *
 * Design tokens: --hw-tool-* (use in tool-specific stylesheets too)
 * Body grid: optional <div class="hw-tool-body-pattern" aria-hidden="true"></div> as first
 *   child inside .hw-tool-body; use .hw-tool-body-inner (1020px) or .hw-tool-body-content
 *   (full-width column, max-width via your utility) above the pattern layer.
 *
 * Shared nav: pages that opt in with data-hw-tool-nav-mount get menu links from
 * js/hw-tool-shell.js (TOOL_MENU_ITEMS); set data-hw-tool-current="<id>" on the
 * same [data-hw-tool-menu] wrapper to mark the active item.
 */

:root {
  --hw-tool-ink: #0f1a33;
  --hw-tool-ocean: #203e7a;
  --hw-tool-mist: #f4f7fb;
  --hw-tool-white: #ffffff;
  --hw-tool-line: rgba(32, 62, 122, 0.16);
  --hw-tool-text-soft: rgba(15, 26, 51, 0.7);
  --hw-tool-header-bg-start: #101b34;
  --hw-tool-header-bg-end: #16294f;
  --hw-tool-layout-max-width: 1020px;
}

/* Kill the default ~8px body margin so the shell is full-bleed; !important wins
   over other stylesheets (e.g. host or third-party) that set body margins. */
html {
  margin: 0 !important;
  padding: 0 !important;
  width: 100%;
  overflow-x: hidden;
  background: var(--hw-tool-mist);
}

body {
  margin: 0 !important;
  padding: 0 !important;
  width: 100%;
  overflow-x: hidden;
  background: var(--hw-tool-mist);
  min-height: 100vh;
  min-height: 100dvh;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* -------------------------------------------------------------------------- */
/* Page frame                                                                 */
/* -------------------------------------------------------------------------- */

.hw-tool-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  background: var(--hw-tool-mist);
  color: var(--hw-tool-ink);
}

@media (prefers-reduced-motion: reduce) {
  .hw-tool-menu-button,
  .hw-tool-menu-link {
    transition: none;
  }
}

/* Horizontal padding: aligns header, main, footer at the same breakpoints */
.hw-tool-pad {
  padding-left: 40px;
  padding-right: 40px;
}

/* -------------------------------------------------------------------------- */
/* Header                                                                     */
/* -------------------------------------------------------------------------- */

.hw-tool-header {
  position: relative;
  z-index: 30;
  overflow: visible;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--hw-tool-header-bg-start) 0%, var(--hw-tool-header-bg-end) 100%);
  color: var(--hw-tool-white);
  padding: 18px 40px 20px;
}

.hw-tool-header-pattern {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at 50% 28%, black, transparent 75%);
  pointer-events: none;
}

.hw-tool-header-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(135, 194, 107, 0.22), transparent 70%);
  pointer-events: none;
}

.hw-tool-header-inner {
  max-width: var(--hw-tool-layout-max-width);
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.hw-tool-header-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  column-gap: clamp(10px, 2.5vw, 16px);
}

.hw-tool-header-cluster {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.hw-tool-header-brand {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  color: inherit;
  text-decoration: none;
}

.hw-tool-header-brand img {
  height: 26px;
  width: 26px;
  opacity: 0.92;
  display: block;
}

@media (max-width: 720px) {
  .hw-tool-header-brand.hw-tool-header-brand--hidden-wrapped {
    display: none;
  }
}

.hw-tool-header-title-wrap {
  min-width: 0;
  flex: 1 1 auto;
}

.hw-tool-header-title {
  font-family: "Cormorant Garamond", "Times New Roman", serif;
  font-size: clamp(1.35rem, 3.2vw, 2rem);
  font-weight: 400;
  line-height: 1.1;
  margin: 0;
  letter-spacing: -0.01em;
  overflow-wrap: break-word;
}

.hw-tool-header-actions {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* -------------------------------------------------------------------------- */
/* Menu                                                                       */
/* -------------------------------------------------------------------------- */

.hw-tool-menu {
  position: relative;
  z-index: 100;
}

.hw-tool-menu-button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: var(--hw-tool-white);
  border-radius: 10px;
  cursor: pointer;
  padding: 8px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.hw-tool-menu-button:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
}

.hw-tool-menu-button:focus-visible {
  outline: 3px solid rgba(135, 194, 107, 0.38);
  outline-offset: 2px;
}

.hw-tool-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 244px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #ffffff;
  box-shadow: 0 20px 36px rgba(16, 24, 41, 0.2);
  padding: 10px 0;
  z-index: 200;
  display: none;
}

.hw-tool-menu-panel.is-open {
  display: block;
}

.hw-tool-menu-group {
  padding: 0 12px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #64748b;
}

.hw-tool-menu-sep {
  margin: 6px 0;
  border-top: 1px solid #e5e7eb;
}

.hw-tool-menu-link {
  display: block;
  padding: 10px 16px;
  font-size: 0.9rem;
  color: #334155;
  text-decoration: none;
}

.hw-tool-menu-link:hover {
  background: #f8fafc;
}

.hw-tool-menu-link.hw-tool-menu-link--current {
  background: #f8fafc;
  color: #21214f;
  font-weight: 700;
}

.hw-tool-menu-link.hw-tool-menu-link--external {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hw-tool-menu-link-main {
  min-width: 0;
  flex: 1 1 auto;
}

.hw-tool-menu-external-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  line-height: 0;
}

.hw-tool-menu-external-icon svg {
  display: block;
}

.hw-tool-menu-link.hw-tool-menu-link--external:hover .hw-tool-menu-external-icon {
  color: #64748b;
}

.hw-tool-menu-link.hw-tool-menu-link--current .hw-tool-menu-external-icon {
  color: #94a3b8;
}

/* -------------------------------------------------------------------------- */
/* Main + optional background pattern                                         */
/* -------------------------------------------------------------------------- */

.hw-tool-body {
  position: relative;
  z-index: 0;
  padding: 40px 40px 48px;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  justify-content: safe center;
  overflow-y: auto;
  min-height: 0;
}

.hw-tool-body-pattern {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(32, 62, 122, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(32, 62, 122, 0.06) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: radial-gradient(circle at 50% 50%, black, transparent 88%);
  pointer-events: none;
}

.hw-tool-body-inner {
  max-width: var(--hw-tool-layout-max-width);
  margin: 0 auto;
  position: relative;
  z-index: 1;
  width: 100%;
}

/* Wide / unconstrained content column — sits above .hw-tool-body-pattern */
.hw-tool-body-content {
  position: relative;
  z-index: 1;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* Flat pages (no vertical centering) */
.hw-tool-body--top {
  justify-content: flex-start;
}

.hw-tool-body--dense {
  padding-top: 28px;
  padding-bottom: 32px;
}

/* -------------------------------------------------------------------------- */
/* Local tool family nav                                                      */
/* -------------------------------------------------------------------------- */

.hw-tool-subnav {
  position: relative;
  z-index: 20;
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(11, 22, 44, 0.98) 0%, rgba(15, 30, 60, 0.98) 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.hw-tool-subnav-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  min-height: 52px;
  max-width: var(--hw-tool-layout-max-width);
  margin: 0 auto;
}

.hw-tool-subnav-inner--center {
  justify-content: center;
}

.hw-tool-subnav-label {
  padding: 0 16px 0 0;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  font-family: "Cormorant Garamond", "Times New Roman", serif;
  font-size: 1.18rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.64);
}

.hw-tool-subnav-link {
  display: inline-flex;
  align-items: center;
  min-height: 52px;
  padding: 0 0 1px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.62);
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.1;
  text-decoration: none;
  transition: color 0.18s ease, opacity 0.18s ease;
  position: relative;
}

.hw-tool-subnav-link:hover {
  color: rgba(255, 255, 255, 0.9);
}

.hw-tool-subnav-link.hw-tool-subnav-link--current {
  color: #ffffff;
  text-decoration-line: underline;
  text-decoration-color: rgba(224, 236, 255, 0.9);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.22em;
  text-decoration-skip-ink: none;
}

/*
 * Small viewports: remove default tool-body / pad inset (e.g. full-bleed forms).
 * Pairs with .hw-tool-pad on the same element; overrides responsive !important pad.
 */
@media (max-width: 680px) {
  .hw-tool-body.hw-tool-pad.hw-tool-body--flush-xs {
    padding: 0 0 max(0.75rem, env(safe-area-inset-bottom, 0)) !important;
  }
}

/* -------------------------------------------------------------------------- */
/* Footer                                                                     */
/* -------------------------------------------------------------------------- */

.hw-tool-footer {
  flex-shrink: 0;
  background: linear-gradient(135deg, #101b34, #16294f);
  color: rgba(255, 255, 255, 0.9);
  padding: 22px 40px;
}

.hw-tool-footer-inner {
  max-width: var(--hw-tool-layout-max-width);
  margin: 0 auto;
  text-align: center;
}

.hw-tool-footer-kicker {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.72;
  margin: 0;
}

.hw-tool-footer-note {
  margin: 5px 0 0;
  font-size: 0.88rem;
  opacity: 0.8;
}

/* -------------------------------------------------------------------------- */
/* Responsive padding (matches QR generator breakpoints)                        */
/* -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .hw-tool-pad {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }
}

@media (max-width: 680px) {
  .hw-tool-pad {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  .hw-tool-header.hw-tool-pad {
    padding-top: 15px;
    padding-bottom: 17px;
  }

  .hw-tool-body.hw-tool-pad {
    padding: 28px 16px 24px;
  }

  .hw-tool-footer.hw-tool-pad {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .hw-tool-menu-panel {
    width: min(220px, calc(100vw - 32px));
  }

  .hw-tool-subnav {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .hw-tool-subnav-inner {
    gap: 12px;
    min-height: 0;
  }

  .hw-tool-subnav-label {
    width: 100%;
    padding: 0 0 8px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .hw-tool-subnav-link {
    min-height: 34px;
    padding-bottom: 4px;
    font-size: 0.91rem;
  }
}

@media (max-width: 420px) {
  .hw-tool-pad {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
}
