/* Phase 3: shared application shell. Keep this layer route-neutral and priority-free. */

body.phase3-app-shell {
  --shell-header-height: 72px;
  --shell-mobile-header-height: 62px;
  --shell-mobile-nav-height: 72px;
  --shell-inline: clamp(14px, 3vw, 42px);
}

body.phase3-app-shell .site-header {
  box-sizing: border-box;
  min-height: var(--shell-header-height);
  padding: 8px var(--shell-inline);
  gap: clamp(12px, 2vw, 26px);
  border-bottom: 1px solid rgba(157, 13, 17, .1);
}

body.phase3-app-shell .brand {
  display: inline-flex;
  min-width: 0;
  flex: 0 1 220px;
  align-items: center;
}

body.phase3-app-shell .brand img {
  display: block;
  width: clamp(170px, 16vw, 220px);
  max-width: 100%;
  max-height: 52px;
}

body.phase3-app-shell .site-nav {
  min-width: 0;
  flex: 1 1 auto;
  justify-content: flex-end;
  gap: 4px;
}

body.phase3-app-shell .site-nav .nav-icon-link {
  box-sizing: border-box;
  min-width: 62px;
  min-height: 48px;
  padding: 7px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: .78rem;
  line-height: 1.1;
}

body.phase3-app-shell .site-nav .nav-icon-link:hover,
body.phase3-app-shell .site-nav .nav-icon-link:focus-visible,
body.phase3-app-shell .site-nav .nav-icon-link.is-active {
  border-color: rgba(157, 13, 17, .18);
  background: #fff3e6;
  color: #9d0d11;
}

body.phase3-app-shell .site-nav .nav-auth-link {
  min-width: 72px;
  border-color: #9d0d11;
  background: #9d0d11;
  color: #fff;
}

body.phase3-app-shell .site-nav .nav-auth-link:visited {
  color: #fff;
}

body.phase3-app-shell .site-nav .nav-auth-link:hover,
body.phase3-app-shell .site-nav .nav-auth-link:focus-visible {
  border-color: #7d0a0e;
  background: #7d0a0e;
  color: #fff;
}

body.phase3-app-shell .nav-link-icon .ui-icon-svg {
  width: 21px;
  height: 21px;
}

body.phase3-app-shell .nav-toggle {
  min-width: 44px;
  min-height: 44px;
  gap: 7px;
  justify-content: center;
}

body.phase3-app-shell .nav-toggle-icon {
  display: inline-grid;
  place-items: center;
}

body.phase3-app-shell .nav-toggle-icon .ui-icon-svg {
  width: 20px;
  height: 20px;
}

body.phase3-app-shell .site-footer {
  position: relative;
  overflow: hidden;
}

body.phase3-app-shell .footer-grid {
  position: relative;
  z-index: 2;
  width: min(100%, 1380px);
  margin-inline: auto;
  grid-template-columns: minmax(260px, 1.55fr) repeat(3, minmax(150px, 1fr));
  align-items: start;
  gap: clamp(24px, 3vw, 48px);
}

body.phase3-app-shell .footer-grid > *,
body.phase3-app-shell .footer-link-group {
  min-width: 0;
}

body.phase3-app-shell .footer-link-group {
  display: grid;
  align-content: start;
}

body.phase3-app-shell .site-footer a {
  box-sizing: border-box;
  min-height: 40px;
  margin: 0;
  padding: 7px 0;
  line-height: 1.3;
}

body.phase3-app-shell .footer-bottom {
  position: relative;
  z-index: 2;
  width: min(100%, 1380px);
  margin-inline: auto;
}

@media (max-width: 1100px) and (min-width: 981px) {
  body.phase3-app-shell .site-nav .nav-icon-link {
    min-width: 56px;
    padding-inline: 4px;
    font-size: .72rem;
  }

  body.phase3-app-shell .brand {
    flex-basis: 190px;
  }
}

