/* Site header (menus) and footer, shared by every page: the content pages (with content.css) and the home page
   (with styles.css). Markup from site/layout.mjs header() / footer(); the build injects it into public/index.html.
   Colours fall back to the site palette when a page does not define the variable. */
/* Header with section menus */
.site-header { position: sticky; top: 0; z-index: 20; background: rgba(246, 250, 254, .94); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.site-header__row { display: flex; align-items: center; gap: 20px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { border-radius: 9px; }
.brand span { font-size: 21px; font-weight: 800; color: var(--ink); }
.site-nav { display: flex; gap: 4px; margin-left: auto; }
.menu { position: relative; }
.menu__top { display: block; padding: 10px 12px; border-radius: 12px; color: var(--ink-2); font-weight: 800; font-size: 15px; text-decoration: none; }
.menu__top:hover, .menu__top[aria-current] { color: var(--primary, #E63946); }
.menu__panel { position: absolute; top: 100%; left: -8px; z-index: 30; display: none; min-width: 280px; padding: 10px; border-radius: 18px; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow, 0 10px 24px rgba(16, 24, 40, .10), 0 2px 6px rgba(16, 24, 40, .06)); }
.menu:hover .menu__panel, .menu:focus-within .menu__panel { display: flex; flex-direction: column; }
.menu__panel a { padding: 8px 10px; border-radius: 10px; color: var(--ink); font-size: 15px; font-weight: 700; text-decoration: none; }
.menu__panel a:hover { background: var(--tile, #F5F7FA); color: var(--primary, #E63946); }
.menu__panel .menu__all { margin-top: 4px; color: var(--primary, #E63946); font-weight: 800; }
.menu__col { display: flex; flex-direction: column; min-width: 200px; }
.menu__panel .menu__intro { grid-column: 1 / -1; margin-bottom: 4px; padding: 10px 12px; border-radius: 12px; background: var(--tile, #F5F7FA); color: var(--ink); font-weight: 800; }
.menu__panel .menu__intro:hover { color: var(--primary, #E63946); }
.menu__panel .menu__head { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.site-header__row { position: relative; }
.menu--mega { position: static; }
.menu--mega .menu__panel { left: auto; right: 0; top: calc(100% - 6px); }
.menu:hover .menu__panel--mega, .menu:focus-within .menu__panel--mega { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px 16px; width: min(820px, calc(100vw - 32px)); min-width: 0; }
.site-nav .menu:last-child .menu__panel, .site-nav .menu:nth-last-child(2) .menu__panel { left: auto; right: -8px; }
.mobile-menu { display: none; position: relative; }
.mobile-menu summary { display: flex; flex-direction: column; justify-content: center; gap: 5px; width: 44px; height: 44px; padding: 0 11px; border-radius: 12px; cursor: pointer; list-style: none; }
.mobile-menu summary::-webkit-details-marker { display: none; }
.mobile-menu summary span { display: block; height: 3px; border-radius: 2px; background: var(--ink); }
.mobile-menu nav { position: absolute; right: 0; top: 52px; display: flex; flex-direction: column; min-width: 220px; padding: 10px; border-radius: 18px; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow, 0 10px 24px rgba(16, 24, 40, .10), 0 2px 6px rgba(16, 24, 40, .06)); }
.mobile-menu nav a { padding: 8px 12px; border-radius: 10px; color: var(--ink); font-weight: 700; text-decoration: none; }
.mobile-menu nav { max-height: calc(100vh - 90px); overflow-y: auto; min-width: 260px; }
.mobile-menu nav details { border-bottom: 1px solid var(--border); }
.mobile-menu nav details summary { display: block; height: auto; width: auto; padding: 12px; font-weight: 800; cursor: pointer; }
.mobile-menu nav details summary::after { content: " +"; color: var(--muted); }
.mobile-menu nav details[open] summary::after { content: " −"; }
.mobile-menu nav details a { display: block; padding-left: 20px; }
.mobile-menu nav .mobile-menu__head { padding-left: 12px; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.mobile-menu nav .mobile-menu__all { color: var(--primary, #E63946); font-weight: 800; }
.mobile-menu nav .mobile-menu__plain { padding: 12px; font-weight: 800; }

/* Account button: avatar (signed in) or "Log in", drawn before first paint from the learn pages' local hint
   (site/layout.mjs ACCOUNT_SLOT); on the learn pages public/learn/ui/profile.js turns the avatar into the profile menu. */
.lx-header-user { position: relative; display: flex; align-items: center; }
.lx-header-user:empty { display: none; }
.lx-avatar { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 999px; background: #101828; color: #fff; font-size: 14px; font-weight: 800; border: 0; flex-shrink: 0; text-decoration: none; }
.lx-avatar--btn { cursor: pointer; font-family: inherit; }
.lx-avatar--photo { padding: 0; overflow: hidden; background: #E4E7EC; }
.lx-avatar--photo img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.lx-header-login { padding: 9px 14px; border-radius: 999px; color: #101828; font-size: 15px; font-weight: 800; text-decoration: none; box-shadow: inset 0 0 0 1.5px #D0D5DD; white-space: nowrap; }
.lx-header-login:hover { color: #101828; background: #fff; }
@media (max-width: 900px) {
  .lx-header-login { display: none; }
  .site-header__row:has(.lx-avatar) .site-header__cta { display: none; }
  .site-header__row:has(.lx-avatar) .lx-header-user { margin-left: auto; }
}

/* Signed in (html.aa-in, set from the local hint before the header is parsed): Dashboard replaces the Quizzes
   menu and the app button goes away */
.menu__dash, .mobile-menu nav .mobile-menu__dash { display: none; }
.aa-in .menu__dash { display: block; }
.aa-in .mobile-menu nav .mobile-menu__dash { display: block; border-bottom: 1px solid var(--border); }
.aa-in .menu--quiz, .aa-in .mobile-menu__quiz, .aa-in .site-header__cta { display: none; }
@media (max-width: 900px) { .aa-in .lx-header-user { margin-left: auto; } }

/* Footer: brand, four short columns, then the legal line */
.site-footer { margin-top: 64px; padding: 48px 0 28px; background: #fff; border-top: 1px solid var(--border); }
.site-footer__top { display: grid; grid-template-columns: minmax(220px, 1.5fr) repeat(4, minmax(0, 1fr)); gap: 32px; padding-bottom: 36px; border-bottom: 1px solid var(--border); }
.site-footer__brand { max-width: 320px; }
.site-footer__brand p { margin: 12px 0 16px; color: var(--ink-2); font-weight: 700; line-height: 1.5; }
.site-footer nav { display: flex; flex-direction: column; gap: 10px; }
.site-footer nav strong { margin-bottom: 2px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.site-footer nav a { color: var(--ink); font-size: 14px; font-weight: 700; line-height: 1.35; text-decoration: none; }
.site-footer nav a:hover { color: var(--primary, #E63946); }
.site-footer__bottom { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px 32px; padding-top: 20px; }
.site-footer nav.site-footer__legal { flex-direction: row; flex-wrap: wrap; gap: 8px 20px; }
.site-footer__legal a { font-size: 13px; color: var(--ink-2); }
.site-footer__fine { margin: 0; max-width: 640px; font-size: 13px; font-weight: 700; color: var(--muted); }

@media (max-width: 900px) {
  .site-nav { display: none; }
  .mobile-menu { display: block; }
  .site-header__row .btn { margin-left: auto; }
  .site-footer__top { grid-template-columns: 1fr 1fr; }
  .site-footer__brand { grid-column: 1 / -1; max-width: none; }
}

/* Header button: the full label, shortened on phones so it never runs into the site name */
.site-header__cta .cta-short { display: none; }
@media (max-width: 480px) {
  .site-header__cta .cta-long { display: none; }
  .site-header__cta .cta-short { display: inline; }
  .site-header .brand span { font-size: 18px; }
}

/* App bar (iPhone and iPad, after half the page or a quiz): fixed to the bottom, clear of the home indicator */
.app-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; align-items: center; gap: 10px;
  padding: 10px max(14px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px));
  background: rgba(255, 255, 255, .97); border-top: 1px solid var(--border); box-shadow: 0 -6px 20px rgba(16, 24, 40, .08); font-family: inherit; }
.app-bar img { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.app-bar span { display: flex; flex-direction: column; min-width: 0; font-size: 13px; color: var(--ink-2); line-height: 1.3; }
.app-bar strong { font-size: 15px; color: var(--ink); }
.app-bar__get { margin-left: auto; padding: 8px 20px; border-radius: 999px; background: var(--primary, #E63946); color: #FFFFFF; font-size: 15px; font-weight: 800; text-decoration: none; }
.app-bar__close { width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }
