/**
 * Purpose: Defines the shared public-site header, footer, navigation, and page-shell layout.
 * TODOs: None
 * Maintainer: John B.
 * Contact: john@sobriety.works
 */

/* Core layout, component, and interaction rules for this stylesheet's interface area. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid var(--sw-color-border);
  padding-right: var(--sw-scrollbar-gutter);
  background: rgb(var(--sw-rgb-canvas) / 0.94);
  backdrop-filter: blur(18px);
  transform: translateY(var(--sw-header-translate-y, 0px));
  will-change: transform;
  transition:
    background-color var(--sw-mobile-nav-duration) var(--sw-mobile-nav-ease),
    border-color var(--sw-mobile-nav-duration) var(--sw-mobile-nav-ease),
    color var(--sw-mobile-nav-duration) var(--sw-mobile-nav-ease);
}

.site-header:focus-within,
body.nav-open .site-header,
body.nav-opening .site-header,
body.nav-closing .site-header {
  transform: translateY(0);
}

body.nav-closing .site-header {
  transform: translateY(0);
}

.sw-nav,
.sw-nav-inner {
  min-height: 86px;
}

.sw-nav {
  padding: 0;
}

.sw-nav-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.sw-brand {
  position: relative;
  z-index: 1100;
  display: inline-flex;
  align-items: center;
  width: auto;
  max-width: calc(100% - 56px);
  height: 28px;
  text-decoration: none;
}

.sw-brand img {
  display: block;
  width: auto;
  max-width: 100%;
  height: 100%;
  filter: none;
  transition: filter var(--sw-mobile-nav-duration) var(--sw-mobile-nav-ease);
}

.sw-nav-toggle {
  position: relative;
  z-index: 1100;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-left: auto;
  border: 0;
  border-radius: var(--sw-radius-control);
  padding: 0;
  background: transparent;
  box-shadow: none;
  color: var(--sw-color-text);
  transition:
    border-color var(--sw-mobile-nav-duration) var(--sw-mobile-nav-ease),
    color var(--sw-mobile-nav-duration) var(--sw-mobile-nav-ease);
}

.sw-nav-toggle:focus {
  box-shadow: none;
}

.sw-toggle-lines {
  position: relative;
  width: 22px;
  height: 2px;
  background: currentColor;
  transition: background-color var(--sw-mobile-nav-duration) var(--sw-mobile-nav-ease);
}

.sw-toggle-lines::before,
.sw-toggle-lines::after {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
  content: "";
  transition:
    top var(--sw-mobile-nav-duration) var(--sw-mobile-nav-ease),
    transform var(--sw-mobile-nav-duration) var(--sw-mobile-nav-ease),
    background-color var(--sw-mobile-nav-duration) var(--sw-mobile-nav-ease);
}

.sw-toggle-lines::before {
  top: -7px;
}

.sw-toggle-lines::after {
  top: 7px;
}

.sw-nav-collapse {
  flex-grow: 1;
}

.sw-main-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 32px;
  margin-left: auto;
  font-size: var(--font-size-control);
  font-weight: 600;
  line-height: var(--line-height-control);
}

.sw-main-nav a {
  position: relative;
  display: inline-flex;
  padding: 0.4rem 0;
  color: var(--sw-color-text);
  text-decoration: none;
}

.sw-main-nav a::after {
  position: absolute;
  right: 0;
  bottom: -0.2rem;
  left: 0;
  height: 1px;
  transform: scaleX(0);
  transform-origin: left;
  background: currentColor;
  content: "";
  transition: transform 180ms ease;
}

.sw-main-nav a:hover::after,
.sw-main-nav a[aria-current="page"]::after {
  transform: scaleX(1);
}

.sw-main-nav a[aria-current="page"] {
  color: var(--sw-color-action);
}

.sw-main-nav a.sw-nav-sign-up {
  border: 1px solid var(--sw-color-action);
  border-radius: var(--sw-radius-control);
  padding: 0.65rem 0.9rem;
  background: var(--sw-color-action);
  color: var(--sw-color-on-action);
  transition: background-color 180ms ease, border-color 180ms ease;
}

.sw-main-nav a.sw-nav-sign-up::after {
  display: none;
}

.sw-main-nav a.sw-nav-sign-up:hover,
.sw-main-nav a.sw-nav-sign-up:focus-visible {
  border-color: var(--sw-color-action-hover);
  background: var(--sw-color-action-hover);
  color: var(--sw-color-on-action);
}

body.nav-open .site-header {
  border-bottom-color: transparent;
  background: var(--sw-color-surface-raised);
  color: var(--sw-color-text);
  backdrop-filter: none;
}

body.nav-open .sw-brand img {
  filter: none;
}

body.nav-open .sw-nav-toggle {
  border-color: var(--sw-color-border);
  color: var(--sw-color-text);
}

body.nav-open .sw-toggle-lines {
  background: transparent;
}

body.nav-open .sw-toggle-lines::before {
  top: 0;
  transform: rotate(45deg);
}

body.nav-open .sw-toggle-lines::after {
  top: 0;
  transform: rotate(-45deg);
}

.sw-tool-chooser {
  width: min(calc(100% - 2rem), 680px);
  max-width: 680px;
  max-height: calc(100dvh - 2rem);
  border: 1px solid var(--sw-color-border);
  border-radius: var(--sw-radius-panel);
  padding: 0;
  background: var(--sw-color-surface);
  color: var(--sw-color-text);
  box-shadow: 0 24px 80px rgb(var(--sw-rgb-text) / 0.2);
}

.sw-tool-chooser-panel {
  padding: clamp(1.25rem, 4vw, 2rem);
}

.sw-tool-chooser-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.sw-tool-chooser-heading h2 {
  margin: 0;
  font-family: var(--sw-font-sans);
  font-size: var(--font-size-section-title);
  font-weight: 600;
  line-height: var(--line-height-section-title);
}

.sw-tool-chooser-close {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--sw-color-border);
  border-radius: var(--sw-radius-round);
  background: transparent;
  color: var(--sw-color-text);
  font-size: 1.75rem;
  line-height: 1;
}

.sw-tool-chooser-options {
  display: grid;
  gap: 0;
  margin-top: 1.5rem;
  border-top: 1px solid var(--sw-color-border);
}

.sw-tool-choice {
  display: grid;
  gap: 0.35rem;
  min-height: 88px;
  border-bottom: 1px solid var(--sw-color-border);
  padding: 1.15rem 0;
  color: var(--sw-color-text);
  text-decoration: none;
}

a.sw-tool-choice:hover {
  color: var(--sw-color-action-hover);
}

.sw-tool-choice strong {
  font-size: var(--font-size-body);
  font-weight: 600;
  line-height: var(--line-height-body);
}

.sw-tool-choice span {
  color: var(--sw-color-text-muted);
}

.sw-tool-choice--instruction {
  min-height: auto;
}

.site-footer {
  flex-shrink: 0;
  padding: 4.2rem 0 2rem;
  background: var(--sw-color-surface-raised);
  color: var(--sw-color-text);
}

.footer-grid {
  display: grid;
  gap: 3.2rem;
}

.footer-brand {
  display: inline-block;
  max-width: 320px;
}

.footer-brand img {
  width: min(70vw, 270px);
  filter: none;
}

.footer-line,
.footer-column p {
  color: var(--sw-color-text-muted);
}

.footer-line {
  max-width: 360px;
  margin-top: 1.5rem;
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
}

.footer-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2rem;
}

.footer-columns--account {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.footer-column h2 {
  margin: 0 0 1.05rem;
  color: var(--sw-color-text-muted);
  font-family: var(--sw-font-sans);
  font-size: var(--font-size-small);
  font-weight: 600;
  line-height: var(--line-height-small);
}

.footer-column a,
.footer-language-form button {
  display: block;
  width: fit-content;
  border: 0;
  background: transparent;
  color: var(--sw-color-text);
  padding: 0;
  font-size: var(--font-size-small);
  font-weight: 500;
  line-height: var(--line-height-small);
  text-decoration: none;
  cursor: pointer;
}

.footer-column a + a,
.footer-language-form + .footer-language-form {
  margin-top: 0.65rem;
}

.footer-column p {
  max-width: 18rem;
  font-size: var(--font-size-small);
  font-weight: 500;
  line-height: var(--line-height-small);
}

.footer-column p + a {
  margin-top: 0.65rem;
}

.footer-column a:hover,
.footer-column a[aria-current="page"],
.footer-language-form button:hover,
.footer-language-form button[aria-current="true"] {
  color: var(--sw-color-action);
  text-decoration: underline;
  text-underline-offset: 0.35em;
}

.footer-bottom {
  margin-top: 4rem;
  border-top: 1px solid var(--sw-color-border-soft);
  padding-top: 1.2rem;
  color: var(--sw-color-text-muted);
  font-size: var(--font-size-small);
  line-height: var(--line-height-small);
}

.photo-credit {
  flex-shrink: 0;
  padding: 1.4rem 0;
  color: var(--sw-color-text-muted);
  font-size: var(--font-size-small);
  line-height: var(--line-height-small);
}

.photo-credit .sw-content-width {
  width: var(--sw-content-width);
  max-width: var(--sw-content-width);
  margin-inline: auto;
}

.photo-credit a {
  color: var(--sw-color-text);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.28em;
}

@media (min-width: 768px) {

  .sw-brand {
    height: 35.2px;
  }

  .footer-columns--account {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 992px) {

  :root {
    --sw-header-height: 64px;
  }

  .sw-nav,
  .sw-nav-inner {
    min-height: 64px;
  }

  .sw-nav-toggle {
    display: none;
  }

  .sw-nav-collapse {
    display: flex !important;
    justify-content: flex-end;
  }

  .footer-grid {
    grid-template-columns: minmax(280px, 0.9fr) 1.1fr;
    align-items: start;
  }
}

@media (max-width: 991.98px) {

  :root {
    --sw-header-height: 60px;
  }

  body.nav-open,
  body.nav-closing {
    overflow: hidden;
  }

  .sw-nav,
  .sw-nav-inner {
    min-height: 60px;
  }

  .sw-nav-inner {
    flex-wrap: nowrap;
  }

  .sw-brand {
    max-width: min(42vw, 210px);
    height: 23px;
  }

  .sw-nav-toggle {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    margin-left: auto;
  }

  .sw-toggle-lines {
    width: 16px;
  }

  .sw-toggle-lines::before {
    top: -5px;
  }

  .sw-toggle-lines::after {
    top: 5px;
  }

  body.nav-open .site-header,
  body.nav-closing .site-header {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
  }

  .sw-nav-collapse {
    position: fixed;
    inset: 0;
    z-index: 1050;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    border-top: 0;
    margin-top: 0;
    overflow-y: auto;
    padding: clamp(5.25rem, 11vh, 6.75rem) 0 2.5rem;
    background: var(--sw-color-canvas);
    color: var(--sw-color-text);
    opacity: 0;
    pointer-events: none;
    transition:
      opacity var(--sw-mobile-nav-duration) var(--sw-mobile-nav-ease),
      background-color var(--sw-mobile-nav-duration) var(--sw-mobile-nav-ease),
      color var(--sw-mobile-nav-duration) var(--sw-mobile-nav-ease);
  }

  .sw-nav-collapse.show,
  .sw-nav-collapse.collapsing {
    flex-basis: 100%;
    background: var(--sw-color-surface-raised);
    color: var(--sw-color-text);
    opacity: 1;
    pointer-events: auto;
  }

  .sw-nav-collapse.collapsing {
    height: 100vh !important;
    height: 100dvh !important;
  }

  body.nav-closing .sw-nav-collapse.collapsing {
    opacity: 0;
  }

  .sw-main-nav {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.68rem;
    justify-content: flex-start;
    width: min(calc(100% - 3rem), 560px);
    min-height: auto;
    margin-inline: auto;
    padding: 0;
    font-size: var(--font-size-section-title);
    font-weight: 600;
    line-height: var(--line-height-section-title);
  }

  .sw-main-nav a {
    justify-content: flex-start;
    width: auto;
    border-bottom: 0;
    padding: 0.18rem 0;
    color: var(--sw-color-text);
    font-family: var(--sw-font-sans);
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    text-align: left;
  }

  .sw-main-nav a::after {
    display: none;
  }

  .sw-main-nav a[aria-current="page"] {
    color: var(--sw-color-action);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
  }

  .sw-main-nav a.sw-nav-sign-up {
    margin-top: 0.35rem;
    padding: 0.6rem 0.85rem;
    color: var(--sw-color-on-action);
    font-size: var(--font-size-control);
    font-weight: 600;
    line-height: var(--line-height-control);
  }

}

@media (max-width: 575.98px) {

  :root {
    --sw-header-height: 56px;
  }

  .sw-nav,
  .sw-nav-inner {
    min-height: 56px;
  }

  .sw-nav-toggle {
    width: 30px;
    height: 30px;
  }

  .sw-toggle-lines {
    width: 14px;
  }

  .sw-toggle-lines::before {
    top: -4px;
  }

  .sw-toggle-lines::after {
    top: 4px;
  }

  .footer-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {

  .sw-brand {
    max-width: 38vw;
    height: 20px;
  }

}