@media (max-width: 980px) {
  body.phase3-app-shell .site-header {
    min-height: var(--shell-mobile-header-height);
    padding: 7px 12px;
  }

  body.phase3-app-shell .brand {
    flex: 0 1 190px;
  }

  body.phase3-app-shell .brand img {
    width: min(185px, 54vw);
    max-height: 46px;
  }

  body.phase3-app-shell .nav-toggle {
    display: inline-flex;
    align-items: center;
    padding: 8px 11px;
    border: 1px solid #dec7ae;
    border-radius: 6px;
    background: #fffdf9;
    color: #241812;
    font: inherit;
    font-size: .82rem;
    font-weight: 850;
    letter-spacing: 0;
  }

  body.phase3-app-shell .site-nav {
    display: none;
    position: fixed;
    top: calc(var(--shell-mobile-header-height) + 8px);
    left: 12px;
    right: 12px;
    z-index: 120;
    max-height: calc(100dvh - var(--shell-mobile-header-height) - 24px);
    overflow-y: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 8px;
    padding: 12px;
    border: 1px solid #dec7ae;
    border-radius: 8px;
    background: #fffdf9;
    box-shadow: 0 22px 54px rgba(35, 23, 17, .22);
    overscroll-behavior: contain;
  }

  body.phase3-app-shell .site-nav.open {
    display: grid;
  }

  body.phase3-app-shell .site-nav .nav-icon-link {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr);
    grid-template-rows: 1fr;
    min-width: 0;
    min-height: 48px;
    padding: 9px 10px;
    justify-items: start;
    align-items: center;
    gap: 8px;
    font-size: .84rem;
    text-align: left;
  }

  body.phase3-app-shell .site-nav .nav-auth-link {
    grid-column: 1 / -1;
    justify-content: center;
    grid-template-columns: 26px auto;
  }

  body.phase3-app-shell.site-nav-open {
    overflow: hidden;
  }

  body.phase3-app-shell.site-nav-open .site-header {
    z-index: 130;
  }

  body.phase3-app-shell.site-nav-open::before {
    content: '';
    position: fixed;
    inset: var(--shell-mobile-header-height) 0 0;
    z-index: 110;
    background: rgba(35, 23, 17, .36);
    backdrop-filter: blur(2px);
  }

  body.phase3-app-shell .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    text-align: left;
    justify-items: stretch;
  }

  body.phase3-app-shell .footer-grid > :first-child {
    grid-column: 1 / -1;
  }

  body.phase3-app-shell .footer-link-group,
  body.phase3-app-shell .site-footer .footer-grid > div {
    width: 100%;
    justify-items: start;
  }

  body.phase3-app-shell .site-footer a {
    width: 100%;
    justify-content: flex-start;
    margin-inline: 0;
  }
}

@media (max-width: 760px) {
  body.phase3-app-shell {
    padding-bottom: calc(var(--shell-mobile-nav-height) + env(safe-area-inset-bottom));
  }

  body.phase3-app-shell .mobile-app-nav {
    box-sizing: border-box;
    min-height: calc(var(--shell-mobile-nav-height) + env(safe-area-inset-bottom));
    gap: 0;
    padding: 6px 5px calc(6px + env(safe-area-inset-bottom));
    border-top-color: rgba(157, 13, 17, .14);
    background: rgba(255, 251, 245, .98);
  }

  body.phase3-app-shell .mobile-app-nav-item {
    box-sizing: border-box;
    min-width: 0;
    min-height: 58px;
    padding: 4px 1px;
    gap: 3px;
    border-radius: 6px;
    font-size: .75rem;
    line-height: 1;
    letter-spacing: 0;
  }

  body.phase3-app-shell .mobile-app-nav-item > span:last-of-type {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.phase3-app-shell .mobile-app-nav-item[href$="/requests"] > span:last-of-type {
    letter-spacing: 0;
  }

  body.phase3-app-shell .mobile-app-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
  }

  body.phase3-app-shell .site-footer {
    padding-bottom: calc(var(--shell-mobile-nav-height) + 30px + env(safe-area-inset-bottom));
  }

  body.phase3-app-shell .footer-grid {
    grid-template-columns: 1fr;
    gap: 22px;
    text-align: center;
  }

  body.phase3-app-shell .footer-grid > :first-child {
    grid-column: auto;
  }

  body.phase3-app-shell .footer-link-group,
  body.phase3-app-shell .site-footer .footer-grid > div {
    justify-items: center;
  }

  body.phase3-app-shell .site-footer a {
    min-height: 44px;
    justify-content: center;
    text-align: center;
  }
}

@media (max-width: 340px) {
  body.phase3-app-shell .mobile-app-nav {
    padding-inline: 2px;
  }
}

/* U1: one authoritative application shell across every route family. */
body.u1-platform-shell.phase3-app-shell {
  --app-mobile-header-height: var(--shell-mobile-header-height);
  overflow-x: clip;
}

body.u1-platform-shell.phase3-app-shell .site-header {
  display: flex;
  height: var(--shell-header-height);
  min-height: var(--shell-header-height);
  padding: 8px var(--shell-inline);
  border-bottom: 1px solid rgba(157, 13, 17, .12);
  background: rgba(255, 251, 245, .97);
  backdrop-filter: blur(14px);
}

body.u1-platform-shell.phase3-app-shell .site-header.is-scrolled {
  background: rgba(255, 251, 245, .99);
  box-shadow: 0 12px 30px rgba(61, 35, 18, .08);
}

body.u1-platform-shell.phase3-app-shell .site-header .brand {
  flex: 0 1 220px;
}

body.u1-platform-shell.phase3-app-shell .site-header .brand img {
  width: clamp(170px, 16vw, 220px);
  max-height: 52px;
  object-position: left center;
}

body.u1-platform-shell.phase3-app-shell .site-nav .nav-icon-link {
  border-radius: 8px;
}

