/* The Authorwerks menu bar and footer (inc/menu.php), on every Authorwerks site: authorwerks.com links it, and
   account.authorwerks.com and docs.authorwerks.com load it from authorwerks.com, so the header looks
   the same everywhere.
   Self-contained: it uses only the color and font variables both sites define (--ground,
   --surface, --rule, --violet..., --text, --muted, --display, --body, --mono).

   Wide:   [brand]      Features  Download  Documentation  About | [Sign in] [Create account]  (EN)
   Narrow: [brand]                                  [Sign in] [Create account]  (EN)  [≡]
           (the pages are in the ≡ menu, and the account buttons are smaller; on a phone everything
           is smaller still, but the icon and "Authorwerks" always show)
   (Signed in, the two buttons are the account menu: [name], filled with the accent.)
           Features  Download  Documentation  About                                        */
.site-header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  background: color-mix(in srgb, var(--ground) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: flex-start;
  flex-wrap: wrap; gap: 0.5rem 1.25rem;
  padding-block: 0.6rem;
}
.site-header .brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--text); }
.site-header .brand img { width: 2.25rem; height: 2.25rem; }
.site-header .brand span { font: 600 1.3rem/1 var(--display); }

/* The pages: Features, Download, Documentation, About. */
.site-nav { display: flex; align-items: center; gap: 0.5rem 1.25rem; flex-wrap: wrap; margin-left: auto; }
.site-nav a {
  color: var(--muted); text-decoration: none; font: 500 1rem/1.4 var(--body); padding: 0.4rem 0; white-space: nowrap;
}
.site-nav a:hover { color: var(--lavender); }
.site-nav a[aria-current="page"] {
  color: var(--lavender); text-decoration: underline; text-decoration-color: var(--violet-light); text-underline-offset: 0.4em;
}
.site-header a:focus-visible, .site-header summary:focus-visible, .site-header button:focus-visible {
  outline: 3px solid var(--lavender); outline-offset: 3px; border-radius: 4px;
}

/* The visitor's account, after a thin rule, and plain to see whether they're signed in or not.
   Signed out: Sign in (outlined in the accent) and Create account (filled with it). Signed in: the
   account menu's button, filled with the accent (.account-menu summary below). */
.site-account { display: flex; align-items: center; gap: 0.5rem; padding-left: 1.25rem; border-left: 1px solid var(--rule); }
.site-account-btn {
  display: inline-flex; align-items: center; padding: 0.45rem 0.85rem; border-radius: 0.6rem;
  border: 1px solid var(--violet-light); color: var(--lavender); text-decoration: none;
  font: 600 0.95rem/1.2 var(--body); white-space: nowrap;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}
.site-account-btn:hover { background: color-mix(in srgb, var(--violet) 14%, transparent); }
.site-account-btn.is-primary, .site-account .account-menu summary {
  background: linear-gradient(180deg, var(--violet), var(--violet-mid)); color: #fff;
  border: 1px solid var(--violet-deep); box-shadow: 0 2px 0 var(--handle);
}
.site-account-btn.is-primary:hover, .site-account .account-menu summary:hover {
  transform: translateY(-1px); box-shadow: 0 3px 0 var(--handle); color: #fff;
  background: linear-gradient(180deg, var(--violet), var(--violet-mid));
}
.site-account-btn.is-primary:active, .site-account .account-menu summary:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--handle); }
.site-account .account-menu[open] summary { color: #fff; border-color: var(--violet-deep); }
.site-account-btn[aria-current="page"] { text-decoration: underline; text-underline-offset: 0.3em; }

/* The account and language menus: a quiet button that opens a list. */
.header-menu { position: relative; }
.header-menu summary {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 0.65rem; border: 1px solid var(--rule); border-radius: 0.5rem;
  color: var(--muted); cursor: pointer; list-style: none; user-select: none; white-space: nowrap;
}
.header-menu summary::-webkit-details-marker { display: none; }
.header-menu summary:hover, .header-menu[open] summary { color: var(--lavender); border-color: var(--violet-light); }
.header-menu-chevron { flex: none; transition: transform 0.15s ease; }
.header-menu[open] .header-menu-chevron { transform: rotate(180deg); }
.header-menu ul {
  position: absolute; right: 0; top: calc(100% + 0.4rem); z-index: 20;
  list-style: none; margin: 0; padding: 0.35rem; min-width: 11rem;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 0.6rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  font: 500 0.95rem/1.2 var(--body); letter-spacing: normal;
}
.header-menu li { margin: 0; }
.header-menu a, .header-menu button {
  display: block; width: 100%; margin: 0; padding: 0.6rem 0.75rem; border: 0; border-radius: 0.4rem;
  background: none; box-shadow: none; color: var(--text); text-align: left; text-decoration: none;
  font: inherit; cursor: pointer; transform: none;
}
.header-menu a:hover, .header-menu a:focus-visible, .header-menu button:hover, .header-menu button:focus-visible {
  background: var(--rule); outline: none; transform: none; box-shadow: none;
}
.header-menu a[aria-current] { color: var(--violet-light); }
.header-menu form { margin: 0; }
.header-menu-note {
  padding: 0.5rem 0.75rem 0.6rem; color: var(--muted); font-size: 0.85rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16rem;
}
.header-menu-separator { height: 1px; margin: 0.3rem 0.4rem; background: var(--rule); }

.account-menu summary { font: 600 0.95rem/1 var(--body); }
/* (Clipped for the "…" of a long name: a taller line than the button's, so a g or y isn't cut,
   with the extra taken back by the margins so the button keeps its height.) */
.account-menu-name { max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.4; margin-block: -0.2em; }

.lang-menu summary { font: 500 0.8125rem/1 var(--mono); letter-spacing: 0.08em; }
/* The pages' menu (≡): only in a narrow window. */
.nav-menu { display: none; }
.nav-menu summary { padding: 0.4rem 0.5rem; }
.nav-menu a { font-size: 1rem; }
.header-menu-user { padding-bottom: 0; color: var(--text); }
.lang-menu a[aria-current]::after { content: " ✓"; }

/* The footer: the icon on the left, the copyright just after it. */
.site-footer { margin-top: auto; border-top: 1px solid var(--rule); }
.site-footer .wrap {
  display: flex; align-items: center; justify-content: flex-start; gap: 0.75rem;
  padding-block: 1.5rem;
}
.site-footer-icon { display: flex; border-radius: 0.5rem; }
.site-footer-icon img { display: block; width: 2rem; height: 2rem; }
.site-footer-icon:focus-visible { outline: 3px solid var(--lavender); outline-offset: 3px; }
.site-footer p { margin: 0; color: var(--muted); font: 400 0.9rem/1.4 var(--body); }

/* Narrower than the whole bar: one line, the brand on the left and, at the right, the account
   (smaller), the language menu and the pages' menu (≡). */
@media (max-width: 67.99rem) {
  .site-header .wrap { flex-wrap: nowrap; gap: 0.5rem; }
  .site-nav { display: none; }
  .site-account { order: 1; margin-left: auto; padding-left: 0; border-left: 0; gap: 0.4rem; min-width: 0; }
  .lang-menu { order: 2; }
  .nav-menu { display: block; order: 3; }
  .site-account-btn { padding: 0.35rem 0.6rem; font-size: 0.85rem; }
  .site-account .account-menu summary { padding: 0.4rem 0.55rem; font-size: 0.85rem; }
  .account-menu-name { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .header-menu summary { padding: 0.45rem 0.55rem; }
  .lang-menu .header-menu-chevron { display: none; }
}
/* Phones: everything stays on one line and nothing is hidden: the icon and "Authorwerks", then the
   account, the language menu (globe and code) and the pages' menu, each a little smaller. The
   account buttons give way first: their words wrap onto two lines when there's no room for one. */
@media (max-width: 34rem) {
  .site-header .wrap { gap: 0.4rem; }
  .site-header .brand { flex: none; gap: 0.4rem; }
  .site-header .brand img { width: 2rem; height: 2rem; }
  .site-header .brand span { font-size: 1.1rem; }
  .lang-menu, .nav-menu { flex: none; }
  .header-menu summary { padding: 0.4rem 0.45rem; }
  .site-account { gap: 0.3rem; flex: 0 1 auto; }
  .site-account-btn {
    padding: 0.3rem 0.45rem; font-size: 0.78rem; line-height: 1.1;
    white-space: normal; text-align: center; justify-content: center; min-width: 0;
  }
  .site-account .account-menu { min-width: 0; }
  .site-account .account-menu summary { padding: 0.35rem 0.45rem; font-size: 0.78rem; gap: 0.3rem; min-width: 0; max-width: 100%; }
  .account-menu-name { max-width: 6.5rem; min-width: 0; }
}
/* The narrowest phones (320px): smaller again, with a narrower margin at the sides. */
@media (max-width: 22.5rem) {
  .site-header .wrap { gap: 0.3rem; padding-inline: 0.5rem; }
  .site-header .brand { gap: 0.3rem; }
  .site-header .brand img { width: 1.6rem; height: 1.6rem; }
  .site-header .brand span { font-size: 0.95rem; }
  .header-menu summary { padding: 0.3rem 0.35rem; }
  .header-menu summary svg { width: 14px; height: 14px; }
  .nav-menu summary svg { width: 18px; height: 18px; }
  .lang-menu summary { gap: 0.15rem; font-size: 0.7rem; letter-spacing: 0.02em; }
  .site-account { gap: 0.25rem; }
  .site-account-btn { padding: 0.25rem 0.35rem; font-size: 0.7rem; border-radius: 0.5rem; }
  .site-account .account-menu summary { padding: 0.3rem 0.35rem; font-size: 0.7rem; gap: 0.2rem; }
  .account-menu-name { max-width: 4.75rem; }
  .account-menu .header-menu-chevron { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .header-menu-chevron, .site-account-btn, .account-menu summary { transition: none; }
}

/* Light theme (the color variables change with it): a softer shadow under the menus. */
@media (prefers-color-scheme: light) {
  .header-menu ul { box-shadow: 0 12px 32px rgba(29, 24, 56, 0.16); }
}

/* The footer's links after the copyright: the cookie policy and the cookie settings (a button,
   shown by assets/consent.js, that brings back the cookie choices). */
/* (.site-footer p would otherwise take its margin: the links are anchored at the right.) */
.site-footer .site-footer-links { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin-left: auto; }
.site-footer-links a, .site-footer-links button {
  color: var(--muted); font: 400 0.9rem/1.4 var(--body); text-decoration: underline;
  text-decoration-color: var(--rule); text-underline-offset: 0.25em;
  background: none; border: 0; border-radius: 0; box-shadow: none; padding: 0; margin: 0;
  width: auto; min-height: 0; transform: none; cursor: pointer;
}
.site-footer-links a:hover, .site-footer-links button:hover { color: var(--lavender); text-decoration-color: currentColor; }
.site-footer-links a:focus-visible, .site-footer-links button:focus-visible { outline: 3px solid var(--lavender); outline-offset: 3px; border-radius: 4px; }
.site-footer-links [hidden] { display: none; }
@media (max-width: 30rem) {
  .site-footer .wrap { flex-wrap: wrap; }
  .site-footer .site-footer-links { margin-left: 0; flex-basis: 100%; }
}

/* The cookie choices (assets/consent.js): a card at the bottom of the window, across the bottom on
   a phone. It doesn't cover the page's controls nor stop the page being used: nothing that needs
   consent loads until it's given. Rejecting is as easy and as plain to see as accepting. */
.aw-consent {
  position: fixed; z-index: 50;
  left: max(var(--gutter, 1rem), env(safe-area-inset-left, 0px));
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  width: min(34rem, calc(100% - 2 * var(--gutter, 1rem)));
}
.aw-consent[hidden] { display: none; }
.aw-consent-box {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--rule); border-radius: 0.9rem;
  box-shadow: 0 12px 40px rgba(8, 6, 18, 0.35);
  padding: 1.1rem 1.25rem 1.2rem;
  max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem); overflow: auto;
}
.aw-consent h2 { margin: 0 0 0.4rem; font: 600 1.2rem/1.3 var(--display); color: var(--text); }
.aw-consent p { margin: 0; font: 400 0.95rem/1.5 var(--body); color: var(--muted); }
.aw-consent a { color: var(--violet-light); text-underline-offset: 0.2em; }
.aw-consent a:hover { color: var(--lavender); }
.aw-consent-choices { display: grid; gap: 0.6rem; margin-top: 0.9rem; }
.aw-consent-choices[hidden] { display: none; }
.aw-consent-choice { display: flex; align-items: flex-start; gap: 0.6rem; }
.aw-consent-choice input { margin: 0.2rem 0 0; width: 1.1rem; height: 1.1rem; accent-color: var(--violet); flex: none; }
.aw-consent-choice label { display: grid; gap: 0.1rem; font: 400 0.9rem/1.4 var(--body); color: var(--muted); cursor: pointer; }
.aw-consent-choice input:disabled + label { cursor: default; }
.aw-consent-choice strong { font-weight: 600; color: var(--text); }
.aw-consent-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.aw-consent-btn {
  flex: 1 1 auto; box-shadow: none; transform: none; width: auto; padding: 0.55rem 0.9rem; border-radius: 0.6rem; cursor: pointer;
  border: 1px solid var(--violet-light); background: transparent; color: var(--lavender);
  font: 600 0.95rem/1.2 var(--body); white-space: nowrap;
}
.aw-consent-btn:hover { background: color-mix(in srgb, var(--violet) 14%, transparent); }
.aw-consent-btn[hidden] { display: none; }
.aw-consent-btn:focus-visible, .aw-consent-choice input:focus-visible, .aw-consent a:focus-visible {
  outline: 3px solid var(--lavender); outline-offset: 2px;
}
@media (max-width: 30rem) {
  .aw-consent { left: 0; bottom: 0; width: 100%; }
  .aw-consent-box {
    border-radius: 0.9rem 0.9rem 0 0; border-bottom: 0;
    padding-bottom: max(1.2rem, env(safe-area-inset-bottom, 0px));
  }
  .aw-consent-btn { flex-basis: 100%; }
}