body.u1-platform-shell:not(.page-dashboard):not(.page-admin) .app-main h1,
body.u1-platform-shell:not(.page-dashboard):not(.page-admin) .app-main h2 {
  font-family: Fraunces, Georgia, serif;
  letter-spacing: -.015em;
}

body.u1-platform-shell:not(.page-dashboard):not(.page-admin) .app-main h1 {
  line-height: 1.08;
}

body.u1-platform-shell.phase3-app-shell .site-footer {
  position: relative;
  inset: auto;
  min-height: 0;
  height: auto;
  margin: 0;
  padding: 48px var(--shell-inline) 24px;
  overflow: hidden;
  transform: none;
  background: #211813;
}

body.u1-platform-shell.phase3-app-shell .footer-video-overlay {
  position: absolute;
  inset: 0;
  height: 100%;
  background: radial-gradient(circle at 12% 0%, rgba(157, 13, 17, .24), transparent 36%);
}

body.u1-platform-shell.phase3-app-shell .footer-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1.55fr) repeat(3, minmax(150px, 1fr));
  gap: clamp(24px, 3vw, 48px);
  width: min(100%, 1280px);
}

body.u1-platform-shell.phase3-app-shell .footer-grid > *,
body.u1-platform-shell.phase3-app-shell .footer-link-group {
  position: relative;
  display: grid;
  align-content: start;
  gap: 4px;
}

body.u1-platform-shell.phase3-app-shell .site-footer a {
  width: fit-content;
  min-height: 40px;
  margin: 0;
  padding: 8px 0;
}

body.u1-platform-shell.phase3-app-shell .footer-bottom {
  width: min(100%, 1280px);
  margin: 28px auto 0;
  padding-top: 18px;
  white-space: normal;
  text-align: center;
}

@media (max-width: 980px) {
  body.u1-platform-shell.phase3-app-shell .site-header {
    display: flex;
    height: var(--shell-mobile-header-height);
    min-height: var(--shell-mobile-header-height);
    padding: 7px 12px;
  }

  body.u1-platform-shell.phase3-app-shell .site-header .brand {
    flex: 0 1 190px;
  }

  body.u1-platform-shell.phase3-app-shell .site-header .brand img {
    width: min(185px, 54vw);
    max-height: 46px;
  }

  body.u1-platform-shell.phase3-app-shell .site-nav {
    top: calc(var(--shell-mobile-header-height) + 8px);
  }

  body.u1-platform-shell.phase3-app-shell .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.u1-platform-shell.phase3-app-shell .footer-grid > :first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  body.u1-platform-shell.phase3-app-shell {
    padding-top: var(--shell-mobile-header-height);
    padding-bottom: calc(var(--shell-mobile-nav-height) + env(safe-area-inset-bottom));
  }

  body.u1-platform-shell.phase3-app-shell:not(.page-auth):not(.page-admin) .mobile-app-nav {
    display: grid;
    grid-template-columns: minmax(0, .92fr) minmax(0, .92fr) minmax(0, .92fr) minmax(0, 1.35fr) minmax(0, .92fr) minmax(0, .92fr);
    min-height: calc(var(--shell-mobile-nav-height) + env(safe-area-inset-bottom));
  }

  body.u1-platform-shell.phase3-app-shell .site-footer {
    padding: 38px 18px calc(var(--shell-mobile-nav-height) + 28px + env(safe-area-inset-bottom));
  }

  body.u1-platform-shell.phase3-app-shell .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 16px;
  }

  body.u1-platform-shell.phase3-app-shell .footer-grid > :first-child {
    grid-column: 1 / -1;
  }

  body.u1-platform-shell.phase3-app-shell .footer-link-group:last-child {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 14px;
  }

  body.u1-platform-shell.phase3-app-shell .footer-link-group:last-child h3 {
    grid-column: 1 / -1;
  }

  body.u1-platform-shell.phase3-app-shell .footer-grid > *,
  body.u1-platform-shell.phase3-app-shell .footer-link-group {
    justify-items: center;
    text-align: center;
  }

  body.u1-platform-shell.phase3-app-shell .site-footer a {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-height: 44px;
    justify-content: center;
    text-align: center;
  }

  body.u1-platform-shell.phase3-app-shell .footer-grid > *,
  body.u1-platform-shell.phase3-app-shell .footer-link-group {
    min-width: 0;
    max-width: 100%;
  }
}

@media (max-width: 360px) {
  body.u1-platform-shell.phase3-app-shell .footer-grid,
  body.u1-platform-shell.phase3-app-shell .footer-link-group:last-child {
    grid-template-columns: minmax(0, 1fr);
  }

  body.u1-platform-shell.phase3-app-shell .footer-link-group:last-child {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.phase3-app-shell .site-header,
  body.phase3-app-shell .site-nav,
  body.phase3-app-shell .mobile-app-nav-item {
    scroll-behavior: auto;
    transition: none;
  }
}
